tazpkg annotate modules/description @ rev 840

Add a bunch of modules with new-style support of 'root' (not all commands are modules yet); strip and compress resources.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Aug 28 16:10:34 2015 +0300 (2015-08-28)
parents
children d6cbd0c5f273
rev   line source
al@840 1 #!/bin/sh
al@840 2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
al@840 3 # description - TazPkg module
al@840 4 # Display package description
al@840 5
al@840 6
al@840 7 # Connect function libraries
al@840 8 . /lib/libtaz.sh
al@840 9
al@840 10 # Get TazPkg working environment
al@840 11 . @@MODULES@@/getenv
al@840 12
al@840 13
al@840 14
al@840 15
al@840 16 # Interactive mode
al@840 17
al@840 18 im() { tty -s; }
al@840 19
al@840 20
al@840 21
al@840 22
al@840 23 unset desc
al@840 24
al@840 25 # 1) Localized description
al@840 26 for LC in $LANG ${LANG%_*}; do
al@840 27 [ -e "$PKGS_DB/descriptions.$LC.txt" ] &&
al@840 28 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" '
al@840 29 $1 == p { $1 = ""; print $0; exit; }
al@840 30 ' "$PKGS_DB/descriptions.$LC.txt" | sed '1d')"
al@840 31 done
al@840 32
al@840 33 # 2) Installed description
al@840 34 if [ -z "$desc" -a -s "$INSTALLED/$1/description.txt" ]; then
al@840 35 desc="$(cat "$INSTALLED/$1/description.txt")"
al@840 36 fi
al@840 37
al@840 38 # 3) Mirrored description
al@840 39 if [ -z "$desc" -a -s "$PKGS_DB/descriptions.txt" ]; then
al@840 40 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" '
al@840 41 $1==p {$1 = ""; print $0; exit}
al@840 42 ' "$PKGS_DB/descriptions.txt" | sed '1d')"
al@840 43 fi
al@840 44
al@840 45 # 4) Short description only in interactive terminal
al@840 46 if [ -z "$desc" ] && im; then
al@840 47 for LC in $LANG ${LANG%_*}; do
al@840 48 [ -e "$PKGS_DB/packages-desc.$LC" ] &&
al@840 49 desc=$(awk -F$'\t' -vp="$1" '$1==p {print $2; exit}' "$PKGS_DB/packages-desc.$LC")
al@840 50 done
al@840 51
al@840 52 [ -z "$desc" -a -s "$PKGS_DB/packages.info" ] &&
al@840 53 desc="$(awk -F$'\t' -vp="$1" '$1==p {print $4; exit}' "$PKGS_DB/packages.info")"
al@840 54 fi
al@840 55
al@840 56 if [ -n "$desc" ]; then
al@840 57 # Title and footer only in interactive terminal
al@840 58 im && title 'Description of package "%s"' "$1"
al@840 59 longline "$desc"
al@840 60 im && footer
al@840 61 else
al@840 62 im && _ 'Description absent.'
al@840 63 fi