tazpkg annotate tazpkg-box @ rev 923
Tiny edit
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Sun Sep 18 14:15:39 2016 +0100 (2016-09-18) |
parents | 688494ca8f5f |
children |
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@858 | 16 icon="system-software-install" |
al@858 | 17 opts="--window-icon=$icon --image=$icon --image-on-top --center --on-top \ |
al@886 | 18 --height=350 --width=550 --title=TazPkg" |
pankso@589 | 19 |
al@707 | 20 |
pankso@649 | 21 usage() { |
al@785 | 22 cat <<EOT |
al@707 | 23 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')] |
al@840 | 24 |
al@819 | 25 Examples: |
al@840 | 26 |
al@819 | 27 $(basename $0) actions /path/to/package-1.0.tazpkg |
al@819 | 28 display box to extract or install given package |
al@840 | 29 |
al@819 | 30 $(basename $0) tazpkg://example.com/path/to/package-1.0.tazpkg |
al@819 | 31 download and install given package |
pankso@649 | 32 EOT |
pankso@649 | 33 } |
pankso@649 | 34 |
al@707 | 35 |
pankso@589 | 36 # Nice GTK output for install and extract. |
al@707 | 37 |
pankso@589 | 38 output() { |
al@886 | 39 yad --text-info $opts --tail --margins='4' --text="$text" --fontname='monospace,10' \ |
al@812 | 40 --button='gtk-close:0' |
pankso@589 | 41 } |
pankso@555 | 42 |
al@707 | 43 |
pankso@649 | 44 pkginfo() { |
al@840 | 45 tazpkg info --output=gtk "$dir/$pkg" | sed 's| *:</b> |</b>\n|' |
pankso@649 | 46 } |
pankso@649 | 47 |
al@707 | 48 |
pankso@541 | 49 # Main GUI box function with pure Yad spec |
al@707 | 50 |
pankso@541 | 51 actions_main() { |
al@812 | 52 pkgname="${pkg%.tazpkg}" |
al@840 | 53 pkginfo | yad $opts --list --no-headers --dclick-action="echo" --text="$text" \ |
al@840 | 54 --column='' --column='' \ |
al@840 | 55 --button="$(_ 'Install')!package-install:3" \ |
al@840 | 56 --button="$(_ 'Extract')!extract-archive:2" \ |
al@812 | 57 --button='gtk-cancel:1' |
pankso@541 | 58 } |
pankso@541 | 59 |
al@707 | 60 |
pankso@541 | 61 # Actions user can do when clicking on a package. |
al@707 | 62 |
pankso@541 | 63 actions() { |
pankso@541 | 64 # Store box results |
al@812 | 65 main="$(actions_main)" |
pankso@541 | 66 # Deal with --button values |
al@812 | 67 case "$?" in |
pankso@541 | 68 1) exit 0 ;; |
al@886 | 69 2) tazpkg extract "$pkg" . --output='raw' --cols=65 | output ;; |
al@886 | 70 3) tazpkg -i "$pkg" . --forced --output='raw' --cols=65 | output ;; |
pankso@541 | 71 esac |
pankso@541 | 72 } |
pankso@541 | 73 |
al@707 | 74 |
al@633 | 75 # TazPkg URL Handler. |
al@707 | 76 |
pankso@589 | 77 dl_inst() { |
al@812 | 78 pkg="$(basename $url)" |
al@812 | 79 _ 'Downloading: %s' "$pkg"; newline |
al@840 | 80 TMP_DIR=$(mktemp); cd "$TMP_DIR" |
al@840 | 81 wget "$url" 2>&1 |
al@886 | 82 tazpkg -i "$TMP_DIR/$pkg" --forced --output='raw' --cols=65 2>&1 |
al@840 | 83 rm -f "$TMP_DIR" |
pankso@589 | 84 } |
pankso@589 | 85 |
al@707 | 86 |
al@707 | 87 |
pankso@541 | 88 # |
pankso@541 | 89 # Script commands |
pankso@541 | 90 # |
pankso@541 | 91 |
pankso@541 | 92 case "$1" in |
al@819 | 93 --help|-h|help|usage|-u) |
pankso@649 | 94 usage ;; |
pankso@589 | 95 tazpkg://*) |
al@633 | 96 # TazPkg URL's handler. |
pankso@589 | 97 url="http://${1#tazpkg://}" |
pankso@589 | 98 dl_inst | output ;; |
pankso@541 | 99 actions) |
al@819 | 100 [ -z "$2" ] && exit 1 |
al@840 | 101 # fight against strange space at the end |
al@840 | 102 pkg="$(basename "$(realpath "${2%% }")")" |
al@812 | 103 dir="$(dirname "$(realpath "${2%% }")")" |
al@812 | 104 cd "$dir" |
pankso@541 | 105 actions ;; |
pankso@541 | 106 esac |
pankso@541 | 107 |
pankso@541 | 108 exit 0 |