tazpkg view tazpkg-box @ rev 819

tazpkg: re-write "desc" function to use all available sorts of descriptions (installed, mirrored, short, long, localized)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Jul 24 15:11:32 2015 +0300 (2015-07-24)
parents a41fb2cbc248
children a02e36d44d06
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')]
26 Examples:
28 $(basename $0) actions /path/to/package-1.0.tazpkg
29 display box to extract or install given package
31 $(basename $0) tazpkg://example.com/path/to/package-1.0.tazpkg
32 download and install given package
33 EOT
34 }
37 # Nice GTK output for install and extract.
39 output() {
40 yad --text-info $opts --tail --margins='4' --text="$text" \
41 --button='gtk-close:0'
42 }
45 pkginfo() {
46 tmp="$(mktemp -d)"; cd "$tmp"
47 { cpio --quiet -i receipt >/dev/null 2>&1; } < "$dir/$pkg"
48 . "$tmp/receipt"
49 rm -rf "$tmp"
50 size=$(du -sh "$dir/$pkg" | awk '{print $1}')
51 echo -e "$(_ 'Package')\n$PACKAGE
52 $(_ 'Version')\n$VERSION
53 $(_ 'Short desc')\n$SHORT_DESC
54 $(_ 'Unpacked size')\n$UNPACKED_SIZE
55 $(_ 'Depends')\n$DEPENDS"
56 }
59 # Main GUI box function with pure Yad spec
61 actions_main() {
62 pkgname="${pkg%.tazpkg}"
63 pkginfo | yad $opts --list --no-headers --no-click --text="$text" \
64 --column '' --column '' \
65 --button="$(_ 'Install'):3" \
66 --button="$(_ 'Extract'):2" \
67 --button='gtk-cancel:1'
68 }
71 # Actions user can do when clicking on a package.
73 actions() {
74 # Store box results
75 main="$(actions_main)"
76 # Deal with --button values
77 case "$?" in
78 1) exit 0 ;;
79 2) tazpkg extract "$pkg" . --output='raw' | output ;;
80 3) tazpkg -i "$pkg" . --forced --output='raw' | output ;;
81 esac
82 }
85 # TazPkg URL Handler.
87 dl_inst() {
88 pkg="$(basename $url)"
89 _ 'Downloading: %s' "$pkg"; newline
90 cd /tmp; wget "$url" 2>&1
91 tazpkg -i "$pkg" --forced --output='raw' 2>&1
92 rm -f "$pkg"
93 }
97 #
98 # Script commands
99 #
101 case "$1" in
102 --help|-h|help|usage|-u)
103 usage ;;
104 tazpkg://*)
105 # TazPkg URL's handler.
106 url="http://${1#tazpkg://}"
107 dl_inst | output ;;
108 actions)
109 [ -z "$2" ] && exit 1
110 pkg="$(basename "$(realpath "${2%% }")")" # fight against strange space at the end
111 dir="$(dirname "$(realpath "${2%% }")")"
112 cd "$dir"
113 actions ;;
114 esac
116 exit 0