tazpkg rev 819
tazpkg: re-write "desc" function to use all available sorts of descriptions (installed, mirrored, short, long, localized)
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Jul 24 15:11:32 2015 +0300 (2015-07-24) |
parents | d2eaee40047c |
children | 5c4634856840 |
files | tazpkg tazpkg-box |
line diff
1.1 --- a/tazpkg Sun Jul 19 15:17:03 2015 +0300 1.2 +++ b/tazpkg Fri Jul 24 15:11:32 2015 +0300 1.3 @@ -1547,17 +1547,40 @@ 1.4 1.5 desc|-d) 1.6 # Display package description 1.7 - if [ -n "$(grep -e "^$PACKAGE"$'\t' $PKGS_DB/installed.info)" ]; then 1.8 + unset desc 1.9 + 1.10 + # 1) Localized description 1.11 + for LC in $LANG ${LANG%_*}; do 1.12 + [ -e "$PKGS_DB/descriptions.$LC.txt" ] && 1.13 + desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$PACKAGE" ' 1.14 + $1 == p { $1 = ""; print $0; exit; } 1.15 + ' "$PKGS_DB/descriptions.$LC.txt" | sed '1d')" 1.16 + done 1.17 + 1.18 + # 2) Installed description 1.19 + if [ -z "$desc" -a -s "$INSTALLED/$PACKAGE/description.txt" ]; then 1.20 + desc="$(cat "$INSTALLED/$PACKAGE/description.txt")" 1.21 + fi 1.22 + 1.23 + # 3) Mirrored description 1.24 + if [ -z "$desc" -a -s "$PKGS_DB/descriptions.txt" ]; then 1.25 + desc="$(awk -vRS='' -vFS='\n' -vOFS='\n' -vp="$PACKAGE" ' 1.26 + $1 == p { $1 = ""; print $0; exit; } 1.27 + ' "$PKGS_DB/descriptions.txt" | sed '1d')" 1.28 + fi 1.29 + 1.30 + # 4) Short description only in terminal 1.31 + if [ -z "$desc" ] && im; then 1.32 + desc="$(print_short_description "$PACKAGE")" 1.33 + fi 1.34 + 1.35 + if [ -n "$desc" ]; then 1.36 + # Title and footer only in terminal 1.37 im && title 'Description of package "%s"' "$PACKAGE" 1.38 - if [ -s "$INSTALLED/$PACKAGE/description.txt" ]; then 1.39 - cat "$INSTALLED/$PACKAGE/description.txt" 1.40 - else 1.41 - im && awk -F$'\t' -vp="$PACKAGE" '{ 1.42 - if ($1 == p) print $4 }' $PKGS_DB/installed.info 1.43 - fi 1.44 + echo "$desc" 1.45 im && footer 1.46 else 1.47 - im && _ 'Package "%s" is not installed.' "$PACKAGE" 1.48 + im && _ 'Description absent.' 1.49 fi 1.50 ;; 1.51
2.1 --- a/tazpkg-box Sun Jul 19 15:17:03 2015 +0300 2.2 +++ b/tazpkg-box Fri Jul 24 15:11:32 2015 +0300 2.3 @@ -22,6 +22,14 @@ 2.4 usage() { 2.5 cat <<EOT 2.6 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')] 2.7 + 2.8 +Examples: 2.9 + 2.10 +$(basename $0) actions /path/to/package-1.0.tazpkg 2.11 + display box to extract or install given package 2.12 + 2.13 +$(basename $0) tazpkg://example.com/path/to/package-1.0.tazpkg 2.14 + download and install given package 2.15 EOT 2.16 } 2.17 2.18 @@ -91,13 +99,14 @@ 2.19 # 2.20 2.21 case "$1" in 2.22 - usage|help|-u|-h) 2.23 + --help|-h|help|usage|-u) 2.24 usage ;; 2.25 tazpkg://*) 2.26 # TazPkg URL's handler. 2.27 url="http://${1#tazpkg://}" 2.28 dl_inst | output ;; 2.29 actions) 2.30 + [ -z "$2" ] && exit 1 2.31 pkg="$(basename "$(realpath "${2%% }")")" # fight against strange space at the end 2.32 dir="$(dirname "$(realpath "${2%% }")")" 2.33 cd "$dir"