Skip to content

Commit 3cda9eb

Browse files
authored
Merge pull request #458 from dscho/pacman-helper-and-aarch64
Prepare for uploading Pacman packages targeting Windows/ARM64
2 parents a8464e1 + 8e9b157 commit 3cda9eb

File tree

1 file changed

+57
-42
lines changed

1 file changed

+57
-42
lines changed

pacman-helper.sh

Lines changed: 57 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ this_script_dir="$(cygpath -am "${0%/*}")"
6161
base_url=https://wingit.blob.core.windows.net
6262
mirror=/var/local/pacman-mirror
6363

64-
architectures="i686 x86_64"
64+
architectures="i686 x86_64 aarch64"
6565

6666
arch_dir () { # <architecture>
6767
echo "$mirror/$1"
@@ -71,6 +71,7 @@ map_arch () { # <architecture>
7171
# Azure Blobs does not allow underlines, but dashes in container names
7272
case "$1" in
7373
x86_64) echo "x86-64";;
74+
clang-aarch64) echo "aarch64";;
7475
*) echo "$1";;
7576
esac
7677
}
@@ -80,12 +81,11 @@ arch_url () { # <architecture>
8081
}
8182

8283
arch_to_mingw () { # <arch>
83-
if test i686 = "$arch"
84-
then
85-
echo mingw32
86-
else
87-
echo mingw64
88-
fi
84+
case "$arch" in
85+
i686) echo mingw32;;
86+
aarch64) echo aarch64;;
87+
*) echo mingw64;;
88+
esac
8989
}
9090

9191
fetch () {
@@ -436,24 +436,20 @@ push () {
436436
for arch in $architectures sources
437437
do
438438
case "$name,$arch" in
439-
mingw-w64-i686,x86_64|mingw-w64-x86_64,i686)
440-
# wrong architecture
441-
continue
442-
;;
443-
mingw-w64-i686-*,sources)
444-
# sources are "included" in x86_64
445-
continue
446-
;;
447439
mingw-w64-x86_64-*,sources)
448440
# sources are "included" in x86_64
449441
filename=mingw-w64${name#*_64}.src.tar.gz
450442
;;
451443
*,sources)
452444
filename=$name.src.tar.gz
453445
;;
454-
mingw-w64-*)
446+
mingw-w64-$arch,$arch)
455447
filename=$name-any.pkg.tar.xz
456448
;;
449+
mingw-w64-*)
450+
# wrong architecture
451+
continue
452+
;;
457453
*)
458454
filename=$name-$arch.pkg.tar.xz
459455
;;
@@ -544,11 +540,13 @@ quick_add () { # <file>...
544540
545541
# Create a temporary directory to work with
546542
dir="$(mktemp -d)" &&
547-
mkdir "$dir/x86_64" "$dir/i686" "$dir/sources" ||
543+
mkdir "$dir/x86_64" "$dir/aarch64" "$dir/i686" "$dir/sources" ||
548544
die "Could not create temporary directory"
549545
550546
i686_mingw=
551547
i686_msys=
548+
aarch64_mingw=
549+
aarch64_msys=
552550
x86_64_mingw=
553551
x86_64_msys=
554552
all_files=
@@ -559,7 +557,7 @@ quick_add () { # <file>...
559557
file="${path##*/}"
560558
mingw=
561559
case "${path##*/}" in
562-
mingw-w64-*.pkg.tar.xz) arch=${file##mingw-w64-}; arch=${arch%%-*}; key=${arch}_mingw;;
560+
mingw-w64-*.pkg.tar.xz) arch=${file##mingw-w64-}; arch=${arch#clang-}; arch=${arch%%-*}; key=${arch}_mingw;;
563561
git-extra-*.pkg.tar.xz) arch=${file%.pkg.tar.xz}; arch=${arch##*-}; key=${arch}_mingw;;
564562
*-*.pkg.tar.xz) arch=${file%.pkg.tar.xz}; arch=${arch##*-}; test any != "$arch" || arch="$FALLBACK_ARCHITECTURE"; key=${arch}_msys;;
565563
*.src.tar.gz) arch=sources; key= ;;
@@ -606,26 +604,47 @@ quick_add () { # <file>...
606604
eval "mingw=\$${arch}_mingw"
607605
test -n "$msys$mingw" || continue
608606
609-
case "$arch,$mingw" in *,) db2=;; i686,*) db2=mingw32;; *) db2=mingw64;; esac
607+
case "$(test aarch64 = $arch && curl -sI "$(arch_url $arch)/git-for-windows.db")" in
608+
*404*) initialize_fresh_pacman_repository=t;; # this one is new
609+
*) initialize_fresh_pacman_repository=;;
610+
esac
611+
612+
case "$arch,$mingw" in
613+
*,) db2=;;
614+
i686,*) db2=mingw32;;
615+
*aarch64*) db2=aarch64;;
616+
*) db2=mingw64;;
617+
esac
610618
for db in git-for-windows ${db2:+git-for-windows-$db2}
611619
do
612620
for infix in db files
613621
do
614622
file=$db.$infix.tar.xz
615-
echo "Downloading current $arch/$file..." >&2
616-
curl -sfo "$dir/$arch/$file" "$(arch_url $arch)/$file" || return 1
623+
if test -n "$initialize_fresh_pacman_repository"
624+
then
625+
echo "Will initialize new $arch/$file..." >&2
626+
else
627+
echo "Downloading current $arch/$file..." >&2
628+
curl -sfo "$dir/$arch/$file" "$(arch_url $arch)/$file" || return 1
629+
fi
617630
dbs="$dbs $arch/$file $arch/${file%.tar.xz}"
618631
if test -n "$sign_option"
619632
then
620-
curl -sfo "$dir/$arch/$file.sig" "$(arch_url $arch)/$file.sig" ||
621-
return 1
622-
gpg --verify "$dir/$arch/$file.sig" ||
623-
die "Could not verify GPG signature: $dir/$arch/$file"
633+
if test -z "$initialize_fresh_pacman_repository"
634+
then
635+
curl -sfo "$dir/$arch/$file.sig" "$(arch_url $arch)/$file.sig" ||
636+
return 1
637+
gpg --verify "$dir/$arch/$file.sig" ||
638+
die "Could not verify GPG signature: $dir/$arch/$file"
639+
fi
624640
dbs="$dbs $arch/$file.sig $arch/${file%.tar.xz}.sig"
625641
fi
626-
sanitize_db "$dir/$arch/$file" || return 1
627-
test ! -f "$dir/$arch/${file%.tar.xz}" ||
628-
sanitize_db "$dir/$arch/${file%.tar.xz}" || return 1
642+
if test -z "$initialize_fresh_pacman_repository"
643+
then
644+
sanitize_db "$dir/$arch/$file" || return 1
645+
test ! -f "$dir/$arch/${file%.tar.xz}" ||
646+
sanitize_db "$dir/$arch/${file%.tar.xz}" || return 1
647+
fi
629648
done
630649
done
631650
(cd "$dir/$arch" &&
@@ -741,14 +760,6 @@ push_missing_signatures () {
741760
for arch in $architectures sources
742761
do
743762
case "$name,$arch" in
744-
mingw-w64-i686-*,x86_64|mingw-w64-x86_64-*,i686)
745-
# wrong architecture
746-
continue
747-
;;
748-
mingw-w64-i686-*,sources)
749-
# sources are "included" in x86_64
750-
continue
751-
;;
752763
libcurl*,sources|mingw-w64-*-git-doc*,sources|msys2-runtime-devel*,sources)
753764
# extra package's source included elsewhere
754765
continue
@@ -760,9 +771,13 @@ push_missing_signatures () {
760771
*,sources)
761772
filename=$name.src.tar.gz
762773
;;
763-
mingw-w64-*)
774+
mingw-w64-$arch,$arch)
764775
filename=$name-any.pkg.tar.xz
765776
;;
777+
mingw-w64-*)
778+
# wrong architecture
779+
continue
780+
;;
766781
*)
767782
filename=$name-$arch.pkg.tar.xz
768783
;;
@@ -810,11 +825,7 @@ push_missing_signatures () {
810825

811826
for name in $list
812827
do
813-
case "$name,$arch" in
814-
mingw-w64-i686*,x86_64|mingw-w64-x86_64*,i686)
815-
# wrong architecture; skip
816-
continue
817-
;;
828+
case "$name" in
818829
mingw-w64-$arch-*)
819830
filename=$name-any.pkg.tar.xz
820831
s=$(arch_to_mingw $arch)
@@ -828,6 +839,10 @@ push_missing_signatures () {
828839
die "Could not add $name in $arch/mingw"
829840
}
830841
;;
842+
mingw-w64-*)
843+
# wrong architecture; skip
844+
continue
845+
;;
831846
*)
832847
filename=$name-$arch.pkg.tar.xz
833848
;;

0 commit comments

Comments
 (0)