Skip to content

Commit 05a6719

Browse files
committed
flatpak: use archive for zigimg
The fork in use force pushes too much, making the requested commit unreachable from default branch. Add a mechanism to allow working around this issue by fetching commit archive from GitHub directly.
1 parent 7e387a6 commit 05a6719

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

flatpak/build-support/check-zig-cache.sh

+35
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,32 @@ decode_hash() {
4545
echo "$input" | base64 -d | od -vAn -t x1 | tr -d ' \n'
4646
}
4747

48+
# Download GitHub source code as an archive and print out its
49+
# URL and sha256sum.
50+
#
51+
# Use for packages that are force-pushed frequently.
52+
github_archive() {
53+
url=$2
54+
git_commit=$3
55+
56+
if [[ ! $url =~ https://github\.com/* ]]; then
57+
echo -e "\nERROR: '$url' is not a github url" >&2
58+
return 1
59+
fi
60+
61+
archive=$url/archive/${git_commit}.tar.gz
62+
echo -e "\nDownloading '$archive'..." >&2
63+
sha256=$(curl -Lq "$archive" | sha256sum - | cut -d' ' -f1)
64+
65+
printf "%s\n" archive "$archive" "" "$sha256"
66+
}
67+
68+
# Special handling for troublesome sources
69+
declare -A workarounds=(
70+
# TUSF/zigimg force pushes a lot, orphaning the requested commit
71+
[https://github.com/TUSF/zigimg]=github_archive
72+
)
73+
4874
ROOT="$(realpath "$(dirname "$0")/../../")"
4975
ZIG_PACKAGES_JSON="$ROOT/flatpak/zig-packages.json"
5076
BUILD_ZIG_ZON_JSON="$ROOT/build.zig.zon.json"
@@ -72,6 +98,15 @@ while read -r url sha256 dest; do
7298
url=${url%%#*}
7399
fi
74100

101+
workaround=${workarounds[$url]-}
102+
if [[ -n "$workaround" ]]; then
103+
mapfile -t transform < <("$workaround" "$src_type" "$url" "$git_commit" "$sha256")
104+
src_type=${transform[0]}
105+
url=${transform[1]}
106+
git_commit=${transform[2]}
107+
sha256=${transform[3]}
108+
fi
109+
75110
jq \
76111
-nec \
77112
--arg type "$src_type" \

flatpak/zig-packages.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
},
3838
{
3939
"type": "archive",
40-
"url": "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.0-2025-03-11-16-1/ghostty-gobject-0.14.0-2025-03-11-16-1.tar.gz",
41-
"dest": "vendor/p/gobject-0.2.0-Skun7H6DlQDWCiNQtdE5TXYcCvx7MyjW01OQe5M_n_jV",
42-
"sha256": "78c992f68cac661787c12082be63944832663fdccdedc02beaaa8321bcfa1266"
40+
"url": "https://github.com/jcollie/ghostty-gobject/releases/download/0.14.0-2025-03-18-21-1/ghostty-gobject-0.14.0-2025-03-18-21-1.tar.zst",
41+
"dest": "vendor/p/gobject-0.2.0-Skun7IWDlQAOKu4BV7LapIxL9Imbq1JRmzvcIkazvAxR",
42+
"sha256": "85672997459ddd7c9d4fe458efe548a315cf842cde95ed48a7be984a1f8a98b2"
4343
},
4444
{
4545
"type": "archive",
@@ -186,10 +186,10 @@
186186
"sha256": "13bec6675e403d86db3b55b39ae262f1e1bdfe24056dcd82824341c6308b5219"
187187
},
188188
{
189-
"type": "git",
190-
"url": "https://github.com/TUSF/zigimg",
191-
"commit": "0ce4eca3560d5553b13263d6b6bb72e146dd43d0",
192-
"dest": "vendor/p/zigimg-0.1.0-lly-O4heEADSRxoTwJwrD3TBfUob9052sIgb9SL8Iz-A"
189+
"type": "archive",
190+
"url": "https://github.com/TUSF/zigimg/archive/0ce4eca3560d5553b13263d6b6bb72e146dd43d0.tar.gz",
191+
"dest": "vendor/p/zigimg-0.1.0-lly-O4heEADSRxoTwJwrD3TBfUob9052sIgb9SL8Iz-A",
192+
"sha256": "002a334b8a82aea2ea06795a0836350fea78cb74cfc88e9b8efc6e0f506590fa"
193193
},
194194
{
195195
"type": "archive",

0 commit comments

Comments
 (0)