tazpkg annotate modules/description @ rev 963
modules/install: prefex "exact" packages over than "provided" packages.
In other words when requested "linux-agp": prefer "linux-agp" (if it exists) over the "linux-libre-agp".
In other words when requested "linux-agp": prefer "linux-agp" (if it exists) over the "linux-libre-agp".
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Feb 26 00:54:19 2018 +0200 (2018-02-26) |
parents | d6cbd0c5f273 |
children |
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 unset desc |
al@840 | 17 |
al@840 | 18 # 1) Localized description |
al@844 | 19 for lang in $LANG ${LANG%_*}; do |
al@844 | 20 [ -e "$PKGS_DB/descriptions.$lang.txt" ] || continue |
al@840 | 21 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" ' |
al@840 | 22 $1 == p { $1 = ""; print $0; exit; } |
al@844 | 23 ' "$PKGS_DB/descriptions.$lang.txt" | sed '1d')" |
al@840 | 24 done |
al@840 | 25 |
al@840 | 26 # 2) Installed description |
al@840 | 27 if [ -z "$desc" -a -s "$INSTALLED/$1/description.txt" ]; then |
al@840 | 28 desc="$(cat "$INSTALLED/$1/description.txt")" |
al@840 | 29 fi |
al@840 | 30 |
al@840 | 31 # 3) Mirrored description |
al@840 | 32 if [ -z "$desc" -a -s "$PKGS_DB/descriptions.txt" ]; then |
al@840 | 33 desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$1" ' |
al@840 | 34 $1==p {$1 = ""; print $0; exit} |
al@840 | 35 ' "$PKGS_DB/descriptions.txt" | sed '1d')" |
al@840 | 36 fi |
al@840 | 37 |
al@840 | 38 # 4) Short description only in interactive terminal |
al@840 | 39 if [ -z "$desc" ] && im; then |
al@844 | 40 for lang in $LANG ${LANG%_*}; do |
al@844 | 41 [ -e "$PKGS_DB/packages-desc.$lang" ] || continue |
al@844 | 42 desc=$(awk -F$'\t' -vp="$1" '$1==p {print $2; exit}' "$PKGS_DB/packages-desc.$lang") |
al@840 | 43 done |
al@840 | 44 |
al@840 | 45 [ -z "$desc" -a -s "$PKGS_DB/packages.info" ] && |
al@840 | 46 desc="$(awk -F$'\t' -vp="$1" '$1==p {print $4; exit}' "$PKGS_DB/packages.info")" |
al@840 | 47 fi |
al@840 | 48 |
al@840 | 49 if [ -n "$desc" ]; then |
al@844 | 50 case $output in |
al@844 | 51 html) |
al@844 | 52 # Description for TazPanel in html format |
al@844 | 53 if [ -n "$(which sundown)" ]; then |
al@844 | 54 # Parse description as markdown |
al@844 | 55 echo "$desc" | sundown |
al@844 | 56 else |
al@844 | 57 # Dump description within <pre> tag |
al@844 | 58 echo '<pre class="pre-wrap">' |
al@844 | 59 echo "$desc" | sed -e 's|\&|\&|g; s|<|\<|g; s|>|\>|g' |
al@844 | 60 echo '</pre>' |
al@844 | 61 fi |
al@844 | 62 ;; |
al@844 | 63 *) |
al@844 | 64 # Description for terminal tazpkg in plain text |
al@844 | 65 # Title and footer only in interactive terminal |
al@844 | 66 im && title 'Description of package "%s"' "$1" |
al@844 | 67 echo "$desc" |
al@844 | 68 im && footer |
al@844 | 69 ;; |
al@844 | 70 esac |
al@844 | 71 |
al@840 | 72 else |
al@840 | 73 im && _ 'Description absent.' |
al@840 | 74 fi |
al@844 | 75 |
al@844 | 76 exit 0 |