tazpkg annotate tazpkg-box @ rev 819
tazpkg: re-write "desc" function to use all available sorts of descriptions (installed, mirrored, short, long, localized)
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Jul 24 15:11:32 2015 +0300 (2015-07-24) |
parents | a41fb2cbc248 |
children | a02e36d44d06 |
rev | line source |
---|---|
pankso@541 | 1 #!/bin/sh |
pankso@541 | 2 # |
al@707 | 3 # Small GTK boxes to TazPkg for deep desktop integration. PCManFM 0.5.x has a |
al@633 | 4 # patch to extract a TazPkg file but not Thunar and other FM. TazPkgBox tries |
al@812 | 5 # to follow Freedesktop standards. |
pankso@541 | 6 # |
al@785 | 7 # Copyright (C) 2011-2015 SliTaz GNU/Linux - GNU GPL v2 |
pankso@541 | 8 # |
al@633 | 9 # Authors: Christophe Lincoln <pankso@slitaz.org> |
pankso@541 | 10 # |
pankso@541 | 11 |
al@603 | 12 # Internationalization. |
al@707 | 13 |
al@707 | 14 . /lib/libtaz.sh |
al@812 | 15 export TEXTDOMAIN='tazpkg' |
al@603 | 16 |
al@812 | 17 text="<b>$(_ 'SliTaz Package Action')</b>" |
al@812 | 18 opts="--window-icon=tazpkg --image=tazpkg --image-on-top --center --on-top \ |
al@812 | 19 --height=260 --width=520 --title=TazPkg" |
pankso@589 | 20 |
al@707 | 21 |
pankso@649 | 22 usage() { |
al@785 | 23 cat <<EOT |
al@707 | 24 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')] |
al@819 | 25 |
al@819 | 26 Examples: |
al@819 | 27 |
al@819 | 28 $(basename $0) actions /path/to/package-1.0.tazpkg |
al@819 | 29 display box to extract or install given package |
al@819 | 30 |
al@819 | 31 $(basename $0) tazpkg://example.com/path/to/package-1.0.tazpkg |
al@819 | 32 download and install given package |
pankso@649 | 33 EOT |
pankso@649 | 34 } |
pankso@649 | 35 |
al@707 | 36 |
pankso@589 | 37 # Nice GTK output for install and extract. |
al@707 | 38 |
pankso@589 | 39 output() { |
al@812 | 40 yad --text-info $opts --tail --margins='4' --text="$text" \ |
al@812 | 41 --button='gtk-close:0' |
pankso@589 | 42 } |
pankso@555 | 43 |
al@707 | 44 |
pankso@649 | 45 pkginfo() { |
al@812 | 46 tmp="$(mktemp -d)"; cd "$tmp" |
al@812 | 47 { cpio --quiet -i receipt >/dev/null 2>&1; } < "$dir/$pkg" |
al@812 | 48 . "$tmp/receipt" |
al@812 | 49 rm -rf "$tmp" |
al@812 | 50 size=$(du -sh "$dir/$pkg" | awk '{print $1}') |
al@707 | 51 echo -e "$(_ 'Package')\n$PACKAGE |
al@707 | 52 $(_ 'Version')\n$VERSION |
al@707 | 53 $(_ 'Short desc')\n$SHORT_DESC |
al@707 | 54 $(_ 'Unpacked size')\n$UNPACKED_SIZE |
al@707 | 55 $(_ 'Depends')\n$DEPENDS" |
pankso@649 | 56 } |
pankso@649 | 57 |
al@707 | 58 |
pankso@541 | 59 # Main GUI box function with pure Yad spec |
al@707 | 60 |
pankso@541 | 61 actions_main() { |
al@812 | 62 pkgname="${pkg%.tazpkg}" |
al@812 | 63 pkginfo | yad $opts --list --no-headers --no-click --text="$text" \ |
al@812 | 64 --column '' --column '' \ |
al@707 | 65 --button="$(_ 'Install'):3" \ |
al@707 | 66 --button="$(_ 'Extract'):2" \ |
al@812 | 67 --button='gtk-cancel:1' |
pankso@541 | 68 } |
pankso@541 | 69 |
al@707 | 70 |
pankso@541 | 71 # Actions user can do when clicking on a package. |
al@707 | 72 |
pankso@541 | 73 actions() { |
pankso@541 | 74 # Store box results |
al@812 | 75 main="$(actions_main)" |
pankso@541 | 76 # Deal with --button values |
al@812 | 77 case "$?" in |
pankso@541 | 78 1) exit 0 ;; |
al@812 | 79 2) tazpkg extract "$pkg" . --output='raw' | output ;; |
al@812 | 80 3) tazpkg -i "$pkg" . --forced --output='raw' | output ;; |
pankso@541 | 81 esac |
pankso@541 | 82 } |
pankso@541 | 83 |
al@707 | 84 |
al@633 | 85 # TazPkg URL Handler. |
al@707 | 86 |
pankso@589 | 87 dl_inst() { |
al@812 | 88 pkg="$(basename $url)" |
al@812 | 89 _ 'Downloading: %s' "$pkg"; newline |
al@812 | 90 cd /tmp; wget "$url" 2>&1 |
al@812 | 91 tazpkg -i "$pkg" --forced --output='raw' 2>&1 |
al@812 | 92 rm -f "$pkg" |
pankso@589 | 93 } |
pankso@589 | 94 |
al@707 | 95 |
al@707 | 96 |
pankso@541 | 97 # |
pankso@541 | 98 # Script commands |
pankso@541 | 99 # |
pankso@541 | 100 |
pankso@541 | 101 case "$1" in |
al@819 | 102 --help|-h|help|usage|-u) |
pankso@649 | 103 usage ;; |
pankso@589 | 104 tazpkg://*) |
al@633 | 105 # TazPkg URL's handler. |
pankso@589 | 106 url="http://${1#tazpkg://}" |
pankso@589 | 107 dl_inst | output ;; |
pankso@541 | 108 actions) |
al@819 | 109 [ -z "$2" ] && exit 1 |
al@812 | 110 pkg="$(basename "$(realpath "${2%% }")")" # fight against strange space at the end |
al@812 | 111 dir="$(dirname "$(realpath "${2%% }")")" |
al@812 | 112 cd "$dir" |
pankso@541 | 113 actions ;; |
pankso@541 | 114 esac |
pankso@541 | 115 |
pankso@541 | 116 exit 0 |