tazpkg view modules/help @ rev 884

Module 'check': fix to work with $root; start to add tests
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Dec 05 16:14:14 2015 +0200 (2015-12-05)
parents 8e696ea00167
children d2e1b7133079
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 list-cache $(_ 'List *.tazpkg packages downloaded to the cache')
31 shell $(_ 'Run interactive TazPkg shell')
33 -l list $(_ 'List installed packages on the system')
34 -lm list-mirror $(_ 'List all available packages on the mirror')
35 list-config $(_ 'List the configuration files')
37 -s search $(_ 'Search for a package by pattern or name')
38 -sp search-pkgname $(_ 'Search on mirror for package having a particular file')
39 -sf search-file $(_ 'Search for file in all installed packages files')
41 -g get $(_ 'Download a package into the current directory')
42 -i install $(_ 'Install a local package')
43 -gi get-install $(_ 'Download and install a package from the mirror')
44 install-list $(_ 'Install all packages from a list of packages')
45 get-install-list $(_ 'Download and install a list of packages from the mirror')
46 -r remove $(_ 'Remove the specified package and all installed files')
47 reconfigure $(_ 'Replay post install script from package')
48 link $(_ 'Link a package from another SliTaz installation')
49 set-release $(_ 'Change release and update packages')
50 add-flavor $(_ 'Install the flavor list of packages')
51 install-flavor $(_ 'Install the flavor list of packages and remove other ones')
53 info $(_ 'Print information about a package')
54 -d desc $(_ 'Print description of a package')
55 -lf list-files $(_ 'List the files installed with a package')
56 -b|u block|unblock $(_ 'Block an installed package version or unblock it for upgrade')
57 check $(_ 'Verify consistency of installed packages')
58 bugs $(_ 'Show known bugs in packages')
59 depends $(_ 'Display dependencies tree')
60 rdepends $(_ 'Display reverse dependencies tree')
61 -e extract $(_ 'Extract a (*.tazpkg) package into a directory')
62 pack $(_ 'Pack an unpacked or prepared package tree')
63 repack $(_ 'Create a package archive from an installed package')
64 repack-config $(_ 'Create a package archive with configuration files')
65 recompress $(_ 'Rebuild a package with a better compression ratio')
66 convert $(_ 'Convert alien package to tazpkg')
67 list-suggested $(_ 'Print list of suggested packages')
69 recharge $(_ 'Recharge your packages.list from the mirror')
70 up $(_ 'Check packages %s to list and install latest upgrades' $CHECKSUM)
71 -sm setup-mirror $(_ 'Change the mirror URL configuration')
72 setup-undigest $(_ 'Update an undigest mirror')
73 list-undigest $(_ 'List undigest mirrors')
74 add-undigest $(_ 'Add an undigest mirror')
75 remove-undigest $(_ 'Remove an undigest mirror')
76 mkdb $(_ 'Make a TazPkg database for a folder with *.tazpkg packages')
77 ")
78 EOT
79 }
84 T="${1#-}"
85 DOC='/usr/share/doc/tazpkg/tazpkg.html'
86 QUERY="$T"
88 if [ -z "$T" ]; then
89 usage; exit 0
90 fi
92 commands="\
93 :usage::help,h::activity,log,a::clean-cache,cc::shell::list,l::list-mirror,lm:\
94 :list-config::search,s::search-pkgname,sp::search-file,sf::get,g::install,i:\
95 :get-install,gi::install-list,get-install-list::remove,r::reconfigure::link:\
96 :set-release::add-flavor,install-flavor::info::desc,d::list-files,lf:\
97 :block,b,unblock,u,chblock::check::bugs::depends,rdepends::extract,e::pack:\
98 :repack::repack-config::recompress::convert,c::list-suggested::recharge:\
99 :upgrade,up::setup-mirror,sm::add-undigest,setup-undigest::list-undigest:\
100 :remove-undigest:"
102 if [ ! $(echo $commands | grep -e "[:,]$T[:,]") ]; then
103 try1=$(echo $commands | grep -oe ":[^:]*$T[^:]*:")
104 if [ -z "$try1" ]; then
105 _ 'Sorry, no help for "%s"' "$QUERY"; newline; exit 0
106 fi
108 try2=$(echo "$try1" | tr -d : )
110 trynum=$(echo "$try2" | wc -l)
111 if [ "$trynum" -ne 1 ]; then
112 _p '%d help topic available:' '%d help topics available:' "$trynum" \
113 "$trynum"; newline
114 echo "$try2" | sed 's|^| * &|; s| ,| |; s|,|, |g'
115 exit 0
116 else
117 T="${try2%%,*}"
118 fi
119 else
120 try3=$(echo $commands | grep -oe "[:,]$T[:,]")
121 case $try3 in
122 :*) try4="$try3";;
123 ,*) try4=$(echo $commands | grep -oe ":[^:]*$try3" | cut -d, -f1);;
124 esac
126 T=$(echo $try4 | tr -d ':,')
127 fi
129 title=$(echo $commands | grep -oe ":$T\(,[^:]*\)*:" | tr -d : | sed 's|,|, |g')
132 # style: <article id="TOPIC">
133 HLP=$(sed "/article id=\"$T\"/,/<\/article/!d; /<article/d; /<\/article/d" $DOC)
135 if [ -z "$HLP" ]; then
136 _ 'Sorry, no help for "%s"' "$QUERY"
137 exit 0
138 fi
140 PRE=$(echo "$HLP" | sed "/^$/d; /<pre>/,/<\/pre\>/{s|.*|  &|; s| |·|g}; \
141 s|^  </*pre>$||; s|<pre>||; s|</pre>||; s|  ·#|  #|;" | tr '\n' ' ' | \
142 sed '/^[ ]*$/d' | \
143 sed 's|[ ][ ]*| |g;' | \
144 sed 's|[ ]*<dl>|O\n|g; s|[ ]*</dl>|L\n|g; s|[ ]*</*dt>||g;' | \
145 sed 's|[ ]*<dd>| |g; s|</dd>|\n|g;' | \
146 sed 's|<h4>|<b>|g; s|</h4>|</b>\n|g' | \
147 sed 's|[ ]*<p>[ ]*||g; s|[ ]*</p>|\n \n|g; s|  |\n  |g' | \
148 sed 's|<a [^>]*>||g; s|</a>||g; s|·| |g' | \
149 sed 's|</*nobr>||g; s|&shy;||g; s|^[ ]*||' | \
150 sed '/^$/d' | \
151 sed 's|<tt>|A|g; s|<code>|A|g; s|<em>|B|g; s|<strong>|B|g; \
152 s|</tt>|D|g; s|</code>|D|g; s|</em>|D|g; s|</strong>|C|g; \
153 s|DD|D|g;')
155 OPT=$(echo "$PRE" | sed '/O/,/L/!d; /[OL]/d')
156 OPTLIST=$(optlist "$OPT")
158 OPT0=$(echo "$PRE" | tr '\n' '@')
159 OPTA=$(echo "$OPT" | tr '\n' '@')
160 OPTB=$(echo "$OPTLIST" | tr '\n' '@')
162 PRE2=$(echo "$OPT0" | sed "s|$OPTA|$OPTB|" | tr '@' '\n' | sed '/O/d; s|L||')
164 [ ! -z "$TA" ] && T="$T, $TA"
166 title '%s' "$title"
167 emsg "$(longline "$PRE2" | sed 's|A|<c 33>|g; s|B|<c 36>|g; s|C|<b>|g; s|D|</c>|g; ')"
168 newline