tazpkg view tazpkg-box @ rev 971

modules/get: fix plain mode and cookmode again
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Nov 26 20:27:56 2018 +0200 (2018-11-26)
parents 688494ca8f5f
children
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # tazpkg-box - part of TazPkg
4 # Small GTK boxes to TazPkg for deep desktop integration
6 # Copyright (C) 2011-2015 SliTaz - GNU General Public License v3.
7 # Authors: See the AUTHORS files
10 # Internationalization.
12 . /lib/libtaz.sh
13 export TEXTDOMAIN='tazpkg'
15 text="<b>$(_ 'SliTaz Package Action')</b>"
16 icon="system-software-install"
17 opts="--window-icon=$icon --image=$icon --image-on-top --center --on-top \
18 --height=350 --width=550 --title=TazPkg"
21 usage() {
22 cat <<EOT
23 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')]
25 Examples:
27 $(basename $0) actions /path/to/package-1.0.tazpkg
28 display box to extract or install given package
30 $(basename $0) tazpkg://example.com/path/to/package-1.0.tazpkg
31 download and install given package
32 EOT
33 }
36 # Nice GTK output for install and extract.
38 output() {
39 yad --text-info $opts --tail --margins='4' --text="$text" --fontname='monospace,10' \
40 --button='gtk-close:0'
41 }
44 pkginfo() {
45 tazpkg info --output=gtk "$dir/$pkg" | sed 's| *:</b> |</b>\n|'
46 }
49 # Main GUI box function with pure Yad spec
51 actions_main() {
52 pkgname="${pkg%.tazpkg}"
53 pkginfo | yad $opts --list --no-headers --dclick-action="echo" --text="$text" \
54 --column='' --column='' \
55 --button="$(_ 'Install')!package-install:3" \
56 --button="$(_ 'Extract')!extract-archive:2" \
57 --button='gtk-cancel:1'
58 }
61 # Actions user can do when clicking on a package.
63 actions() {
64 # Store box results
65 main="$(actions_main)"
66 # Deal with --button values
67 case "$?" in
68 1) exit 0 ;;
69 2) tazpkg extract "$pkg" . --output='raw' --cols=65 | output ;;
70 3) tazpkg -i "$pkg" . --forced --output='raw' --cols=65 | output ;;
71 esac
72 }
75 # TazPkg URL Handler.
77 dl_inst() {
78 pkg="$(basename $url)"
79 _ 'Downloading: %s' "$pkg"; newline
80 TMP_DIR=$(mktemp); cd "$TMP_DIR"
81 wget "$url" 2>&1
82 tazpkg -i "$TMP_DIR/$pkg" --forced --output='raw' --cols=65 2>&1
83 rm -f "$TMP_DIR"
84 }
88 #
89 # Script commands
90 #
92 case "$1" in
93 --help|-h|help|usage|-u)
94 usage ;;
95 tazpkg://*)
96 # TazPkg URL's handler.
97 url="http://${1#tazpkg://}"
98 dl_inst | output ;;
99 actions)
100 [ -z "$2" ] && exit 1
101 # fight against strange space at the end
102 pkg="$(basename "$(realpath "${2%% }")")"
103 dir="$(dirname "$(realpath "${2%% }")")"
104 cd "$dir"
105 actions ;;
106 esac
108 exit 0