From f5108dd8093052c7d71c1f330fa66cdefde385a3 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 22 Dec 2022 12:08:58 +0000 Subject: [PATCH 1/3] pacman-helper: simplify logic In `push` and `push_missing_signatures`, we need to skip sources for architectures other than x86_64, and MINGW packages for other architectures than the current one. The logic worked, but was convoluted, and unnecessarily verbose. Let's fix this, and at the same time future-proof the code: We are about to introduce support for packages targeting Windows/ARM64. Signed-off-by: Johannes Schindelin --- pacman-helper.sh | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/pacman-helper.sh b/pacman-helper.sh index ca0c6c5c85..f8de458ff7 100755 --- a/pacman-helper.sh +++ b/pacman-helper.sh @@ -436,14 +436,6 @@ 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 @@ -451,9 +443,13 @@ push () { *,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 ;; @@ -741,14 +737,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 @@ -760,9 +748,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 ;; @@ -810,11 +802,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) @@ -828,6 +816,10 @@ push_missing_signatures () { die "Could not add $name in $arch/mingw" } ;; + mingw-w64-*) + # wrong architecture; skip + continue + ;; *) filename=$name-$arch.pkg.tar.xz ;; From f020553c1517b477618fecde934466b0192e7b1b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 22 Dec 2022 11:42:32 +0000 Subject: [PATCH 2/3] pacman-helper: start supporting ARM64 Signed-off-by: Johannes Schindelin --- pacman-helper.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/pacman-helper.sh b/pacman-helper.sh index f8de458ff7..dbc5beb585 100755 --- a/pacman-helper.sh +++ b/pacman-helper.sh @@ -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 () { # echo "$mirror/$1" @@ -71,6 +71,7 @@ map_arch () { # # 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 } @@ -80,12 +81,11 @@ arch_url () { # } arch_to_mingw () { # - if test i686 = "$arch" - then - echo mingw32 - else - echo mingw64 - fi + case "$arch" in + i686) echo mingw32;; + aarch64) echo aarch64;; + *) echo mingw64;; + esac } fetch () { @@ -540,11 +540,13 @@ quick_add () { # ... # 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= @@ -555,7 +557,7 @@ quick_add () { # ... 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= ;; @@ -602,7 +604,12 @@ quick_add () { # ... eval "mingw=\$${arch}_mingw" test -n "$msys$mingw" || continue - case "$arch,$mingw" in *,) db2=;; i686,*) db2=mingw32;; *) db2=mingw64;; 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 From 8e9b1571e5eeca2c38649928ecbaf9a88b56779b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 22 Dec 2022 11:53:56 +0000 Subject: [PATCH 3/3] pacman-helper: be prepared to initialize the aarch64 Pacman repository We do not have any official packages in Git for Windows targeting Windows/ARM64 yet. But this is about to change. This commit is best viewed with `-w`. Signed-off-by: Johannes Schindelin --- pacman-helper.sh | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/pacman-helper.sh b/pacman-helper.sh index dbc5beb585..29e4ae79ba 100755 --- a/pacman-helper.sh +++ b/pacman-helper.sh @@ -604,6 +604,11 @@ quick_add () { # ... eval "mingw=\$${arch}_mingw" test -n "$msys$mingw" || continue + 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;; @@ -615,20 +620,31 @@ quick_add () { # ... 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" &&