spk rev 62

Fixes and small improvments to spk-mirror, spk-ls handle extra repo
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 18 02:49:36 2012 +0200 (2012-05-18)
parents bfd859410ab4
children d0fa46ea46bd
files Makefile lib/libspk.sh spk-ls spk-mirror
line diff
     1.1 --- a/Makefile	Thu May 17 23:41:42 2012 +0200
     1.2 +++ b/Makefile	Fri May 18 02:49:36 2012 +0200
     1.3 @@ -45,6 +45,7 @@
     1.4  	install -m 0755 spk-rm $(DESTDIR)$(PREFIX)/sbin
     1.5  	install -m 0755 spk-add $(DESTDIR)$(PREFIX)/sbin
     1.6  	install -m 0755 spk-archive $(DESTDIR)$(PREFIX)/sbin
     1.7 +	install -m 0755 spk-mirror $(DESTDIR)$(PREFIX)/sbin
     1.8  
     1.9  # Clean source
    1.10  
     2.1 --- a/lib/libspk.sh	Thu May 17 23:41:42 2012 +0200
     2.2 +++ b/lib/libspk.sh	Fri May 18 02:49:36 2012 +0200
     2.3 @@ -45,6 +45,24 @@
     2.4  EOT
     2.5  }
     2.6  
     2.7 +# Display package info from a packages.desc list
     2.8 +# Usage: read_pkgsdesc /path/to/packages.desc
     2.9 +read_pkgsdesc() {
    2.10 +	local list="$1"
    2.11 +	IFS="|"
    2.12 +	cat $list | while read package version desc category
    2.13 +	do
    2.14 +		if [ "$short" ]; then
    2.15 +			echo -n "$(colorize "$package" 32)"; indent 28 " $version"
    2.16 +		else
    2.17 +			newline
    2.18 +			gettext "Package    :"; colorize " $package" 32
    2.19 +			gettext "Version    :"; echo "$version"
    2.20 +			gettext "Short desc :"; echo "$desc"
    2.21 +		fi
    2.22 +	done && unset IFS
    2.23 +}
    2.24 +
    2.25  # Extract receipt from tazpkg
    2.26  # Parameters: result_dir package_file
    2.27  extract_receipt() {
    2.28 @@ -73,13 +91,14 @@
    2.29  
    2.30  # Used by: list
    2.31  count_mirrored() {
    2.32 +	[ -f "$pkgsmd5" ] || return
    2.33  	local count=$(cat $pkgsmd5 | wc -l)
    2.34  	gettext "Mirrored      :"; echo " $count"
    2.35  }
    2.36  
    2.37  is_package_mirrored() {
    2.38  	local name=$1
    2.39 -	local occurance=$(fgrep "$name |" $pkgsdesc)
    2.40 +	local occurance=$(grep "^$name |" $pkgsdesc)
    2.41  	[ -n "$occurance" ]
    2.42  }
    2.43  
     3.1 --- a/spk-ls	Thu May 17 23:41:42 2012 +0200
     3.2 +++ b/spk-ls	Fri May 18 02:49:36 2012 +0200
     3.3 @@ -22,13 +22,15 @@
     3.4  $(gettext "List packages or installed files by packages")
     3.5  
     3.6  $(boldify $(gettext "Options:"))
     3.7 -  --count     $(gettext "Display the number of installed packages")
     3.8 -  --mirror    $(gettext "List all the packages on mirror")
     3.9 -  --blocked   $(gettext "List all blocked packages")
    3.10 -  --short     $(gettext "Short list of installed packages")
    3.11 -  --root=     $(gettext "Set the root file system path")
    3.12 -  --color=NB  $(gettext "Set package name color in list")
    3.13 -  --debug     $(gettext "Display some usefull debug information")
    3.14 +  --count      $(gettext "Display the number of installed packages")
    3.15 +  --mirror     $(gettext "List all the packages on mirror")
    3.16 +  --extra      $(gettext "List packages on extra mirrors ")
    3.17 +  --blocked    $(gettext "List all blocked packages")
    3.18 +  --short      $(gettext "Short packages list format")
    3.19 +  --modifiers  $(gettext "List package modifiers")
    3.20 +  --root=      $(gettext "Set the root file system path")
    3.21 +  --color=NB   $(gettext "Set package name color in list")
    3.22 +  --debug      $(gettext "Display some usefull debug information")
    3.23  
    3.24  $(boldify $(gettext "Examples:"))
    3.25    $name package1 package2 packageN
    3.26 @@ -51,19 +53,33 @@
    3.27  			count_mirrored
    3.28  			exit 0 ;;
    3.29  		--mirror)
    3.30 -			IFS="|"
    3.31 -			cat $pkgsdesc | while read package version desc category
    3.32 -			do
    3.33 -				newline
    3.34 -				gettext "Package    :"; colorize " $package" 32
    3.35 -				gettext "Version    :"; echo "$version"
    3.36 -				gettext "Short desc :"; echo "$desc"
    3.37 -			done && unset IFS
    3.38 +			newline
    3.39 +			boldify "$(gettext "Mirror") $(cat $mirrorurl)"
    3.40 +			read_pkgsdesc $pkgsdesc
    3.41  			separator
    3.42  			boldify $(count_mirrored)
    3.43 -			echo "" && exit 0 ;;
    3.44 +			newline && exit 0 ;;
    3.45 +		--extra)
    3.46 +				[ -d "$extradb" ] || exit 1
    3.47 +				for extra in $extradb/*
    3.48 +				do
    3.49 +					newline
    3.50 +					boldify "$(gettext "Extra mirror")"
    3.51 +					if [ ! -f "$extra/packages.desc" ]; then
    3.52 +						echo "URL: $(cat $extra/mirror)"
    3.53 +						gettext "Missing:"; colorize " packages.desc" 31
    3.54 +						continue
    3.55 +					fi
    3.56 +					separator
    3.57 +					read_pkgsdesc $extra/packages.desc
    3.58 +					separator
    3.59 +					boldify $(echo -n "$(cat $extra/packages.$SUM | wc -l) "
    3.60 +					gettext "packages in:"; echo " $(basename $extra)")
    3.61 +					newline
    3.62 +				done
    3.63 +				exit 0 ;;
    3.64  		--blocked)
    3.65 -			if [ -f "$blocked" ]; then
    3.66 +			if [ -s "$blocked" ]; then
    3.67  				cat $blocked
    3.68  			else
    3.69  				gettext "No blocked packages"; echo ""
    3.70 @@ -87,15 +103,29 @@
    3.71  			for pkg in $@
    3.72  			do
    3.73  				[ -f "$installed/$pkg/files.list" ] || continue
    3.74 +				nb=$(cat $installed/$pkg/files.list | wc -l)
    3.75  				count=$(($count + 1))
    3.76  				[ "$count" == 1 ] && newline
    3.77 +				# List modifiers
    3.78 +				if [ "$modifiers" ]; then
    3.79 +					modifiers=$installed/$pkg/modifiers
    3.80 +					if [ -f "$modifiers" ]; then
    3.81 +						boldify "$(gettext "Modifiers for") $pkg"
    3.82 +						separator
    3.83 +						cat $modifiers
    3.84 +						separator && newline
    3.85 +					else
    3.86 +						echo -n "$(boldify "$pkg") "
    3.87 +						gettext "package was not modified"; newline
    3.88 +					fi
    3.89 +					continue
    3.90 +				fi
    3.91  				boldify $(gettext "Installed files by"; echo " $pkg")
    3.92  				separator
    3.93  				cat $installed/$pkg/files.list
    3.94 -				files=$(wc -l $installed/$pkg/files.list | cut -d " " -f 1)
    3.95  				separator
    3.96 -				gettext "Installed files by"; echo " $pkg : $files"
    3.97 -				newline
    3.98 +				gettext "Installed files by"; echo -n " $pkg: "
    3.99 +				colorize "$nb" 32 && newline
   3.100  			done && exit 0 ;;
   3.101  	esac
   3.102  done
     4.1 --- a/spk-mirror	Thu May 17 23:41:42 2012 +0200
     4.2 +++ b/spk-mirror	Fri May 18 02:49:36 2012 +0200
     4.3 @@ -60,17 +60,27 @@
     4.4  	debug "extra DB: $db"
     4.5  }
     4.6  
     4.7 -# Add a package to lists
     4.8 +# Display info about an extra repo
     4.9 +extra_info() {
    4.10 +	local db=$1
    4.11 +	debug "extra DB: $extradb/$db"
    4.12 +	nb=$(cat $extradb/$db/packages.$SUM 2>/dev/null | wc -l)
    4.13 +	echo -n "Extra DB  :"; boldify " $db"
    4.14 +	echo -n "Extra URL :"; echo " $(cat $extradb/$db/mirror)"
    4.15 +	gettext "Packages  :"; colorize " $nb" 32
    4.16 +}
    4.17 +
    4.18 +# Add a package to packages.* lists
    4.19  addto_list() {
    4.20  	cd $pkgsdir
    4.21  	echo "$PACKAGE-${VERSION}${EXTRAVERSION}" >> packages.list
    4.22  	$CHECKSUM $(basename $pkg) >> packages.$SUM
    4.23  	#
    4.24 -	# Add PACKED_SIZE UNPACKED_SIZE to be used to know packages size
    4.25 +	# Add PACKED_SIZE UNPACKED_SIZE to know packages size
    4.26  	# before installing ??? --> actually done via packages.txt
    4.27  	#
    4.28  	cat >> packages.desc << EOT
    4.29 -$PACKAGE | ${VERSION}${EXTRAVERSION} | $SHORT_DESC | $CATEGORY | $WEBSITE"
    4.30 +$PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
    4.31  EOT
    4.32  	# packages.equiv is used by tazpkg install to check depends.
    4.33  	touch packages.equiv
    4.34 @@ -178,15 +188,17 @@
    4.35  			extra_db
    4.36  			if [ -d "$extradb/$db" ]; then
    4.37  				gettext "Extra mirror already exist"; newline
    4.38 -				echo -n "DB:"; boldify " $db"
    4.39 +				extra_info $db
    4.40  			else
    4.41 -				gettext "Enabling: extra mirror"; newline
    4.42 +				boldify $(gettext "Enabling: extra mirror")
    4.43 +				separator
    4.44  				echo "URL: $(boldify "$url")"
    4.45  				if ! check_mirror $url; then
    4.46  					continue
    4.47  				fi
    4.48  				mkdir -p $extradb/$db
    4.49  				echo "$url" > $extradb/$db/mirror
    4.50 +				separator
    4.51  				gettext "New extra mirror is ready to use"; newline
    4.52  			fi
    4.53  			newline ;;
    4.54 @@ -206,7 +218,7 @@
    4.55  			cd $pkgsdir
    4.56  			if [ ! "$nodb" ]; then
    4.57  				time=$(date +%s)
    4.58 -				rm -f packages.* ID
    4.59 +				rm -f packages.* ID *.lzma
    4.60  				newline
    4.61  				boldify $(gettext "Creating packages lists")
    4.62  				separator
    4.63 @@ -261,6 +273,11 @@
    4.64  		*)
    4.65  			[ "$count" == 0 ] && newline
    4.66  			count=$(($count + 1))
    4.67 +			# Should we handle --rm also here ?
    4.68 +			if [ -d "$extradb/$url" ]; then
    4.69 +				extra_info $(basename $extradb/$url)
    4.70 +				newline && continue
    4.71 +			fi
    4.72  			gettext "Can't handle:"
    4.73  			colorize " $url" 31 && newline ;;
    4.74  	esac