tazpkg view modules/description @ rev 958

Add Italian; make pot; make msgmerge; make clean
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Jan 30 11:49:21 2018 +0200 (2018-01-30)
parents d6cbd0c5f273
children
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 unset desc
18 # 1) Localized description
19 for lang in $LANG ${LANG%_*}; do
20 [ -e "$PKGS_DB/descriptions.$lang.txt" ] || continue
21 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" '
22 $1 == p { $1 = ""; print $0; exit; }
23 ' "$PKGS_DB/descriptions.$lang.txt" | sed '1d')"
24 done
26 # 2) Installed description
27 if [ -z "$desc" -a -s "$INSTALLED/$1/description.txt" ]; then
28 desc="$(cat "$INSTALLED/$1/description.txt")"
29 fi
31 # 3) Mirrored description
32 if [ -z "$desc" -a -s "$PKGS_DB/descriptions.txt" ]; then
33 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" '
34 $1==p {$1 = ""; print $0; exit}
35 ' "$PKGS_DB/descriptions.txt" | sed '1d')"
36 fi
38 # 4) Short description only in interactive terminal
39 if [ -z "$desc" ] && im; then
40 for lang in $LANG ${LANG%_*}; do
41 [ -e "$PKGS_DB/packages-desc.$lang" ] || continue
42 desc=$(awk -F$'\t' -vp="$1" '$1==p {print $2; exit}' "$PKGS_DB/packages-desc.$lang")
43 done
45 [ -z "$desc" -a -s "$PKGS_DB/packages.info" ] &&
46 desc="$(awk -F$'\t' -vp="$1" '$1==p {print $4; exit}' "$PKGS_DB/packages.info")"
47 fi
49 if [ -n "$desc" ]; then
50 case $output in
51 html)
52 # Description for TazPanel in html format
53 if [ -n "$(which sundown)" ]; then
54 # Parse description as markdown
55 echo "$desc" | sundown
56 else
57 # Dump description within <pre> tag
58 echo '<pre class="pre-wrap">'
59 echo "$desc" | sed -e 's|\&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g'
60 echo '</pre>'
61 fi
62 ;;
63 *)
64 # Description for terminal tazpkg in plain text
65 # Title and footer only in interactive terminal
66 im && title 'Description of package "%s"' "$1"
67 echo "$desc"
68 im && footer
69 ;;
70 esac
72 else
73 im && _ 'Description absent.'
74 fi
76 exit 0