tazpkg annotate 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
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
paul@943 16 # Unset variables that may be 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@950 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"