tazpkg annotate tazpkg-box @ rev 840
Add a bunch of modules with new-style support of 'root' (not all commands are modules yet); strip and compress resources.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Aug 28 16:10:34 2015 +0300 (2015-08-28) |
parents | 3f3db6d5be82 |
children | b069086a45a4 |
rev | line source |
---|---|
pankso@541 | 1 #!/bin/sh |
al@840 | 2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg |
al@840 | 3 # tazpkg-box - part of TazPkg |
al@840 | 4 # Small GTK boxes to TazPkg for deep desktop integration |
al@840 | 5 |
al@840 | 6 # Copyright (C) 2011-2015 SliTaz - GNU General Public License v3. |
al@840 | 7 # Authors: See the AUTHORS files |
al@840 | 8 |
pankso@541 | 9 |
al@603 | 10 # Internationalization. |
al@707 | 11 |
al@707 | 12 . /lib/libtaz.sh |
al@812 | 13 export TEXTDOMAIN='tazpkg' |
al@603 | 14 |
al@812 | 15 text="<b>$(_ 'SliTaz Package Action')</b>" |
al@812 | 16 opts="--window-icon=tazpkg --image=tazpkg --image-on-top --center --on-top \ |
al@840 | 17 --height=350 --width=520 --title=TazPkg" |
pankso@589 | 18 |
al@707 | 19 |
pankso@649 | 20 usage() { |
al@785 | 21 cat <<EOT |
al@707 | 22 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')] |
al@840 | 23 |
al@819 | 24 Examples: |
al@840 | 25 |
al@819 | 26 $(basename $0) actions /path/to/package-1.0.tazpkg |
al@819 | 27 display box to extract or install given package |
al@840 | 28 |
al@819 | 29 $(basename $0) tazpkg://example.com/path/to/package-1.0.tazpkg |
al@819 | 30 download and install given package |
pankso@649 | 31 EOT |
pankso@649 | 32 } |
pankso@649 | 33 |
al@707 | 34 |
pankso@589 | 35 # Nice GTK output for install and extract. |
al@707 | 36 |
pankso@589 | 37 output() { |
al@812 | 38 yad --text-info $opts --tail --margins='4' --text="$text" \ |
al@812 | 39 --button='gtk-close:0' |
pankso@589 | 40 } |
pankso@555 | 41 |
al@707 | 42 |
pankso@649 | 43 pkginfo() { |
al@840 | 44 tazpkg info --output=gtk "$dir/$pkg" | sed 's| *:</b> |</b>\n|' |
pankso@649 | 45 } |
pankso@649 | 46 |
al@707 | 47 |
pankso@541 | 48 # Main GUI box function with pure Yad spec |
al@707 | 49 |
pankso@541 | 50 actions_main() { |
al@812 | 51 pkgname="${pkg%.tazpkg}" |
al@840 | 52 pkginfo | yad $opts --list --no-headers --dclick-action="echo" --text="$text" \ |
al@840 | 53 --column='' --column='' \ |
al@840 | 54 --button="$(_ 'Install')!package-install:3" \ |
al@840 | 55 --button="$(_ 'Extract')!extract-archive:2" \ |
al@812 | 56 --button='gtk-cancel:1' |
pankso@541 | 57 } |
pankso@541 | 58 |
al@707 | 59 |
pankso@541 | 60 # Actions user can do when clicking on a package. |
al@707 | 61 |
pankso@541 | 62 actions() { |
pankso@541 | 63 # Store box results |
al@812 | 64 main="$(actions_main)" |
pankso@541 | 65 # Deal with --button values |
al@812 | 66 case "$?" in |
pankso@541 | 67 1) exit 0 ;; |
al@812 | 68 2) tazpkg extract "$pkg" . --output='raw' | output ;; |
al@812 | 69 3) tazpkg -i "$pkg" . --forced --output='raw' | output ;; |
pankso@541 | 70 esac |
pankso@541 | 71 } |
pankso@541 | 72 |
al@707 | 73 |
al@633 | 74 # TazPkg URL Handler. |
al@707 | 75 |
pankso@589 | 76 dl_inst() { |
al@812 | 77 pkg="$(basename $url)" |
al@812 | 78 _ 'Downloading: %s' "$pkg"; newline |
al@840 | 79 TMP_DIR=$(mktemp); cd "$TMP_DIR" |
al@840 | 80 wget "$url" 2>&1 |
al@840 | 81 tazpkg -i "$TMP_DIR/$pkg" --forced --output='raw' 2>&1 |
al@840 | 82 rm -f "$TMP_DIR" |
pankso@589 | 83 } |
pankso@589 | 84 |
al@707 | 85 |
al@707 | 86 |
pankso@541 | 87 # |
pankso@541 | 88 # Script commands |
pankso@541 | 89 # |
pankso@541 | 90 |
pankso@541 | 91 case "$1" in |
al@819 | 92 --help|-h|help|usage|-u) |
pankso@649 | 93 usage ;; |
pankso@589 | 94 tazpkg://*) |
al@633 | 95 # TazPkg URL's handler. |
pankso@589 | 96 url="http://${1#tazpkg://}" |
pankso@589 | 97 dl_inst | output ;; |
pankso@541 | 98 actions) |
al@819 | 99 [ -z "$2" ] && exit 1 |
al@840 | 100 # fight against strange space at the end |
al@840 | 101 pkg="$(basename "$(realpath "${2%% }")")" |
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 |