tazpkg view 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
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # description - TazPkg module
4 # Display package description
7 # Connect function libraries
8 . /lib/libtaz.sh
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
16 # Interactive mode
18 im() { tty -s; }
23 unset desc
25 # 1) Localized description
26 for LC in $LANG ${LANG%_*}; do
27 [ -e "$PKGS_DB/descriptions.$LC.txt" ] &&
28 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" '
29 $1 == p { $1 = ""; print $0; exit; }
30 ' "$PKGS_DB/descriptions.$LC.txt" | sed '1d')"
31 done
33 # 2) Installed description
34 if [ -z "$desc" -a -s "$INSTALLED/$1/description.txt" ]; then
35 desc="$(cat "$INSTALLED/$1/description.txt")"
36 fi
38 # 3) Mirrored description
39 if [ -z "$desc" -a -s "$PKGS_DB/descriptions.txt" ]; then
40 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" '
41 $1==p {$1 = ""; print $0; exit}
42 ' "$PKGS_DB/descriptions.txt" | sed '1d')"
43 fi
45 # 4) Short description only in interactive terminal
46 if [ -z "$desc" ] && im; then
47 for LC in $LANG ${LANG%_*}; do
48 [ -e "$PKGS_DB/packages-desc.$LC" ] &&
49 desc=$(awk -F$'\t' -vp="$1" '$1==p {print $2; exit}' "$PKGS_DB/packages-desc.$LC")
50 done
52 [ -z "$desc" -a -s "$PKGS_DB/packages.info" ] &&
53 desc="$(awk -F$'\t' -vp="$1" '$1==p {print $4; exit}' "$PKGS_DB/packages.info")"
54 fi
56 if [ -n "$desc" ]; then
57 # Title and footer only in interactive terminal
58 im && title 'Description of package "%s"' "$1"
59 longline "$desc"
60 im && footer
61 else
62 im && _ 'Description absent.'
63 fi