spk rev 15

Add spk-ls (list pkgs and files installed ba packages)
author Christophe Lincoln <pankso@slitaz.org>
date Tue May 15 11:32:21 2012 +0200 (2012-05-15)
parents dcf6700bb045
children 57ae420bd1c2
files spk-ls spk-rm
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/spk-ls	Tue May 15 11:32:21 2012 +0200
     1.3 @@ -0,0 +1,109 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# Spk-ls - List SliTaz packages and files. Read the README before adding or
     1.7 +# modifing any code in spk!
     1.8 +#
     1.9 +# Copyright (C) SliTaz GNU/Linux - BSD License
    1.10 +# Author: See AUTHORS files
    1.11 +#
    1.12 +#. /usr/lib/slitaz/libspk.sh
    1.13 +. lib/libspk.sh
    1.14 +
    1.15 +#
    1.16 +# Functions
    1.17 +#
    1.18 +
    1.19 +# Help and usage
    1.20 +usage() {
    1.21 +	name=$(basename $0)
    1.22 +	cat << EOT
    1.23 +
    1.24 +$(boldify $(gettext "Usage:")) $name [packages|--options]
    1.25 +
    1.26 +$(gettext "List packages or installed files by packages")
    1.27 +
    1.28 +$(boldify $(gettext "Options:"))
    1.29 +  --count     $(gettext "Display the number of installed packages")
    1.30 +  --mirror    $(gettext "List all the packages on mirror")
    1.31 +  --blocked   $(gettext "List all blocked packages")
    1.32 +  --short     ls: $(gettext "Short list of installed packages")
    1.33 +  --debug     $(gettext "Display some usefull debug information")
    1.34 +
    1.35 +$(boldify $(gettext "Examples:"))
    1.36 +  $name package1 package2 packageN
    1.37 +  $name --count
    1.38 +
    1.39 +EOT
    1.40 +	exit 0
    1.41 +}
    1.42 +
    1.43 +#
    1.44 +# Handle --options
    1.45 +#
    1.46 +
    1.47 +for opt in $@
    1.48 +do
    1.49 +	case "$opt" in
    1.50 +		*usage|*help) usage ;;
    1.51 +		--count)
    1.52 +			count_installed
    1.53 +			count_mirrored
    1.54 +			exit 0 ;;
    1.55 +		--mirror)
    1.56 +			IFS="|"
    1.57 +			cat $pkgsdesc | while read package version desc category
    1.58 +			do
    1.59 +				echo ""
    1.60 +				gettext "Package    :"; echo " $package"
    1.61 +				gettext "Version    :"; echo "$version"
    1.62 +				gettext "Short desc :"; echo "$desc"
    1.63 +			done && unset IFS
    1.64 +			separator
    1.65 +			count_mirrored
    1.66 +			echo "" && exit 0 ;;
    1.67 +		--blocked)
    1.68 +			if [ -f "$blocked" ]; then
    1.69 +				cat $blocked
    1.70 +			else
    1.71 +				gettext "No blocked packages"; echo ""
    1.72 +			fi && exit 0 ;;
    1.73 +		--short)
    1.74 +			ls -1 $installed
    1.75 +			boldify $(count_installed)
    1.76 +			exit 0 ;;
    1.77 +		--*) continue ;;
    1.78 +		*)
    1.79 +			# List installed files by the package.
    1.80 +			count=0
    1.81 +			for pkg in $@
    1.82 +			do
    1.83 +				[ -f "$installed/$pkg/files.list" ] || continue
    1.84 +				count=$(($count + 1))
    1.85 +				[ "$count" == 1 ] && newline
    1.86 +				boldify $(gettext "Installed files by"; echo " $pkg")
    1.87 +				separator
    1.88 +				cat $installed/$pkg/files.list
    1.89 +				files=$(wc -l $installed/$pkg/files.list | cut -d " " -f 1)
    1.90 +				separator
    1.91 +				gettext "Installed files by"; echo " $pkg : $files"
    1.92 +				newline
    1.93 +			done && exit 0 ;;
    1.94 +	esac
    1.95 +done
    1.96 +
    1.97 +#
    1.98 +# Parse all installed pkgs receipt.
    1.99 +#
   1.100 +
   1.101 +boldify "$(gettext "Installed packages")"
   1.102 +separator
   1.103 +for pkg in $installed/*
   1.104 +do
   1.105 +	unset_receipt
   1.106 +	. $pkg/receipt
   1.107 +	newline
   1.108 +	receipt_info
   1.109 +done
   1.110 +separator
   1.111 +count_installed && newline
   1.112 +exit 0
     2.1 --- a/spk-rm	Tue May 15 10:19:36 2012 +0200
     2.2 +++ b/spk-rm	Tue May 15 11:32:21 2012 +0200
     2.3 @@ -20,6 +20,8 @@
     2.4  
     2.5  $(boldify $(gettext "Usage:")) $name [packages|--options]
     2.6  
     2.7 +$(gettext "Remove installed packages and ther dependencies")
     2.8 +
     2.9  $(boldify $(gettext "Options:"))
    2.10    --confirm   $(gettext "Ask before removing any packages")
    2.11    --verbose   $(gettext "Be more verbose when removing files")
    2.12 @@ -158,7 +160,7 @@
    2.13  #
    2.14  
    2.15  case "$1" in
    2.16 -	""|usage|help) usage ;;
    2.17 +	""|*usage|*help) usage ;;
    2.18  esac
    2.19  
    2.20  #
    2.21 @@ -196,5 +198,4 @@
    2.22  	separator
    2.23  	echo "" && log "Removed package: $pkg"
    2.24  done
    2.25 -
    2.26  exit 0