tazpkg view modules/info @ rev 955

modules/search: allow search file with dash at start: tazpkg -sf "-spi"
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Dec 22 00:02:54 2017 +0200 (2017-12-22)
parents 50421cb50644
children
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 be 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 # Allow maintainer in form: John Doe <john@example.com>
101 case $output in
102 html|gtk) MAINTAINER=$(echo "$MAINTAINER" | sed 's|&|\&amp;|g; s|<|\&lt;|g; s|>|\&gt;|g');;
103 esac
105 emsg "$(
106 {
107 _ 'Package : %s' "$PACKAGE"
108 _ 'State : %s' "$STATE"
109 _ 'Version : %s' "$VERSION$EXTRAVERSION"
110 _ 'Category : %s' "$(_ $CATEGORY)"
111 itemize "$(_ 'Short desc : %s' "$SHORT_DESC")"
112 _ 'Maintainer : %s' "$MAINTAINER"
113 _ 'License : %s' "$LICENSE"
114 itemize "$(_ 'Depends : %s' "$DEPENDS")"
115 itemize "$(_ 'Suggested : %s' "$SUGGESTED")"
116 itemize "$(_ 'Build deps : %s' "$BUILD_DEPENDS")"
117 itemize "$(_ 'Wanted src : %s' "$WANTED")"
118 _ 'Web site : %s' "$WEB_SITE"
119 itemize "$(_ 'Conf. files: %s' "$CONFIG_FILES")"
120 itemize "$(_ 'Provide : %s' "$PROVIDE")"
121 _ 'Size : %s' "$SIZES"
122 itemize "$(_ 'Tags : %s' "$TAGS")"
123 } | sed '/: $/d; s|^\([^:]*\):|<b>\1:</b>|')"
124 im && footer >&2