tazpkg view modules/info @ rev 828
Add modules "info", "list" with extended functions; update documentations and translations
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Aug 11 01:09:15 2015 +0300 (2015-08-11) |
parents | |
children | 7acf0290bdb2 |
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # info - TazPkg module
4 # Information about package (both installed, mirrored, or local)
7 # Connect function libraries
8 . /lib/libtaz.sh
9 # Get TazPkg configuration variables
10 . /etc/slitaz/slitaz.conf
11 . /etc/slitaz/tazpkg.conf
14 # Interactive mode
16 im() { tty -s; }
19 # Unset variables that may absent in the receipt
20 unset EXTRAVERSION TAGS DEPENDS PROVIDE SIZES
22 if [ -e "$1" ]; then
23 # Local package given
25 # Extract receipt from package
26 PKG="$(realpath "$1")"
27 TMP_DIR=$(mktemp -d); cd $TMP_DIR
28 cpio -F "$PKG" -i receipt >/dev/null 2>&1
30 . receipt; rm -r $TMP_DIR
31 STATE="$(_ 'local package')"
33 elif [ -d "$INSTALLED/$1" ]; then
34 # Installed package given
36 . "$INSTALLED/$1/receipt"
37 STATE="$(_ 'installed package')"
39 elif [ -n "$(awk -F$'\t' -vp="$1" '$1==p{print $1}' "$PKGS_DB/packages.info")" ]; then
40 # Mirrored package given
42 TMP_RECEIPT=$(mktemp)
43 awk -F$'\t' -vp="$1" '$1==p{
44 printf "PACKAGE=\"%s\"\n", $1
45 printf "VERSION=\"%s\"\n", $2
46 printf "CATEGORY=\"%s\"\n", $3
47 printf "SHORT_DESC=\"%s\"\n", $4
48 printf "WEB_SITE=\"%s\"\n", $5
49 printf "TAGS=\"%s\"\n", $6
50 printf "SIZES=\"%s\"\n", $7
51 printf "DEPENDS=\"%s\"\n", $8
52 }' "$PKGS_DB/packages.info" > $TMP_RECEIPT
54 . $TMP_RECEIPT; rm $TMP_RECEIPT
55 SIZES="$(echo $SIZES | tr ' ' '/')"
56 STATE="$(_ 'mirrored package')"
58 else
59 newline
60 _ 'Package "%s" not available.' "$1"
61 newline
62 exit 1
63 fi
66 im && title 'TazPkg information'
68 # Display localized short description
69 for LC in $LANG ${LANG%_*}; do
70 PDL="$PKGS_DB/packages-desc.$LC"
71 if [ -e "$PDL" ]; then
72 LOCDESC=$(awk -F$'\t' -vp="$PACKAGE" '$1==p{print $2}' $PDL)
73 [ -n "$LOCDESC" ] && SHORT_DESC="$LOCDESC"
74 fi
75 done
77 [ -z "$SIZES" ] && SIZES=$(echo $PACKED_SIZE/$UNPACKED_SIZE | sed 's|\.0||g' | sed 's|^/$||')
79 emsg "$(
80 {
81 _ 'Package : %s' "$PACKAGE"
82 _ 'State : %s' "$STATE"
83 _ 'Version : %s' "$VERSION$EXTRAVERSION"
84 _ 'Category : %s' "$(_ $CATEGORY)"
85 itemize "$(_ 'Short desc : %s' "$SHORT_DESC")"
86 _ 'Maintainer : %s' "$MAINTAINER"
87 _ 'License : %s' "$LICENSE"
88 itemize "$(_ 'Depends : %s' "$DEPENDS")"
89 itemize "$(_ 'Suggested : %s' "$SUGGESTED")"
90 itemize "$(_ 'Build deps : %s' "$BUILD_DEPENDS")"
91 itemize "$(_ 'Wanted src : %s' "$WANTED")"
92 _ 'Web site : %s' "$WEB_SITE"
93 itemize "$(_ 'Conf. files: %s' "$CONFIG_FILES")"
94 itemize "$(_ 'Provide : %s' "$PROVIDE")"
95 _ 'Size : %s' "$SIZES"
96 itemize "$(_ 'Tags : %s' "$TAGS")"
97 } | sed '/: $/d; s|^\([^:]*\):|<b>\1:</b>|')"
98 im && footer