From 2222e9f8dfe6e149262f629571b3432718351d3f Mon Sep 17 00:00:00 2001 From: Andres P Date: Tue, 22 Jun 2010 22:12:51 -0430 Subject: rankmirrors: fix bogus variable assignment $replacedurl was being built from an expansion of itself. But at the time it happened, it was empty. Fixes FS#19911 Signed-off-by: Andres P Signed-off-by: Allan McRae --- scripts/rankmirrors.sh.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/rankmirrors.sh.in b/scripts/rankmirrors.sh.in index 9b4e973a..201cc4be 100644 --- a/scripts/rankmirrors.sh.in +++ b/scripts/rankmirrors.sh.in @@ -70,15 +70,15 @@ ARCH="$(uname -m)" getfetchurl() { local strippedurl="${1%/}" - local replacedurl="${replacedurl//'$arch'/$ARCH}" + local replacedurl="${strippedurl//'$arch'/$ARCH}" if [[ ! $TARGETREPO ]]; then - replacedurl="${strippedurl//'$repo'/core}" + replacedurl="${replacedurl//'$repo'/core}" local tmp="${replacedurl%/*}" tmp="${tmp%/*}" local reponame="${tmp##*/}" else - replacedurl="${strippedurl//'$repo'/$TARGETREPO}" + replacedurl="${replacedurl//'$repo'/$TARGETREPO}" local reponame="$TARGETREPO" fi -- cgit v1.2.3-70-g09d2 From 226c137245192444085d03a7f841b35afe99791c Mon Sep 17 00:00:00 2001 From: Andres P Date: Tue, 22 Jun 2010 22:12:50 -0430 Subject: rankmirrors: fix bogus pacman configuration parsing Valid pacman configuration files do not have to start with a hash for that line to be a comment, neither do directives need to be in column 0. Signed-off-by: Andres P Signed-off-by: Allan McRae --- scripts/rankmirrors.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/rankmirrors.sh.in b/scripts/rankmirrors.sh.in index 201cc4be..fcb42fa4 100644 --- a/scripts/rankmirrors.sh.in +++ b/scripts/rankmirrors.sh.in @@ -184,9 +184,9 @@ fi timesarray=() for line in "${linearray[@]}"; do - if [[ $line =~ ^# ]]; then + if [[ $line =~ ^[[:space:]]*# ]]; then [[ $TIMESONLY ]] || echo $line - elif [[ $line =~ ^Server ]]; then + elif [[ $line =~ ^[[:space:]]*Server ]]; then # Getting values and times and such server="${line#*= }" -- cgit v1.2.3-70-g09d2 From 708f186f98a0c2094225aa94ac8a139ac3a9163e Mon Sep 17 00:00:00 2001 From: Andres P Date: Tue, 22 Jun 2010 22:12:49 -0430 Subject: rankmirrors: pipe errors to stderr If this is to be scripted with AIF or another tool, it needs to respect stderr. Signed-off-by: Andres P Signed-off-by: Allan McRae --- scripts/rankmirrors.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rankmirrors.sh.in b/scripts/rankmirrors.sh.in index fcb42fa4..b0dc1ab7 100644 --- a/scripts/rankmirrors.sh.in +++ b/scripts/rankmirrors.sh.in @@ -49,7 +49,7 @@ version() { } err() { - echo "$1" + echo "$1" >&2 exit 1 } -- cgit v1.2.3-70-g09d2 From 07a9effdd06345d09f09cdc92e23c937d8fa94b5 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Wed, 23 Jun 2010 13:16:36 +1000 Subject: makepkg: prevent error trap activation in bash-3.2 Running "pacman -T foo" is expected to return a non-zero value when "foo" is not installed. This sets of the error trap in bash-3.2 but not bash 4.x. Work around this by disabling the error trap around this pacman call as we are manually checking the return value anyway. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4f9f89b1..2699f637 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -382,11 +382,15 @@ run_pacman() { } check_deps() { - (( $# > 0 )) || return + (( $# > 0 )) || return 0 + # Disable error trap in pacman subshell call as this breaks bash-3.2 compatibility + # Also, a non-zero return value is not unexpected and we are manually dealing them + set +E local ret=0 - pmout=$(run_pacman -T "$@") - ret=$? + pmout=$(run_pacman -T "$@") || ret=$? + set -E + if (( ret == 127 )); then #unresolved deps echo "$pmout" elif (( ret )); then -- cgit v1.2.3-70-g09d2 From 6f4f9c1b66ed859b3679d70e15c003ab4907b823 Mon Sep 17 00:00:00 2001 From: Andres P Date: Mon, 21 Jun 2010 22:00:44 -0430 Subject: bash_completion: fix bash 3.2 incompatibility To avoid errors with bash 3.2, compopt will be skipped if it's not a shell builtin. compopt is needed to not append slashes to package names that coincide with directories in PWD. This is currently not possible to fix in bash versions that do not support compopt, so these users will have to bear that regression. Signed-off-by: Andres P Signed-off-by: Allan McRae --- contrib/bash_completion | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/contrib/bash_completion b/contrib/bash_completion index 2713ba4d..1ec2cd53 100644 --- a/contrib/bash_completion +++ b/contrib/bash_completion @@ -52,10 +52,6 @@ _pacman_pkg() { )" } -_pacman_file() { - compopt -o filenames; _filedir 'pkg.tar.*' -} - _pacman() { local common core cur database prev query remove sync upgrade o COMPREPLY=() @@ -102,7 +98,18 @@ _pacman() { true } +if [[ $(type -t compopt) = "builtin" ]]; then + _pacman_file() { + compopt -o filenames; _filedir 'pkg.tar.*' + } + complete -F _pacman -o default pacman +else + _pacman_file() { + _filedir 'pkg.tar.*' + } + complete -F _pacman -o filenames -o default pacman +fi + complete -F _makepkg -o default makepkg -complete -F _pacman -o default pacman # ex:et ts=2 sw=2 ft=sh -- cgit v1.2.3-70-g09d2