tazpkg annotate tazpkg-box @ rev 811

Update documentation (attempt to describe all the commands both with all options). Strongly need to review and update translations and docs! Add TazPkg help system for commandline (based on the HTML docs). Attempt to drop all package lists but "packages.info". Small improvements and code prettify.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Jun 04 00:15:13 2015 +0300 (2015-06-04)
parents 1ab24812ad7e
children a41fb2cbc248
rev   line source
pankso@541 1 #!/bin/sh
pankso@541 2 #
al@707 3 # Small GTK boxes to TazPkg for deep desktop integration. PCManFM 0.5.x has a
al@633 4 # patch to extract a TazPkg file but not Thunar and other FM. TazPkgBox tries
paul@579 5 # to follow freedesktop standards.
pankso@541 6 #
al@785 7 # Copyright (C) 2011-2015 SliTaz GNU/Linux - GNU GPL v2
pankso@541 8 #
al@633 9 # Authors: Christophe Lincoln <pankso@slitaz.org>
pankso@541 10 #
pankso@541 11
al@707 12
al@603 13 # Internationalization.
al@707 14
al@707 15 . /lib/libtaz.sh
al@603 16 TEXTDOMAIN='tazpkg'
al@603 17 export TEXTDOMAIN
al@603 18
al@707 19 title="$(_ 'TazPkg')"
al@707 20 text="$(_ 'SliTaz Package Action')"
pankso@555 21 icon="/usr/share/pixmaps/tazpkg.png"
al@633 22 opts="--image=tazpkg --image-on-top --center --on-top"
pankso@589 23
al@707 24
pankso@649 25 usage() {
al@785 26 cat <<EOT
al@707 27 $(_ 'Usage:') $(basename $0) [actions|URL] [$(_ 'package')]
pankso@649 28 EOT
pankso@649 29 }
pankso@649 30
al@707 31
pankso@589 32 # Nice GTK output for install and extract.
al@707 33
pankso@589 34 output() {
pankso@649 35 yad --text-info $opts --title="$title" --text="<b>$text</b>" \
pankso@649 36 --height=260 --width=520 --window-icon=$icon \
pankso@589 37 --tail --margins=4 --button="gtk-close:0"
pankso@589 38 }
pankso@555 39
al@707 40
pankso@649 41 pkginfo() {
pankso@649 42 tmp=/tmp/$(basename $0)/$$
al@707 43 mkdir -p $tmp; cd $tmp
pankso@649 44 { cpio --quiet -i receipt > /dev/null 2>&1; } < ${dir}/$pkg
pankso@649 45 . $tmp/receipt
pankso@649 46 #rm -rf /tmp/$(basename $0)
pankso@649 47 size=$(du -sh ${dir}/$pkg | awk '{print $1}')
al@707 48 echo -e "$(_ 'Package')\n$PACKAGE
al@707 49 $(_ 'Version')\n$VERSION
al@707 50 $(_ 'Short desc')\n$SHORT_DESC
al@707 51 $(_ 'Unpacked size')\n$UNPACKED_SIZE
al@707 52 $(_ 'Depends')\n$DEPENDS"
pankso@649 53 }
pankso@649 54
al@707 55
pankso@541 56 # Main GUI box function with pure Yad spec
al@707 57
pankso@541 58 actions_main() {
al@603 59 pkgname=${pkg%.tazpkg}
pankso@649 60 pkginfo | yad $opts --title="$title" \
pankso@649 61 --list --no-headers --no-click \
pankso@649 62 --height=260 --width=520 \
pankso@649 63 --text="<b>$text</b>" \
al@633 64 --window-icon=$icon \
al@707 65 --column "" --column "" \
al@707 66 --button="$(_ 'Install'):3" \
al@707 67 --button="$(_ 'Extract'):2" \
al@633 68 --button="gtk-cancel:1"
pankso@541 69 }
pankso@541 70
al@707 71
pankso@541 72 # Actions user can do when clicking on a package.
al@707 73
pankso@541 74 actions() {
pankso@541 75 # Store box results
pankso@541 76 main=$(actions_main)
pankso@541 77 ret=$?
pankso@541 78 # Deal with --button values
pankso@541 79 case $ret in
pankso@541 80 1) exit 0 ;;
al@603 81 2) tazpkg extract $pkg . --output="raw" | output ;;
al@603 82 3) tazpkg -i $pkg . --forced --output="raw" | output ;;
pankso@541 83 esac
pankso@541 84 }
pankso@541 85
al@707 86
al@633 87 # TazPkg URL Handler.
al@707 88
pankso@589 89 dl_inst() {
pankso@589 90 pkg=$(basename $url)
al@707 91 _ 'Downloading: %s' $pkg; newline
al@707 92 cd /tmp; wget $url 2>&1
pankso@595 93 tazpkg -i $pkg --forced --output="raw" 2>&1
pankso@589 94 rm -f $pkg
pankso@589 95 }
pankso@589 96
al@707 97
al@707 98
pankso@541 99 #
pankso@541 100 # Script commands
pankso@541 101 #
pankso@541 102
pankso@541 103 case "$1" in
pankso@555 104 usage|help|-u|-h)
pankso@649 105 usage ;;
pankso@589 106 tazpkg://*)
al@633 107 # TazPkg URL's handler.
pankso@589 108 url="http://${1#tazpkg://}"
pankso@589 109 dl_inst | output ;;
pankso@541 110 actions)
pankso@555 111 pkg=$(basename $2)
pankso@649 112 dir=$(dirname $2)
pankso@649 113 cd $dir
pankso@541 114 actions ;;
pankso@541 115 esac
pankso@541 116
pankso@541 117 exit 0