tazpkg view tazpkg-box @ rev 846

Remove "busybox" "prefixes" (thanks llev)
We used "busybox wget", etc. to be sure we called Busybox's "wget", not any other "wget". Workaround already done in "getenv" module.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Oct 09 13:14:01 2015 +0300 (2015-10-09)
parents 3f3db6d5be82
children b069086a45a4
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 opts="--window-icon=tazpkg --image=tazpkg --image-on-top --center --on-top \
17 --height=350 --width=520 --title=TazPkg"
20 usage() {
21 cat <<EOT
22 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')]
24 Examples:
26 $(basename $0) actions /path/to/package-1.0.tazpkg
27 display box to extract or install given package
29 $(basename $0) tazpkg://example.com/path/to/package-1.0.tazpkg
30 download and install given package
31 EOT
32 }
35 # Nice GTK output for install and extract.
37 output() {
38 yad --text-info $opts --tail --margins='4' --text="$text" \
39 --button='gtk-close:0'
40 }
43 pkginfo() {
44 tazpkg info --output=gtk "$dir/$pkg" | sed 's| *:</b> |</b>\n|'
45 }
48 # Main GUI box function with pure Yad spec
50 actions_main() {
51 pkgname="${pkg%.tazpkg}"
52 pkginfo | yad $opts --list --no-headers --dclick-action="echo" --text="$text" \
53 --column='' --column='' \
54 --button="$(_ 'Install')!package-install:3" \
55 --button="$(_ 'Extract')!extract-archive:2" \
56 --button='gtk-cancel:1'
57 }
60 # Actions user can do when clicking on a package.
62 actions() {
63 # Store box results
64 main="$(actions_main)"
65 # Deal with --button values
66 case "$?" in
67 1) exit 0 ;;
68 2) tazpkg extract "$pkg" . --output='raw' | output ;;
69 3) tazpkg -i "$pkg" . --forced --output='raw' | output ;;
70 esac
71 }
74 # TazPkg URL Handler.
76 dl_inst() {
77 pkg="$(basename $url)"
78 _ 'Downloading: %s' "$pkg"; newline
79 TMP_DIR=$(mktemp); cd "$TMP_DIR"
80 wget "$url" 2>&1
81 tazpkg -i "$TMP_DIR/$pkg" --forced --output='raw' 2>&1
82 rm -f "$TMP_DIR"
83 }
87 #
88 # Script commands
89 #
91 case "$1" in
92 --help|-h|help|usage|-u)
93 usage ;;
94 tazpkg://*)
95 # TazPkg URL's handler.
96 url="http://${1#tazpkg://}"
97 dl_inst | output ;;
98 actions)
99 [ -z "$2" ] && exit 1
100 # fight against strange space at the end
101 pkg="$(basename "$(realpath "${2%% }")")"
102 dir="$(dirname "$(realpath "${2%% }")")"
103 cd "$dir"
104 actions ;;
105 esac
107 exit 0