tazpkg view modules/info @ rev 931

Add module/bb: manage Busybox applets.
Remove function definitions that are now in the /lib/libtaz.sh (die, im).
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Jan 08 11:24:12 2017 +0200 (2017-01-08)
parents a02e36d44d06
children 9e271be1090b
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
10 # Get TazPkg working environment
11 . @@MODULES@@/getenv
16 # Unset variables that may absent in the receipt
17 unset EXTRAVERSION TAGS DEPENDS PROVIDE SIZES
19 if [ -e "$1" -a "${1%.tazpkg}" != "$1" ]; then
20 # Local package given
22 # Extract receipt from package
23 PKG=$(realpath "$1")
24 TMP_DIR=$(mktemp -d); cd "$TMP_DIR"
25 cpio -F "$PKG" -i receipt >/dev/null 2>&1
27 . receipt; rm -r "$TMP_DIR"
28 STATE=$(_ 'local package')
30 elif [ -d "$INSTALLED/$1" ]; then
31 # Installed package given
33 . "$INSTALLED/$1/receipt"
34 STATE=$(_ 'installed package')
36 if [ -e "$PKGS_DB/packages.info" ]; then
37 # Check if upgrade available
38 NEWVER=$(awk -F$'\t' -vp="$1" '$1==p{print $2}' "$PKGS_DB/packages.info")
39 if [ "$VERSION" != "$NEWVER" ]; then
40 VERSION="$VERSION $(_n '(new version "%s" available)' "$NEWVER")"
41 else
42 OLDMD5=$(awk -F$'\t' -vp="$1" '$1==p{print $9}' "$PKGS_DB/installed.info")
43 NEWMD5=$(awk -F$'\t' -vp="$1" '$1==p{print $9}' "$PKGS_DB/packages.info")
44 if [ "$OLDMD5" != "$NEWMD5" ]; then
45 VERSION="$VERSION $(_n '(new build available)')"
46 fi
47 fi
48 fi
50 elif [ -e "$PKGS_DB/packages.info" ]; then
51 # Mirrored packages DB is available
52 if [ -n "$(awk -F$'\t' -vp="$1" '$1==p{print $1}' "$PKGS_DB/packages.info")" ]; then
53 # Mirrored package given
55 TMP_RECEIPT=$(mktemp)
56 awk -F$'\t' -vp="$1" '$1==p{
57 printf "PACKAGE=\"%s\"\n", $1
58 printf "VERSION=\"%s\"\n", $2
59 printf "CATEGORY=\"%s\"\n", $3
60 printf "SHORT_DESC=\"%s\"\n", $4
61 printf "WEB_SITE=\"%s\"\n", $5
62 printf "TAGS=\"%s\"\n", $6
63 printf "SIZES=\"%s\"\n", $7
64 printf "DEPENDS=\"%s\"\n", $8
65 }' "$PKGS_DB/packages.info" > "$TMP_RECEIPT"
67 . "$TMP_RECEIPT"; rm "$TMP_RECEIPT"
68 SIZES=$(echo $SIZES | tr ' ' '/')
69 STATE=$(_ 'mirrored package')
70 else
71 newline
72 _ 'Package "%s" not available.' "$1"
73 newline
74 exit 1
75 fi
76 else
77 # Mirrored packages DB isn't available
78 newline
79 longline "$(_ "No \"%s\" found to check for mirrored packages. For more \
80 results, please run \"%s\" once as root before searching." 'packages.info' \
81 'tazpkg recharge')"
82 newline
83 exit 1
84 fi
87 im && title 'TazPkg information' >&2
89 # Display localized short description
90 for LC in $LANG ${LANG%_*}; do
91 PDL="$PKGS_DB/packages-desc.$LC"
92 if [ -e "$PDL" ]; then
93 LOCDESC=$(awk -F$'\t' -vp="$PACKAGE" '$1==p{print $2}' $PDL)
94 [ -n "$LOCDESC" ] && SHORT_DESC="$LOCDESC"
95 fi
96 done
98 [ -z "$SIZES" ] && SIZES=$(echo $PACKED_SIZE/$UNPACKED_SIZE | sed 's|\.0||g' | sed 's|^/$||')
100 emsg "$(
101 {
102 _ 'Package : %s' "$PACKAGE"
103 _ 'State : %s' "$STATE"
104 _ 'Version : %s' "$VERSION$EXTRAVERSION"
105 _ 'Category : %s' "$(_ $CATEGORY)"
106 itemize "$(_ 'Short desc : %s' "$SHORT_DESC")"
107 _ 'Maintainer : %s' "$MAINTAINER"
108 _ 'License : %s' "$LICENSE"
109 itemize "$(_ 'Depends : %s' "$DEPENDS")"
110 itemize "$(_ 'Suggested : %s' "$SUGGESTED")"
111 itemize "$(_ 'Build deps : %s' "$BUILD_DEPENDS")"
112 itemize "$(_ 'Wanted src : %s' "$WANTED")"
113 _ 'Web site : %s' "$WEB_SITE"
114 itemize "$(_ 'Conf. files: %s' "$CONFIG_FILES")"
115 itemize "$(_ 'Provide : %s' "$PROVIDE")"
116 _ 'Size : %s' "$SIZES"
117 itemize "$(_ 'Tags : %s' "$TAGS")"
118 } | sed '/: $/d; s|^\([^:]*\):|<b>\1:</b>|')"
119 im && footer >&2