Commit 0ef4d2a
committed
pacman-helper.sh quick_*: be more careful about removing archives
An important part of the `quick_*` functions is to remove the archives
that are no longer needed. For example, when adding a new version with
`quick_add`, the package archive of the superseded version (if any) is
removed.
Example: When deploying OpenSSH v9.9p2, `pacman-helper.sh quick_add
`openssh-9.9p2-1-x86_64.pkg.tar.xz`, was called, which removed
`openssh-9.9p1-2-x86_64.pkg.tar.xz` because that was no longer needed,
and likewise the corresponding `.sig` file.
As pointed out by Jeremy Drake, the shell pattern that is used to
perform this job, however, is too fragile: it does not account for
package names that have an `-<digit>` infix, e.g. `msys2-runtime-3.3`.
That is, when upgrading `msys2-runtime` via `quick_add`, it would not
only remove the superseded `msys2-runtime` package, but also the
`msys2-runtime-3.3` and the `msys2-runtime-3.3-devel` archives as well!
Lets' be more careful about this.
Sadly, there is no way to do this with non-greedy patterns: wildcard
patterns only support greedy matches. That is, `-[0-9]*` will happily
match anything via that `*`, including `-<digit>`, i.e. the maximal
suffix, not the minimal suffix.
So let's use "exclude patterns" (a Git-specific feature) to exclude
any false positives.
This is still slightly fragile, as it will prevent `quick_*` from
working correctly when passing, say, _both_ `msys2-runtime-3.3` _and_
`msys2-runtime`: exclude patterns are not positional, and therefore
this command would _not_ match `msys2-runtime-3.3`:
git ls-files -- \
'msys2-runtime-[0-9]*' \
':(exclude)msys2-runtime-[0-9]*-*-*-*' \
'msys2-runtime-3.3-[0-9]*' \
':(exclude)msys2-runtime-3.3-[0-9]*-*-*-*'
The first `:(exclude)` pattern would prevent the subsequent pattern from
matching `msys2-runtime-3.3-<digit>`.
Nevertheless, this scenario is unlikely, as the principal use case of
`quick_add` is the `/deploy` slash command in Git for Windows'
MINGW-packages and MSYS2-packages PullRequests. And there, we only
deploy a single package at a time, not two.
And even in case we should run afoul of this fragility in a
(semi-manual) `quick_remove` invocation, the fix is easy: manually
remove the files that haven't been removed by mistake. This is all about
the tip of the `x86_64`, `aarch64` and `i686` branches of
https://github.com/git-for-windows/pacman-repo, after all, and such a
manual fix is but a trivial PullRequest away. Contrary to the problem
addressed by this commit, this fragility would not affect the operation
of the Pacman repository, either, because it would serve too many files,
not too few.
Helped-by: Jeremy Drake <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>1 parent 3df2696 commit 0ef4d2a
1 file changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
| |||
0 commit comments