# HG changeset patch # User Christophe Lincoln # Date 1202217139 -3600 # Node ID a32f68caef5061d7fb9ac3d39641a5dbf8542b17 # Parent 695f9848b93ad173547765034f34e15664042c5c Support for creating xHTML list of installed packages diff -r 695f9848b93a -r a32f68caef50 tazpkg --- a/tazpkg Tue Feb 05 01:30:25 2008 +0100 +++ b/tazpkg Tue Feb 05 14:12:19 2008 +0100 @@ -73,6 +73,7 @@ \033[1mCommands: \033[0m usage Print this short usage. list List installed packages on the system by category or all. + xhtml-list Creat a xHTML list of installed packges. list-mirror List all available packages on the mirror (--diff for new). info Print informations about the package. desc Print description of a package (if it exist). @@ -324,6 +325,74 @@ fi } +# xHTML packages list header. +xhtml_header() +{ + cat > $XHTML_LIST << _EOT_ + + + + Installed packages list + + + + + + + +
+ +
+ +

+_packages_ packages installed - List generated on : $DATE +

+ +_EOT_ +} + +# xHTML content with packages infos. +xhtml_pkg_info() +{ + cat >> $XHTML_LIST << _EOT_ +

$PACKAGE

+
+Version    : $VERSION
+Short desc : $SHORT_DESC
+Web site   : $WEB_SITE
+
+ +_EOT_ +} + +# xHTML packages list footer. +xhtml_footer() +{ + cat >> $XHTML_LIST << _EOT_ +
+ + + +
+ + +_EOT_ +} + ################### # Tazpkg commands # ################### @@ -372,6 +441,38 @@ echo "" fi ;; + xhtml-list) + # Get infos in receipts and build list. + DATE=`date +%Y-%m-%d\ \%H:%M:%S` + if [ -n "$2" ]; then + XHTML_LIST=$2 + else + XHTML_LIST=packages.html + fi + echo "" + echo -e "\033[1mCreating xHTML list of installed packages\033[0m" + echo "================================================================================" + echo -n "Generating xHTML header..." + xhtml_header + status + # Packages + echo -n "Creating packages informations..." + for pkg in $INSTALLED/* + do + . $pkg/receipt + xhtml_pkg_info + packages=$(($packages+1)) + done + status + echo -n "Generating xHTML footer..." + xhtml_footer + status + # sed pkgs nb in header. + sed -i s/'_packages_'/"$packages"/ $XHTML_LIST + echo "================================================================================" + echo "$XHTML_LIST created - $packages packages." + echo "" + ;; list-mirror) # List all available packages on the mirror. Option --diff display # last mirrored packages diff (see recharge). @@ -611,11 +712,11 @@ ALTERED="" THE_PACKAGE=$PACKAGE # altered by receipt for i in $(cd $INSTALLED ; ls); do + DEPENDS="" . $INSTALLED/$i/receipt case " $(echo $DEPENDS) " in *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";; esac - DEPENDS="" done . $INSTALLED/$THE_PACKAGE/receipt fi @@ -647,7 +748,9 @@ echo -n " (y/N) ? "; read anser if [ "$anser" = "y" ]; then for i in $ALTERED; do - tazpkg remove $i + if [ -d "$INSTALLED/$i" ]; then + tazpkg remove $i + fi done fi fi @@ -919,7 +1022,7 @@ echo -e "$MSG $file" MSG="" done < $PACKAGE/files.list - MSG="Missing dependancies for $PACKAGE $VERSION :\n" + MSG="Missing dependencies for $PACKAGE $VERSION :\n" for i in $DEPENDS; do [ -d $i ] && continue echo -e "$MSG $i" @@ -1018,7 +1121,7 @@ check_root # Backup old list. if [ -f "$LOCALSTATE/mirror" ]; then - mv -f $LOCALSTATE/mirror $LOCALSTATE/mirror.bak + cp -f $LOCALSTATE/mirror $LOCALSTATE/mirror.bak fi echo "" echo -e "\033[1mCurrent mirror(s)\033[0m"