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