From a8a452e2c1cb19c0e05d8dfe810596477d4bc7b0 Mon Sep 17 00:00:00 2001 From: rudson Date: Sat, 3 Mar 2007 15:17:33 +0000 Subject: lspkg e mkbuild: alteração do nome do mkbuild e mudanças do lspkg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@200 04377dda-e619-0410-9926-eae83683ac58 --- trunk/src/lspkg | 135 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 78 insertions(+), 57 deletions(-) (limited to 'trunk/src/lspkg') diff --git a/trunk/src/lspkg b/trunk/src/lspkg index e3add47..a329aee 100755 --- a/trunk/src/lspkg +++ b/trunk/src/lspkg @@ -16,23 +16,13 @@ # 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 -- cgit v1.2.3