tazpkg view modules/help @ rev 846

Remove "busybox" "prefixes" (thanks llev)
We used "busybox wget", etc. to be sure we called Busybox's "wget", not any other "wget". Workaround already done in "getenv" module.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Oct 09 13:14:01 2015 +0300 (2015-10-09)
parents a02e36d44d06
children e54a3ba8cc25
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # help - TazPkg module
4 # TazPkg help system
7 . /lib/libtaz.sh
12 # Print the usage.
14 usage () {
15 cat <<EOT
17 $(_ 'SliTaz package manager - Version: %s' $(colorize 34 $VERSION))
19 $(boldify "$(_ 'Usage:')")
20 $(_ 'tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]')
22 $(boldify "$(_ 'SHell:')") tazpkg shell
24 $(boldify "$(_ 'Commands:')")
25 $(optlist "\
26 usage $(_ 'Print this short usage')
27 -h help $(_ 'Show help on the TazPkg commands')
28 -a activity $(_ 'Show TazPkg activity log')
29 -cc clean-cache $(_ 'Clean all packages downloaded in cache directory')
30 shell $(_ 'Run interactive TazPkg shell')
32 -l list $(_ 'List installed packages on the system')
33 -lm list-mirror $(_ 'List all available packages on the mirror')
34 list-config $(_ 'List the configuration files')
36 -s search $(_ 'Search for a package by pattern or name')
37 -sp search-pkgname $(_ 'Search on mirror for package having a particular file')
38 -sf search-file $(_ 'Search for file in all installed packages files')
40 -g get $(_ 'Download a package into the current directory')
41 -i install $(_ 'Install a local package')
42 -gi get-install $(_ 'Download and install a package from the mirror')
43 install-list $(_ 'Install all packages from a list of packages')
44 get-install-list $(_ 'Download and install a list of packages from the mirror')
45 -r remove $(_ 'Remove the specified package and all installed files')
46 reconfigure $(_ 'Replay post install script from package')
47 link $(_ 'Link a package from another SliTaz installation')
48 set-release $(_ 'Change release and update packages')
49 add-flavor $(_ 'Install the flavor list of packages')
50 install-flavor $(_ 'Install the flavor list of packages and remove other ones')
52 info $(_ 'Print information about a package')
53 -d desc $(_ 'Print description of a package')
54 -lf list-files $(_ 'List the files installed with a package')
55 -b|u block|unblock $(_ 'Block an installed package version or unblock it for upgrade')
56 check $(_ 'Verify consistency of installed packages')
57 bugs $(_ 'Show known bugs in packages')
58 depends $(_ 'Display dependencies tree')
59 rdepends $(_ 'Display reverse dependencies tree')
60 -e extract $(_ 'Extract a (*.tazpkg) package into a directory')
61 pack $(_ 'Pack an unpacked or prepared package tree')
62 repack $(_ 'Create a package archive from an installed package')
63 repack-config $(_ 'Create a package archive with configuration files')
64 recompress $(_ 'Rebuild a package with a better compression ratio')
65 convert $(_ 'Convert alien package to tazpkg')
66 list-suggested $(_ 'Print list of suggested packages')
68 recharge $(_ 'Recharge your packages.list from the mirror')
69 up $(_ 'Check packages %s to list and install latest upgrades' $CHECKSUM)
70 -sm setup-mirror $(_ 'Change the mirror URL configuration')
71 setup-undigest $(_ 'Update an undigest mirror')
72 list-undigest $(_ 'List undigest mirrors')
73 add-undigest $(_ 'Add an undigest mirror')
74 remove-undigest $(_ 'Remove an undigest mirror')
75 ")
76 EOT
77 }
82 T="${1#-}"
83 DOC='/usr/share/doc/tazpkg/tazpkg.html'
84 QUERY="$T"
86 if [ -z "$T" ]; then
87 usage; exit 0
88 fi
90 commands="\
91 :usage::help,h::activity,log,a::clean-cache,cc::shell::list,l::list-mirror,lm:\
92 :list-config::search,s::search-pkgname,sp::search-file,sf::get,g::install,i:\
93 :get-install,gi::install-list,get-install-list::remove,r::reconfigure::link:\
94 :set-release::add-flavor,install-flavor::info::desc,d::list-files,lf:\
95 :block,b,unblock,u,chblock::check::bugs::depends,rdepends::extract,e::pack:\
96 :repack::repack-config::recompress::convert,c::list-suggested::recharge:\
97 :upgrade,up::setup-mirror,sm::add-undigest,setup-undigest::list-undigest:\
98 :remove-undigest:"
100 if [ ! $(echo $commands | grep -e "[:,]$T[:,]") ]; then
101 try1=$(echo $commands | grep -oe ":[^:]*$T[^:]*:")
102 if [ -z "$try1" ]; then
103 _ 'Sorry, no help for "%s"' "$QUERY"; newline; exit 0
104 fi
106 try2=$(echo "$try1" | tr -d : )
108 trynum=$(echo "$try2" | wc -l)
109 if [ "$trynum" -ne 1 ]; then
110 _p '%d help topic available:' '%d help topics available:' "$trynum" \
111 "$trynum"; newline
112 echo "$try2" | sed 's|^| * &|; s| ,| |; s|,|, |g'
113 exit 0
114 else
115 T="${try2%%,*}"
116 fi
117 else
118 try3=$(echo $commands | grep -oe "[:,]$T[:,]")
119 case $try3 in
120 :*) try4="$try3";;
121 ,*) try4=$(echo $commands | grep -oe ":[^:]*$try3" | cut -d, -f1);;
122 esac
124 T=$(echo $try4 | tr -d ':,')
125 fi
127 title=$(echo $commands | grep -oe ":$T\(,[^:]*\)*:" | tr -d : | sed 's|,|, |g')
130 # style: <article id="TOPIC">
131 HLP=$(sed "/article id=\"$T\"/,/<\/article/!d; /<article/d; /<\/article/d" $DOC)
133 if [ -z "$HLP" ]; then
134 _ 'Sorry, no help for "%s"' "$QUERY"
135 exit 0
136 fi
138 PRE=$(echo "$HLP" | sed "/^$/d; /<pre>/,/<\/pre\>/{s|.*|  &|; s| |·|g}; \
139 s|^  </*pre>$||; s|<pre>||; s|</pre>||; s|  ·#|  #|;" | tr '\n' ' ' | \
140 sed '/^[ ]*$/d' | \
141 sed 's|[ ][ ]*| |g;' | \
142 sed 's|[ ]*<dl>|O\n|g; s|[ ]*</dl>|L\n|g; s|[ ]*</*dt>||g;' | \
143 sed 's|[ ]*<dd>| |g; s|</dd>|\n|g;' | \
144 sed 's|<h4>|<b>|g; s|</h4>|</b>\n|g' | \
145 sed 's|[ ]*<p>[ ]*||g; s|[ ]*</p>|\n \n|g; s|  |\n  |g' | \
146 sed 's|<a [^>]*>||g; s|</a>||g; s|·| |g' | \
147 sed 's|</*nobr>||g; s|&shy;||g; s|^[ ]*||' | \
148 sed '/^$/d' | \
149 sed 's|<tt>|A|g; s|<code>|A|g; s|<em>|B|g; s|<strong>|B|g; \
150 s|</tt>|D|g; s|</code>|D|g; s|</em>|D|g; s|</strong>|C|g; \
151 s|DD|D|g;')
153 OPT=$(echo "$PRE" | sed '/O/,/L/!d; /[OL]/d')
154 OPTLIST=$(optlist "$OPT")
156 OPT0=$(echo "$PRE" | tr '\n' '@')
157 OPTA=$(echo "$OPT" | tr '\n' '@')
158 OPTB=$(echo "$OPTLIST" | tr '\n' '@')
160 PRE2=$(echo "$OPT0" | sed "s|$OPTA|$OPTB|" | tr '@' '\n' | sed '/O/d; s|L||')
162 [ ! -z "$TA" ] && T="$T, $TA"
164 title '%s' "$title"
165 emsg "$(longline "$PRE2" | sed 's|A|<c 33>|g; s|B|<c 36>|g; s|C|<b>|g; s|D|</c>|g; ')"
166 newline