diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-09-12 15:16:34 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-09-12 15:16:34 +0200 |
commit | b5bfe9be6c3c23700c3b25cd1d70bb21d38d2fbd (patch) | |
tree | ff7668281c705d2eca621ade1965df9b51100aff /xdowngrade | |
parent | 1223db6d637b9dc74a1b3371a9a5289a2ec818b6 (diff) | |
download | xtools-b5bfe9be6c3c23700c3b25cd1d70bb21d38d2fbd.tar.gz xtools-b5bfe9be6c3c23700c3b25cd1d70bb21d38d2fbd.tar.xz xtools-b5bfe9be6c3c23700c3b25cd1d70bb21d38d2fbd.zip |
xdowngrade: make more robust
Diffstat (limited to 'xdowngrade')
-rwxr-xr-x | xdowngrade | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/xdowngrade b/xdowngrade index c7ce16b..e64beb0 100755 --- a/xdowngrade +++ b/xdowngrade @@ -1,14 +1,25 @@ #!/bin/sh -e # xdowngrade PKGS.xbps... - install XBPS package directly from .xbps file +for f; do + if ! [ -r "$f" ]; then + echo "$0: no such package: $f" 2>&1 + exit 2 + fi +done T=$(mktemp --tmpdir -d xdowngrade-$(date -I).XXXXXXXX) -ln -s -r -t $T/ "$@" +ln -s -r -t "$T/" -- "$@" xbps-rindex -a $T/* +n=$(xbps-query -i --repository="$T/" -L 2>/dev/null | awk '{print $1}') +if [ -z "$n" ] || [ "$n" -ne "$#" ]; then + echo "$0: failed to register all $# packages." 2>&1 + exit 2 +fi pkg= for f; do f=${f##*/} f=${f%.*.*} pkg="$pkg ${f%-*}" done -xbps-install -i -R $T -f $pkg -rm -r $T +xbps-install -i -R "$T" -f -- $pkg +rm -r "$T" |