tazpkg view tazpkg-box @ rev 807

Tiny edit
author Paul Issott <paul@slitaz.org>
date Mon May 25 06:24:54 2015 +0100 (2015-05-25)
parents 1ab24812ad7e
children a41fb2cbc248
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 #
13 # Internationalization.
15 . /lib/libtaz.sh
16 TEXTDOMAIN='tazpkg'
17 export TEXTDOMAIN
19 title="$(_ 'TazPkg')"
20 text="$(_ 'SliTaz Package Action')"
21 icon="/usr/share/pixmaps/tazpkg.png"
22 opts="--image=tazpkg --image-on-top --center --on-top"
25 usage() {
26 cat <<EOT
27 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')]
28 EOT
29 }
32 # Nice GTK output for install and extract.
34 output() {
35 yad --text-info $opts --title="$title" --text="<b>$text</b>" \
36 --height=260 --width=520 --window-icon=$icon \
37 --tail --margins=4 --button="gtk-close:0"
38 }
41 pkginfo() {
42 tmp=/tmp/$(basename $0)/$$
43 mkdir -p $tmp; cd $tmp
44 { cpio --quiet -i receipt > /dev/null 2>&1; } < ${dir}/$pkg
45 . $tmp/receipt
46 #rm -rf /tmp/$(basename $0)
47 size=$(du -sh ${dir}/$pkg | awk '{print $1}')
48 echo -e "$(_ 'Package')\n$PACKAGE
49 $(_ 'Version')\n$VERSION
50 $(_ 'Short desc')\n$SHORT_DESC
51 $(_ 'Unpacked size')\n$UNPACKED_SIZE
52 $(_ 'Depends')\n$DEPENDS"
53 }
56 # Main GUI box function with pure Yad spec
58 actions_main() {
59 pkgname=${pkg%.tazpkg}
60 pkginfo | yad $opts --title="$title" \
61 --list --no-headers --no-click \
62 --height=260 --width=520 \
63 --text="<b>$text</b>" \
64 --window-icon=$icon \
65 --column "" --column "" \
66 --button="$(_ 'Install'):3" \
67 --button="$(_ 'Extract'):2" \
68 --button="gtk-cancel:1"
69 }
72 # Actions user can do when clicking on a package.
74 actions() {
75 # Store box results
76 main=$(actions_main)
77 ret=$?
78 # Deal with --button values
79 case $ret in
80 1) exit 0 ;;
81 2) tazpkg extract $pkg . --output="raw" | output ;;
82 3) tazpkg -i $pkg . --forced --output="raw" | output ;;
83 esac
84 }
87 # TazPkg URL Handler.
89 dl_inst() {
90 pkg=$(basename $url)
91 _ 'Downloading: %s' $pkg; newline
92 cd /tmp; wget $url 2>&1
93 tazpkg -i $pkg --forced --output="raw" 2>&1
94 rm -f $pkg
95 }
99 #
100 # Script commands
101 #
103 case "$1" in
104 usage|help|-u|-h)
105 usage ;;
106 tazpkg://*)
107 # TazPkg URL's handler.
108 url="http://${1#tazpkg://}"
109 dl_inst | output ;;
110 actions)
111 pkg=$(basename $2)
112 dir=$(dirname $2)
113 cd $dir
114 actions ;;
115 esac
117 exit 0