diff --git a/please.sh b/please.sh index 9183da73b3..56b33a0a53 100755 --- a/please.sh +++ b/please.sh @@ -147,256 +147,11 @@ is_independent_shell () { # test t = "$independent_shell" } -prepare_keep_despite_upgrade () { # - keep_despite_upgrade="$(cat "${this_script_path%/*}/keep-despite-upgrade.txt")" || - die 'Could not read keep-despite-upgrade.txt\n' - - case "$keep_despite_upgrade" in *' '*) die 'keep-despite-upgrade.txt contains spaces!\n';; esac - - test "$sdk64" = "$1" || - keep_despite_upgrade="$(echo "$keep_despite_upgrade" | sed '/^mingw64/d')" - - rm -rf "$1/.keep" && - { test -n "$keep_despite_upgrade" || return 0; } && - mkdir -p "$1/.keep" && - for f in $keep_despite_upgrade - do - d=${f%/*} - test $d = $f || - mkdir -p "$1/.keep/$d" - cp "$1/$f" "$1/.keep/$d/" || - break - done -} - -process_keep_despite_upgrade () { # [--keep] - test --keep != "$1" || { - test -d "$2/.keep" || return 0 - cp -Ru "$2/.keep/"* "$2/" - return $? - } - - test -d "$1/.keep" || return 0 - cp -Ru "$1/.keep/"* "$1/" && - rm -rf "$1/.keep" -} - mount_sdks () { # test -d /sdk32 || mount "$sdk32" /sdk32 test -d /sdk64 || mount "$sdk64" /sdk64 } -# set_package -set_package () { - package="$1" - extra_packages= - extra_makepkg_opts= - case "$package" in - git-extra|mingw-w64-git-extra) - package=mingw-w64-git-extra - type=MINGW - # This will need to be replaced with mingw-w64-git-extra once the folder has been renamed - pkgpath=/usr/src/build-extra/git-extra - ;; - git-for-windows-keyring) - type=MSYS - pkgpath=/usr/src/build-extra/$package - ;; - git) - package=mingw-w64-git - extra_packages="mingw-w64-git-doc-html mingw-w64-git-doc-man mingw-w64-git-test-artifacts mingw-w64-git-pdb" - type=MINGW - pkgpath=/usr/src/MINGW-packages/$package - ;; - mingw-w64-git) - type=MINGW - extra_packages="mingw-w64-git-doc-html mingw-w64-git-doc-man mingw-w64-git-test-artifacts mingw-w64-git-pdb" - pkgpath=/usr/src/MINGW-packages/$package - ;; - mingw-w64-git-credential-manager) - type=MINGW - pkgpath=/usr/src/build-extra/mingw-w64-git-credential-manager - ;; - gcm|credential-manager|git-credential-manager) - package=mingw-w64-git-credential-manager - type=MINGW - pkgpath=/usr/src/build-extra/mingw-w64-git-credential-manager - ;; - lfs|git-lfs|mingw-w64-git-lfs) - package=mingw-w64-git-lfs - type=MINGW - pkgpath=/usr/src/build-extra/mingw-w64-git-lfs - ;; - git-sizer|mingw-w64-git-sizer) - package=mingw-w64-git-sizer - type=MINGW - pkgpath=/usr/src/build-extra/mingw-w64-git-sizer - ;; - cv2pdb|mingw-w64-cv2pdb) - package=mingw-w64-cv2pdb - type=MINGW - pkgpath=/usr/src/build-extra/mingw-w64-cv2pdb - ;; - pcre2|mingw-w64-pcre2) - package=mingw-w64-pcre2 - type=MINGW - pkgpath=/usr/src/MINGW-packages/mingw-w64-pcre2 - ;; - busybox|mingw-w64-busybox) - package=mingw-w64-busybox - type=MINGW - extra_packages="mingw-w64-busybox-pdb" - pkgpath=/usr/src/MINGW-packages/mingw-w64-busybox - ;; - msys2-runtime) - type=MSYS - extra_packages="msys2-runtime-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - mintty) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - w3m) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - openssh) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - openssl) - type=MSYS - extra_packages="libopenssl openssl-devel" - pkgpath=/usr/src/MSYS2-packages/$package - extra_makepkg_opts=--nocheck - ;; - mingw-w64-openssl) - type=MINGW - extra_packages="mingw-w64-openssl-pdb" - pkgpath=/usr/src/MINGW-packages/$package - ;; - gnutls) - type=MSYS - extra_packages="libgnutls libgnutls-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - mingw-w64-gnutls) - type=MINGW - pkgpath=/usr/src/MINGW-packages/$package - ;; - curl) - type=MSYS - extra_packages="libcurl libcurl-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - mingw-w64-curl) - type=MINGW - extra_packages="mingw-w64-curl-pdb" - pkgpath=/usr/src/MINGW-packages/$package - ;; - git-flow) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - p7zip) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - mingw-w64-asciidoctor-extensions) - type=MINGW - pkgpath=/usr/src/MINGW-packages/$package - ;; - wintoast|mingw-w64-wintoast) - package=mingw-w64-wintoast - type=MINGW - pkgpath=/usr/src/build-extra/mingw-w64-wintoast - ;; - bash) - type=MSYS - extra_packages="$package-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - heimdal) - type=MSYS - extra_packages="$package-libs $package-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - perl) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - extra_makepkg_opts=--nocheck - ;; - perl-Net-SSLeay|perl-HTML-Parser|perl-TermReadKey|perl-Locale-Gettext|perl-XML-Parser|perl-YAML-Syck|perl-Clone) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - tig) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - subversion) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - gawk) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - extra_makepkg_opts=--nocheck - ;; - nodejs|mingw-w64-nodejs) - package=mingw-w64-nodejs - type=MINGW - pkgpath=/usr/src/MINGW-packages/mingw-w64-nodejs - extra_makepkg_opts=--nocheck - ;; - xpdf|xpdf-tools|mingw-w64-xpdf-tools) - package=mingw-w64-xpdf-tools - type=MINGW - pkgpath=/usr/src/MINGW-packages/mingw-w64-xpdf - ;; - serf) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - pkgconf) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - libgpg-error) - type=MSYS - extra_packages="libgpg-error-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - libgcrypt) - type=MSYS - extra_packages="libgcrypt-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - gnupg) - type=MSYS - pkgpath=/usr/src/MSYS2-packages/$package - ;; - libcbor) - type=MSYS - extra_packages="$package-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - libfido2) - type=MSYS - extra_packages="$package-devel" - pkgpath=/usr/src/MSYS2-packages/$package - ;; - mingw-w64-connect) - type=MINGW - pkgpath=/usr/src/MINGW-packages/$package - ;; - *) - die "Unknown package: %s\n" "$package" - ;; - esac -} - require_clean_worktree () { git update-index --ignore-submodules --refresh && git diff-files --ignore-submodules && @@ -404,168 +159,6 @@ require_clean_worktree () { die "%s not up-to-date\n" "$sdk$pkgpath" } -ff_main_branch () { - case "$(git rev-parse --symbolic-full-name HEAD)" in - refs/heads/main) ;; # okay - refs/heads/master) - git branch -m main || - die "%s: could not rename the main branch\n" "$sdk$pkgpath" - ;; - *) - die "%s: Not on 'main'\n" "$sdk$pkgpath" - ;; - esac - - require_clean_worktree - - git pull --ff-only origin HEAD || - test 0 -eq $(git rev-list --count ..FETCH_HEAD) || - die "%s: cannot fast-forward main branch\n" "$sdk$pkgpath" -} - -# require -require () { - test -d "$sdk"/var/lib/pacman/local/"${2:-$1}"-[0-9]* || - "$sdk"/git-cmd.exe --command=usr\\bin\\pacman.exe \ - -Sy --needed --noconfirm "$1" || - die "Could not install %s\n" "$1" -} - -install_git_32bit_prereqs () { - require mingw-w64-i686-asciidoctor -} - -pkg_build () { - require_clean_worktree - - test "a$sdk" = "a$sdk32" && - arch=i686 || - arch=x86_64 - - # Git for Windows' packages are only visible to the SDK of the - # matching architecture. However, we want to build Git for both - # 32-bit and 64-bit in the 64-bit SDK at the same time, therefore - # we need even the prerequisite asciidoctor for 32-bit. - # Let's just steal it from the 32-bit SDK - test mingw-w64-git != $package || - test x86_64 != $arch || - install_git_32bit_prereqs - - case "$type" in - MINGW) - require mingw-w64-toolchain mingw-w64-$arch-make - - if test mingw-w64-git = "$package" - then - tag="$(git --git-dir=src/git/.git for-each-ref \ - --format='%(refname:short)' --sort=-taggerdate \ - --count=1 'refs/tags/*.windows.*')" && - test -n "$tag" || - die "Could not determine latest tag\n" - - sed -i "s/^\(tag=\).*/\1${tag#v}/" PKGBUILD || - die "Could not edit tag\n" - fi - - if test -z "$(git --git-dir="$sdk64/usr/src/build-extra/.git" \ - config alias.signtool)" - then - extra= - else - extra="SIGNTOOL=\"git --git-dir=\\\"$sdk64/usr/src" - extra="$extra/build-extra/.git\\\" signtool\" " - fi - "$sdk/git-cmd.exe" --command=usr\\bin\\sh.exe -l -c \ - 'MAKEFLAGS=-j5 MINGW_ARCH=mingw32\ mingw64 \ - '"$extra"'makepkg-mingw -s --noconfirm \ - '"$extra_makepkg_opts"' && - if test mingw-w64-git = "'"$package"'" - then - git -C src/git push "$PWD/git" \ - refs/tags/"'"$tag"'" - fi && - MINGW_ARCH=mingw64 makepkg-mingw --allsource \ - '"$extra_makepkg_opts" || - die "%s: could not build\n" "$sdk$pkgpath" - - git update-index -q --refresh && - git diff-files --quiet --ignore-submodules PKGBUILD || - git commit -s -m "$package: new version" PKGBUILD || - die "%s: could not commit after build\n" "$sdk$pkgpath" - ;; - MSYS) - require msys2-devel binutils - opt_j=-j5 - if test -z "$(git --git-dir="$sdk64/usr/src/build-extra/.git" \ - config alias.signtool)" - then - extra= - else - extra="SIGNTOOL=\"git --git-dir=\\\"$sdk64/usr/src" - extra="$extra/build-extra/.git\\\" signtool\" " - fi - if test msys2-runtime = "$package" - then - opt_j=-j1 - require mingw-w64-cross-crt-git mingw-w64-cross-gcc - test ! -d msys2-runtime || - git -C msys2-runtime fetch || - die "Could not fetch from origin" - test ! -d src/msys2-runtime/.git || - (cd src/msys2-runtime && - case "$(test -x /usr/bin/git && cat .git/objects/info/alternates 2>/dev/null)" in - /*) - echo "dissociating worktree, to allow MINGW Git to access the worktree" >&2 && - /usr/bin/git repack -ad && - rm .git/objects/info/alternates - ;; - esac && - if test -n "$(git config remote.upstream.url)" - then - git fetch upstream - else - git remote add -f upstream \ - https://github.com/Alexpux/Cygwin - fi && - if test -n "$(git config remote.cygwin.url)" - then - git fetch --tags cygwin - else - git remote add -f cygwin \ - git://sourceware.org/git/newlib-cygwin.git - fi) || - die "Could not update msys2-runtime's upstream\n" - fi - - "$sdk/git-cmd" --command=usr\\bin\\sh.exe -l -c \ - 'cd '"$pkgpath"' && - export MSYSTEM=MSYS && - export PATH=/usr/bin:/opt/bin:/mingw64/bin:/mingw32/bin:$PATH && - unset ORIGINAL_PATH && - . /etc/profile && - MAKEFLAGS='"$opt_j"' '"$extra"'makepkg -s --noconfirm \ - '"$extra_makepkg_opts"' && - makepkg --allsource '"$extra_makepkg_opts" || - die "%s: could not build\n" "$sdk$pkgpath" - - if test "a$sdk32" = "a$sdk" - then - git update-index -q --refresh && - git diff-files --quiet --ignore-submodules PKGBUILD || - git commit -s -m "$package: new version" PKGBUILD || - die "%s: could not commit after build\n" "$sdk$pkgpath" - else - git add PKGBUILD && - git pull "$sdk32/${pkgpath%/*}/.git" \ - "$(git rev-parse --symbolic-full-name HEAD)" && - require_clean_worktree || - die "%s: unexpected difference between 32/64-bit\n" \ - "$pkgpath" - fi - ;; - esac -} - fast_forward () { if test -d "$2"/.git then @@ -597,45 +190,6 @@ up_to_date () { fi } -# require_remote -require_remote () { - if test -z "$(git config remote."$1".url)" - then - git remote add -f "$1" "$2" - else - test "$2" = "$(git config remote."$1".url)" || - die "Incorrect URL for %s: %s\n" \ - "$1" "$(git config remote."$1".url)" - - git fetch "$1" - fi || - die "Could not fetch from %s\n" "$1" -} - -# require_push_url # [] -require_push_url () { - remote=${1:-origin} - if ! grep -q '^Host github.com$' "$HOME/.ssh/config" 2>/dev/null - then - # Allow build agents to use Personal Access Tokens - url="$(git config remote."$remote".url)" && - case "$(git config http."$url".extraHeader)" in - Authorization:*) true;; # okay - *) false;; - esac || - die "No github.com entry in ~/.ssh/config\n" - elif test -z "$(git config remote."$remote".pushurl)" - then - pushurl="$(git config remote."$remote".url | - sed -n 's|^https://github.com/\(.*\)|github.com:\1|p')" - test -n "$pushurl" || - die "Not a GitHub remote: %s\n" "$remote" - - git remote set-url --push "$remote" "$pushurl" || - die "Could not set push URL of %s to %s\n" "$remote" "$pushurl" - fi -} - whatis () { git show -s --pretty='tformat:%h (%s, %ad)' --date=short "$@" } @@ -648,2094 +202,11 @@ has_merge_conflicts () { test -n "$(git ls-files --unmerged)" } -# ensure_valid_login_shell -ensure_valid_login_shell () { - # Only perform this stunt for special accounts, such as NETWORK SERVICE - test 256 -gt "$UID" || - return 0 - - sdk="$(eval "echo \$sdk$1")" - "$sdk/git-cmd" --command=usr\\bin\\sh.exe -c ' - # use `strace` to avoid segmentation faults for special accounts - line="$(strace -o /dev/null mkpasswd -c | grep -v ^create)" - case "$line" in - */nologin) - if ! grep -q "^${line%%:*}" /etc/passwd 2>/dev/null - then - echo "${line%:*}:/usr/bin/bash" >>/etc/passwd - fi - ;; - esac' >&2 -} - -require_git_src_dir () { - sdk="$sdk64" - if test ! -d "$git_src_dir" - then - if test ! -d "${git_src_dir%/src/git}" - then - mingw_packages_dir="${git_src_dir%/*/src/git}" - if test ! -d "$mingw_packages_dir" - then - case "$mingw_packages_dir" in - */MINGW-packages) - o=https://github.com/git-for-windows && - git -C "${mingw_packages_dir%/*}" \ - clone $o/MINGW-packages || - die "Could not clone into %s\n" \ - "$mingw_packages_dir" - ;; - *) - die "Do not know how to clone %s\n" \ - "$mingw_packages_dir" - ;; - esac - else - git -C "$mingw_packages_dir" fetch && - git -C "$mingw_packages_dir" \ - checkout -t origin/main || - die "Could not check out %s\n" \ - "$mingw_packages_dir" - fi - fi - (cd "${git_src_dir%/src/git}" && - echo "Checking out Git (not making it)" >&2 && - "$sdk64/git-cmd" --command=usr\\bin\\sh.exe -l -c \ - 'makepkg-mingw --noconfirm -s -o' && - case "$(test -x /usr/bin/git && cat src/git/.git/objects/info/alternates 2>/dev/null)" in - /*) - echo "Dissociating worktree, to allow MINGW git to access the worktree" >&2 && - /usr/bin/git -C src/git/ repack -ad && - rm src/git/.git/objects/info/alternates - ;; - esac) || - die "Could not initialize %s\n" "$git_src_dir" - fi - - test ! -f "$git_src_dir/PKGBUILD" || - (cd "$git_src_dir/../.." && - sdk= pkgpath=$PWD ff_main_branch) || - die "MINGW-packages not up-to-date\n" - - test false = "$(git -C "$git_src_dir" config core.autoCRLF)" || - (cd "$git_src_dir" && - git config core.autoCRLF false && - rm .git/index - git reset --hard) || - die "Could not make sure Git sources are checked out LF-only\n" -} - -# build_and_test_64; intended to build and test 64-bit Git in MINGW-packages -build_and_test_64 () { - skip_tests= - filter_make_test=" | perl -ne '"' - s/^ok \d+ # skip/skipped:/; - unless ( - /^1..[0-9]*/ or - /^ok [0-9]*/ or - /^# passed all [0-9]* test\(s\)/ or - /^# passed all remaining [0-9]* test\(s\)/ or - /^# still have [0-9]* known breakage\(s\)/ - ) { - s/^not ok \d+ -(.*)# TODO known breakage/known e:$1/; - s/^\*\*\* (.+) \*\*\*/$1/; - s/(.+)/ $1/ unless /^t\d{4}-|^make/; - print; - }; - '"'; grep '^failed [^0]' t/test-results/*.counts" - test_opts=--quiet - no_svn_tests="NO_SVN_TESTS=1" - while case "$1" in - --skip-tests) - skip_tests=--skip-tests - ;; - --full-log) - test_opts= - filter_make_test= - ;; - --with-svn-tests) - no_svn_tests= - ;; - -*) die "Unknown option: %s\n" "$1";; - *) break;; - esac; do shift; done - test $# = 0 || - die "Expected no argument, got $#: %s\n" "$*" - - make_t_prefix= - test -z "$test_opts" || - make_t_prefix="GIT_TEST_OPTS=\"$test_opts\" $make_t_prefix" - test -z "$no_svn_tests" || - make_t_prefix="$no_svn_tests $make_t_prefix" - - ls //localhost/c$ >/dev/null 2>&1 || { - echo "Administrative shares unavailable; skipping t5580" >&2 - export GIT_SKIP_TESTS="${GIT_SKIP_TESTS:+$GIT_SKIP_TESTS }t5580" - } - - ensure_valid_login_shell 64 && - GIT_CONFIG_PARAMETERS= \ - "$sdk64/git-cmd" --command=usr\\bin\\sh.exe -l -c ' - : make sure that the .dll files are correctly resolved: && - cd $PWD && - rm -f t/test-results/*.{counts,tee} && - printf "\nBuilding Git...\n" >&2 && - if ! make -j5 -k DEVELOPER=1 - then - echo "Re-running build (to show failures)" >&2 - make -k DEVELOPER=1 || { - echo "Build failed!" >&2 - exit 1 - } - fi && - printf "\nTesting Git...\n" >&2 && - if '"$(if test -z "$skip_tests" - then - printf '! %smake -C t -j5 -k%s\n' \ - "$make_t_prefix" "$filter_make_test" - else - echo 'false' - fi)"' - then - cd t && - failed_tests="$(cd test-results && - grep -l "^failed [1-9]" t[0-9]*.counts)" || { - echo "No failed tests ?!?" >&2 - exit 1 - } - still_failing="$(git rev-parse --git-dir)/failing.txt" - rm -f "$still_failing" - for t in $failed_tests - do - t=${t%*.counts} - test -f "$t.sh" || { - t=${t%*-[1-9]*} - test -f "$t.sh" || - echo "Cannot find script for $t" >&2 - exit 1 - } - echo "Re-running $t" >&2 - time bash $t.sh -i -v -x || - echo "$t.sh" >>"$still_failing" - done - test ! -s "$still_failing" || { - printf "Still failing:\n\n%s\n" \ - "$(cat "$still_failing")" >&2 - exit 1 - } - fi' -} - -needs_upload_permissions () { - grep -q '^machine api\.github\.com$' "$HOME"/_netrc && - grep -q '^machine uploads\.github\.com$' "$HOME"/_netrc || - die "Missing GitHub entries in ~/_netrc\n" -} - -# -init_or_update_coverity_tool () { - # check once per week whether there is a new version - coverity_tool=.git/coverity-tool - test ! -d $coverity_tool || - test $(($(date +%s)-$(stat -c %Y $coverity_tool))) \ - -gt $((7*24*60*60)) || return 0 - echo "Downloading current Coverity Scan Self-Build tool" >&2 - if test -f .git/coverity_tool.zip - then - timecond=.git/coverity_tool.zip - else - timecond="19700101 +0000" - fi - curl --form "token=$1" \ - --form "project=git-for-windows" \ - --time-cond "$timecond" \ - -o .git/coverity_tool.zip.new \ - https://scan.coverity.com/download/win64 && - test -f .git/coverity_tool.zip.new || { - echo "Nothing downloaded; will try again in another week" >&2 - test -d "$coverity_tool" || mkdir $coverity_tool - touch $coverity_tool - return - } - mv -f .git/coverity_tool.zip.new .git/coverity_tool.zip || - die "Could not overwrite coverity_tool.zip" - - mkdir $coverity_tool.new && - (cd $coverity_tool.new && - unzip ../coverity_tool.zip) || - die "Could not unpack coverity_tool.zip" - rm -rf $coverity_tool && - mv $coverity_tool.new $coverity_tool || - die "Could not switch to new Coverity tool version" -} - -submit_build_to_coverity () { # [--worktree=] - git_src_dir="$sdk64/usr/src/MINGW-packages/mingw-w64-git/src/git" - while case "$1" in - --worktree=*) - git_src_dir=${1#*=} - test -d "$git_src_dir" || - die "Worktree does not exist: %s\n" "$git_src_dir" - test -f "$git_src_dir/GIT-VERSION-GEN" || - die "Does not appear to contain Git's source code: %s\n" "$git_src_dir" - ;; - -*) die "Unknown option: %s\n" "$1";; - *) break;; - esac; do shift; done - test $# = 1 || - die "Expected 1 argument, got $#: %s\n" "$*" - branch="$1" - - coverity_username="$(git config coverity.username)" - test -n "$coverity_username" || - die "Need a username to access Coverity's services\n" - - coverity_token="$(git config coverity.token)" - test -n "$coverity_token" || - die "Need a token to access Coverity's services\n" - - ensure_valid_login_shell 64 || - die "Could not ensure valid login shell\n" - - sdk="$sdk64" - - build_extra_dir="$sdk64/usr/src/build-extra" - (cd "$build_extra_dir" && - sdk= pkgpath=$PWD ff_main_branch) || - die "Could not update build-extra\n" - - require_git_src_dir - - (cd "$git_src_dir" && - case "$branch" in - git-for-windows/*|v[1-9]*.windows.[1-9]*) - require_remote git-for-windows \ - https://github.com/git-for-windows/git - case "$branch" in git-for-windows/refs/pull/[0-9]*) - git fetch git-for-windows \ - "${branch#git-for-windows/}:refs/remotes/$branch" || - die "Could not fetch %s from git-for-windows\n" \ - "${branch#git-for-windows/}" - ;; - esac - ;; - upstream/*|v[1-9]*) - require_remote upstream https://github.com/git/git - case "$branch" in upstream/refs/pull/[0-9]*) - git fetch upstream "${branch#upstream/}:refs/remotes/$branch" || - die "Could not fetch %s from upstream\n" \ - "${branch#upstream/}" - ;; - esac - ;; - esac && - git checkout -f "$branch" && - git reset --hard && - sed -i -e 's/^\(char strbuf_slopbuf\[\)1\]/\165536]/' strbuf.c && - init_or_update_coverity_tool "$coverity_token" && - coverity_bin_dir=$(echo $PWD/$coverity_tool/*/bin) && - if ! test -x "$coverity_bin_dir/cov-build.exe" - then - die "Unusable Coverity bin/ directory: '%s'\n" \ - "$coverity_bin_dir" - fi && - PATH="$coverity_bin_dir:$PATH" && - cov-configure --gcc && - # Coverity has a long-standing bug where it fails to parse two-digit - # major versions of GCC incorrectly Since Synopsys seems to - # be hardly in a rush to fix this (there's no response at - # https://community.synopsys.com/s/question/0D52H000058Z6KvSAK/ - # since May 2020), we meddle with Coverity's config files - gcc10_workaround="$(test -d cov-int || gcc -v 2>&1 | - sed -n 's/^gcc version \([1-9]\)\([0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/s|\\<\\(\1\\)\\?\\(\2\\.\3\\.\4\\)\\>|\1\\2|g/p')" && - if test -n "$gcc10_workaround" - then - rm -f version.o && - cov-build --dir cov-int make DEVELOPER=1 version.o && - find cov-int/emit/* -name \*.xml -exec sed -i "$gcc10_workaround" {} \; && - rm -f version.o - fi && - cov-build --dir cov-int \ - make -j15 DEVELOPER=1 CPPFLAGS="-DFLEX_ARRAY=65536 -DSUPPRESS_ANNOTATED_LEAKS" && - tar caf git-for-windows.lzma cov-int && - curl --form token="$coverity_token" \ - --form email="$coverity_username" \ - --form file=@git-for-windows.lzma \ - --form version="$(git rev-parse HEAD)" \ - --form version="$(date +%Y-%m-%s-%H-%M-%S)" \ - https://scan.coverity.com/builds?project=git-for-windows) || - die "Could not submit build to Coverity\n" -} - -tag_git () { # [--force] - force= - branch_to_use= - while case "$1" in - -f|--force) - force=--force - ;; - --use-branch=*) branch_to_use="${1#*=}";; - -*) die "Unknown option: %s\n" "$1";; - *) break;; - esac; do shift; done - test $# = 0 || - die "Expected no argument, got $#: %s\n" "$*" - - sdk="$sdk64" require w3m - - build_extra_dir="$sdk64/usr/src/build-extra" - (cd "$build_extra_dir" && - sdk= pkgpath=$PWD ff_main_branch) || - die "Could not update build-extra\n" - - git_src_dir="$sdk64/usr/src/MINGW-packages/mingw-w64-git/src/git" - (cd "$git_src_dir" && - require_remote upstream https://github.com/git/git && - require_remote git-for-windows \ - https://github.com/git-for-windows/git) || exit - - case "$branch_to_use" in - *@*) - git "$dir_option" fetch --tags \ - "${branch_to_use#*@}" "${branch_to_use%%@*}" || - die "Could not fetch '%s' from '%s'\n" \ - "${branch_to_use%%@*}" "${branch_to_use#*@}" - branch_to_use=FETCH_HEAD - ;; - esac - branch_to_use="${branch_to_use:-git-for-windows/main}" - - next_version="$(sed -ne \ - '1s/.* \(v[0-9][.0-9]*\(-rc[0-9]*\)\?\)(\([0-9][0-9]*\)) .*/\1.windows.\3/p' \ - -e '1s/.* \(v[0-9][.0-9]*\(-rc[0-9]*\)\?\) .*/\1.windows.1/p' \ - <"$build_extra_dir/ReleaseNotes.md")" - ! git --git-dir="$git_src_dir" rev-parse --verify \ - refs/tags/"$next_version" >/dev/null 2>&1 || - test -n "$force" || - die "Already tagged: %s\n" "$next_version" - - notes="$("$sdk64/git-cmd.exe" --command=usr\\bin\\sh.exe -l -c \ - 'markdown /dev/null; then sign_option=-s; fi && - git tag -m "$tag_message" -a $sign_option $force \ - "$next_version" $branch_to_use) || - die "Could not tag %s in %s\n" "$next_version" "$git_src_dir" - - echo "Created tag $next_version" >&2 -} - -version_from_pkgbuild () { # - sed -ne \ - '/^_base_\?ver=/{N;N;s/.*=\([0-9].*\)\n.*\npkgrel=\(.*\)/\1-\2/p}' \ - -e '/^_ver=/{N;N;N;s/.*=\([.0-9]*\)\([a-z][a-z]*\)\n.*\n.*\npkgrel=\(.*\)/\1.\2-\3/p}' \ - -e '/^_\?pkgver=/{N;N;s/.*=\([0-9].*\)\npkgrel=\([0-9]*\)\nepoch=\([0-9\*\)/\3~\1-\2/p;s/.*=\([0-9].*\)\npkgrel=\([0-9]*\).*/\1-\2/p;N;s/.*=\([0-9].*\)\n.*\npkgrel=\([0-9]*\).*/\1-\2/p}' \ - -e '/^_\?pkgver=/{N;N;s/[^=]*=\([0-9].*\)\npkgrel=\([0-9]*\)\nepoch=\([0-9]*\).*/\3~\1-\2/p;s/[^=]*=\([0-9].*\)\npkgrel=\([0-9]*\).*/\1-\2/p}' \ - -e '/^_basever=/{N;s/^_basever=\([0-9].*\)\n_patchlevel=\([0-9]*\) .*\n.*\npkgrel=\([0-9]*\).*/\1.\2-\3/p}' \ - <"$1" -} - -pkg_files () { - pkgver="$(version_from_pkgbuild PKGBUILD)" - test -n "$pkgver" || - die "%s: could not determine pkgver\n" "$sdk$pkgpath" - - test a--for-upload != "a$1" || - echo $package-$pkgver.src.tar.gz - - if test -z "$sdk" - then - arch="$(uname -m)" - elif test "a$sdk" = "a$sdk32" - then - arch=i686 - else - arch=x86_64 - fi - - for p in $package $extra_packages - do - case "$p" in - mingw-w64-git-test-artifacts|mingw-w64-git-pdb) - test "--for-upload" = "$1" || continue;; - esac - - case "$p" in - mingw-w64-*) - suffix=-${p#mingw-w64-}-$pkgver-any.pkg.tar.xz - case "$1" in - --for-upload) - printf " mingw-w64-i686$suffix" - printf " mingw-w64-x86_64$suffix" - ;; - --i686|--x86_64) - printf " mingw-w64${1#-}$suffix" - ;; - '') - printf " mingw-w64-$arch$suffix" - ;; - *) - die "Whoops: unknown option %s\n" "$1" - ;; - esac - ;; - git-extra) - prefix=$p-$pkgver - suffix=.pkg.tar.xz - case "$1" in - --for-upload) - printf " $prefix-i686$suffix" - printf " $prefix-x86_64$suffix" - ;; - --i686|--x86_64) - printf " $prefix${1#-}$suffix" - ;; - '') - printf " $prefix-$arch$suffix" - ;; - *) - die "Whoops: unknown option %s\n" "$1" - ;; - esac - ;; - *) - printf " $p-$pkgver-$arch.pkg.tar.xz" - ;; - esac - done -} - -pkg_install () { - require_clean_worktree - - files="$(pkg_files)" || exit - - case "$package" in - msys2-runtime) - require_not_in_use "$sdk" "usr/bin/msys-2.0.dll" - ;; - bash) - require_not_in_use "$sdk" "usr/bin/sh.exe" - require_not_in_use "$sdk" "usr/bin/bash.exe" - ;; - esac - - prepare_keep_despite_upgrade "$sdk" || - die 'Could not keep files as planned\n' - - "$sdk/git-cmd.exe" --command=usr\\bin\\sh.exe -l -c \ - "pacman -U --noconfirm $files" - - process_keep_despite_upgrade "$sdk" || - die 'Could not keep files as planned\n' - - if test MINGW = "$type" - then - prepare_keep_despite_upgrade "$sdk32" || - die 'Could not keep files as planned\n' - - "$sdk32/git-cmd.exe" --command=usr\\bin\\sh.exe -l -c \ - "pacman -U --noconfirm $(pkg_files --i686)" - - process_keep_despite_upgrade "$sdk32" || - die 'Could not keep files as planned\n' - fi -} - -# origin HEAD -really_push () { - if ! git push "$@" - then - if test "origin HEAD" = "$*" - then - git pull origin main - else - git pull "$@" - fi && - git push "$@" || - return 1 - fi - return 0 -} - pacman_helper () { "$sdk64/git-cmd.exe" --command=usr\\bin\\bash.exe -l \ "$sdk64/usr/src/build-extra/pacman-helper.sh" "$@" } -maybe_init_repository () { - test ! -d "$1" || return 0 - - top_dir="${1%/*}" - case "$top_dir" in - */MSYS2-packages|*/MINGW-packages|*/build-extra) - url=https://github.com/git-for-windows/"${top_dir##*/}" && - if test ! -d "$top_dir" - then - git -C "${top_dir%/*}" clone $url || - die "Could not clone/fetch %s into %s\n" \ - "$url" "$top_dir" - else - test -d "$top_dir/.git" || git -C "$top_dir" init || - die "Could not initialize '%s'" "$top_dir" - - git -C "$top_dir" config remote.origin.url >/dev/null || - git -C "$top_dir" remote add origin $url || - die "Could not add remote to '%s'" "$top_dir" - - git -C "$top_dir" fetch origin && - git -C "$top_dir" checkout -t origin/main || - die "Could not check out main branch in '%s'" "$top_dir" - fi - ;; - *) - die "Cannot initialize '%s'\n" "$1" - ;; - esac -} - -create_bundle_artifact () { - test -n "$artifactsdir" || return 0 - upstream_main_branch="$(git rev-parse --verify -q git-for-windows/main)" || - upstream_main_branch="$(git rev-parse --verify -q origin/main)" || - return - repo_name=$(git rev-parse --show-toplevel) && - repo_name=${repo_name##*/} && - if ! main_branch="$(git symbolic-ref --short HEAD)" - then - main_branch=main && - git switch -C $main_branch - fi && - range="$upstream_main_branch..$main_branch" && - if test 0 -lt $(git rev-list --count "$range") - then - git bundle create "$artifactsdir"/$repo_name.bundle "$range" - else - echo "Range $range is empty" >"$artifactsdir/$repo_name.empty" - fi -} - -pkg_copy_artifacts () { - test -n "$artifactsdir" || return 0 - files="$(pkg_files --for-upload)" || exit - cp $files "$artifactsdir/" && - create_bundle_artifact -} - -# -maybe_force_pkgrel () { - if test -n "$1" - then - test -z "$(echo "$1" | tr -d 0-9)" || - die "Invalid pkgrel: '%s'\n" "$1" - - sed -i "s/^\\(pkgrel=\\).*/\\1$1/" PKGBUILD - elif git diff --exit-code -G'^(_ver|_realver|pkgver|_pkgver|_base_ver)=' -- PKGBUILD # version was not changed - then - # Maybe there have been changes since the latest release? - blame_ver="$(MSYS_NO_PATHCONV=1 git blame -L '/^pkgver=/,+1' -- ./PKGBUILD)" && - blame_ver="$(echo "$blame_ver" | sed -e 's/ .*//' -e 's/^0*$//')" && - blame="$(MSYS_NO_PATHCONV=1 git blame -L '/^pkgrel=/,+1' HEAD -- ./PKGBUILD)" && - blame="$(echo "$blame" | sed -e '/^00* /d')" && - if test -n "$blame_ver" && - test 0 -lt $(git rev-list --count ${blame:+${blame%% *}..} ${blame_ver:+$blame_ver..} -- PKGBUILD) - then - sed -i "s/^\\(pkgrel=\\).*/\\1"$((1+${blame##*=}))/ PKGBUILD - else - case "${PWD##*/MSYS2-packages/}" in - perl-*|subversion) - # Handle perl dependencees: if perl changed, increment pkgrel - blame_perl="$(MSYS_NO_PATHCONV=1 git blame -L '/^pkgver=/,+1' -- ../perl/PKGBUILD)" && - blame_perl="$(echo "$blame_perl" | sed -e 's/ .*//' -e 's/^0*$//')" && - blame_perl_pkgrel="$(MSYS_NO_PATHCONV=1 git blame -L '/^pkgrel=/,+1' "$blame_perl.." -- ../perl/PKGBUILD)" && - if test -n "$blame_perl_pkgrel" - then - blame_perl="$(echo "$blame_perl_pkgrel" | sed -e 's/ .*//' -e 's/^0*$//')" - fi && - if test -n "$blame_perl" && - test 0 = $(git rev-list --count $blame_perl.. -- ./PKGBUILD) - then - sed -i "s/^\\(pkgrel=\\).*/\\1"$((1+${blame##*=}))/ PKGBUILD - fi - ;; - esac - fi - else - # version changed; verify that pkgrel is 0 or 1 - case "$(sed -n 's/^pkgrel=\([0-9][0-9]*\)$/\1/p' PKGBUILD)" in - 0|1) return 0;; # okay - *) - die 'pkgrel needs to be reset to 1 when changing the version:\n\n%s\n' \ - "$(git diff HEAD -- PKGBUILD)" - ;; - esac - fi - - # make sure that we did not downgrade - if test 0 -gt $(($(git diff HEAD -- PKGBUILD | - sed -n 's/^\([-+]\)pkgrel=\([0-9]*\)$/\1\2/p' | tr -d '\n'))) - then - die 'pkgrel must not be downgraded:\n\n%s\n' \ - "$(git diff HEAD -- PKGBUILD)" - fi -} - -# --force overwrites existing an Git tag, or existing package files -upgrade () { # [--directory=] [--only-mingw] [--no-build] [--no-upload] [--force] [--release-date=] [--use-branch=[@]] [--force-pkgrel=] [--cleanbuild] - artifactsdir= - skip_build= - skip_upload= - force= - delete_existing_tag= - release_date= - use_branch= - force_pkgrel= - cleanbuild= - only_mingw= - skip_mingw= - while case "$1" in - --directory=*) - artifactsdir="$(cygpath -am "${1#*=}")" || exit - test -d "$artifactsdir" || - mkdir "$artifactsdir" || - die "Could not create artifacts directory: %s\n" "$artifactsdir" - ;; - --directory) - shift - artifactsdir="$(cygpath -am "$1")" || exit - test -d "$artifactsdir" || - mkdir "$artifactsdir" || - die "Could not create artifacts directory: %s\n" "$artifactsdir" - ;; - --no-build) - skip_build=t - skip_upload=t - ;; - --no-upload) - skip_upload=t - ;; - --only-mingw) - only_mingw=t - ;; - --skip-mingw) - skip_mingw=t - ;; - -f|--force) - force=--force - delete_existing_tag=--delete-existing-tag - ;; - --release-date=*) - release_date="$(echo "$1" | tr ' ' _)" - ;; - --use-branch=*) - use_branch="$1" - ;; - --force-pkgrel=*) - force_pkgrel="${1#*=}" - ;; - --cleanbuild) - cleanbuild=--cleanbuild - ;; - -*) die "Unknown option: %s\n" "$1";; - *) break;; - esac; do shift; done - test $# = 1 || - die "Expected 1 argument, got $#: %s\n" "$*" - - test -n "$skip_build" || - test -n "$GPGKEY" || - die "Need GPGKEY to upload packages\n" - - test -n "$skip_upload" || - test -s "$HOME"/.azure-blobs-token || - die "Missing token in ~/.azure-blobs-token\n" - - set_package "$1" - - test -z "$only_mingw" || - test curl = "$package" || - test openssl = "$package" || - test gnutls = "$package" || - test MINGW = "$type" || - die "The --only-mingw option is supported only for openssl/gnutls/curl\n" - - test -z "$skip_mingw" || - test openssl = "$package" || - test gnutls = "$package" || - test curl = "$package" || - test MSYS = "$type" || - die "The --skip-mingw option is supported only for openssl/gnutls/curl\n" - - test -z "$only_mingw" || test -z "$skip_mingw" || - die "--only-mingw and --skip-mingw are mutually exclusive\n" - - test -z "$release_date" || - test mingw-w64-git = "$package" || - die "The --release-date option is supported only for git\n" - - test -z "$use_branch" || - test mingw-w64-git = "$package" || - die "The --use-branch option is supported only for git\n" - - test -n "$skip_build" || - case "$package" in - msys2-runtime) - require_not_in_use "$sdk32" "usr/bin/msys-2.0.dll" - require_not_in_use "$sdk64" "usr/bin/msys-2.0.dll" - ;; - bash) - require_not_in_use "$sdk32" "usr/bin/sh.exe" - require_not_in_use "$sdk32" "usr/bin/bash.exe" - require_not_in_use "$sdk64" "usr/bin/sh.exe" - require_not_in_use "$sdk64" "usr/bin/bash.exe" - ;; - esac - - maybe_init_repository "$sdk64$pkgpath" - test -n "$skip_build" || test MSYS != "$type" || maybe_init_repository "$sdk32$pkgpath" - - test -n "$skip_upload" || - (cd "$sdk64$pkgpath" && - require_push_url origin && - sdk="$sdk64" ff_main_branch) || exit - - release_notes_feature= - case "$package" in - mingw-w64-git-credential-manager) - repo=GitCredentialManager/git-credential-manager - url=https://api.github.com/repos/$repo/releases - release="$(curl --netrc -s $url)" - test -n "$release" || - die "Could not determine the latest version of %s\n" "$package" - tag_name="$(echo "$release" | - sed -n 's/^ "tag_name": "\(.*\)",\?$/\1/p' | head -n 1)" - zip_name="$(echo "$release" | sed -ne 's/gcm[^"]*-symbols\.zip//' -e \ - 's/.*"browser_download_url":.*\/\(gcm.*\.zip\).*/\1/p' | head -n 1)" - version=${zip_name#gcmcore-win-x86-} - version=${zip_name#gcm-win-x86-} - version=${version%.zip} - zip_prefix=${zip_name%$version.zip} - if test "$zip_prefix" = "$zip_name" - then - # The version in the tag and the zip file name differ - zip_replace='s/^\(zip_url=.*\/\)gcm[^"]*/\1'$zip_name/ - else - zip_replace='s/^\(zip_url=.*\/\)gcm[^"]*/\1'$zip_prefix'${_realver}.zip/' - fi - (cd "$sdk64$pkgpath" && - sed -i -e "s/^\\(pkgver=\\).*/\1$version/" -e "$zip_replace" \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - updpkgsums && - maybe_force_pkgrel "$force_pkgrel" && - git commit -s -m "Upgrade $package to $version${force_pkgrel:+-$force_pkgrel}" PKGBUILD && - create_bundle_artifact) && - url=https://github.com/$repo/releases/tag/$tag_name && - release_notes_feature='Comes with [Git Credential Manager Core v'$version']('"$url"').' - ;; - git-for-windows-keyring) - (cd "$sdk64$pkgpath" && - updpkgsums && - git update-index -q --refresh && - if ! git diff-files --quiet -- PKGBUILD - then - git commit -s -m "$package: adjust checksums" PKGBUILD && - create_bundle_artifact - fi && - "$sdk64"/git-cmd.exe --command=usr\\bin\\sh.exe -l -c \ - 'makepkg --nobuild -s --noconfirm' && - if ! git diff-files --quiet -- PKGBUILD - then - git commit -s -m "$package: update pkgver" PKGBUILD && - create_bundle_artifact - fi) - ;; - git-extra) - (cd "$sdk64$pkgpath" && - updpkgsums && - git update-index -q --refresh && - if ! git diff-files --quiet -- PKGBUILD - then - git commit -s -m "git-extra: adjust checksums" PKGBUILD && - create_bundle_artifact - fi && - if test git-extra.install.in -nt git-extra.install - then - MINGW_ARCH=mingw64 \ - "$sdk64"/git-cmd.exe --command=usr\\bin\\sh.exe -l -c \ - 'makepkg-mingw --nobuild -s --noconfirm' && - git checkout HEAD -- PKGBUILD && - git update-index -q --refresh && - if ! git diff-files --quiet -- git-extra.install - then - git commit -s -m \ - "git-extra: regenerate .install file" \ - git-extra.install - fi - fi) - ;; - curl) - version="$(curl -Ls https://curl.haxx.se/download.html | - sed -n 's/.*"$artifactsdir/next_version" && - echo "$display_version" >"$artifactsdir/display_version" && - set_version_from_tag_name "$next_version" && - echo "$ver" >"$artifactsdir/ver" && - git -C "$git_src_dir" bundle create \ - "$artifactsdir/git.bundle" \ - git-for-windows/main..$next_version && - git -C "$sdk64/usr/src/build-extra" bundle create \ - "$artifactsdir/build-extra.bundle" \ - -9 main - fi && - rm -rf "$git_src_dir"/sha1collisiondetection - ;; - mingw-w64-git-lfs) - repo=git-lfs/git-lfs - url=https://api.github.com/repos/$repo/releases/latest - release="$(curl --netrc -s $url)" - test -n "$release" || - die "Could not determine the latest version of %s\n" "$package" - version="$(echo "$release" | - sed -n 's/^ "tag_name": "v\(.*\)",\?$/\1/p')" - test -n "$version" || - die "Could not determine version of %s\n" "$package" - needle1='^ "body": ".* SHA-256 hashes.*git-lfs-windows' - # Git LFS sometimes lists SHA-256 sums below, sometimes - # above the file names. Work around that particular issue - if test -n "$(echo "$release" | - grep "$needle1"'.*\\n[0-9a-z]\{64\}\(\\r\)\?\(\\n\)\?",\?$')" - then - # The SHA-256 sums are listed below the file names - needle2="$version\\.zip[^0-9a-f]*\\([0-9a-f]*\\).*" - else - needle1='^ "body": ".* SHA-256 hashes.*[^0-9a-f]' - needle1="$needle1\\([0-9a-f]\\+\\)" - needle1="$needle1[^0-9a-f]*git-lfs-windows" - needle2="$version\\.zip.*" - fi - sha256_32="$(echo "$release" | - sed -n "s/$needle1-386-$needle2/\1/p")" - extra_v= - test -n "$sha256_32" || { - sha256_32="$(echo "$release" | - sed -n "s/$needle1-386-v$needle2/\1/p")" - test -n "$sha256_32" || - die 'Could not find version in %s\n' \ - "$(echo "$release" | sed -n "/$needle1/p")" - extra_v=v - } - test 64 = $(echo -n "$sha256_32" | wc -c) || - die "Could not determine SHA-256 of 32-bit %s\n" "$package" - - # Incorrect SHA-256 for 32-bit 2.2.1: - # see https://github.com/git-lfs/git-lfs/issues/2408 - test 2.2.1,1142055d51a7d70b3c2fbf184db41100457f170a532b638253991821890927b5 != "$version,$sha256_32" || sha256_32=0d6347bbdf25946f14949b50f18b9929183aefe55f6b626f8a618ae53c2220bb - - sha256_64="$(echo "$release" | - sed -n "s/$needle1-amd64-$extra_v$needle2/\1/p")" - test 64 = $(echo -n "$sha256_64" | wc -c) || - die "Could not determine SHA-256 of 64-bit %s\n" "$package" - (cd "$sdk64$pkgpath" && - url=https://github.com/$repo/releases/download/v$version/ && - zip32="git-lfs-windows-386-$extra_v$version.zip" && - zip64="git-lfs-windows-amd64-$extra_v$version.zip" && - curl -LO $url$zip32 && - curl -LO $url$zip64 && - printf "%s *%s\n%s *%s\n" \ - "$sha256_32" "$zip32" "$sha256_64" "$zip64" | - sha256sum -c - && - exesuffix32="$(unzip -l $zip32 | sed -n 's/.*git-lfs\([^\/]*\)\.exe$/\1/p')" && - exesuffix64="$(unzip -l $zip64 | sed -n 's/.*git-lfs\([^\/]*\)\.exe$/\1/p')" && - dir32="$(unzip -l $zip32 | - sed -n 's/^.\{28\} *\(.*\)\/\?git-lfs'"$exesuffix32"'\.exe$/\1/p' | - sed -e 's/^$/./' -e 's/\//\\&/g')" && - dir64="$(unzip -l $zip64 | - sed -n 's/^.\{28\} *\(.*\)\/\?git-lfs'"$exesuffix64"'\.exe/\1/p' | - sed -e 's/^$/./' -e 's/\//\\&/g')" && - s1='s/\(folder=\)[^\n]*/\1' && - s2='s/\(sha256sum=\)[0-9a-f]*/\1' && - s3='s/\(386-\|amd64-\)v\?\(\$pkgver\.zip\)/\1'$extra_v'\2/' && - s4_32='s/\(exesuffix=\).*/\1'"$exesuffix32"'/' && - s4_64='s/\(exesuffix=\).*/\1'"$exesuffix64"'/' && - sed -i -e "s/^\\(pkgver=\\).*/\\1$version/" \ - -e "s/^\\(pkgrel=\\).*/\\11/" \ - -e "/^i686)/{N;N;N;N;$s1$dir32/;$s2$sha256_32/;$s3;$s4_32}" \ - -e "/^x86_64)/{N;N;N;N;$s1$dir64/;$s2$sha256_64/;$s3;$s4_64}" \ - PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - git commit -s -m "Upgrade $package to $version${force_pkgrel:+-$force_pkgrel}" PKGBUILD && - create_bundle_artifact) && - url=https://github.com/$repo/releases/tag/v$version && - release_notes_feature='Comes with [Git LFS v'$version']('"$url"').' - ;; - msys2-runtime) - (cd "$sdk64/usr/src/MSYS2-packages/msys2-runtime" && - if test ! -d src/msys2-runtime - then - MSYSTEM=msys PATH="$sdk64/usr/bin:$PATH" \ - "$sdk64"/git-cmd.exe --command=usr\\bin\\sh.exe -l -c \ - 'makepkg -s --noconfirm --nobuild -s' - fi || - die "Could not initialize worktree for '%s\n" "$package" - - cd src/msys2-runtime || - die "Invalid worktree for '%s'\n" "$package" - - case "$(test -x /usr/bin/git && cat .git/objects/info/alternates 2>/dev/null)" in - /*) - echo "dissociating worktree, to allow MINGW Git to access the worktree" >&2 && - /usr/bin/git repack -ad && - rm .git/objects/info/alternates || - die "Could not dissociate src/msys2-runtime\n" - ;; - esac - - require_remote cygwin \ - git://sourceware.org/git/newlib-cygwin.git && - git fetch --tags cygwin && - require_remote git-for-windows \ - https://github.com/git-for-windows/msys2-runtime || - die "Could not connect remotes for '%s'\n" "$package" - - tag=$(git for-each-ref --sort=-taggerdate --count=1 \ - --format='%(refname)' refs/tags/cygwin-\*-release) && - test -n "$tag" || - die "Could not determine latest tag of '%s'\n" "$package" - - # Git for Windows will skip v3.2.0 and stay on v3.1.7 until v3.2.1 comes out - test refs/tags/cygwin-3_2_0-release != "$tag" || tag=refs/tags/cygwin-3_1_7-release - - version="$(echo "$tag" | sed -ne 'y/_/./' -e \ - 's|^refs/tags/cygwin-\([1-9][.0-9]*\)-release$|\1|p')" && - test -n "$version" || - die "Invalid version '%s' for '%s'\n" "$version" "$package" - - # rebase if necessary - git reset --hard && - git checkout git-for-windows/main && - if test 0 -lt $(git rev-list --count \ - git-for-windows/main..$tag) - then - { test -n "$skip_upload" || - require_push_url git-for-windows; } && - GIT_EDITOR=true \ - "$sdk64"/usr/src/build-extra/shears.sh \ - --merging --onto "$tag" merging-rebase && - create_bundle_artifact && - { test -n "$skip_upload" || - git push git-for-windows HEAD:main; } || - die "Could not rebase '%s' to '%s'\n" "$package" "$tag" - fi - - test -n "$force_pkgrel" || - case "$(version_from_pkgbuild ../../PKGBUILD)" in - $version-[1-9]*) - msys2_runtime_mtime=$(git log -1 --format=%ct \ - git-for-windows/main --) && - msys2_package_mtime=$(git -C ../.. log -1 \ - --format=%ct -G'pkg(rel|ver)' -- PKGBUILD) && - test $msys2_runtime_mtime -gt $msys2_package_mtime - ;; - esac || - die "Package '%s' already up-to-date\n\t%s: %s\n\t%s: %s\n" \ - "$package" \ - "Most recent source code update" \ - "$(date --date="@$msys2_runtime_mtime")" \ - "Most recent package update" \ - "$(date --date="@$msys2_package_mtime")" - - if test 2.11.2 = "$version" - then - cygwin_url=https://cygwin.com/ml/cygwin-announce/2018-11/msg00007.html - elif test 3.1.7 = "$version" - then - cygwin_url=https://cygwin.com/pipermail/cygwin-announce/2020-August/009678.html - else - cygwin_url="$(curl -s https://cygwin.com/ | - sed -n '/The most recent version of the Cygwin DLL is/{ - N;s/.*'"$version"'<\/a>.*/\1/p - }')" - test -n "$cygwin_url" || - cygwin_url="$(curl -Lis https://cygwin.com/ml/cygwin-announce/current | - sed -ne '/^[Ll]ocation: /{s/^location: //;s/[^\/]*$//;x}' \ - -e '/<[Aa] \([Nn][Aa][Mm][Ee]=[^ ]* \)\?[Hh][Rr][Ee][Ff]=[^>]*>[Cc]ygwin '"$(echo "$version" | - sed 's/\./\\&/g')"'/{s/.* [Hh][Rr][Ee][Ff]="\([^"]*\).*/\1/;H;x;s/\n//;p;q}')" - fi && - - test -n "$cygwin_url" || - die "Could not retrieve Cygwin mail about v%s\n" "$version" - - commit_url=https://github.com/git-for-windows/msys2-runtime && - commit_url=$commit_url/commit/$(git rev-parse HEAD) && - cd ../.. && - if test "$version" = "$(sed -n 's/^pkgver=//p' ../.git/release_notes && - sed -i "s/^\\(pkgrel=\\).*/\\1$pkgrel/" PKGBUILD - else - pkgrel= - printf 'Comes with %s [%s](%s).' \ - 'MSYS2 runtime (Git for Windows flavor) based on' \ - "Cygwin $version" "$cygwin_url" >../.git/release_notes && - sed -i -e "s/^\\(pkgver=\\).*/\\1$version/" \ - -e "s/^\\(pkgrel=\\).*/\\11/" PKGBUILD - fi && - git commit -s -m "$package: update to v$version${pkgrel:+ ($pkgrel)}" PKGBUILD && - MSYSTEM=msys PATH="$sdk64/usr/bin:$PATH" \ - "$sdk64"/git-cmd.exe --command=usr\\bin\\sh.exe -l -c \ - ./update-patches.sh && - git commit --amend --no-edit -C HEAD && - create_bundle_artifact || - die "Could not update PKGBUILD of '%s' to version %s\n" \ - "$package" "$version" && - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main - ) || exit - release_notes_feature="$(cat "$sdk64$pkgpath/../.git/release_notes")" - ;; - mingw-w64-busybox) - (cd "$sdk64$pkgpath" && - if test ! -d src/busybox-w32 - then - MINGW_ARCH=mingw64 \ - "$sdk64"/git-cmd.exe --command=usr\\bin\\sh.exe -l -c \ - 'makepkg-mingw --nobuild --noprepare -s --noconfirm' - fi && - case "$(test -x /usr/bin/git && cat src/busybox-w32/.git/objects/info/alternates 2>/dev/null)" in - /*) - echo "dissociating worktree, to allow MINGW Git to access the worktree" >&2 && - /usr/bin/git -C src/busybox-w32 repack -ad && - rm src/busybox-w32/.git/objects/info/alternates - ;; - esac && - git stash && - url=https://github.com/git-for-windows/busybox-w32 && - (cd src/busybox-w32 && - require_remote git-for-windows "$url" && - require_remote rmyorston \ - https://github.com/rmyorston/busybox-w32 || - die "Could not connect remotes for '%s'\n" "$package" - base_rev=$(git for-each-ref --format='%(objectname)' --sort=-taggerdate \ - --count=1 refs/tags/FRP-\*) || - die "Could not determine base revision\n" - if test 0 -lt $(git rev-list --count \ - git-for-windows/main..$base_rev) - then - { test -n "$skip_upload" || - require_push_url git-for-windows; } && - git reset --hard && - git checkout git-for-windows/main && - GIT_EDITOR=true \ - "$sdk64"/usr/src/build-extra/shears.sh --merging \ - --onto $base_rev merging-rebase && - create_bundle_artifact && - { test -n "$skip_upload" || - git push git-for-windows HEAD:main; } || - die "Could not rebase '%s' to '%s'\n" \ - "$package" "rmyorston/HEAD" - fi) || - die "Could not initialize/rebase '%s'\n" "$package" - - built_from_commit="$(sed -n \ - 's/^pkgver=.*\.\([0-9a-f]*\)$/\1/p' ../.git/release_notes) || exit - release_notes_feature="$(cat "$sdk64$pkgpath/../.git/release_notes")" - ;; - openssh) - url=https://www.openssh.com - notes="$(curl -s $url/releasenotes.html)" || - die 'Could not obtain release notes from %s\n' \ - "$url/releasenotes.html" - newest="$(echo "$notes" | - sed -n '/OpenSSH [1-9].*href=.txt\/.*[0-9]p[1-9]/{ - s/.*href=.\(txt\/[^ ]*\). .*>\([1-9][^<]*\).*/\1 \2/p - q - }')" - version=${newest#* } - test -n "$version" || - die "Could not determine newest OpenSSH version\n" - url=$url/${newest% *} - release_notes_feature='Comes with [OpenSSH v'$version']('"$url"').' - sha256="$(echo "$notes" | - sed -n "s/.*SHA256 (openssh-$version\\.tar\\.gz) = \([^ ]*\).*/\\1/p" | - base64 -d | hexdump -e '1/1 "%02x"')" - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - grep "sha256sums.*$sha256" PKGBUILD && - git commit -s -m "openssh: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - ;; - openssl) - version="$(curl -s https://www.openssl.org/source/ | - sed -n 's/.*G[Nn][Uu] \?TLS [1-9]/{s/.*TLS \([1-9][0-9.]*\).*/\1/p;q}')" && - test -n "$version" || - die "Could not determine newest GNU TLS version\n" - - test -n "$only_mingw" || - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(_base_ver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) && - test 0 = $? || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main && - - (if test -n "$skip_mingw" - then - exit 0 - fi && - set_package mingw-w64-$1 && - maybe_init_repository "$sdk64$pkgpath" && - cd "$sdk64$pkgpath" && - { test -n "$skip_upload" || - require_push_url origin; } && - sdk="$sdk64" ff_main_branch || exit - - sed -i -e 's/^\(_pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "${package#mingw-w64-}: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact && - - if test -z "$skip_build" - then - build $force $cleanbuild "$package" && - sdk="$sdk64" pkg_copy_artifacts && - install "$package" && - if test -z "$skip_upload" - then - upload "$package" - fi - fi) && - test 0 = $? && - - v="$(echo "$version" | tr -dc 0-9.)" && - url="$(echo "$feed" | - sed -n '/]*>G[Nn][Uu] \?TLS [1-9]/{s/.*]*gawk-\([1-9][0-9.]*[0-9]\).*/\1/p;q}')" - test -n "$version" || - die "Could not determine version of %s\n" "$package" - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: upgrade to v$version" PKGBUILD && - create_bundle_artifact) || - exit - - url=http://git.savannah.gnu.org/cgit/gawk.git/plain && - url=$url/NEWS?h=gawk-$version && - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - release_notes_feature="Comes with [$package $v]($url)." - ;; - mingw-w64-git-sizer) - repo=github/git-sizer - url=https://api.github.com/repos/$repo/releases/latest - release="$(curl --netrc -s $url)" - test -n "$release" || - die "Could not determine the latest version of %s\n" "$package" - version="$(echo "$release" | - sed -n 's/^ "tag_name": "v\(.*\)",\?$/\1/p')" - test -n "$version" || - die "Could not determine version of %s\n" "$package" - - (cd "$sdk64$pkgpath" && - url=https://github.com/$repo/releases/download/v$version/ && - zip32="git-sizer-$version-windows-386.zip" && - zip64="git-sizer-$version-windows-amd64.zip" && - curl -LO $url$zip32 && - curl -LO $url$zip64 && - sha256_32=$(sha256sum $zip32 | cut -c-64) && - sha256_64=$(sha256sum $zip64 | cut -c-64) && - s1='s/\(sha256sum=\)[0-9a-f]*/\1' && - sed -i -e "s/^\\(pkgver=\\).*/\\1$version/" \ - -e "s/^\\(pkgrel=\\).*/\\11/" \ - -e "/^i686)/{N;N;$s1$sha256_32/}" \ - -e "/^x86_64)/{N;N;$s1$sha256_64/}" \ - PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - git commit -s -m "Upgrade $package to $version${force_pkgrel:+-$force_pkgrel}" PKGBUILD && - create_bundle_artifact) - ;; - mingw-w64-nodejs) - url=https://nodejs.org/en/download/ - downloads="$(curl $url)" || - die "Could not download node.js' Downloads page\n" - - version="$(echo "$downloads" | sed -n -e \ - 's|.*https://nodejs.org/dist/v\([0-9.]*\)/.*|\1|p' | - uniq)" - test -n "$version" || - die "Could not determine current node.js version\n" - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: upgrade to v$version" PKGBUILD && - create_bundle_artifact) || - exit - - url=https://nodejs.org/en/blog/release/v$version/ && - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - release_notes_feature="Comes with [$package $v]($url)." - ;; - mingw-w64-xpdf-tools) - # If we ever have to upgrade beyond xpdf 4.00, we will - # implement this part. But no sooner. - ;; - mintty) - repo=mintty/mintty - url=https://api.github.com/repos/$repo/releases/latest - release="$(curl --netrc -s $url)" - test -n "$release" || - die "Could not determine the latest version of %s\n" "$package" - version="$(echo "$release" | - sed -n 's/^ "tag_name": "\(.*\)",\?$/\1/p')" - test -n "$version" || - die "Could not determine version of %s\n" "$package" - - (cd "$sdk64$pkgpath" && - sed -i -e "s/^\\(pkgver=\\).*/\\1$version/" \ - -e "s/^\\(pkgrel=\\).*/\\11/" \ - PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "Upgrade $package to $version${force_pkgrel:+-$force_pkgrel}" PKGBUILD && - create_bundle_artifact) - ;; - git-flow) - repo=petervanderdoes/gitflow-avh - url=https://api.github.com/repos/$repo/releases/latest - release="$(curl --netrc -s $url)" - test -n "$release" || - die "Could not determine the latest version of %s\n" "$package" - version="$(echo "$release" | - sed -n 's/^ "tag_name": "\(.*\)",\?$/\1/p')" - test -n "$version" || - die "Could not determine version of %s\n" "$package" - - # git-flow 1.12.2 was somehow released as tag only, without - # release notes, so we would only find 1.12.1... - # see https://github.com/petervanderdoes/gitflow-avh/issues/406 - # for details. - test 1.12.1 != "$version" || - version=1.12.2 - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - - url=https://github.com/$repo/releases/tag/$version && - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - release_notes_feature="Comes with [$package $v]($url)." - ;; - serf) - url=https://serf.apache.org/download - notes="$(curl -s $url)" || - die 'Could not obtain download page from %s\n' \ - "$url" - version="$(echo "$notes" | - sed -n 's|.*The latest stable release of Serf is \(\)\?\([1-9][.0-9]*\).*|\2|p')" - test -n "$version" || - die "Could not determine newest $package version\n" - url=https://svn.apache.org/repos/asf/serf/trunk/CHANGES - release_notes_feature='Comes with ['$package' v'$version']('"$url"').' - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - ;; - pkgconf) - url=https://api.github.com/repos/pkgconf/pkgconf/tags - tags="$(curl --netrc -s $url)" - test -n "$tags" || - die "Could not get tags of %s\n" "$package" - version="$(echo "$tags" | - sed -n 's/^ "name": "pkgconf-\(.*\)",\?$/\1/p' | - sort -rnt. -k1,1 -k2,2 -k3,3 | - head -n 1)" - test -n "$version" || - die "Could not determine version of %s\n" "$package" - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - ;; - libgpg-error) - url='https://dev.gnupg.org/source/libgpg-error/tags/' - tags="$(curl -s "$url")" || - test $? = 56 || - die 'Could not obtain download page from %s\n' "$url" - version="$(echo "$tags" | - sed 'y/]*>libgpg-error-[1-9][.0-9]*$/{s/.*>libgpg-error-\([.0-9]*\).*/\1/p}' | - sort -rnt. -k1,1 -k2,2 -k3,3 | - head -n 1)" - test -n "$version" || - die "Could not determine newest $package version\n" - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - ;; - libgcrypt) - url='https://dev.gnupg.org/source/libgcrypt/tags/' - tags="$(curl -s "$url")" || - test $? = 56 || - die 'Could not obtain download page from %s\n' "$url" - version="$(echo "$tags" | - sed 'y/]*>libgcrypt-[1-9][.0-9]*$/{s/.*>libgcrypt-\([.0-9]*\).*/\1/p}' | - sort -rnt. -k1,1 -k2,2 -k3,3 | - head -n 1)" - test -n "$version" || - die "Could not determine newest $package version\n" - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - ;; - gnupg) - url='https://dev.gnupg.org/source/gnupg/tags/' - tags="$(curl -s "$url")" || - test $? = 56 || - die 'Could not obtain download page from %s\n' "$url" - version="$(echo "$tags" | - sed -n '/ href=[^>]*>gnupg-[1-9][.0-9]*gnupg-\([.0-9]*\).*/>\1/;s/.*>//p;q}')" - test -n "$version" || - die "Could not determine newest $package version\n" - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - - announce_url= - url2=https://lists.gnupg.org/pipermail/gnupg-announce/ - mails="$(curl -s "$url2")" || - die 'Could not obtain download page from %s\n' "$url2" - for d in $(echo "$mails" | sed -n 's/.*.*GnuPG '"$(echo "$version" | - sed 's/\./\\./g' - )"'/{s/.* HREF="\([^"]*\).*/\1/p;q}')" - test -n "$m" || continue - announce_url="$url2${d%/*}/$m" - break - done - test -n "$announce_url" || - die "Did not find announcement mail for GNU Privacy Guard %s\n" "$v" - release_notes_feature='Comes with [GNU Privacy Guard '"$v"']('"$announce_url"').' - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - ;; - mingw-w64-pcre2) - repo=PCRE2Project/pcre2 - url=https://api.github.com/repos/$repo/releases/latest - release="$(curl --netrc -Ls $url)" - test -n "$release" || - die "Could not determine the latest version of %s\n" "$package" - tag="$(echo "$release" | - sed -n 's/^ "tag_name": "\(.*\)",\?$/\1/p')" - version=${tag#pcre2-} - test -n "$version" || - die "Could not determine version of %s\n" "$package" - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: upgrade to v$version" PKGBUILD && - create_bundle_artifact) || - exit - - url=https://raw.githubusercontent.com/$repo/$tag/ChangeLog - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - release_notes_feature="Comes with [PCRE2 $v]($url)." - ;; - libcbor) - repo=PJK/libcbor - url=https://api.github.com/repos/$repo/releases/latest - release="$(curl --netrc -s $url)" - test -n "$release" || - die "Could not determine the latest version of %s\n" "$package" - version="$(echo "$release" | - sed -n 's/^ "tag_name": "v\(.*\)",\?$/\1/p')" - test -n "$version" || - die "Could not determine version of %s\n" "$package" - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - - url=https://github.com/$repo/releases/tag/$version && - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - release_notes_feature="Comes with [$package $v]($url)." - ;; - libfido2) - repo=Yubico/libfido2 - url=https://api.github.com/repos/$repo/tags?per_page=1 - release="$(curl --netrc -s $url)" - test -n "$release" || - die "Could not determine the latest version of %s\n" "$package" - version="$(echo "$release" | - sed -n 's/^ "name": "\(.*\)",\?$/\1/p')" - test -n "$version" || - die "Could not determine version of %s\n" "$package" - - (cd "$sdk64$pkgpath" && - sed -i -e 's/^\(pkgver=\).*/\1'$version/ \ - -e 's/^pkgrel=.*/pkgrel=1/' PKGBUILD && - maybe_force_pkgrel "$force_pkgrel" && - updpkgsums && - git commit -s -m "$package: new version ($version${force_pkgrel:+-$force_pkgrel})" PKGBUILD && - create_bundle_artifact) || - die "Could not update %s\n" "$sdk64$pkgpath/PKGBUILD" - - git -C "$sdk32$pkgpath" pull "$sdk64$pkgpath/.." main || - die "Could not update $sdk32$pkgpath" - - url=https://github.com/$repo/releases/tag/$version && - v="v$version${force_pkgrel:+ ($force_pkgrel)}" && - release_notes_feature="Comes with [$package $v]($url)." - ;; - *) - die "Unhandled package: %s\n" "$package" - ;; - esac && - - if test -n "$release_notes_feature" && test -z "$skip_upload" - then - (cd "$sdk64/usr/src/build-extra" && - require_push_url origin) - fi && - - if { test -z "$only_mingw" || test MINGW = $type; } && test -z "$skip_build" - then - build $force $cleanbuild "$package" && - (cd "$pkgpath" && sdk= && pkg_copy_artifacts) && - install "$package" && - if test -z "$skip_upload"; then upload "$package"; fi - fi && - - if test -n "$release_notes_feature" - then - (cd "$sdk64/usr/src/build-extra" && - git pull origin main && - mention --may-be-already-there feature \ - "$release_notes_feature" && - create_bundle_artifact && - if test -z "$skip_upload" - then - really_push origin HEAD - fi) - fi -} - -set_version_from_tag_name () { - version="${1#refs/tags/}" - version="${version#v}" - ver="$(echo "$version" | sed -n \ - 's/^\([0-9]*\.[0-9]*\.[0-9]*\(-rc[0-9]*\)\?\)\.windows\(\.1\|\(\.[0-9]*\)\)$/\1\4/p')" - test -n "$ver" || - die "Unexpected version format: %s\n" "$version" - - display_version="$ver" - case "$display_version" in - *.*.*.*) - display_version="${display_version%.*}(${display_version##*.})" - ;; - esac -} - -version_from_release_notes () { - sed -e '1s/^# Git for Windows v\(.*\) Release Notes$/\1/' -e 1q \ - "$sdk64/usr/src/build-extra/ReleaseNotes.md" -} - -today () { - LC_ALL=C date +"%B %-d %Y" | - sed -e 's/\( [2-9]\?[4-90]\| 1[0-9]\) /\1th /' \ - -e 's/1 /1st /' -e 's/2 /2nd /' -e 's/3 /3rd /' -} - -mention () { # [--may-be-already-there] - up_to_date /usr/src/build-extra || - die "build-extra is not up-to-date\n" - - (cd /usr/src/build-extra && node ./add-release-note.js --commit "$@") -} - -finalize () { # [--delete-existing-tag] - delete_existing_tag= - release_date= - branch_to_use= - while case "$1" in - --delete-existing-tag) delete_existing_tag=t;; - --release-date=*) release_date="$(echo "${1#*=}" | tr +_ ' ')";; - --use-branch=*) branch_to_use="${1#*=}";; - *) break;; - esac; do shift; done - - case "$1" in - rel|rel-notes|release-notes) ;; - *) die "I don't know how to finalize %s\n" "$1";; - esac - - up_to_date /usr/src/build-extra || - die "build-extra is not up-to-date\n" - - set_package git && - git_src_dir="$sdk64$pkgpath"/src/git && - require_git_src_dir && - (cd "$git_src_dir"/.git && - require_remote upstream https://github.com/git/git && - require_remote git-for-windows \ - https://github.com/git-for-windows/git) && - dir_option="--git-dir=$sdk64$pkgpath"/src/git/.git && - git "$dir_option" fetch --tags git-for-windows && - git "$dir_option" fetch --tags upstream || - die "Could not update Git\n" - - case "$branch_to_use" in - *@*) - git "$dir_option" fetch --tags --prune-tags \ - "${branch_to_use#*@}" "${branch_to_use%%@*}" || - die "Could not fetch '%s' from '%s'\n" \ - "${branch_to_use%%@*}" "${branch_to_use#*@}" - branch_to_use=FETCH_HEAD - ;; - esac - branch_to_use="${branch_to_use:-git-for-windows/main}" - - ver="$(git "$dir_option" \ - describe --first-parent --match 'v[0-9]*[0-9]' \ - "$branch_to_use")" || - die "Cannot describe current revision of Git\n" - - ver=${ver%%-[1-9]*} - - # With --delete-existing-tag, delete previously generated tags, e.g. - # from failed automated builds - while test -n "$delete_existing_tag" && - test 0 = $(git "$dir_option" rev-list --count \ - "$ver".."$branch_to_use") - do - case "$ver" in - *.windows.*) ;; # delete and continue - *) break;; - esac - - git "$dir_option" tag -d "$ver" || - die "Could not delete tag '%s'\n" "$ver" - - ver="$(git "$dir_option" \ - describe --first-parent --match 'v[0-9]*[0-9]' \ - "$branch_to_use")" || - die "Cannot describe current revision of Git\n" - - ver=${ver%%-*} - done - - case "$ver" in - *.windows.*) - test 0 -lt $(git "$dir_option" rev-list --count \ - "$ver".."$branch_to_use") || - die "Already tagged: %s\n" "$ver" - - next_version=${ver%.windows.*}.windows.$((${ver##*.windows.}+1)) - display_version="${ver%.windows.*}(${next_version##*.windows.})" - ;; - *) - i=1 - display_version="$ver" - while git "$dir_option" \ - rev-parse --verify $ver.windows.$i >/dev/null 2>&1 - do - i=$(($i+1)) - display_version="$ver($i)" - done - next_version=$ver.windows.$i - ;; - esac - display_version=${display_version#v} - - test "$display_version" != "$(version_from_release_notes)" || - die "Version %s already in the release notes\n" "$display_version" - - case "$next_version" in - *.windows.1) - v=${next_version%.windows.1} && - if ! grep -q "^\\* Comes with \\[Git $v\\]" \ - "$sdk64"/usr/src/build-extra/ReleaseNotes.md - then - url=https://github.com/git/git/blob/$v && - adoc="$(echo "${v#v}" | sed 's/-rc[0-9]*$//').adoc" && - url=$url/Documentation/RelNotes/$adoc && - mention feature 'Comes with [Git '$v']('$url').' - fi || - die "Could not mention that Git was upgraded to $v\n" - ;; - esac - - test -n "$release_date" || - release_date="$(today)" - - sed -i -e "1s/.*/# Git for Windows v$display_version Release Notes/" \ - -e "2s/.*/Latest update: $release_date/" \ - "$sdk64"/usr/src/build-extra/ReleaseNotes.md || - die "Could not edit release notes\n" - - (cd "$sdk64"/usr/src/build-extra && - git commit -s -m "Prepare release notes for v$display_version" \ - ReleaseNotes.md) || - die "Could not commit finalized release notes\n" - - (cd "$sdk32"/usr/src/build-extra && - git pull --ff-only "$sdk64"/usr/src/build-extra main) || - die "Could not update 32-bit SDK's release notes\n" -} - -sign_files () { - if test -z "$(git --git-dir="$sdk64/usr/src/build-extra/.git" \ - config alias.signtool)" - then - printf "\n%s\n\n%s\n\n\t%s %s\n\n%s\n\n\t%s\n" \ - "WARNING: No signing performed!" \ - "To fix this, set alias.signtool to something like" \ - "!'c:/PROGRA~1/MICROS~1/Windows/v7.1/Bin/signtool.exe" \ - "sign //v //f my-cert.p12 //p my-password'" \ - "The Windows Platform SDK contains the signtool.exe:" \ - http://go.microsoft.com/fwlink/p/?linkid=84091 >&2 - else - for file in "$@" - do - git --git-dir="$sdk64/usr/src/build-extra/.git" \ - signtool "$file" || - die "Could not sign %s\n" "$file" - done - fi -} - bundle_pdbs () { # [--directory=] [--arch=] [] packages="mingw-w64-git-pdb mingw-w64-curl-pdb mingw-w64-openssl-pdb" @@ -2901,100 +372,6 @@ bundle_pdbs () { # [--directory=] [-- done } -render_release_notes_and_mail () { # [...] - test -d "$1" || mkdir "$1" || die "Could not create '%s'\n" "$1" - case "$2" in - *-[0-9]*) - ver="${2#v}" - display_version="prerelease-$2" - ;; - v[0-9]*.windows.[0-9]|v[1-9]*.windows.[1-9][0-9]) - set_version_from_tag_name "$2" - ;; - *) - die "Unhandled version: %s\n" "$2" - ;; - esac - - name="Git for Windows $display_version" - text="$(sed -n \ - "/^## Changes since/,\${s/## //;:1;p;n;/^## Changes/q;b1}" \ - <"$sdk64"/usr/src/build-extra/ReleaseNotes.md)" - checksums="$(printf '%s | %s\n' \ - Git-"$ver"-64-bit.exe $3 \ - Git-"$ver"-32-bit.exe $4 \ - PortableGit-"$ver"-64-bit.7z.exe $5 \ - PortableGit-"$ver"-32-bit.7z.exe $6 \ - MinGit-"$ver"-64-bit.zip $7 \ - MinGit-"$ver"-32-bit.zip $8 \ - MinGit-"$ver"-busybox-64-bit.zip $9 \ - MinGit-"$ver"-busybox-32-bit.zip ${10} \ - Git-"$ver"-64-bit.tar.bz2 ${11} \ - Git-"$ver"-32-bit.tar.bz2 ${12})" - body="$(printf "%s\n\n%s\n%s\n%s" "$text" \ - 'Filename | SHA-256' '-------- | -------' "$checksums")" - echo "$body" >"$1/release-notes-$ver" - - # Required to render the release notes for the announcement mail - type w3m || - case "$(uname -s)" in - Linux) - sudo apt-get -y install w3m || - die "Could not install w3m\n" - ;; - MINGW*|MSYS) - sdk="$sdk64" require w3m - ;; - *) - die "Could not install w3m\n" - ;; - esac - - url=https://gitforwindows.org/ - case "$display_version" in - prerelease-*) - url=https://gitforwindows.org/git-snapshots/ - ;; - *-rc*) - url=https://github.com/git-for-windows/git/releases/tag/$2 - ;; - esac - - prefix="$(printf "%s\n\n%s%s\n\n %s\n" \ - "Dear Git users," \ - "I hereby announce that Git for Windows " \ - "$display_version is available from:" \ - "$url")" - rendered="$(echo "$text" | - if type markdown >&2 - then - markdown | - LC_CTYPE=C w3m -dump -cols 72 -T text/html - else - "$sdk64/git-cmd.exe" --command=usr\\bin\\sh.exe -l -c \ - 'markdown | - LC_CTYPE=C w3m -dump -cols 72 -T text/html' - fi)" - printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n%s\n" \ - "From $version Mon Sep 17 00:00:00 2001" \ - "From: $(git var GIT_COMMITTER_IDENT | sed -e 's/>.*/>/')" \ - "Date: $(date -R)" \ - "To: git-for-windows@googlegroups.com, git@vger.kernel.org, git-packagers@googlegroups.com" \ - "Subject: [ANNOUNCE] Git for Windows $display_version" \ - "Content-Type: text/plain; charset=UTF-8" \ - "Content-Transfer-Encoding: 8bit" \ - "MIME-Version: 1.0" \ - "Fcc: Sent" \ - "$prefix" \ - "$rendered" \ - "$checksums" \ - "Ciao," \ - "$(git var GIT_COMMITTER_IDENT | sed -e 's/ .*//')" \ - >"$1/announce-$ver" - - echo "Announcement saved as $1/announcement-$ver" >&2 -} - release_sdk () { # version="$1" tag=git-sdk-"$version" @@ -3677,48 +1054,6 @@ make_installers_from_mingw_w64_git () { # [--pkg=[,...]] [--ve done } -# This function can build a given package in the current SDK and copy the result into a specified directory -build_and_copy_artifacts () { # --directory= [--force] [--cleanbuild] - artifactsdir= - force= - cleanbuild= - while case "$1" in - --directory=*) - artifactsdir="$(cygpath -am "${1#*=}")" || exit - test -d "$artifactsdir" || - mkdir "$artifactsdir" || - die "Could not create artifacts directory: %s\n" "$artifactsdir" - ;; - --directory) - shift - artifactsdir="$(cygpath -am "$1")" || exit - test -d "$artifactsdir" || - mkdir "$artifactsdir" || - die "Could not create artifacts directory: %s\n" "$artifactsdir" - ;; - -f|--force) - force=--force - ;; - --cleanbuild) - cleanbuild=--cleanbuild - ;; - -*) die "Unknown option: %s\n" "$1";; - *) break;; - esac; do shift; done - test $# = 1 || - die "Expected 1 argument, got $#: %s\n" "$*" - - test -n "$artifactsdir" || - die "Need a directory to copy the artifacts to\n" - - set_package "$1" && - - cd "$pkgpath" && - sdk= pkg_build $force $cleanbuild && - sdk= pkg_copy_artifacts || - die "Could not copy artifacts for '%s' to '%s'\n" "$package" "$artifactsdir" -} - this_script_path="$(cd "$(dirname "$0")" && echo "$(pwd -W)/$(basename "$0")")" || die "Could not determine this script's path\n"