rev |
line source |
al@822
|
1 #!/bin/sh
|
al@828
|
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
|
al@828
|
3 # help - TazPkg module
|
al@822
|
4 # TazPkg help system
|
al@822
|
5
|
al@828
|
6
|
al@822
|
7 . /lib/libtaz.sh
|
al@822
|
8
|
al@942
|
9 # Determine the help language
|
al@942
|
10
|
al@942
|
11 BASE='/usr/share/doc/tazpkg'
|
al@942
|
12
|
al@942
|
13 for i in $(echo $LANGUAGE | tr ':' ' ') ${LANG%.*} ${LANG%_*} en; do
|
al@942
|
14 if [ -f "$BASE/tazpkg.$i.html" ]; then
|
al@942
|
15 DOC="$BASE/tazpkg.$i.html"
|
al@942
|
16 break
|
al@942
|
17 fi
|
al@942
|
18 done
|
al@942
|
19
|
al@840
|
20
|
al@840
|
21
|
al@840
|
22
|
al@840
|
23 # Print the usage.
|
al@840
|
24
|
al@840
|
25 usage () {
|
al@840
|
26 cat <<EOT
|
al@840
|
27
|
al@840
|
28 $(_ 'SliTaz package manager - Version: %s' $(colorize 34 $VERSION))
|
al@840
|
29
|
al@840
|
30 $(boldify "$(_ 'Usage:')")
|
al@840
|
31 $(_ 'tazpkg [command] [package|dir|pattern|list|cat|--opt] [dir|--opt]')
|
al@840
|
32
|
al@840
|
33 $(boldify "$(_ 'SHell:')") tazpkg shell
|
al@840
|
34
|
al@840
|
35 $(boldify "$(_ 'Commands:')")
|
al@840
|
36 $(optlist "\
|
al@840
|
37 usage $(_ 'Print this short usage')
|
al@840
|
38 -h help $(_ 'Show help on the TazPkg commands')
|
al@840
|
39 -a activity $(_ 'Show TazPkg activity log')
|
al@840
|
40 -cc clean-cache $(_ 'Clean all packages downloaded in cache directory')
|
al@875
|
41 list-cache $(_ 'List *.tazpkg packages downloaded to the cache')
|
al@840
|
42 shell $(_ 'Run interactive TazPkg shell')
|
al@840
|
43
|
al@840
|
44 -l list $(_ 'List installed packages on the system')
|
al@840
|
45 -lm list-mirror $(_ 'List all available packages on the mirror')
|
al@840
|
46 list-config $(_ 'List the configuration files')
|
al@840
|
47
|
al@840
|
48 -s search $(_ 'Search for a package by pattern or name')
|
al@840
|
49 -sp search-pkgname $(_ 'Search on mirror for package having a particular file')
|
al@840
|
50 -sf search-file $(_ 'Search for file in all installed packages files')
|
al@840
|
51
|
al@840
|
52 -g get $(_ 'Download a package into the current directory')
|
al@840
|
53 -i install $(_ 'Install a local package')
|
al@840
|
54 -gi get-install $(_ 'Download and install a package from the mirror')
|
al@840
|
55 install-list $(_ 'Install all packages from a list of packages')
|
al@840
|
56 get-install-list $(_ 'Download and install a list of packages from the mirror')
|
al@840
|
57 -r remove $(_ 'Remove the specified package and all installed files')
|
al@840
|
58 reconfigure $(_ 'Replay post install script from package')
|
al@840
|
59 link $(_ 'Link a package from another SliTaz installation')
|
al@840
|
60 set-release $(_ 'Change release and update packages')
|
al@840
|
61 add-flavor $(_ 'Install the flavor list of packages')
|
al@840
|
62 install-flavor $(_ 'Install the flavor list of packages and remove other ones')
|
al@840
|
63
|
al@840
|
64 info $(_ 'Print information about a package')
|
al@840
|
65 -d desc $(_ 'Print description of a package')
|
al@840
|
66 -lf list-files $(_ 'List the files installed with a package')
|
al@840
|
67 -b|u block|unblock $(_ 'Block an installed package version or unblock it for upgrade')
|
al@840
|
68 check $(_ 'Verify consistency of installed packages')
|
al@840
|
69 bugs $(_ 'Show known bugs in packages')
|
al@840
|
70 depends $(_ 'Display dependencies tree')
|
al@840
|
71 rdepends $(_ 'Display reverse dependencies tree')
|
al@840
|
72 -e extract $(_ 'Extract a (*.tazpkg) package into a directory')
|
al@840
|
73 pack $(_ 'Pack an unpacked or prepared package tree')
|
al@840
|
74 repack $(_ 'Create a package archive from an installed package')
|
al@840
|
75 repack-config $(_ 'Create a package archive with configuration files')
|
al@840
|
76 recompress $(_ 'Rebuild a package with a better compression ratio')
|
al@840
|
77 convert $(_ 'Convert alien package to tazpkg')
|
al@840
|
78 list-suggested $(_ 'Print list of suggested packages')
|
al@840
|
79
|
al@840
|
80 recharge $(_ 'Recharge your packages.list from the mirror')
|
al@840
|
81 up $(_ 'Check packages %s to list and install latest upgrades' $CHECKSUM)
|
al@840
|
82 -sm setup-mirror $(_ 'Change the mirror URL configuration')
|
al@840
|
83 setup-undigest $(_ 'Update an undigest mirror')
|
al@840
|
84 list-undigest $(_ 'List undigest mirrors')
|
al@840
|
85 add-undigest $(_ 'Add an undigest mirror')
|
al@840
|
86 remove-undigest $(_ 'Remove an undigest mirror')
|
paul@848
|
87 mkdb $(_ 'Make a TazPkg database for a folder with *.tazpkg packages')
|
al@840
|
88 ")
|
al@840
|
89 EOT
|
al@840
|
90 }
|
al@840
|
91
|
al@840
|
92
|
al@840
|
93
|
al@840
|
94
|
al@822
|
95 T="${1#-}"
|
al@822
|
96 QUERY="$T"
|
al@822
|
97
|
al@822
|
98 if [ -z "$T" ]; then
|
al@840
|
99 usage; exit 0
|
al@822
|
100 fi
|
al@822
|
101
|
al@822
|
102 commands="\
|
al@822
|
103 :usage::help,h::activity,log,a::clean-cache,cc::shell::list,l::list-mirror,lm:\
|
al@822
|
104 :list-config::search,s::search-pkgname,sp::search-file,sf::get,g::install,i:\
|
al@822
|
105 :get-install,gi::install-list,get-install-list::remove,r::reconfigure::link:\
|
al@822
|
106 :set-release::add-flavor,install-flavor::info::desc,d::list-files,lf:\
|
al@822
|
107 :block,b,unblock,u,chblock::check::bugs::depends,rdepends::extract,e::pack:\
|
al@822
|
108 :repack::repack-config::recompress::convert,c::list-suggested::recharge:\
|
al@822
|
109 :upgrade,up::setup-mirror,sm::add-undigest,setup-undigest::list-undigest:\
|
al@822
|
110 :remove-undigest:"
|
al@822
|
111
|
pascal@976
|
112 if ! echo $commands | grep -qe "[:,]$T[:,]"; then
|
al@822
|
113 try1=$(echo $commands | grep -oe ":[^:]*$T[^:]*:")
|
al@822
|
114 if [ -z "$try1" ]; then
|
al@822
|
115 _ 'Sorry, no help for "%s"' "$QUERY"; newline; exit 0
|
al@822
|
116 fi
|
al@822
|
117
|
al@822
|
118 try2=$(echo "$try1" | tr -d : )
|
al@822
|
119
|
al@822
|
120 trynum=$(echo "$try2" | wc -l)
|
al@822
|
121 if [ "$trynum" -ne 1 ]; then
|
al@822
|
122 _p '%d help topic available:' '%d help topics available:' "$trynum" \
|
al@822
|
123 "$trynum"; newline
|
al@822
|
124 echo "$try2" | sed 's|^| * &|; s| ,| |; s|,|, |g'
|
al@822
|
125 exit 0
|
al@822
|
126 else
|
al@822
|
127 T="${try2%%,*}"
|
al@822
|
128 fi
|
al@822
|
129 else
|
al@822
|
130 try3=$(echo $commands | grep -oe "[:,]$T[:,]")
|
al@822
|
131 case $try3 in
|
al@822
|
132 :*) try4="$try3";;
|
al@822
|
133 ,*) try4=$(echo $commands | grep -oe ":[^:]*$try3" | cut -d, -f1);;
|
al@822
|
134 esac
|
al@822
|
135
|
al@822
|
136 T=$(echo $try4 | tr -d ':,')
|
al@822
|
137 fi
|
al@822
|
138
|
al@822
|
139 title=$(echo $commands | grep -oe ":$T\(,[^:]*\)*:" | tr -d : | sed 's|,|, |g')
|
al@822
|
140
|
al@822
|
141
|
al@844
|
142 # style: <article id="TOPIC">
|
al@886
|
143 HLP=$(sed "/article id=\"$T\"/,/<\/article/!d; s|</*article[^>]*>||; s|<h3>.*</h3>||" $DOC)
|
al@822
|
144
|
al@822
|
145 if [ -z "$HLP" ]; then
|
al@822
|
146 _ 'Sorry, no help for "%s"' "$QUERY"
|
al@822
|
147 exit 0
|
al@822
|
148 fi
|
al@822
|
149
|
al@822
|
150 PRE=$(echo "$HLP" | sed "/^$/d; /<pre>/,/<\/pre\>/{s|.*| &|; s| |·|g}; \
|
al@822
|
151 s|^ </*pre>$||; s|<pre>||; s|</pre>||; s| ·#| #|;" | tr '\n' ' ' | \
|
al@822
|
152 sed 's|[ ][ ]*| |g;' | \
|
al@822
|
153 sed 's|[ ]*<dl>|O\n|g; s|[ ]*</dl>|L\n|g; s|[ ]*</*dt>||g;' | \
|
al@822
|
154 sed 's|[ ]*<dd>| |g; s|</dd>|\n|g;' | \
|
al@895
|
155 sed 's|[ ]*<ul>|O\n|g; s|[ ]*</ul>|L\n|g; s|[ ]*<li>|* |g; s|</li>|\n|g;' | \
|
al@822
|
156 sed 's|<h4>|<b>|g; s|</h4>|</b>\n|g' | \
|
al@822
|
157 sed 's|[ ]*<p>[ ]*||g; s|[ ]*</p>|\n \n|g; s| |\n |g' | \
|
al@822
|
158 sed 's|<a [^>]*>||g; s|</a>||g; s|·| |g' | \
|
al@822
|
159 sed 's|</*nobr>||g; s|­||g; s|^[ ]*||' | \
|
al@822
|
160 sed '/^$/d' | \
|
al@822
|
161 sed 's|<tt>|A|g; s|<code>|A|g; s|<em>|B|g; s|<strong>|B|g; \
|
al@822
|
162 s|</tt>|D|g; s|</code>|D|g; s|</em>|D|g; s|</strong>|C|g; \
|
al@822
|
163 s|DD|D|g;')
|
al@822
|
164
|
al@822
|
165 OPT=$(echo "$PRE" | sed '/O/,/L/!d; /[OL]/d')
|
al@822
|
166 OPTLIST=$(optlist "$OPT")
|
al@822
|
167
|
al@822
|
168 OPT0=$(echo "$PRE" | tr '\n' '@')
|
al@895
|
169 OPTA=$(echo "$OPT" | tr '\n' '@' | sed 's|\*|\\*|g;')
|
al@895
|
170 OPTB=$(echo "$OPTLIST" | tr '\n' '@' | sed 's|\*|\\*|g;')
|
al@822
|
171
|
al@822
|
172 PRE2=$(echo "$OPT0" | sed "s|$OPTA|$OPTB|" | tr '@' '\n' | sed '/O/d; s|L||')
|
al@822
|
173
|
pascal@976
|
174 [ -n "$TA" ] && T="$T, $TA"
|
al@822
|
175
|
al@840
|
176 title '%s' "$title"
|
al@894
|
177 emsg "$(longline "$PRE2" | sed 's|A|<c 33>|g; s|B|<c 36>|g; s|C|</b>|g; s|D|</c>|g; ')"
|
al@822
|
178 newline
|