rev |
line source |
al@828
|
1 #!/bin/sh
|
al@828
|
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
|
al@828
|
3 # info - TazPkg module
|
al@828
|
4 # Information about package (both installed, mirrored, or local)
|
al@828
|
5
|
al@828
|
6
|
al@828
|
7 # Connect function libraries
|
al@828
|
8 . /lib/libtaz.sh
|
al@840
|
9
|
al@840
|
10 # Get TazPkg working environment
|
al@840
|
11 . @@MODULES@@/getenv
|
al@840
|
12
|
al@840
|
13
|
al@828
|
14
|
al@828
|
15
|
al@828
|
16 # Unset variables that may absent in the receipt
|
al@828
|
17 unset EXTRAVERSION TAGS DEPENDS PROVIDE SIZES
|
al@828
|
18
|
al@840
|
19 if [ -e "$1" -a "${1%.tazpkg}" != "$1" ]; then
|
al@828
|
20 # Local package given
|
al@828
|
21
|
al@828
|
22 # Extract receipt from package
|
al@840
|
23 PKG=$(realpath "$1")
|
al@840
|
24 TMP_DIR=$(mktemp -d); cd "$TMP_DIR"
|
al@828
|
25 cpio -F "$PKG" -i receipt >/dev/null 2>&1
|
al@828
|
26
|
al@840
|
27 . receipt; rm -r "$TMP_DIR"
|
al@840
|
28 STATE=$(_ 'local package')
|
al@828
|
29
|
al@828
|
30 elif [ -d "$INSTALLED/$1" ]; then
|
al@828
|
31 # Installed package given
|
al@828
|
32
|
al@828
|
33 . "$INSTALLED/$1/receipt"
|
al@840
|
34 STATE=$(_ 'installed package')
|
al@828
|
35
|
al@830
|
36 if [ -e "$PKGS_DB/packages.info" ]; then
|
al@830
|
37 # Check if upgrade available
|
al@840
|
38 NEWVER=$(awk -F$'\t' -vp="$1" '$1==p{print $2}' "$PKGS_DB/packages.info")
|
al@830
|
39 if [ "$VERSION" != "$NEWVER" ]; then
|
al@830
|
40 VERSION="$VERSION $(_n '(new version "%s" available)' "$NEWVER")"
|
al@830
|
41 else
|
al@840
|
42 OLDMD5=$(awk -F$'\t' -vp="$1" '$1==p{print $9}' "$PKGS_DB/installed.info")
|
al@840
|
43 NEWMD5=$(awk -F$'\t' -vp="$1" '$1==p{print $9}' "$PKGS_DB/packages.info")
|
al@830
|
44 if [ "$OLDMD5" != "$NEWMD5" ]; then
|
al@830
|
45 VERSION="$VERSION $(_n '(new build available)')"
|
al@830
|
46 fi
|
al@830
|
47 fi
|
al@830
|
48 fi
|
al@828
|
49
|
al@830
|
50 elif [ -e "$PKGS_DB/packages.info" ]; then
|
al@830
|
51 # Mirrored packages DB is available
|
al@830
|
52 if [ -n "$(awk -F$'\t' -vp="$1" '$1==p{print $1}' "$PKGS_DB/packages.info")" ]; then
|
al@830
|
53 # Mirrored package given
|
al@828
|
54
|
al@830
|
55 TMP_RECEIPT=$(mktemp)
|
al@830
|
56 awk -F$'\t' -vp="$1" '$1==p{
|
al@840
|
57 printf "PACKAGE=\"%s\"\n", $1
|
al@840
|
58 printf "VERSION=\"%s\"\n", $2
|
al@840
|
59 printf "CATEGORY=\"%s\"\n", $3
|
al@830
|
60 printf "SHORT_DESC=\"%s\"\n", $4
|
al@840
|
61 printf "WEB_SITE=\"%s\"\n", $5
|
al@840
|
62 printf "TAGS=\"%s\"\n", $6
|
al@840
|
63 printf "SIZES=\"%s\"\n", $7
|
al@840
|
64 printf "DEPENDS=\"%s\"\n", $8
|
al@840
|
65 }' "$PKGS_DB/packages.info" > "$TMP_RECEIPT"
|
al@828
|
66
|
al@840
|
67 . "$TMP_RECEIPT"; rm "$TMP_RECEIPT"
|
al@840
|
68 SIZES=$(echo $SIZES | tr ' ' '/')
|
al@840
|
69 STATE=$(_ 'mirrored package')
|
al@830
|
70 else
|
al@830
|
71 newline
|
al@830
|
72 _ 'Package "%s" not available.' "$1"
|
al@830
|
73 newline
|
al@830
|
74 exit 1
|
al@830
|
75 fi
|
al@828
|
76 else
|
al@830
|
77 # Mirrored packages DB isn't available
|
al@828
|
78 newline
|
al@830
|
79 longline "$(_ "No \"%s\" found to check for mirrored packages. For more \
|
al@830
|
80 results, please run \"%s\" once as root before searching." 'packages.info' \
|
al@830
|
81 'tazpkg recharge')"
|
al@828
|
82 newline
|
al@828
|
83 exit 1
|
al@828
|
84 fi
|
al@828
|
85
|
al@828
|
86
|
al@840
|
87 im && title 'TazPkg information' >&2
|
al@828
|
88
|
al@828
|
89 # Display localized short description
|
al@828
|
90 for LC in $LANG ${LANG%_*}; do
|
al@828
|
91 PDL="$PKGS_DB/packages-desc.$LC"
|
al@828
|
92 if [ -e "$PDL" ]; then
|
al@828
|
93 LOCDESC=$(awk -F$'\t' -vp="$PACKAGE" '$1==p{print $2}' $PDL)
|
al@828
|
94 [ -n "$LOCDESC" ] && SHORT_DESC="$LOCDESC"
|
al@828
|
95 fi
|
al@828
|
96 done
|
al@828
|
97
|
al@828
|
98 [ -z "$SIZES" ] && SIZES=$(echo $PACKED_SIZE/$UNPACKED_SIZE | sed 's|\.0||g' | sed 's|^/$||')
|
al@828
|
99
|
al@940
|
100 # Allow maintainer in form: John Doe <john@example.com>
|
al@940
|
101 case $output in
|
al@940
|
102 html|gtk) MAINTAINER=$(echo "$MAINTAINER" | sed 's|&|\&|g; s|<|\<|g; s|>|\>|g');;
|
al@940
|
103 esac
|
al@940
|
104
|
al@828
|
105 emsg "$(
|
al@828
|
106 {
|
al@840
|
107 _ 'Package : %s' "$PACKAGE"
|
al@840
|
108 _ 'State : %s' "$STATE"
|
al@840
|
109 _ 'Version : %s' "$VERSION$EXTRAVERSION"
|
al@840
|
110 _ 'Category : %s' "$(_ $CATEGORY)"
|
al@828
|
111 itemize "$(_ 'Short desc : %s' "$SHORT_DESC")"
|
al@828
|
112 _ 'Maintainer : %s' "$MAINTAINER"
|
al@828
|
113 _ 'License : %s' "$LICENSE"
|
al@828
|
114 itemize "$(_ 'Depends : %s' "$DEPENDS")"
|
al@828
|
115 itemize "$(_ 'Suggested : %s' "$SUGGESTED")"
|
al@828
|
116 itemize "$(_ 'Build deps : %s' "$BUILD_DEPENDS")"
|
al@828
|
117 itemize "$(_ 'Wanted src : %s' "$WANTED")"
|
al@828
|
118 _ 'Web site : %s' "$WEB_SITE"
|
al@828
|
119 itemize "$(_ 'Conf. files: %s' "$CONFIG_FILES")"
|
al@828
|
120 itemize "$(_ 'Provide : %s' "$PROVIDE")"
|
al@828
|
121 _ 'Size : %s' "$SIZES"
|
al@828
|
122 itemize "$(_ 'Tags : %s' "$TAGS")"
|
al@828
|
123 } | sed '/: $/d; s|^\([^:]*\):|<b>\1:</b>|')"
|
al@840
|
124 im && footer >&2
|
al@828
|
125
|