tazpkg view modules/description @ rev 898

Module 'get': fix temp dir; module 'find-depends': faster search, add debug messages
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Dec 29 22:00:47 2015 +0200 (2015-12-29)
parents a02e36d44d06
children 45d90da42ede
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 lang in $LANG ${LANG%_*}; do
27 [ -e "$PKGS_DB/descriptions.$lang.txt" ] || continue
28 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" '
29 $1 == p { $1 = ""; print $0; exit; }
30 ' "$PKGS_DB/descriptions.$lang.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 lang in $LANG ${LANG%_*}; do
48 [ -e "$PKGS_DB/packages-desc.$lang" ] || continue
49 desc=$(awk -F$'\t' -vp="$1" '$1==p {print $2; exit}' "$PKGS_DB/packages-desc.$lang")
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 case $output in
58 html)
59 # Description for TazPanel in html format
60 if [ -n "$(which sundown)" ]; then
61 # Parse description as markdown
62 echo "$desc" | sundown
63 else
64 # Dump description within <pre> tag
65 echo '<pre class="pre-wrap">'
66 echo "$desc" | sed -e 's|\&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g'
67 echo '</pre>'
68 fi
69 ;;
70 *)
71 # Description for terminal tazpkg in plain text
72 # Title and footer only in interactive terminal
73 im && title 'Description of package "%s"' "$1"
74 echo "$desc"
75 im && footer
76 ;;
77 esac
79 else
80 im && _ 'Description absent.'
81 fi
83 exit 0