diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-06-02 16:13:03 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-06-02 16:13:03 +0200 |
commit | e21078be903494852cf9c4d3db797f091e296596 (patch) | |
tree | bc1b1cd46db51d870d8940026843dae11372ffaf /bin | |
parent | 29fd9d105abe64b4b7c342eb5c303853e08f2b09 (diff) |
various
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/pkg | 50 |
1 files changed, 32 insertions, 18 deletions
@@ -27,14 +27,35 @@ die () { exit 100 } -pkg_proto () { - if (echo "$PKG_ROOT" | grep "^ssh" &> /dev/null) { - echo 'ssh' +# Local configuration +if ([ -f $HOME/.pkg.conf ]) { + . $HOME/.pkg.conf +} + +export PDIR +export PKG_ROOT + +## Gather some additional information about the PKG_ROOT + +# Protocol +if (echo "$PKG_ROOT" | grep "^ssh" &> /dev/null) { + PKG_PROTO='ssh' } elif (echo "$PKG_ROOT" | grep "^/" &> /dev/null) { - echo 'file' - } else { - false - } + PKG_PROTO='file' +} else { + false +} + +# Host +if ([ "$PKG_PROTO" = "ssh" ]) { + PKG_HOST=$(echo "$PKG_ROOT" | sed 's!^ssh://!!' | sed -r 's!^([^/]*)/.*$!\1!') +} + +# Remote path +if ([ "$PKG_PROTO" = "ssh" ]) { + PKG_PATH$(echo "$PKG_ROOT" | sed 's!^ssh://!!' | sed -r 's!^([^/]*)/.*$!\1!') +} elif ([ "$PKG_PROTO" = "file" ]) { + PKG_PATH="$PKG_ROOT" } confirm_yes () { @@ -61,13 +82,6 @@ check_sed () { } } -if ([ -f $HOME/.pkg.conf ]) { - . $HOME/.pkg.conf -} - -export PDIR -export PKG_ROOT - if ([ ! -d $PDIR ]) { die "$PDIR not found!!" } @@ -183,10 +197,10 @@ pkg_list_installed () { } pkg_list_available () { - if ([ "$(pkg_proto)" = 'ssh' ]) { - ssh -q $(echo "$PKG_ROOT" | sed 's!^ssh://!!' | sed -r 's!^([^/]*)/.*$!\1!') ls -1 $(echo "$PKG_ROOT" | sed 's!^ssh://[^/]*/!!') - } elif ([ "$(pkg_proto)" = 'file' ]) { - ls -1 $PKG_ROOT + if ([ "$PKG_PROTO" = 'ssh' ]) { + ssh -q "$PKG_HOST" ls -1 "$PKG_PATH" + } elif ([ "$PKG_PROTO" = 'file' ]) { + ls -1 "$PKG_PATH" } } |