archlinux-downgrade / downgrade

Downgrade packages in Arch Linux
GNU General Public License v2.0
570 stars 24 forks source link

Does not handle multile architectures in pacman.conf #185

Closed pbrisbin closed 2 years ago

pbrisbin commented 2 years ago

:bug: Bug Report

Checklist

Environment

Omitted.

Description

See AUR comment.

Steps to reproduce

  1. Have multiple repositories of different architectures (one use-case is optimized architectures).

  2. Observe the following:

    % pacman-conf Architecture
    x86_64
    x86_64_v3
  3. Attempt to downgrade something.

Expected behavior

We can assume:

Therefore, the first item of the list should become the DOWNGRADE_ARCH default.

Actual behavior

The multi-line string becomes DOWNGRADE_ARCH and we break with a sed error.

Known workarounds

^ I suggest we add this to the template.

Users can manually specify the correct DOWNGRADE_ARCH.

Command trace

Trace ``` + . gettext.sh ++ test 'X\t' = 'X\t' ++ echo=echo ++ test -z '' ++ case "$0" in + PACMAN=pacman + PACMAN_CONF=/etc/pacman.conf ++ pacman-conf Architecture + DOWNGRADE_ARCH='x86_64 x86_64_v3' + DOWNGRADE_ALA_URL=https://archive.archlinux.org + DOWNGRADE_FROM_ALA=1 + DOWNGRADE_FROM_CACHE=1 + DOWNGRADE_MAXDEPTH=1 + DOWNGRADE_CONF=/etc/xdg/downgrade/downgrade.conf + DOWNGRADE_VERSION=11.0.0 + (( !LIB )) + set -e ++ dirname downgrade + locale=./../share/locale + [[ -d ./../share/locale ]] + TEXTDOMAINDIR=/usr/share/locale + export TEXTDOMAIN=downgrade TEXTDOMAINDIR + TEXTDOMAIN=downgrade + for arg in "$@" + [[ mc =~ ^-h$|^--help$ ]] + [[ mc == \-\-\v\e\r\s\i\o\n ]] + (( UID )) + cli mc + conf_args=() + local conf_args + read_downgrade_conf conf_args + local var=conf_args ++ grep -E -v '^ *(#.*)?$' /etc/xdg/downgrade/downgrade.conf ++ xargs printf '%q ' + eval 'conf_args=( )' ++ conf_args=() + parse_options mc + [[ -n mc ]] + case "$1" in + terms+=("$1") + shift + [[ -n '' ]] + (( !1 )) + read_unique terms mc + local var=terms + shift + [[ -n mc ]] + mapfile -t terms ++ printf '%s\n' mc ++ sort -u + read_unique PACMAN_CACHE + local var=PACMAN_CACHE + shift + [[ -n '' ]] + main mc + local term candidates choice pkg exit_code=0 + (( 1 )) + for term in "$@" + process_term mc + local term=mc name operator version candidates choice + read -r name operator version ++ sed -r 's/(.*[^<>=~])(<=|>=|<|>|=|=~|==)([^<>=~].*)/\1 \2 \3/g' + installed=($(previously_installed "$name")) ++ previously_installed mc +++ read_pacman_conf LogFile +++ sed '/^#\?LogFile *= *\(.*\)$/!d; s//\1/' /etc/pacman.conf ++ : /var/log/pacman.log ++ : /var/log/pacman.log ++ sed ' /.*\(installed\|upgraded\) \(mc\) (\(.* -> \)\?\([^)]*\))/!d s//\2-\4/ ' /var/log/pacman.log ++ currently_installed mc ++ LC_ALL=C.UTF8 ++ pacman -Qi mc ++ awk -F ' : ' ' /^Name / { name=$2 }; /^Version / { version=$2 }; END { if (name != "") printf("%s-%s\n", name, version) } ' + current=mc-4.8.27-2 + candidates=($(search_packages "$name" | filter_packages "$name" "$operator" "$version" | sort_packages)) ++ search_packages mc ++ local name=mc pkgfile_re index ++ filter_packages mc '' '' ++ pkgfile_re='mc-[^-]+-[0-9.]+-(any|x86_64 x86_64_v3)\.pkg\.tar\.(gz|xz|zst)' ++ local name=mc operator= version= pkg ++ index=https://archive.archlinux.org/packages/m/mc/ ++ (( DOWNGRADE_FROM_ALA )) ++ read -r pkg ++ sort_packages ++ curl --fail --silent https://archive.archlinux.org/packages/m/mc/ ++ sed -E ' /.* href="(mc-[^-]+-[0-9.]+-(any|x86_64 x86_64_v3)\.pkg\.tar\.(gz|xz|zst))".*/!d; s||https://archive.archlinux.org/packages/m/mc/\1|g; s|\+| |g; s|%|\\x|g' ++ xargs -0 printf %b ++ grep -Fv testing/ ++ awk 'BEGIN { FS="/"; OFS="|" } { print $NF, $0 }' ++ pacsort -f -t '|' -k 1 ++ cut -d '|' -f 2- sed: -e expression #1, char 46: unterminated address regex ++ (( DOWNGRADE_FROM_CACHE )) ++ (( !0 )) ++ mapfile -t PACMAN_CACHE +++ read_pacman_conf CacheDir +++ sed '/^#\?CacheDir *= *\(.*\)$/!d; s//\1/' /etc/pacman.conf ++ (( !1 )) ++ find -L /var/cache/pacman/pkg/ -maxdepth 1 -regextype posix-extended -regex '.*/mc-[^-]+-[0-9.]+-(any|x86_64 x86_64_v3)\.pkg\.tar\.(gz|xz|zst)' + (( 0 == 0 )) + gettext 'No results found' No results found+ echo + [[ -n '' ]] + eval_gettext 'Unable to downgrade $name' + gettext 'Unable to downgrade $name' ++ envsubst --variables 'Unable to downgrade $name' + export PATH name + envsubst 'Unable to downgrade $name' Unable to downgrade mc+ echo + return 1 + exit_code=1 + return 1 ```
atreyasha commented 2 years ago

Ooh never knew that it was possible to specify two architectures. I agree that default behaviour should select the first of the architectures outputted by pacman-conf.

But another edge case: what if the user wants to explicitly specify the non-initial architecture outputted by pacman-conf? Even with a fix for this issue, that would not be possible. Perhaps it makes sense to re-introduce the --arch CLI option?

pbrisbin commented 2 years ago

Perhaps it makes sense to re-introduce the --arch CLI option?

I personally don't mind a mix of env and CLI configuration. And so something like this, that is rarely in need of setting, could be an env-only situation.

But I think you prefer the consistency of all-and-only CLI options for changing behavior. I'm happy to support you in that, in which case, yes --arch sounds like a good idea.