tazpkg rev 37

Support for creating xHTML list of installed packages
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 05 14:12:19 2008 +0100 (2008-02-05)
parents 695f9848b93a
children abe47a57b67b
files tazpkg
line diff
     1.1 --- a/tazpkg	Tue Feb 05 01:30:25 2008 +0100
     1.2 +++ b/tazpkg	Tue Feb 05 14:12:19 2008 +0100
     1.3 @@ -73,6 +73,7 @@
     1.4  \033[1mCommands: \033[0m
     1.5    usage         Print this short usage.
     1.6    list          List installed packages on the system by category or all.
     1.7 +  xhtml-list    Creat a xHTML list of installed packges.
     1.8    list-mirror   List all available packages on the mirror (--diff for new).
     1.9    info          Print informations about the package.
    1.10    desc          Print description of a package (if it exist).
    1.11 @@ -324,6 +325,74 @@
    1.12  	fi
    1.13  }
    1.14  
    1.15 +# xHTML packages list header.
    1.16 +xhtml_header()
    1.17 +{
    1.18 +	cat > $XHTML_LIST << _EOT_
    1.19 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    1.20 +	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    1.21 +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    1.22 +<head>
    1.23 +	<title>Installed packages list</title>
    1.24 +	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
    1.25 +	<meta name="modified" content="$DATE" />
    1.26 +	<meta name="generator" content="Tazpkg" />
    1.27 +	<style type="text/css"><!--
    1.28 +	body { font: 12px sans-serif, vernada, arial; margin: 0; }
    1.29 +	#header { background: #f0ba08; color: black; height: 50px;
    1.30 +		border-top: 1px solid black; border-bottom: 1px solid black; }
    1.31 +	#content { margin: 0px 50px 26px 50px; }
    1.32 +	#footer { border-top: 1px solid black; padding-top: 10px;}
    1.33 +	h1 { margin: 14px 0px 0px 16px; }
    1.34 +	pre { padding-left: 5px; }
    1.35 +	hr { color: white; background: white; height: 1px; border: 0; }
    1.36 +	--></style>
    1.37 +</head>
    1.38 +<body bgcolor="#ffffff">
    1.39 +<div id="header">
    1.40 +<h1><font color="#3e1220">Installed packages list</font></h1>
    1.41 +</div>
    1.42 +<hr />
    1.43 +<!-- Start content -->
    1.44 +<div id="content">
    1.45 +
    1.46 +<p>
    1.47 +_packages_ packages installed - List generated on : $DATE
    1.48 +<p>
    1.49 +
    1.50 +_EOT_
    1.51 +}
    1.52 +
    1.53 +# xHTML content with packages infos.
    1.54 +xhtml_pkg_info()
    1.55 +{
    1.56 +	cat >> $XHTML_LIST << _EOT_
    1.57 +<h3>$PACKAGE</h3>
    1.58 +<pre>
    1.59 +Version    : $VERSION
    1.60 +Short desc : $SHORT_DESC
    1.61 +Web site   : <a href="$WEB_SITE">$WEB_SITE</a>
    1.62 +</pre>
    1.63 +
    1.64 +_EOT_
    1.65 +}
    1.66 +
    1.67 +# xHTML packages list footer.
    1.68 +xhtml_footer()
    1.69 +{
    1.70 +	cat >> $XHTML_LIST << _EOT_
    1.71 +<hr />
    1.72 +<p id="footer">
    1.73 +$packages packages installed - List generated on : $DATE
    1.74 +</p>
    1.75 +
    1.76 +<!-- End content -->
    1.77 +</div>
    1.78 +</body>
    1.79 +</html>
    1.80 +_EOT_
    1.81 +}
    1.82 +
    1.83  ###################
    1.84  # Tazpkg commands #
    1.85  ###################
    1.86 @@ -372,6 +441,38 @@
    1.87  			echo ""
    1.88  		fi
    1.89  		;;
    1.90 +	xhtml-list)
    1.91 +		# Get infos in receipts and build list.
    1.92 +		DATE=`date +%Y-%m-%d\ \%H:%M:%S`
    1.93 +		if [ -n "$2" ]; then
    1.94 +			XHTML_LIST=$2
    1.95 +		else
    1.96 +			XHTML_LIST=packages.html
    1.97 +		fi
    1.98 +		echo ""
    1.99 +		echo -e "\033[1mCreating xHTML list of installed packages\033[0m"
   1.100 +		echo "================================================================================"
   1.101 +		echo -n "Generating xHTML header..."
   1.102 +		xhtml_header
   1.103 +		status
   1.104 +		# Packages
   1.105 +		echo -n "Creating packages informations..."
   1.106 +		for pkg in $INSTALLED/*
   1.107 +		do
   1.108 +			. $pkg/receipt
   1.109 +			xhtml_pkg_info
   1.110 +			packages=$(($packages+1))
   1.111 +		done
   1.112 +		status
   1.113 +		echo -n "Generating xHTML footer..."
   1.114 +		xhtml_footer
   1.115 +		status
   1.116 +		# sed pkgs nb in header.
   1.117 +		sed -i s/'_packages_'/"$packages"/ $XHTML_LIST
   1.118 +		echo "================================================================================"
   1.119 +		echo "$XHTML_LIST created - $packages packages."
   1.120 +		echo ""
   1.121 +		;;
   1.122  	list-mirror)
   1.123  		# List all available packages on the mirror. Option --diff display
   1.124  		# last mirrored packages diff (see recharge).
   1.125 @@ -611,11 +712,11 @@
   1.126  			ALTERED=""
   1.127  			THE_PACKAGE=$PACKAGE	# altered by receipt
   1.128  			for i in $(cd $INSTALLED ; ls); do
   1.129 +				DEPENDS=""
   1.130  				. $INSTALLED/$i/receipt
   1.131  				case " $(echo $DEPENDS) " in
   1.132  				*\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";;
   1.133  				esac
   1.134 -				DEPENDS=""
   1.135  			done
   1.136  			. $INSTALLED/$THE_PACKAGE/receipt
   1.137  		fi
   1.138 @@ -647,7 +748,9 @@
   1.139  				echo -n " (y/N) ? "; read anser
   1.140  				if [ "$anser" = "y" ]; then
   1.141  					for i in $ALTERED; do
   1.142 -						tazpkg remove $i
   1.143 +						if [ -d "$INSTALLED/$i" ]; then
   1.144 +							tazpkg remove $i
   1.145 +						fi
   1.146  					done
   1.147  				fi
   1.148  			fi
   1.149 @@ -919,7 +1022,7 @@
   1.150  				echo -e "$MSG  $file"
   1.151  				MSG=""
   1.152  			done < $PACKAGE/files.list
   1.153 -			MSG="Missing dependancies for $PACKAGE $VERSION :\n"
   1.154 +			MSG="Missing dependencies for $PACKAGE $VERSION :\n"
   1.155  			for i in $DEPENDS; do
   1.156  				[ -d $i ] && continue
   1.157  				echo -e "$MSG  $i"
   1.158 @@ -1018,7 +1121,7 @@
   1.159  		check_root
   1.160  		# Backup old list.
   1.161  		if [ -f "$LOCALSTATE/mirror" ]; then
   1.162 -			mv -f $LOCALSTATE/mirror $LOCALSTATE/mirror.bak
   1.163 +			cp -f $LOCALSTATE/mirror $LOCALSTATE/mirror.bak
   1.164  		fi
   1.165  		echo ""
   1.166  		echo -e "\033[1mCurrent mirror(s)\033[0m"