summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-06-02 16:13:03 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2008-06-02 16:13:03 +0200
commite21078be903494852cf9c4d3db797f091e296596 (patch)
treebc1b1cd46db51d870d8940026843dae11372ffaf /bin
parent29fd9d105abe64b4b7c342eb5c303853e08f2b09 (diff)
various
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pkg50
1 files changed, 32 insertions, 18 deletions
diff --git a/bin/pkg b/bin/pkg
index 0ef07e9..a7f5387 100755
--- a/bin/pkg
+++ b/bin/pkg
@@ -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"
}
}