tazpkg view modules/help @ rev 849

Fix working of modules/reconfigure (thank Robertux for bugreport); small changes.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Oct 20 10:24:52 2015 +0300 (2015-10-20)
parents e54a3ba8cc25
children e2e188861988
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 mkdb $(_ 'Make a TazPkg database for a folder with *.tazpkg packages')
76 ")
77 EOT
78 }
83 T="${1#-}"
84 DOC='/usr/share/doc/tazpkg/tazpkg.html'
85 QUERY="$T"
87 if [ -z "$T" ]; then
88 usage; exit 0
89 fi
91 commands="\
92 :usage::help,h::activity,log,a::clean-cache,cc::shell::list,l::list-mirror,lm:\
93 :list-config::search,s::search-pkgname,sp::search-file,sf::get,g::install,i:\
94 :get-install,gi::install-list,get-install-list::remove,r::reconfigure::link:\
95 :set-release::add-flavor,install-flavor::info::desc,d::list-files,lf:\
96 :block,b,unblock,u,chblock::check::bugs::depends,rdepends::extract,e::pack:\
97 :repack::repack-config::recompress::convert,c::list-suggested::recharge:\
98 :upgrade,up::setup-mirror,sm::add-undigest,setup-undigest::list-undigest:\
99 :remove-undigest:"
101 if [ ! $(echo $commands | grep -e "[:,]$T[:,]") ]; then
102 try1=$(echo $commands | grep -oe ":[^:]*$T[^:]*:")
103 if [ -z "$try1" ]; then
104 _ 'Sorry, no help for "%s"' "$QUERY"; newline; exit 0
105 fi
107 try2=$(echo "$try1" | tr -d : )
109 trynum=$(echo "$try2" | wc -l)
110 if [ "$trynum" -ne 1 ]; then
111 _p '%d help topic available:' '%d help topics available:' "$trynum" \
112 "$trynum"; newline
113 echo "$try2" | sed 's|^| * &|; s| ,| |; s|,|, |g'
114 exit 0
115 else
116 T="${try2%%,*}"
117 fi
118 else
119 try3=$(echo $commands | grep -oe "[:,]$T[:,]")
120 case $try3 in
121 :*) try4="$try3";;
122 ,*) try4=$(echo $commands | grep -oe ":[^:]*$try3" | cut -d, -f1);;
123 esac
125 T=$(echo $try4 | tr -d ':,')
126 fi
128 title=$(echo $commands | grep -oe ":$T\(,[^:]*\)*:" | tr -d : | sed 's|,|, |g')
131 # style: <article id="TOPIC">
132 HLP=$(sed "/article id=\"$T\"/,/<\/article/!d; /<article/d; /<\/article/d" $DOC)
134 if [ -z "$HLP" ]; then
135 _ 'Sorry, no help for "%s"' "$QUERY"
136 exit 0
137 fi
139 PRE=$(echo "$HLP" | sed "/^$/d; /<pre>/,/<\/pre\>/{s|.*|  &|; s| |·|g}; \
140 s|^  </*pre>$||; s|<pre>||; s|</pre>||; s|  ·#|  #|;" | tr '\n' ' ' | \
141 sed '/^[ ]*$/d' | \
142 sed 's|[ ][ ]*| |g;' | \
143 sed 's|[ ]*<dl>|O\n|g; s|[ ]*</dl>|L\n|g; s|[ ]*</*dt>||g;' | \
144 sed 's|[ ]*<dd>| |g; s|</dd>|\n|g;' | \
145 sed 's|<h4>|<b>|g; s|</h4>|</b>\n|g' | \
146 sed 's|[ ]*<p>[ ]*||g; s|[ ]*</p>|\n \n|g; s|  |\n  |g' | \
147 sed 's|<a [^>]*>||g; s|</a>||g; s|·| |g' | \
148 sed 's|</*nobr>||g; s|&shy;||g; s|^[ ]*||' | \
149 sed '/^$/d' | \
150 sed 's|<tt>|A|g; s|<code>|A|g; s|<em>|B|g; s|<strong>|B|g; \
151 s|</tt>|D|g; s|</code>|D|g; s|</em>|D|g; s|</strong>|C|g; \
152 s|DD|D|g;')
154 OPT=$(echo "$PRE" | sed '/O/,/L/!d; /[OL]/d')
155 OPTLIST=$(optlist "$OPT")
157 OPT0=$(echo "$PRE" | tr '\n' '@')
158 OPTA=$(echo "$OPT" | tr '\n' '@')
159 OPTB=$(echo "$OPTLIST" | tr '\n' '@')
161 PRE2=$(echo "$OPT0" | sed "s|$OPTA|$OPTB|" | tr '@' '\n' | sed '/O/d; s|L||')
163 [ ! -z "$TA" ] && T="$T, $TA"
165 title '%s' "$title"
166 emsg "$(longline "$PRE2" | sed 's|A|<c 33>|g; s|B|<c 36>|g; s|C|<b>|g; s|D|</c>|g; ')"
167 newline