tazpkg annotate tazpkg-box @ rev 812
tazpkg-box, tazpkg: allow to get and install packages using folder with spaces in the path.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Jun 04 17:15:40 2015 +0300 (2015-06-04) |
parents | 0fc40a0f873f |
children | 3f3db6d5be82 |
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')] |
pankso@649 | 25 EOT |
pankso@649 | 26 } |
pankso@649 | 27 |
al@707 | 28 |
pankso@589 | 29 # Nice GTK output for install and extract. |
al@707 | 30 |
pankso@589 | 31 output() { |
al@812 | 32 yad --text-info $opts --tail --margins='4' --text="$text" \ |
al@812 | 33 --button='gtk-close:0' |
pankso@589 | 34 } |
pankso@555 | 35 |
al@707 | 36 |
pankso@649 | 37 pkginfo() { |
al@812 | 38 tmp="$(mktemp -d)"; cd "$tmp" |
al@812 | 39 { cpio --quiet -i receipt >/dev/null 2>&1; } < "$dir/$pkg" |
al@812 | 40 . "$tmp/receipt" |
al@812 | 41 rm -rf "$tmp" |
al@812 | 42 size=$(du -sh "$dir/$pkg" | awk '{print $1}') |
al@707 | 43 echo -e "$(_ 'Package')\n$PACKAGE |
al@707 | 44 $(_ 'Version')\n$VERSION |
al@707 | 45 $(_ 'Short desc')\n$SHORT_DESC |
al@707 | 46 $(_ 'Unpacked size')\n$UNPACKED_SIZE |
al@707 | 47 $(_ 'Depends')\n$DEPENDS" |
pankso@649 | 48 } |
pankso@649 | 49 |
al@707 | 50 |
pankso@541 | 51 # Main GUI box function with pure Yad spec |
al@707 | 52 |
pankso@541 | 53 actions_main() { |
al@812 | 54 pkgname="${pkg%.tazpkg}" |
al@812 | 55 pkginfo | yad $opts --list --no-headers --no-click --text="$text" \ |
al@812 | 56 --column '' --column '' \ |
al@707 | 57 --button="$(_ 'Install'):3" \ |
al@707 | 58 --button="$(_ 'Extract'):2" \ |
al@812 | 59 --button='gtk-cancel:1' |
pankso@541 | 60 } |
pankso@541 | 61 |
al@707 | 62 |
pankso@541 | 63 # Actions user can do when clicking on a package. |
al@707 | 64 |
pankso@541 | 65 actions() { |
pankso@541 | 66 # Store box results |
al@812 | 67 main="$(actions_main)" |
pankso@541 | 68 # Deal with --button values |
al@812 | 69 case "$?" in |
pankso@541 | 70 1) exit 0 ;; |
al@812 | 71 2) tazpkg extract "$pkg" . --output='raw' | output ;; |
al@812 | 72 3) tazpkg -i "$pkg" . --forced --output='raw' | output ;; |
pankso@541 | 73 esac |
pankso@541 | 74 } |
pankso@541 | 75 |
al@707 | 76 |
al@633 | 77 # TazPkg URL Handler. |
al@707 | 78 |
pankso@589 | 79 dl_inst() { |
al@812 | 80 pkg="$(basename $url)" |
al@812 | 81 _ 'Downloading: %s' "$pkg"; newline |
al@812 | 82 cd /tmp; wget "$url" 2>&1 |
al@812 | 83 tazpkg -i "$pkg" --forced --output='raw' 2>&1 |
al@812 | 84 rm -f "$pkg" |
pankso@589 | 85 } |
pankso@589 | 86 |
al@707 | 87 |
al@707 | 88 |
pankso@541 | 89 # |
pankso@541 | 90 # Script commands |
pankso@541 | 91 # |
pankso@541 | 92 |
pankso@541 | 93 case "$1" in |
pankso@555 | 94 usage|help|-u|-h) |
pankso@649 | 95 usage ;; |
pankso@589 | 96 tazpkg://*) |
al@633 | 97 # TazPkg URL's handler. |
pankso@589 | 98 url="http://${1#tazpkg://}" |
pankso@589 | 99 dl_inst | output ;; |
pankso@541 | 100 actions) |
al@812 | 101 pkg="$(basename "$(realpath "${2%% }")")" # fight against strange space at the end |
al@812 | 102 dir="$(dirname "$(realpath "${2%% }")")" |
al@812 | 103 cd "$dir" |
pankso@541 | 104 actions ;; |
pankso@541 | 105 esac |
pankso@541 | 106 |
pankso@541 | 107 exit 0 |