Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for uploading Pacman packages targeting Windows/ARM64 #458

Merged
merged 3 commits into from
Dec 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 57 additions & 42 deletions pacman-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ this_script_dir="$(cygpath -am "${0%/*}")"
base_url=https://wingit.blob.core.windows.net
mirror=/var/local/pacman-mirror

architectures="i686 x86_64"
architectures="i686 x86_64 aarch64"

arch_dir () { # <architecture>
echo "$mirror/$1"
Expand All @@ -71,6 +71,7 @@ map_arch () { # <architecture>
# Azure Blobs does not allow underlines, but dashes in container names
case "$1" in
x86_64) echo "x86-64";;
clang-aarch64) echo "aarch64";;
*) echo "$1";;
esac
}
Expand All @@ -80,12 +81,11 @@ arch_url () { # <architecture>
}

arch_to_mingw () { # <arch>
if test i686 = "$arch"
then
echo mingw32
else
echo mingw64
fi
case "$arch" in
i686) echo mingw32;;
aarch64) echo aarch64;;
*) echo mingw64;;
esac
}

fetch () {
Expand Down Expand Up @@ -436,24 +436,20 @@ push () {
for arch in $architectures sources
do
case "$name,$arch" in
mingw-w64-i686,x86_64|mingw-w64-x86_64,i686)
# wrong architecture
continue
;;
mingw-w64-i686-*,sources)
# sources are "included" in x86_64
continue
;;
mingw-w64-x86_64-*,sources)
# sources are "included" in x86_64
filename=mingw-w64${name#*_64}.src.tar.gz
;;
*,sources)
filename=$name.src.tar.gz
;;
mingw-w64-*)
mingw-w64-$arch,$arch)
filename=$name-any.pkg.tar.xz
;;
mingw-w64-*)
# wrong architecture
continue
;;
*)
filename=$name-$arch.pkg.tar.xz
;;
Expand Down Expand Up @@ -544,11 +540,13 @@ quick_add () { # <file>...

# Create a temporary directory to work with
dir="$(mktemp -d)" &&
mkdir "$dir/x86_64" "$dir/i686" "$dir/sources" ||
mkdir "$dir/x86_64" "$dir/aarch64" "$dir/i686" "$dir/sources" ||
die "Could not create temporary directory"

i686_mingw=
i686_msys=
aarch64_mingw=
aarch64_msys=
x86_64_mingw=
x86_64_msys=
all_files=
Expand All @@ -559,7 +557,7 @@ quick_add () { # <file>...
file="${path##*/}"
mingw=
case "${path##*/}" in
mingw-w64-*.pkg.tar.xz) arch=${file##mingw-w64-}; arch=${arch%%-*}; key=${arch}_mingw;;
mingw-w64-*.pkg.tar.xz) arch=${file##mingw-w64-}; arch=${arch#clang-}; arch=${arch%%-*}; key=${arch}_mingw;;
git-extra-*.pkg.tar.xz) arch=${file%.pkg.tar.xz}; arch=${arch##*-}; key=${arch}_mingw;;
*-*.pkg.tar.xz) arch=${file%.pkg.tar.xz}; arch=${arch##*-}; test any != "$arch" || arch="$FALLBACK_ARCHITECTURE"; key=${arch}_msys;;
*.src.tar.gz) arch=sources; key= ;;
Expand Down Expand Up @@ -606,26 +604,47 @@ quick_add () { # <file>...
eval "mingw=\$${arch}_mingw"
test -n "$msys$mingw" || continue

case "$arch,$mingw" in *,) db2=;; i686,*) db2=mingw32;; *) db2=mingw64;; esac
case "$(test aarch64 = $arch && curl -sI "$(arch_url $arch)/git-for-windows.db")" in
*404*) initialize_fresh_pacman_repository=t;; # this one is new
*) initialize_fresh_pacman_repository=;;
esac

case "$arch,$mingw" in
*,) db2=;;
i686,*) db2=mingw32;;
*aarch64*) db2=aarch64;;
*) db2=mingw64;;
esac
for db in git-for-windows ${db2:+git-for-windows-$db2}
do
for infix in db files
do
file=$db.$infix.tar.xz
echo "Downloading current $arch/$file..." >&2
curl -sfo "$dir/$arch/$file" "$(arch_url $arch)/$file" || return 1
if test -n "$initialize_fresh_pacman_repository"
then
echo "Will initialize new $arch/$file..." >&2
else
echo "Downloading current $arch/$file..." >&2
curl -sfo "$dir/$arch/$file" "$(arch_url $arch)/$file" || return 1
fi
dbs="$dbs $arch/$file $arch/${file%.tar.xz}"
if test -n "$sign_option"
then
curl -sfo "$dir/$arch/$file.sig" "$(arch_url $arch)/$file.sig" ||
return 1
gpg --verify "$dir/$arch/$file.sig" ||
die "Could not verify GPG signature: $dir/$arch/$file"
if test -z "$initialize_fresh_pacman_repository"
then
curl -sfo "$dir/$arch/$file.sig" "$(arch_url $arch)/$file.sig" ||
return 1
gpg --verify "$dir/$arch/$file.sig" ||
die "Could not verify GPG signature: $dir/$arch/$file"
fi
dbs="$dbs $arch/$file.sig $arch/${file%.tar.xz}.sig"
fi
sanitize_db "$dir/$arch/$file" || return 1
test ! -f "$dir/$arch/${file%.tar.xz}" ||
sanitize_db "$dir/$arch/${file%.tar.xz}" || return 1
if test -z "$initialize_fresh_pacman_repository"
then
sanitize_db "$dir/$arch/$file" || return 1
test ! -f "$dir/$arch/${file%.tar.xz}" ||
sanitize_db "$dir/$arch/${file%.tar.xz}" || return 1
fi
done
done
(cd "$dir/$arch" &&
Expand Down Expand Up @@ -741,14 +760,6 @@ push_missing_signatures () {
for arch in $architectures sources
do
case "$name,$arch" in
mingw-w64-i686-*,x86_64|mingw-w64-x86_64-*,i686)
# wrong architecture
continue
;;
mingw-w64-i686-*,sources)
# sources are "included" in x86_64
continue
;;
libcurl*,sources|mingw-w64-*-git-doc*,sources|msys2-runtime-devel*,sources)
# extra package's source included elsewhere
continue
Expand All @@ -760,9 +771,13 @@ push_missing_signatures () {
*,sources)
filename=$name.src.tar.gz
;;
mingw-w64-*)
mingw-w64-$arch,$arch)
filename=$name-any.pkg.tar.xz
;;
mingw-w64-*)
# wrong architecture
continue
;;
*)
filename=$name-$arch.pkg.tar.xz
;;
Expand Down Expand Up @@ -810,11 +825,7 @@ push_missing_signatures () {

for name in $list
do
case "$name,$arch" in
mingw-w64-i686*,x86_64|mingw-w64-x86_64*,i686)
# wrong architecture; skip
continue
;;
case "$name" in
mingw-w64-$arch-*)
filename=$name-any.pkg.tar.xz
s=$(arch_to_mingw $arch)
Expand All @@ -828,6 +839,10 @@ push_missing_signatures () {
die "Could not add $name in $arch/mingw"
}
;;
mingw-w64-*)
# wrong architecture; skip
continue
;;
*)
filename=$name-$arch.pkg.tar.xz
;;
Expand Down