Repository navigation
Expand file tree
/
Copy pathtazpkg-box
More file actions
executable file
·108 lines (79 loc) · 2.28 KB
/
Copy pathtazpkg-box
File metadata and controls
executable file
·108 lines (79 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
# TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
# tazpkg-box - part of TazPkg
# Small GTK boxes to TazPkg for deep desktop integration
# Copyright (C) 2011-2015 SliTaz - GNU General Public License v3.
# Authors: See the AUTHORS files
# Internationalization.
. /lib/libtaz.sh
export TEXTDOMAIN='tazpkg'
text="<b>$(_ 'SliTaz Package Action')</b>"
icon="system-software-install"
opts="--window-icon=$icon --image=$icon --image-on-top --center --on-top \
--height=350 --width=550 --title=TazPkg"
usage() {
cat <<EOT
$(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')]
Examples:
$(basename $0) actions /path/to/package-1.0.tazpkg
display box to extract or install given package
$(basename $0) tazpkg://example.com/path/to/package-1.0.tazpkg
download and install given package
EOT
}
# Nice GTK output for install and extract.
output() {
yad --text-info $opts --tail --margins='4' --text="$text" --fontname='monospace,10' \
--button='gtk-close:0'
}
pkginfo() {
tazpkg info --output=gtk "$dir/$pkg" | sed 's| *:</b> |</b>\n|'
}
# Main GUI box function with pure Yad spec
actions_main() {
pkgname="${pkg%.tazpkg}"
pkginfo | yad $opts --list --no-headers --dclick-action="echo" --text="$text" \
--column='' --column='' \
--button="$(_ 'Install')!package-install:3" \
--button="$(_ 'Extract')!extract-archive:2" \
--button='gtk-cancel:1'
}
# Actions user can do when clicking on a package.
actions() {
# Store box results
main="$(actions_main)"
# Deal with --button values
case "$?" in
1) exit 0 ;;
2) tazpkg extract "$pkg" . --output='raw' --cols=65 | output ;;
3) tazpkg -i "$pkg" . --forced --output='raw' --cols=65 | output ;;
esac
}
# TazPkg URL Handler.
dl_inst() {
pkg="$(basename $url)"
_ 'Downloading: %s' "$pkg"; newline
TMP_DIR=$(mktemp); cd "$TMP_DIR"
wget "$url" 2>&1
tazpkg -i "$TMP_DIR/$pkg" --forced --output='raw' --cols=65 2>&1
rm -f "$TMP_DIR"
}
#
# Script commands
#
case "$1" in
--help|-h|help|usage|-u)
usage ;;
tazpkg://*)
# TazPkg URL's handler.
url="http://${1#tazpkg://}"
dl_inst | output ;;
actions)
[ -z "$2" ] && exit 1
# fight against strange space at the end
pkg="$(basename "$(realpath "${2%% }")")"
dir="$(dirname "$(realpath "${2%% }")")"
cd "$dir"
actions ;;
esac
exit 0