# HG changeset patch # User Aleksej Bobylev # Date 1437739892 -10800 # Node ID 3f3db6d5be82fe7ef285dbba770c1fa165cc9f10 # Parent d2eaee40047c7f684e90bab39338584a116891ff tazpkg: re-write "desc" function to use all available sorts of descriptions (installed, mirrored, short, long, localized) diff -r d2eaee40047c -r 3f3db6d5be82 tazpkg --- a/tazpkg Sun Jul 19 15:17:03 2015 +0300 +++ b/tazpkg Fri Jul 24 15:11:32 2015 +0300 @@ -1547,17 +1547,40 @@ desc|-d) # Display package description - if [ -n "$(grep -e "^$PACKAGE"$'\t' $PKGS_DB/installed.info)" ]; then + unset desc + + # 1) Localized description + for LC in $LANG ${LANG%_*}; do + [ -e "$PKGS_DB/descriptions.$LC.txt" ] && + desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$PACKAGE" ' + $1 == p { $1 = ""; print $0; exit; } + ' "$PKGS_DB/descriptions.$LC.txt" | sed '1d')" + done + + # 2) Installed description + if [ -z "$desc" -a -s "$INSTALLED/$PACKAGE/description.txt" ]; then + desc="$(cat "$INSTALLED/$PACKAGE/description.txt")" + fi + + # 3) Mirrored description + if [ -z "$desc" -a -s "$PKGS_DB/descriptions.txt" ]; then + desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$PACKAGE" ' + $1 == p { $1 = ""; print $0; exit; } + ' "$PKGS_DB/descriptions.txt" | sed '1d')" + fi + + # 4) Short description only in terminal + if [ -z "$desc" ] && im; then + desc="$(print_short_description "$PACKAGE")" + fi + + if [ -n "$desc" ]; then + # Title and footer only in terminal im && title 'Description of package "%s"' "$PACKAGE" - if [ -s "$INSTALLED/$PACKAGE/description.txt" ]; then - cat "$INSTALLED/$PACKAGE/description.txt" - else - im && awk -F$'\t' -vp="$PACKAGE" '{ - if ($1 == p) print $4 }' $PKGS_DB/installed.info - fi + echo "$desc" im && footer else - im && _ 'Package "%s" is not installed.' "$PACKAGE" + im && _ 'Description absent.' fi ;; diff -r d2eaee40047c -r 3f3db6d5be82 tazpkg-box --- a/tazpkg-box Sun Jul 19 15:17:03 2015 +0300 +++ b/tazpkg-box Fri Jul 24 15:11:32 2015 +0300 @@ -22,6 +22,14 @@ usage() { cat <