aboutsummaryrefslogtreecommitdiff
path: root/trunk/src/lspkg
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/src/lspkg')
-rwxr-xr-xtrunk/src/lspkg39
1 files changed, 23 insertions, 16 deletions
diff --git a/trunk/src/lspkg b/trunk/src/lspkg
index e772fb3..ce7b3b9 100755
--- a/trunk/src/lspkg
+++ b/trunk/src/lspkg
@@ -18,6 +18,7 @@
#
COMMON="/usr/libexec/simplepkg/common.sh"
+PKG_LIST_DIR="var/log/packages"
if [ -f "$COMMON" ]; then
source $COMMON
@@ -48,17 +49,22 @@ options are:
# -----------------------------------------------------
if [ $# -eq 2 ]; then
- LIST_PKGS="`ls /$ROOT/var/log/packages/$2-[0-9]* 2> /dev/null`"
- if [ -z "$LIST_PKGS" ]; then
- LIST_PKGS="`ls /$ROOT/var/log/packages/$2* 2> /dev/null`"
- fi
+ pack=$2
elif [ $# -eq 1 ]; then
- LIST_PKGS="`ls /$ROOT/var/log/packages/$1-[0-9]* 2> /dev/null`"
- if [ -z "$LIST_PKGS" ]; then
- LIST_PKGS="`ls /$ROOT/var/log/packages/$1* 2> /dev/null`"
- fi
+ pack=$1
else
- LIST_PKGS="`ls /$ROOT/var/log/packages/ 2> /dev/null`"
+ pack=""
+fi
+
+if [ ! -z "$pack" ]; then
+ if echo $pack | grep -q "*"; then
+ LIST_PKGS="`ls -1 /$ROOT/$PKG_LIST_DIR/$pack 2> /dev/null`"
+ else
+ pack="`echo $pack | sed -e 's/\+/\\\+/'`"
+ LIST_PKGS=`eval "ls -1 /$ROOT/$PKG_LIST_DIR/ 2> /dev/null | egrep -E '^$pack-[^-]+-[^-]+-[^-]+$'"`
+ fi
+else
+ LIST_PKGS="`ls /$ROOT/$PKG_LIST_DIR/ 2> /dev/null`"
fi
LIST_PKGS="`slash $LIST_PKGS`"
@@ -71,14 +77,14 @@ case $1 in
if [ ! -z "$2" ]; then
if [ ! -z "$LIST_PKGS" ]; then
for file in $LIST_PKGS; do
- less $file
+ less /$PKG_LIST_DIR/$file
done
else
if [ ! -z "$ROOT" ]; then
- echo "$2: package not found on /$ROOT/var/log/packages"
+ echo "$2: package not found on /$ROOT/$PKG_LIST_DIR"
exit 1
else
- echo "$2: package not found on /var/log/packages"
+ echo "$2: package not found on /$PKG_LIST_DIR"
exit 1
fi
fi
@@ -97,13 +103,13 @@ case $1 in
"-r"|"--remove")
if [ ! -z "$2" ]; then
if [ ! -z "$LIST_PKGS" ]; then
- removepkg /$ROOT/var/log/packages/$1-[0-9]*
+ removepkg /$ROOT/$PKG_LIST_DIR/$1-[0-9]*
fi
fi
;;
"-s"|"--search")
if [ ! -z "$2" ]; then
- eval "grep -l '\/$2$' /$ROOT/var/log/packages/*"
+ eval "grep -l '\/$2$' /$ROOT/$PKG_LIST_DIR/*"
fi
;;
"-d"|"--description")
@@ -125,12 +131,13 @@ case $1 in
done
else
if [ ! -z "$ROOT" ]; then
- echo "$1: package not found on /$ROOT/var/log/packages"
+ echo "$1: package not found on /$ROOT/$PKG_LIST_DIR"
exit 1
else
- echo "$1: package not found on /var/log/packages"
+ echo "$1: package not found on /$PKG_LIST_DIR"
exit 1
fi
fi
;;
esac
+