tazpkg view tazpkg-box @ rev 813

tazpkg, tazpkg-convert: few more quoting to allow spaces in the path
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Jun 05 00:37:48 2015 +0300 (2015-06-05)
parents 0fc40a0f873f
children 3f3db6d5be82
line source
1 #!/bin/sh
2 #
3 # Small GTK boxes to TazPkg for deep desktop integration. PCManFM 0.5.x has a
4 # patch to extract a TazPkg file but not Thunar and other FM. TazPkgBox tries
5 # to follow Freedesktop standards.
6 #
7 # Copyright (C) 2011-2015 SliTaz GNU/Linux - GNU GPL v2
8 #
9 # Authors: Christophe Lincoln <pankso@slitaz.org>
10 #
12 # Internationalization.
14 . /lib/libtaz.sh
15 export TEXTDOMAIN='tazpkg'
17 text="<b>$(_ 'SliTaz Package Action')</b>"
18 opts="--window-icon=tazpkg --image=tazpkg --image-on-top --center --on-top \
19 --height=260 --width=520 --title=TazPkg"
22 usage() {
23 cat <<EOT
24 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')]
25 EOT
26 }
29 # Nice GTK output for install and extract.
31 output() {
32 yad --text-info $opts --tail --margins='4' --text="$text" \
33 --button='gtk-close:0'
34 }
37 pkginfo() {
38 tmp="$(mktemp -d)"; cd "$tmp"
39 { cpio --quiet -i receipt >/dev/null 2>&1; } < "$dir/$pkg"
40 . "$tmp/receipt"
41 rm -rf "$tmp"
42 size=$(du -sh "$dir/$pkg" | awk '{print $1}')
43 echo -e "$(_ 'Package')\n$PACKAGE
44 $(_ 'Version')\n$VERSION
45 $(_ 'Short desc')\n$SHORT_DESC
46 $(_ 'Unpacked size')\n$UNPACKED_SIZE
47 $(_ 'Depends')\n$DEPENDS"
48 }
51 # Main GUI box function with pure Yad spec
53 actions_main() {
54 pkgname="${pkg%.tazpkg}"
55 pkginfo | yad $opts --list --no-headers --no-click --text="$text" \
56 --column '' --column '' \
57 --button="$(_ 'Install'):3" \
58 --button="$(_ 'Extract'):2" \
59 --button='gtk-cancel:1'
60 }
63 # Actions user can do when clicking on a package.
65 actions() {
66 # Store box results
67 main="$(actions_main)"
68 # Deal with --button values
69 case "$?" in
70 1) exit 0 ;;
71 2) tazpkg extract "$pkg" . --output='raw' | output ;;
72 3) tazpkg -i "$pkg" . --forced --output='raw' | output ;;
73 esac
74 }
77 # TazPkg URL Handler.
79 dl_inst() {
80 pkg="$(basename $url)"
81 _ 'Downloading: %s' "$pkg"; newline
82 cd /tmp; wget "$url" 2>&1
83 tazpkg -i "$pkg" --forced --output='raw' 2>&1
84 rm -f "$pkg"
85 }
89 #
90 # Script commands
91 #
93 case "$1" in
94 usage|help|-u|-h)
95 usage ;;
96 tazpkg://*)
97 # TazPkg URL's handler.
98 url="http://${1#tazpkg://}"
99 dl_inst | output ;;
100 actions)
101 pkg="$(basename "$(realpath "${2%% }")")" # fight against strange space at the end
102 dir="$(dirname "$(realpath "${2%% }")")"
103 cd "$dir"
104 actions ;;
105 esac
107 exit 0