Skip to content

Commit b9a324f

Browse files
committed
feat: revert add ability to downgrade aur package using git
This reverts commit 3fd2cdc. The m4 processing of src/downgrade is mangling some introduced quotes. This breaks downgrade entirely, not just this feature. Reverting until we can bolster CI to catch such a bug.
1 parent 3fd2cdc commit b9a324f

File tree

5 files changed

+5
-116
lines changed

5 files changed

+5
-116
lines changed

dist/completion/downgrade/fish

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ complete -c $cmd -l pacman -xa "(complete -C(commandline -ct))" -d 'pacman comma
44
complete -c $cmd -l pacman-conf -r -d 'pacman configuration file'
55
complete -c $cmd -l pacman-cache -r -d 'pacman cache directory'
66
complete -c $cmd -l pacman-log -r -d 'pacman log file'
7-
complete -c $cmd -l git -d 'uses git for choosing version, viable only for aur packages'
87
complete -c $cmd -l maxdepth -x -d 'maximum depth to search for cached packages'
98
complete -c $cmd -l ala-url -x -d 'location of ALA server'
109
complete -c $cmd -l ala-only -d 'only use ALA server'

dist/completion/downgrade/zsh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ _downgrade () {
2020
'--pacman-conf[pacman configuration file]:pacman config file:_files' \
2121
'*--pacman-cache[pacman cache directory]:pacman cache directory:_path_files -/' \
2222
'--pacman-log[pacman log file]:pacman log file:_files' \
23-
'--git[uses git for choosing version, viable only for aur packages]' \
2423
'--maxdepth[maximum depth to search for cached packages]:maximum search depth' \
2524
'--ala-url[location of ALA server]:ala url' \
2625
'--ala-only[only use ALA server]' \

doc/downgrade.8.ronn

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@ on the ALA.
7272
Pacman log file, default value is extracted from pacman configuration file, or
7373
otherwise defaults to _/var/log/pacman.log_.
7474

75-
* `--git`:
76-
If the pacman cache contains the source repository for the package (e.g. if
77-
you use yay and are downgrading an AUR package), present any version-like
78-
tags as available for downgrading (together with cached packages if
79-
present). If selected, build and install the package from sources checked
80-
out at that tag.
81-
82-
See [EXAMPLES].
83-
8475
* `--maxdepth`=<INTEGER>:
8576
Maximum depth to search for cached packages, defaults to _1_.
8677

@@ -177,11 +168,6 @@ Non-interactively downgrade `foo` to `1.0.0-1`
177168

178169
# downgrade --latest --prefer-cache --ignore never 'foo=1.0.0-1'
179170

180-
Present cached `downgrade` pkgbuilds together with tags with version greater
181-
than 9
182-
183-
# downgrade --git --pacman-cache ~/.cache/yay --maxdepth 2 'downgrade>9.0.0'
184-
185171
## AUTHORS
186172

187173
* Patrick Brisbin \<pbrisbin@gmail.com>

src/downgrade

Lines changed: 5 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ $(gettext "Options"):
1919
$(gettext "pacman log file,")
2020
$(gettext "default value taken from pacman configuration file,")
2121
$(gettext "or otherwise defaults to") "/var/log/pacman.log"
22-
--git $(gettext "uses git for choosing version, viable only for aur packages")
2322
--maxdepth <$(gettext "integer")>
2423
$(gettext "maximum depth to search for cached packages, defaults to") 1
2524
--ala-url <url>
@@ -168,10 +167,8 @@ matches_name_version_filter() {
168167
return 0
169168
fi
170169

171-
# version: 2025.11.12.r15.g0eed3fe
172-
version_regex="[a-zA-Z0-9.]+"
173-
hash_or_minor="([0-9]+|[a-z0-9]{6,})"
174-
pkg_version=$(sed -r "s/.*$name-($version_regex)(-$hash_or_minor)?-(any|$DOWNGRADE_ARCH)\\.(git)?pkg\\.tar\\.(gz|xz|zst)/\1\2/g" <<<"$pkg")
170+
version_regex="[^-]+-[0-9.]+"
171+
pkg_version=$(sed -r "s/.*$name-($version_regex)-(any|$DOWNGRADE_ARCH)\\.pkg\\.tar\\.(gz|xz|zst)/\1/g" <<<"$pkg")
175172
cmp=$(vercmp "$pkg_version" "$search_version")
176173

177174
case "$operator" in
@@ -199,34 +196,6 @@ matches_name_version_filter() {
199196
esac
200197
}
201198

202-
search_git() {
203-
local name=$1 pairs path
204-
205-
# Delay this defaulting so #read_pacman_conf behavior is tested
206-
if ((!${#PACMAN_CACHE[@]})); then
207-
mapfile -t PACMAN_CACHE < <(read_pacman_conf CacheDir)
208-
fi
209-
210-
for cache in "${PACMAN_CACHE[@]}"; do
211-
path="$cache/$name" # directory name
212-
if ! [[ -d "$path/.git" ]]; then
213-
{
214-
gettext "\`$path\" not a git directory, skipping..."
215-
echo
216-
} >&2
217-
continue
218-
fi
219-
220-
# TODO: in future could be enhanced by counting every commit
221-
# that DOES NOT change version as minor like 0.0.1-2 instead of any
222-
# pair = abcd12 1.0
223-
pairs=$(git -C "$path" log -p --oneline --format="GIT: %h" PKGBUILD | grep -e 'GIT:.*' -e '+pkgver' | grep -Pzo 'GIT: .*\n\+pkgver=.*\n' | sed 's/GIT: \|+pkgver=//' | tr -d '\0')
224-
225-
# shellcheck disable=SC2086
226-
echo "$path/$name" $pairs | awk '{for(i=2;i<NF;i+=2) printf "%s-%s-%s-any.gitpkg.tar.gz\n", $1, $(i+1), $i}' | sort -V
227-
done
228-
}
229-
230199
search_ala() {
231200
local name=$1 uriname pkgfile_re index
232201

@@ -248,10 +217,7 @@ search_ala() {
248217
search_cache() {
249218
local name=$1 pkgfile_re index
250219

251-
# version: 2025.11.12.r15.g0eed3fe
252-
version_regex="[a-zA-Z0-9.]+"
253-
hash_or_minor="([0-9]+|[a-z0-9]{6,})"
254-
pkgfile_re="$name-($version_regex)(-$hash_or_minor)?-(any|$DOWNGRADE_ARCH)\\.pkg\\.tar\\.(gz|xz|zst)"
220+
pkgfile_re="$name-[^-]+-[0-9.]+-(any|$DOWNGRADE_ARCH)\\.pkg\\.tar\\.(gz|xz|zst)"
255221

256222
# Delay this defaulting so #read_pacman_conf behavior is tested
257223
if ((!${#PACMAN_CACHE[@]})); then
@@ -292,7 +258,7 @@ output_package() {
292258
fi
293259

294260
# Remote or local file
295-
if [[ $path =~ ^/ && ! ($path =~ gitpkg) ]]; then
261+
if [[ $path =~ ^/ ]]; then
296262
location="$(dirname "$path")"
297263
timestamp=$(stat -c '%y' "$path" | cut -d' ' -f1)
298264
else
@@ -327,7 +293,7 @@ extract_version_parts() {
327293
s|^.\{'${#pkgname}'\}-\?||;
328294
329295
# Strip package extension
330-
s|\.\(git\)\?pkg\(\.tar\)\?\(\.[a-z0-9A-Z]\+\)\?$||;
296+
s|\.pkg\(\.tar\)\?\(\.[a-z0-9A-Z]\+\)\?$||;
331297
332298
# (epoch:)?version(-release)?(-arch)? -> epoch,version,release,arch
333299
s|\(\([^:]*\):\)\?\([^-]*\)\(-\([^-]*\)\)\?\(-\(.*\)\)\?|\2,\3,\5,\7|;
@@ -354,11 +320,6 @@ process_term() {
354320

355321
candidates=($(printf '%s\n' "${candidates[@]}" | sort_packages))
356322

357-
# this is already sorted
358-
if ((DOWNGRADE_FROM_GIT)); then
359-
candidates=($(search_git "$name" | filter_packages "$name" "$operator" "$version") "${candidates[@]}")
360-
fi
361-
362323
if (("${#candidates[@]}" == 0)); then
363324
{
364325
gettext "No results found"
@@ -479,9 +440,6 @@ parse_options() {
479440
exit 1
480441
fi
481442
;;
482-
--git)
483-
DOWNGRADE_FROM_GIT=1
484-
;;
485443
--maxdepth)
486444
if [[ -n "$2" ]]; then
487445
shift
@@ -565,34 +523,6 @@ parse_options() {
565523
fi
566524
}
567525

568-
build_pkg() {
569-
local item="$1" path commit_hash build_failed versionreg hashreg gitpkgreg
570-
if [[ "$item" =~ .*gitpkg.tar.gz ]]; then
571-
# version: 2025.11.12.r15.g0eed3fe
572-
versionreg="([a-zA-Z0-9]+\.?)*"
573-
hashreg='[a-z0-9]{6,}'
574-
#hash_or_minor="-([0-9]+|[a-z0-9]{6,})" # leaving this as a note, only hash should appear tho
575-
gitpkgreg="(.*)-$versionreg-($hashreg)-(any|$DOWNGRADE_ARCH).gitpkg.tar.gz"
576-
path=$(dirname "$item")
577-
commit_hash=$(sed -r "s/$gitpkgreg/\3/" <<<"$item")
578-
579-
pushd "$path" >/dev/null
580-
su -P "$(stat -c"%U" PKGBUILD)" -c "git checkout $commit_hash &>/dev/null && makepkg -fs | tee makepkg.log"
581-
build_failed=$?
582-
# NOTE: when force-canceling, users might need to manually do checkout master
583-
# otherwise they won't be able to update that pkg using yay or whatever I guess...
584-
su "$(stat -c"%U" PKGBUILD)" -c "git switch - &>/dev/null"
585-
if ((build_failed)); then
586-
exit 1
587-
fi
588-
589-
item="$(find "$path" -maxdepth 1 -type f -name "$(sed -nr '/.*Finished making: ([^ ]+) ([^ ]+) .*/{s//\1-\2/;p}' makepkg.log)*" -print -quit)"
590-
rm makepkg.log
591-
popd >/dev/null
592-
fi
593-
printf "%s\0" "$item" >>new_to_install.downgrade
594-
}
595-
596526
cli() {
597527
local conf_args=()
598528

@@ -606,14 +536,6 @@ cli() {
606536

607537
# Proceed with rest of workflow
608538
main "${terms[@]}"
609-
if ((DOWNGRADE_FROM_GIT)); then
610-
for item in "${to_install[@]}"; do
611-
build_pkg "$item"
612-
done
613-
mapfile -d '' to_install <new_to_install.downgrade
614-
rm new_to_install.downgrade
615-
fi
616-
617539
pacman -U "${pacman_args[@]}" "${to_install[@]}"
618540
prompt_to_ignore "${to_ignore[@]}"
619541
}
@@ -623,7 +545,6 @@ PACMAN="pacman"
623545
PACMAN_CONF="/etc/pacman.conf"
624546
DOWNGRADE_ARCH="$(pacman-conf Architecture | head -n 1)"
625547
DOWNGRADE_ALA_URL="https://archive.archlinux.org"
626-
DOWNGRADE_FROM_GIT=0
627548
DOWNGRADE_FROM_ALA=1
628549
DOWNGRADE_FROM_CACHE=1
629550
DOWNGRADE_MAXDEPTH=1

test/search_git.t

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)