]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
lspkg e mkbuild: alteração do nome do mkbuild e mudanças do lspkg
authorrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>
Sat, 3 Mar 2007 15:17:33 +0000 (15:17 +0000)
committerrudson <rudson@04377dda-e619-0410-9926-eae83683ac58>
Sat, 3 Mar 2007 15:17:33 +0000 (15:17 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@200 04377dda-e619-0410-9926-eae83683ac58

trunk/src/lspkg
trunk/utils/mkbuild [moved from trunk/utils/mkslackbuild with 100% similarity]

index e3add475bae386ddb426a29c6e274e65d4e94ba0..a329aee8df8c1b123d3fa6a51fe7958480c8f2e1 100755 (executable)
 #  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 #  Place - Suite 330, Boston, MA 02111-1307, USA
 #
-
-COMMON="/usr/libexec/simplepkg/common.sh"
-
-if [ -f "$COMMON" ]; then
-  source $COMMON
-else
-  echo "error: file $COMMON found, check your `basename $0` installation"
-  exit 1
-fi
-
-function usage {
-  echo "usage: `basename $0` [option expression]"
+function head_line {
+    echo "usage: `basename $0` [option expression]"
 }
 
-if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
-  usage
-  echo "
+function usage {
+    head_line
+    echo "
 options are:
 
    -v, --view: view installed package contents
@@ -41,48 +31,79 @@ options are:
    -s, --search: search a file under installed packages
    -d, --description: show matching packages' descriptions
 "
-elif [ "$1" == "-v" ] || [ "$1" == "--view" ] ; then
-  if [ ! -z "$2" ]; then
-    if $(ls /var/log/packages/$2* &> /dev/null); then
-      for file in $(ls /var/log/packages/$2*); do
-        less $file
-      done
-    else echo $2: package not found on /var/log/packages
-    fi
-  else
-    usage
-    exit 1
-  fi
-elif [ "$1" == "-p" ] && [ "$1" == "--print" ]; then
-  if [ -f "$2" ]; then
-    tar ztvf $2
-  else echo $2: file not found
-  fi
-elif [ "$1" == "-r" ] && [ "$1" == "--remove" ]; then
-  if [ ! -z "$2" ]; then
-    if `ls /var/log/packages/$1* &> /dev/null`; then
-      removepkg /var/log/packages/$1*
-    fi
-  fi
-elif [ "$1" == "-s" ] || [ "$1" == "--search" ]; then
-  if [ ! -z "$2" ]; then
-    grep $2 /var/log/packages/*
-  fi
-elif [ "$1" == "-d" ] || [ "$1" == "--description" ]; then
-  if [ ! -z "$1" ]; then
-    for file in `lspkg $2`; do
-      name="`package_name $file.tgz`"
-      echo "package description for $name:"
-      echo ""
-      grep -e "^$name:" $file | sed -e "s/^$name:/  /"
-    done
-  else
-    usage
+}
+
+# -----------------------------------------------------
+#                       lspkg
+# -----------------------------------------------------
+COMMON="/usr/libexec/simplepkg/common.sh"
+
+if [ -f "$COMMON" ]; then
+    source $COMMON
+else
+    echo "error: file $COMMON not found, check your `basename $0` installation"
     exit 1
-  fi
+fi
+
+if [ $# -eq 2 ]; then
+    LIST_PKGS=`ls /var/log/packages/$2-[0-9]* 2> /dev/null`
 else
-  if `ls /var/log/packages/$1* &> /dev/null`; then
-    ls /var/log/packages/$1*
-  else echo $1: package not found on /var/log/packages 
-  fi
+    LIST_PKGS=`ls /var/log/packages/$1-[0-9]* 2> /dev/null`
 fi
+
+case $1 in
+    "-h"|"--help")
+        usage
+    ;;
+    "-v"|"--view")
+        if [ ! -z "$2" ]; then
+            if [ ! -z "$LIST_PKGS" ]; then
+                for file in $LIST_PKGS; do
+                    less $file
+                done
+            else
+                echo "$2: package not found on /var/log/packages"
+            fi
+        else
+            head_line
+            exit 1
+        fi
+    ;;
+    "-p"|"--print")
+        if [ -f "$2" ]; then
+            tar ztvf $2
+        else
+            echo $2: file not found
+        fi
+    ;;
+    "-r"|"--remove")
+        if [ ! -z "$2" ]; then
+            if [ ! -z "$LIST_PKGS" ]; then
+                removepkg /var/log/packages/$1-[0-9]*
+            fi
+        fi
+    ;;
+    "-s"|"--search")
+        if [ ! -z "$2" ]; then
+            eval "grep -l '\/$2$' /var/log/packages/*"
+        fi
+    ;;
+    "-d"|"--description")
+        if [ ! -z "$2" ]; then
+            for file in $LIST_PKGS; do
+                echo -e " Package description for $file:\n"
+                sed -n '/^xine-ui:/ { s/xine-ui://; p; }' $file
+            done
+        else
+            head_line
+            exit 1
+        fi
+    ;;
+    *)
+        if [ ! -z "$LIST_PKGS" ]; then
+            echo "$LIST_PKGS"
+        else
+            echo "$1: package not found on /var/log/packages"
+        fi
+    ;;
+esac
similarity index 100%
rename from trunk/utils/mkslackbuild
rename to trunk/utils/mkbuild