@@ -30,13 +30,14 @@ die () {
3030
3131mode=
3232case " $1 " in
33- lock|unlock|break_lock|quick_add)
33+ lock|unlock|break_lock|quick_add|quick_remove )
3434 mode=" $1 "
3535 shift
3636 ;;
3737* )
38- die " Usage:\n%s\n%s\n" \
38+ die " Usage:\n%s\n%s\n%s\n " \
3939 " $0 quick_add <package>..." \
40+ " $0 quick_remove <package>..." \
4041 " $0 ( lock | unlock <id> | break_lock )"
4142 ;;
4243esac
@@ -107,6 +108,23 @@ repo_add () {
107108 " $this_script_dir /repo-add" " $@ "
108109}
109110
111+ repo_remove () {
112+ if test ! -s " $this_script_dir /repo-remove"
113+ then
114+ # Make sure that GPGKEY is used unquoted
115+ sed ' s/"\(\${\?GPGKEY}\?\)"/\1/g' < /usr/bin/repo-remove > " $this_script_dir /repo-remove"
116+ fi &&
117+ " $this_script_dir /repo-remove" $( for arg
118+ do
119+ # repo-remove only accepts package _names_, but we are potentially given _files_.
120+ # Handle this by distilling the package names from filenames.
121+ case " $arg " in
122+ * .pkg.tar.xz|* .pkg.tar.zst) echo " ${arg% -* -* -* } " ;;
123+ * ) echo " $arg " ;;
124+ esac
125+ done)
126+ }
127+
110128sanitize_db () { # <file>...
111129 perl -e '
112130 foreach my $path (@ARGV) {
@@ -174,10 +192,17 @@ sanitize_db () { # <file>...
174192 fi
175193}
176194
177- quick_add () { # <file>...
178- test $# -gt 0 ||
195+ quick_action () { # <action> <file>...
196+ test $# -gt 1 ||
179197 die " Need at least one file"
180198
199+ label=" $1 "
200+ shift
201+ case " $label " in
202+ add|remove) action=repo_$label ;;
203+ * ) die " Unknown action '$action '" ;;
204+ esac
205+
181206 if test -z " $PACMANDRYRUN$azure_blobs_token "
182207 then
183208 azure_blobs_token=" $( cat " $HOME " /.azure-blobs-token) " &&
@@ -212,7 +237,8 @@ quick_add () { # <file>...
212237 x86_64_msys=
213238 all_files=
214239
215- # Copy the file(s) to the temporary directory, and schedule their addition to the appropriate index(es)
240+ # Copy the file(s) to the temporary directory, and schedule their addition to the appropriate index(es),
241+ # or for `remove`: schedule their removal from the appropriate index(es).
216242 for path in " $@ "
217243 do
218244 file=" ${path##*/ } "
@@ -259,12 +285,12 @@ quick_add () { # <file>...
259285 * ) echo " Skipping file with unknown arch: $file " >&2 ; continue ;;
260286 esac
261287
262- echo " Copying $file to $arch /..." >&2
263288 test -z " $key " || eval " $key =\$ $key \\ $file "
264289 all_files=" $all_files $arch /$file "
265290
266291 if test ! -d " $dir /$arch "
267292 then
293+ echo " Initializing $dir /$arch ..." >&2
268294 git -C " $dir " rev-parse --quiet --verify refs/remotes/origin/$arch > /dev/null ||
269295 git -C " $dir " fetch --depth=1 origin x86_64 aarch64 i686 ||
270296 die " $dir : could not fetch from pacman-repo"
@@ -273,6 +299,15 @@ quick_add () { # <file>...
273299 die " Could not initialize $dir /$arch "
274300 fi
275301
302+ case " $label " in
303+ remove)
304+ test -z " $GPGKEY " ||
305+ all_files=" $all_files $arch /$file .sig"
306+ continue
307+ ;;
308+ esac
309+
310+ echo " Copying $file to $arch /..." >&2
276311 cp " $path " " $dir /$arch " ||
277312 die " Could not copy $path to $dir /$arch "
278313
@@ -293,7 +328,7 @@ quick_add () { # <file>...
293328 PACMAN_DB_LEASE=" $( lock) " ||
294329 die ' Could not obtain a lock for uploading'
295330
296- # Verify that the package databases are synchronized and add files
331+ # Verify that the package databases are synchronized and add or remove files
297332 sign_option=
298333 test -z " $GPGKEY " || sign_option=--sign
299334 dbs=
@@ -355,8 +390,8 @@ quick_add () { # <file>...
355390 git diff-index --quiet HEAD -- ||
356391 die " The package databases in $arch differ between Azure Blobs and pacman-repo"
357392
358- # Now add the files to the Pacman database
359- repo_add $sign_option git-for-windows-$arch .db.tar.xz $msys $mingw &&
393+ # Now add or remove the files to the Pacman database
394+ $action $sign_option git-for-windows-$arch .db.tar.xz $msys $mingw &&
360395 { test ! -h git-for-windows-$arch .db || rm git-for-windows-$arch .db; } &&
361396 cp git-for-windows-$arch .db.tar.xz git-for-windows-$arch .db && {
362397 test -z " $sign_option " || {
@@ -366,7 +401,7 @@ quick_add () { # <file>...
366401 } &&
367402 if test -n " $db2 "
368403 then
369- repo_add $sign_option git-for-windows-$db2 .db.tar.xz $mingw &&
404+ $action $sign_option git-for-windows-$db2 .db.tar.xz $mingw &&
370405 { test ! -h git-for-windows-$db2 .db || rm git-for-windows-$db2 .db; } &&
371406 cp git-for-windows-$db2 .db.tar.xz git-for-windows-$db2 .db && {
372407 test -z " $sign_option " || {
@@ -376,20 +411,28 @@ quick_add () { # <file>...
376411 }
377412 fi &&
378413
379- # Remove previous versions from the Git branch
414+ # Remove the existing versions from the Git branch
380415 printf ' %s\n' $msys $mingw |
381416 sed ' s/-[^-]*-[^-]*-[^-]*\.pkg\.tar\.\(xz\|zst\)$/-[0-9]*/' |
382417 xargs git rm --sparse --cached -- ||
383- die " Could not remove previous versions from the Git branch in $arch "
418+ die " Could not remove the existing versions from the Git branch in $arch "
384419
385420 # Now add the files to the Git branch
386- git add --sparse $msys $mingw \* .sig ' :(exclude)*.old.sig' &&
387- msg=" $( printf ' Update %s package(s)\n\n%s\n' \
388- $( printf ' %s\n' $msys $mingw | wc -l) \
389- " $( printf ' %s\n' $msys $mingw |
390- sed ' s/^\(.*\)-\([^-]*-[^-]*\)-[^-]*\.pkg\.tar\.\(xz\|zst\)$/\1 -> \2/' ) " ) " &&
421+ case " $label " in
422+ add)
423+ git add --sparse $msys $mingw \* .sig ' :(exclude)*.old.sig' &&
424+ msg=" $( printf ' Update %s package(s)\n\n%s\n' \
425+ $( printf ' %s\n' $msys $mingw | wc -l) \
426+ " $( printf ' %s\n' $msys $mingw |
427+ sed ' s/^\(.*\)-\([^-]*-[^-]*\)-[^-]*\.pkg\.tar\.\(xz\|zst\)$/\1 -> \2/' ) " ) "
428+ ;;
429+ remove)
430+ msg=" $( printf ' Remove %s package(s)\n\n%s\n' \
431+ $( printf ' %s\n' $msys $mingw | wc -l) \
432+ " $( printf ' %s\n' $msys $mingw ) " ) "
433+ esac &&
391434 git commit -asm " $msg " ) ||
392- die " Could not add $msys $mingw to db in $arch "
435+ die " Could not ${label} $msys $mingw to/from db in $arch "
393436 done
394437
395438 test -n " $to_push " || die " No packages to push?!"
@@ -427,11 +470,14 @@ quick_add () { # <file>...
427470
428471 eval " msys=\$ ${arch} _msys" &&
429472 eval " mingw=\$ ${arch} _mingw" &&
430- printf ' %s\n' $msys $mingw |
431- sed ' s/-[^-]*-[^-]*-[^-]*\.pkg\.tar\.\(xz\|zst\)$/-[0-9]*/' |
432- xargs -r git restore --ignore-skip-worktree-bits -- &&
433-
434- repo_add $sign_option git-for-windows-$arch .db.tar.xz $msys $mingw &&
473+ case " $label " in
474+ add)
475+ printf ' %s\n' $msys $mingw |
476+ sed ' s/-[^-]*-[^-]*-[^-]*\.pkg\.tar\.\(xz\|zst\)$/-[0-9]*/' |
477+ xargs -r git restore --ignore-skip-worktree-bits --
478+ ;;
479+ esac &&
480+ $action $sign_option git-for-windows-$arch .db.tar.xz $msys $mingw &&
435481 { test ! -h git-for-windows-$arch .db || rm git-for-windows-$arch .db; } &&
436482 cp git-for-windows-$arch .db.tar.xz git-for-windows-$arch .db && {
437483 test -z " $sign_option " || {
@@ -441,7 +487,7 @@ quick_add () { # <file>...
441487 } &&
442488 if test -n " $db2 "
443489 then
444- repo_add $sign_option git-for-windows-$db2 .db.tar.xz $mingw &&
490+ $action $sign_option git-for-windows-$db2 .db.tar.xz $mingw &&
445491 { test ! -h git-for-windows-$db2 .db || rm git-for-windows-$db2 .db; } &&
446492 cp git-for-windows-$db2 .db.tar.xz git-for-windows-$db2 .db && {
447493 test -z " $sign_option " || {
@@ -551,6 +597,14 @@ quick_add () { # <file>...
551597 die " Could not remove $dir /"
552598}
553599
600+ quick_add () {
601+ quick_action add " $@ "
602+ }
603+
604+ quick_remove () {
605+ quick_action remove " $@ "
606+ }
607+
554608lock () { #
555609 test -z " $PACMANDRYRUN " || {
556610 echo " upload: wingit-snapshot-helper.sh wingit x86-64 <token> lock git-for-windows.db" >&2
0 commit comments