tazpkg view tazpkg-box @ rev 678

Added tag 5.3.1 for changeset 870805534046
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon May 26 16:15:06 2014 +0300 (2014-05-26)
parents 5317ffe7bfbb
children 1ab24812ad7e
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-2014 SliTaz GNU/Linux - GNU GPL v2
8 #
9 # Authors: Christophe Lincoln <pankso@slitaz.org>
10 #
12 # Internationalization.
13 . /usr/bin/gettext.sh
14 TEXTDOMAIN='tazpkg'
15 export TEXTDOMAIN
17 title=$(gettext "TazPKG")
18 text=$(gettext "SliTaz Package Action")
19 icon="/usr/share/pixmaps/tazpkg.png"
20 opts="--image=tazpkg --image-on-top --center --on-top"
22 usage() {
23 cat << EOT
24 $(gettext 'Usage:') $(basename $0) [actions|URL] [$(gettext 'package')]
25 EOT
26 }
28 # Nice GTK output for install and extract.
29 output() {
30 yad --text-info $opts --title="$title" --text="<b>$text</b>" \
31 --height=260 --width=520 --window-icon=$icon \
32 --tail --margins=4 --button="gtk-close:0"
33 }
35 pkginfo() {
36 tmp=/tmp/$(basename $0)/$$
37 mkdir -p $tmp && cd $tmp
38 { cpio --quiet -i receipt > /dev/null 2>&1; } < ${dir}/$pkg
39 . $tmp/receipt
40 #rm -rf /tmp/$(basename $0)
41 size=$(du -sh ${dir}/$pkg | awk '{print $1}')
42 echo -e "Package\n$PACKAGE
43 Version\n$VERSION
44 Short desc\n$SHORT_DESC
45 Unpacked size\n$UNPACKED_SIZE
46 Depends\n$DEPENDS"
47 }
49 # Main GUI box function with pure Yad spec
50 actions_main() {
51 pkgname=${pkg%.tazpkg}
52 pkginfo | yad $opts --title="$title" \
53 --list --no-headers --no-click \
54 --height=260 --width=520 \
55 --text="<b>$text</b>" \
56 --window-icon=$icon \
57 --column "Name" --column "" \
58 --button="$(gettext 'Install'):3" \
59 --button="$(gettext 'Extract'):2" \
60 --button="gtk-cancel:1"
61 }
63 # Actions user can do when clicking on a package.
64 actions() {
65 # Store box results
66 main=$(actions_main)
67 ret=$?
68 # Deal with --button values
69 case $ret 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 }
76 # TazPkg URL Handler.
77 dl_inst() {
78 pkg=$(basename $url)
79 eval_gettext "Downloading: \$pkg"; echo -e "\n"
80 cd /tmp && wget $url 2>&1
81 tazpkg -i $pkg --forced --output="raw" 2>&1
82 rm -f $pkg
83 }
85 #
86 # Script commands
87 #
89 case "$1" in
90 usage|help|-u|-h)
91 usage ;;
92 tazpkg://*)
93 # TazPkg URL's handler.
94 url="http://${1#tazpkg://}"
95 dl_inst | output ;;
96 actions)
97 pkg=$(basename $2)
98 dir=$(dirname $2)
99 cd $dir
100 actions ;;
101 esac
103 exit 0