tazpkg rev 81

Add Tazpkgbox libraries
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 09 17:26:15 2008 +0200 (2008-05-09)
parents a8959df74675
children 11c07935e43b
files lib/tazpkgbox/list lib/tazpkgbox/package_infos lib/tazpkgbox/search
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/lib/tazpkgbox/list	Fri May 09 17:26:15 2008 +0200
     1.3 @@ -0,0 +1,47 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# List installed packages in a suitable format for GTK tree.
     1.7 +# List mirrored packages using the packages.desc file.
     1.8 +#
     1.9 +
    1.10 +case $1 in
    1.11 +	installed)
    1.12 +		CAT=`cat /tmp/tazpkgbox/installed-category`
    1.13 +		if [ "$CAT" == "all" ]; then
    1.14 +			for pkg in /var/lib/tazpkg/installed/*
    1.15 +			do
    1.16 +				. $pkg/receipt
    1.17 +				echo "$PACKAGE|$VERSION|$SHORT_DESC"
    1.18 +			done
    1.19 +		else
    1.20 +			for pkg in /var/lib/tazpkg/installed/*
    1.21 +			do
    1.22 +				. $pkg/receipt
    1.23 +				if [ "$CATEGORY" == "$CAT" ]; then
    1.24 +					echo "$PACKAGE|$VERSION|$SHORT_DESC"
    1.25 +				fi
    1.26 +			done	
    1.27 +		fi ;;
    1.28 +	mirrored)
    1.29 +		CAT=`cat /tmp/tazpkgbox/mirrored-category`
    1.30 +		if [ "$CAT" == "all" ]; then
    1.31 +			cat /var/lib/tazpkg/packages.desc
    1.32 +		else
    1.33 +			grep "$CAT" /var/lib/tazpkg/packages.desc
    1.34 +			#for pkg in `grep "$CAT" /var/lib/tazpkg/packages.desc | cut -d "|" -f 1`
    1.35 +			#do
    1.36 +				#RES=`grep "^$pkg"  /var/lib/tazpkg/packages.desc | head -n 1`
    1.37 +				#CATEGORY=`echo "$RES" | cut -d "|" -f 4`
    1.38 +				##echo "$pkg|$CATEGORY"
    1.39 +				#if [ "$CATEGORY" == "$CAT" ]; then
    1.40 +					#VERSION=`echo $RES | cut -d "|" -f 2`
    1.41 +					#SHORT_DESC=`echo $RES | cut -d "|" -f 3`
    1.42 +					#echo "$pkg | $VERSION | $SHORT_DESC"
    1.43 +				#fi
    1.44 +			#done
    1.45 +		fi ;;
    1.46 +	*)
    1.47 +		echo "Usage: /usr/lib/slitaz/tazpkgbox/list [installed|mirrored]" ;;
    1.48 +esac
    1.49 +
    1.50 +exit 0
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/lib/tazpkgbox/package_infos	Fri May 09 17:26:15 2008 +0200
     2.3 @@ -0,0 +1,99 @@
     2.4 +#!/bin/sh
     2.5 +#
     2.6 +# Dialog box to provide package infos and actions
     2.7 +#
     2.8 +
     2.9 +XTERM_OPTS="-geometry 80x16+120+120"
    2.10 +
    2.11 +PKG=`cat /tmp/tazpkgbox/pkg | sed s/" "/""/g`
    2.12 +
    2.13 +# Installed or not installed, that the question.
    2.14 +if [ -d /var/lib/tazpkg/installed/$PKG ]; then
    2.15 +	. /var/lib/tazpkg/installed/$PKG/receipt
    2.16 +	export PACKAGE_INFOS="
    2.17 +<window title=\"Package: $PKG\" icon-name=\"package-x-generic\">
    2.18 +<vbox>
    2.19 +
    2.20 +	<tree>
    2.21 +		<width>460</width><height>160</height>
    2.22 +		<label>Package|$PKG</label>
    2.23 +		<item icon=\"tazpkg\">Version: | $VERSION</item>
    2.24 +		<item icon=\"tazpkg\">Category: | $CATEGORY</item>
    2.25 +		<item icon=\"tazpkg\">Depends: | $DEPENDS</item>
    2.26 +		<item icon=\"system-users\">Maintainer: | $MAINTAINER</item>
    2.27 +		<item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
    2.28 +	</tree>
    2.29 +
    2.30 +	<hbox>
    2.31 +		<button>
    2.32 +			<label>Remove</label>
    2.33 +			<input file icon=\"edit-delete\"></input>
    2.34 +			<action>xterm -T \"Remove $PACKAGE\" $XTERM_OPTS -e \"\
    2.35 +			tazpkg remove $PACKAGE; sleep 2\"</action>
    2.36 +			<action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
    2.37 +		</button>
    2.38 +		<button>
    2.39 +			<label>Repack</label>
    2.40 +			<input file icon=\"edit-redo\"></input>
    2.41 +			<action>xterm -T \"Repack $PACKAGE\" $XTERM_OPTS -e \"\
    2.42 +			cd /var/cache/tazpkg; \
    2.43 +			tazpkg repack $PACKAGE; sleep 2\"</action>
    2.44 +			<action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
    2.45 +		</button>
    2.46 +		<button>
    2.47 +			<input file icon=\"gtk-close\"></input>
    2.48 +			<action type=\"closewindow\">INSTALLED_PACKAGE_ACTIONS</action>
    2.49 +		</button>
    2.50 +	</hbox>
    2.51 +
    2.52 +</vbox>
    2.53 +</window>
    2.54 +"
    2.55 +else
    2.56 +	RES=`grep "^$PKG" /var/lib/tazpkg/packages.desc | head -n 1`
    2.57 +	PACKAGE=`echo "$RES" | cut -d "|" -f 1`
    2.58 +	VERSION=`echo "$RES" | cut -d "|" -f 2`
    2.59 +	CATEGORY=`echo "$RES" | cut -d "|" -f 4`
    2.60 +	WEB_SITE=`echo "$RES" | cut -d "|" -f 5`
    2.61 +	export PACKAGE_INFOS="
    2.62 +<window title=\"Package: $PACKAGE\" icon-name=\"package-x-generic\">
    2.63 +<vbox>
    2.64 +
    2.65 +	<tree>
    2.66 +		<width>460</width><height>140</height>
    2.67 +		<label>Package|$PKG</label>
    2.68 +		<item icon=\"tazpkg\">Name: | $PACKAGE</item>
    2.69 +		<item icon=\"tazpkg\">Version: | $VERSION</item>
    2.70 +		<item icon=\"tazpkg\">category: | $CATEGORY</item>
    2.71 +		<item icon=\"applications-internet\">Web site: | $WEB_SITE</item>
    2.72 +	</tree>
    2.73 +
    2.74 +	<hbox>
    2.75 +		<button>
    2.76 +			<label>Get-install</label>
    2.77 +			<input file icon=\"go-next\"></input>
    2.78 +			<action>xterm -T \"Install $PACKAGE\" $XTERM_OPTS -e \"\
    2.79 +			tazpkg get-install $PACKAGE; sleep 2\"</action>
    2.80 +			<action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
    2.81 +		</button>
    2.82 +		<button>
    2.83 +			<label>Get</label>
    2.84 +			<input file icon=\"go-next\"></input>
    2.85 +			<action>xterm -T \"Get $PACKAGE\" $XTERM_OPTS -e \"\
    2.86 +			cd /var/cache/tazpkg; tazpkg get $PACKAGE; sleep 2\"</action>
    2.87 +			<action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
    2.88 +		</button>
    2.89 +		<button>
    2.90 +			<input file icon=\"gtk-close\"></input>
    2.91 +			<action type=\"closewindow\">MIRRORED_PACKAGE_ACTIONS</action>
    2.92 +		</button>
    2.93 +	</hbox>
    2.94 +
    2.95 +</vbox>
    2.96 +</window>
    2.97 +"
    2.98 +fi
    2.99 +
   2.100 +gtkdialog --center --program=PACKAGE_INFOS
   2.101 +
   2.102 +exit 0
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/lib/tazpkgbox/search	Fri May 09 17:26:15 2008 +0200
     3.3 @@ -0,0 +1,22 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# This script provide a suitable output for the search results.
     3.7 +#
     3.8 +
     3.9 +# Clean preview results.
    3.10 +rm -f /tmp/tazpkgbox/search-installed
    3.11 +touch /tmp/tazpkgbox/search-installed
    3.12 +
    3.13 +# Search installed.
    3.14 +for i in `ls /var/lib/tazpkg/installed`
    3.15 +do
    3.16 +	. /var/lib/tazpkg/installed/$i/receipt
    3.17 +	if echo "$PACKAGE $SHORT_DESC" | grep -q "$SEARCH"; then
    3.18 +		echo "$PACKAGE|$VERSION|$SHORT_DESC" >> /tmp/tazpkgbox/search-installed
    3.19 +	fi
    3.20 +done
    3.21 +
    3.22 +# Search mirrored.
    3.23 +grep "$SEARCH" /var/lib/tazpkg/packages.desc > /tmp/tazpkgbox/search-mirrored
    3.24 +
    3.25 +exit 0