Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not handle multile architectures in pacman.conf #185

Closed
2 tasks done
pbrisbin opened this issue Mar 2, 2022 · 2 comments 路 Fixed by #187
Closed
2 tasks done

Does not handle multile architectures in pacman.conf #185

pbrisbin opened this issue Mar 2, 2022 · 2 comments 路 Fixed by #187
Labels

Comments

@pbrisbin
Copy link
Member

pbrisbin commented Mar 2, 2022

馃悰 Bug Report

Checklist

  • No duplicate issues/PRs
  • Are you running the latest downgrade release from the AUR?

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:

  • The first architecture listed will always be the "normal" one
  • The other items, if present, are not useful to downgrade

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
@pbrisbin pbrisbin added bug triage Requires triage to ascertain relevance and actions labels Mar 2, 2022
@atreyasha
Copy link
Member

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?

@atreyasha atreyasha removed the triage Requires triage to ascertain relevance and actions label Mar 2, 2022
@pbrisbin
Copy link
Member Author

pbrisbin commented Mar 2, 2022

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.

@atreyasha atreyasha mentioned this issue Mar 4, 2022
10 tasks
atreyasha added a commit that referenced this issue Mar 4, 2022
@atreyasha atreyasha linked a pull request Mar 4, 2022 that will close this issue
9 tasks
atreyasha added a commit that referenced this issue Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants