# HG changeset patch # User Aleksej Bobylev # Date 1430349674 -10800 # Node ID c079553f3ad4a9d52dc83a3707756c370eadffc6 # Parent afe32a913bc4f30b94995ef1272ff44938070b74 pkgs.cgi: change look of "do=command" page; tazpkg: rework "remove" command. diff -r afe32a913bc4 -r c079553f3ad4 tazpanel/pkgs.cgi --- a/tazpanel/pkgs.cgi Wed Apr 29 17:06:31 2015 +0200 +++ b/tazpanel/pkgs.cgi Thu Apr 30 02:21:14 2015 +0300 @@ -841,9 +841,9 @@ # Describe the command bpkgs="$pkgs"; opt='' case $cmd in - install) MSG="$(_ 'Installing: %s' "$bpkgs")"; opt=--forced; cmd=get-install ;; + install) MSG="$(_ 'Installing: %s' "$bpkgs")"; opt='--forced'; cmd='get-install' ;; remove) MSG="$(_ 'Removing: %s' "$bpkgs")" ;; - link) MSG="$(_ 'Linking: %s' "$bpkgs")"; opt=$(readlink $PKGS_DB/fslink) ;; + link) MSG="$(_ 'Linking: %s' "$bpkgs")"; opt="$(readlink $PKGS_DB/fslink)" ;; block) MSG="$(_ 'Blocking: %s' "$bpkgs")" ;; unblock) MSG="$(_ 'Unblocking: %s' "$bpkgs")" ;; chblock) MSG="$(_ '(Un)blocking: %s' "$bpkgs")" ;; @@ -852,16 +852,18 @@ cat <TazPkg: $(GET do) -
-
$MSG
-
+
+
$MSG
EOT # Do the command for all asked packages cd /tmp + export output='html' + for pkg in $pkgs; do - echo $(_n 'y') | tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs + #echo $(_n 'y') | + tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs done - echo '
' ;; + ;; *\ info\ *) diff -r afe32a913bc4 -r c079553f3ad4 tazpkg --- a/tazpkg Wed Apr 29 17:06:31 2015 +0200 +++ b/tazpkg Thu Apr 30 02:21:14 2015 +0300 @@ -1,23 +1,24 @@ #!/bin/sh # -# TazPKG - Tiny autonomous zone packages manager. +# TazPkg - Tiny autonomous zone packages manager. # # This is a lightweight packages manager for *.tazpkg files written in SHell -# script. It works well with Busybox ash shell and bash. TazPKG lets you +# script. It works well with Busybox ash shell and bash. TazPkg lets you # list, install, remove, download or get information about a package. You # can use 'tazpkg usage' to get a list of commands with short descriptions. -# TazPKG also resolves dependencies and can upgrade packages from a mirror. +# TazPkg also resolves dependencies and can upgrade packages from a mirror. # # (C) 2007-2015 SliTaz - GNU General Public License v3. # # Authors: See the AUTHORS files # + #################### # Script variables # #################### -# TazPKG version +# TazPkg version VERSION=5.3.4 . /etc/slitaz/slitaz.conf @@ -85,12 +86,26 @@ # Print localized title -title() { newline; boldify "$(_ "$@")"; separator; } +title() { + case $output in + html) + echo "
$(_ "$@")
";;
+		*)
+			newline; boldify "$(_ "$@")"; separator;;
+	esac
+}
 
 
 # Print footer
 
-footer() { separator; echo "$1"; [ -n "$1" ] && newline; }
+footer() {
+	case $output in
+		html)
+			echo "
";; + *) + separator; echo "$1"; [ -n "$1" ] && newline;; + esac +} # Print current action in brown color (separate from any other msgs) @@ -645,6 +660,20 @@ } +# Print short package description +print_short_description() { + local short_desc='' + for LC in $LANG ${LANG%_*}; do + if [ -e "$PKGS_DB/packages-desc.$LC" ]; then + short_desc=$(grep -e "^$1 " $PKGS_DB/packages-desc.$LC | cut -d' ' -f2) + fi + done + [ -z "$short_desc" ] && \ + short_desc="$(awk -F$'\t' -vp="$PACKAGE" '{if($1==p){print $4;exit}}' $PKGS_DB/packages.info)" + longline "$short_desc" +} + + # This function installs a package in the rootfs. install_package() @@ -691,8 +720,8 @@ title 'Installation of package "%s"' $PACKAGE - longline "$(awk -F$'\t' -vp="$PACKAGE" '{if($1==p){print $4;exit}}' $PKGS_DB/packages.info)" - separator | tr -c $'\n' '-' + print_short_description $PACKAGE + separator '-' action 'Copying package...' cp $PACKAGE_FILE $TMP_DIR @@ -815,7 +844,7 @@ fi action 'Installing package...' - [ "$(busybox ls fs/* 2> /dev/null)" ] && cp -af fs/* $ROOT/ + [ "$(busybox ls fs/* 2>/dev/null)" ] && cp -af fs/* $ROOT/ status if [ -s files2remove.list ]; then @@ -834,7 +863,9 @@ # Post install commands. if grep -q ^post_install $ROOT$INSTALLED/$PACKAGE/receipt; then + action "Execute post-install commands..." post_install $ROOT + status fi # Update-desktop-database if needed. @@ -1793,120 +1824,132 @@ check_for_installed_info [ -n "$root" ] && ROOT="$root" + if [ ! -f "$ROOT$INSTALLED/$PACKAGE/receipt" ]; then - newline - _ 'Package "%s" is not installed.' $PACKAGE + newline; _ 'Package "%s" is not installed.' $PACKAGE exit 0 - else - ALTERED="" - THE_PACKAGE=$PACKAGE # altered by receipt - for i in $(cd $ROOT$INSTALLED ; ls); do - [ -f $ROOT$INSTALLED/$i/receipt ] || continue - DEPENDS="" - . $ROOT$INSTALLED/$i/receipt - case " $(echo $DEPENDS) " in - *\ $THE_PACKAGE\ *) ALTERED="$ALTERED $i";; - esac - done - EXTRAVERSION="" - . $ROOT$INSTALLED/$THE_PACKAGE/receipt fi - newline + + . $ROOT$INSTALLED/$PACKAGE/receipt + + # Info #1: dependent packages (to be processed later) + ALTERED="$(awk -F$'\t' -vp=" $PACKAGE " ' + index(" " $8 " ", p) { printf " %s\n", $1 } + ' $ROOT/$PKGS_DB/installed.info)" + if [ -n "$ALTERED" ]; then _ 'The following packages depend on package "%s":' $PACKAGE - for i in $ALTERED; do - echo " $i" - done + echo "$ALTERED" fi + + # Info #2: changed packages (to be processed later) REFRESH=$(cd $ROOT$INSTALLED ; grep -sl ^$PACKAGE$ */modifiers) + if [ -n "$REFRESH" ]; then _ 'The following packages have been modified by package "%s":' $PACKAGE for i in $REFRESH; do echo " ${i%/modifiers}" done fi - if [ "$auto" ]; then - answer=0 + + # Confirmation + if im && [ -z "$auto" ]; then + confirm "$(_ 'Remove package "%s" (%s)? (y/N)' $PACKAGE $VERSION$EXTRAVERSION)" + if [ $? != 0 ]; then + newline; _ 'Uninstallation of package "%s" cancelled.' $PACKAGE + exit 0 + fi + fi + # We are here: non-interactive mode, or --auto, or answer 'y' + + # Removing package + title 'Removing package "%s"' $PACKAGE + + # [1/4] Pre-remove commands + if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then + action "Execution of pre-remove commands..." + pre_remove $ROOT + status + fi + + # [2/4] Removing files + action "Removing all files installed..." + if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then + for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do + for mod in $(cat $ROOT$INSTALLED/$PACKAGE/modifiers); do + [ -f $ROOT$INSTALLED/$mod/files.list ] && \ + [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && \ + continue 2 + done + remove_with_path $ROOT$file + done else - confirm "$(_ 'Remove package "%s" (%s)? (y/N)' $PACKAGE $VERSION$EXTRAVERSION)" - answer=$? + for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do + remove_with_path $ROOT$file + done fi - if [ $answer = 0 ]; then - title 'Removing package "%s"' $PACKAGE - # Pre remove commands. - if grep -q ^pre_remove $ROOT$INSTALLED/$PACKAGE/receipt; then - pre_remove $ROOT + status + + # [3/4] Post-remove commands + if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then + action "Execution of post-remove commands..." + post_remove $ROOT + status + fi + + # [4/4] Remove package receipt and remove it from databases + action "Removing package receipt..." + rm -rf $ROOT$INSTALLED/$PACKAGE + sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION.tazpkg$/d" $PKGS_DB/installed.$SUM + sed -i "/^$PACKAGE /d" $PKGS_DB/installed.info + status + + footer "$(_ 'Package "%s" (%s) removed.' $PACKAGE $VERSION$EXTRAVERSION)" + + # Log this activity + log_pkg Removed + + # Stop if non-interactive mode and no --auto option + if ! im && [ -z "$auto" ]; then exit 0; fi + + # Process dependent packages + if [ -n "$ALTERED" ]; then + if [ "$auto" ]; then + answer=0 + else + confirm "$(_ 'Remove packages depending on package "%s"? (y/N)' $PACKAGE)" + answer=$? fi - action "Removing all files installed..." - if [ -f $ROOT$INSTALLED/$PACKAGE/modifiers ]; then - for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do - for mod in $(cat $ROOT$INSTALLED/$PACKAGE/modifiers); do - [ -f $ROOT$INSTALLED/$mod/files.list ] && [ $(grep "^$(echo $file | grepesc)$" $ROOT$INSTALLED/$mod/files.list | wc -l) -gt 1 ] && continue 2 - done - remove_with_path $ROOT$file - done - else - for file in $(cat $ROOT$INSTALLED/$PACKAGE/files.list); do - remove_with_path $ROOT$file + if [ $answer = 0 ]; then + for i in $ALTERED; do + if [ -d "$ROOT$INSTALLED/$i" ]; then + echo "tazpkg remove $i $ROOTOPTS" + fi done fi - status - if grep -q ^post_remove $ROOT$INSTALLED/$PACKAGE/receipt; then - post_remove $ROOT + fi + + # Process changed packages + if [ -n "$REFRESH" ]; then + if [ "$auto" ]; then + answer=0 + else + confirm "$(_ 'Reinstall packages modified by package "%s"? (y/N)' $PACKAGE)" + answer=$? fi - - # Remove package receipt. - action "Removing package receipt..." - rm -rf $ROOT$INSTALLED/$PACKAGE - status - - sed -i "/ $PACKAGE-$VERSION$EXTRAVERSION$/d" \ - $PKGS_DB/installed.$SUM 2> /dev/null - - # Update installed.info - sed -i "/^$PACKAGE /d" $PKGS_DB/installed.info - - # Log this activity - log_pkg Removed - - if [ "$ALTERED" ]; then - if [ "$auto" ]; then - answer=0 - else - confirm "$(_ 'Remove packages depending on package "%s"? (y/N)' $PACKAGE)" - answer=$? - fi - if [ $answer = 0 ]; then - for i in $ALTERED; do - if [ -d "$ROOT$INSTALLED/$i" ]; then - tazpkg remove $i $ROOTOPTS - fi - done - fi + if [ $answer = 0 ]; then + for i in $REFRESH; do + if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then + _ 'Check %s for reinstallation' "$INSTALLED/$i" + continue + fi + echo "rm -r $ROOT$INSTALLED/$i" + echo "tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced" + done fi - if [ "$REFRESH" ]; then - if [ "$auto" ]; then - answer=0 - else - confirm "$(_ 'Reinstall packages modified by package "%s"? (y/N)' $PACKAGE)" - answer=$? - fi - if [ $answer = 0 ]; then - for i in $REFRESH; do - if [ $(wc -l < $ROOT$INSTALLED/$i) -gt 1 ]; then - _ 'Check %s for reinstallation' "$INSTALLED/$i" - continue - fi - rm -r $ROOT$INSTALLED/$i - tazpkg get-install ${i%/modifiers} $ROOTOPTS --forced - done - fi - fi - else - newline - _ 'Uninstallation of package "%s" cancelled.' $PACKAGE fi - newline ;; + + ;; extract|-e)