rev |
line source |
pankso@7
|
1 #!/bin/sh
|
pankso@7
|
2 #
|
paul@52
|
3 # TazPKG CGI interface - Manage packages via a browser
|
pankso@7
|
4 #
|
paul@52
|
5 # This CGI interface intensively uses tazpkg to manage packages and have
|
paul@52
|
6 # its own code for some tasks. Please KISS, it is important and keep speed
|
pankso@7
|
7 # in mind. Thanks, Pankso.
|
pankso@7
|
8 #
|
pankso@44
|
9 # (C) 2011 SliTaz GNU/Linux - GNU gpl v3
|
pankso@7
|
10 #
|
pascal@79
|
11
|
pankso@17
|
12 . lib/libtazpanel
|
pankso@17
|
13 get_config
|
pascal@81
|
14 header
|
pankso@7
|
15
|
pankso@7
|
16 # Include gettext helper script.
|
pankso@7
|
17 . /usr/bin/gettext.sh
|
pankso@7
|
18
|
pankso@7
|
19 # Export package name for gettext.
|
pankso@39
|
20 TEXTDOMAIN='tazpanel'
|
pankso@7
|
21 export TEXTDOMAIN
|
pankso@7
|
22
|
pankso@49
|
23 # xHTML 5 header with special side bar fo categories.
|
pankso@34
|
24 TITLE="- Packages"
|
pankso@41
|
25 xhtml_header | sed 's/id="content"/id="content-sidebar"/'
|
pankso@67
|
26
|
pankso@7
|
27
|
pankso@7
|
28 # We need packages information for list and search
|
pankso@7
|
29 parse_packages_desc() {
|
pankso@45
|
30 IFS="|"
|
pankso@45
|
31 cut -f 1,2,3,5 -d "|" | while read PACKAGE VERSION SHORT_DESC WEB_SITE
|
pankso@7
|
32 do
|
pankso@7
|
33 echo '<tr>'
|
pankso@46
|
34 if [ -d $INSTALLED/${PACKAGE% } ]; then
|
pankso@46
|
35 echo -e "<td><input type='checkbox' name='pkg' value='$PACKAGE'>\n
|
pankso@45
|
36 <a href='$SCRIPT_NAME?info=$PACKAGE'>
|
pankso@45
|
37 <img src='$IMAGES/tazpkg-installed.png'/>$PACKAGE</a></td>"
|
pankso@7
|
38 else
|
pankso@46
|
39 echo -e "<td><input type='checkbox' name='pkg' value='$PACKAGE'>\n
|
pascal@62
|
40 <a href='$SCRIPT_NAME?info=$PACKAGE'>
|
pascal@62
|
41 <img src='$IMAGES/tazpkg.png'/>$PACKAGE</a></td>"
|
pankso@7
|
42 fi
|
pankso@45
|
43 echo "<td>$VERSION</td>"
|
pankso@45
|
44 echo "<td class='desc'>$SHORT_DESC</td>"
|
pankso@45
|
45 echo "<td><a href='$WEB_SITE'>web</a></td>"
|
pankso@7
|
46 echo '</tr>'
|
pankso@7
|
47 done
|
pankso@45
|
48 unset IFS
|
pankso@7
|
49 }
|
pankso@7
|
50
|
pankso@7
|
51 # Display a full summary of packages stats
|
pankso@7
|
52 packages_summary() {
|
pankso@37
|
53 gettext "Last recharge : "
|
pankso@37
|
54 stat=`stat -c %y $LOCALSTATE/packages.list | \
|
pankso@37
|
55 sed 's/\(:..\):.*/\1/' | awk '{print $1}'`
|
pankso@37
|
56 mtime=`find /var/lib/tazpkg/packages.list -mtime +10`
|
pankso@37
|
57 echo -n "$stat "
|
pankso@37
|
58 if [ "$mtime" ]; then
|
pankso@37
|
59 echo "(Older than 10 days)"
|
pankso@37
|
60 else
|
pankso@37
|
61 echo "(Not older than 10 days)"
|
pankso@37
|
62 fi
|
pankso@8
|
63 gettext "Installed packages : "
|
pankso@7
|
64 ls $INSTALLED | wc -l
|
pankso@8
|
65 gettext "Mirrored packages : "
|
pankso@7
|
66 cat $LOCALSTATE/packages.list | wc -l
|
pankso@49
|
67 gettext "Upgradeable packages : "
|
pankso@47
|
68 cat $LOCALSTATE/packages.up | wc -l
|
pankso@44
|
69 #gettext "Installed files : "
|
pankso@44
|
70 #cat $INSTALLED/*/files.list | wc -l
|
pankso@8
|
71 gettext "Blocked packages : "
|
pankso@8
|
72 cat $LOCALSTATE/blocked-packages.list | wc -l
|
pankso@7
|
73 }
|
pankso@7
|
74
|
pankso@10
|
75 # Parse mirrors list to be able to have an icon an remove link
|
pankso@10
|
76 list_mirrors() {
|
pankso@10
|
77 cat $LOCALSTATE/mirrors | while read line
|
pankso@10
|
78 do
|
pankso@10
|
79 cat << EOT
|
pankso@10
|
80 <li><a href="$SCRIPT_NAME?config=rm-mirror=$line"><img
|
pankso@10
|
81 src="$IMAGES/clear.png" /></a><a href="$line">$line</a></li>
|
pankso@10
|
82 EOT
|
pankso@10
|
83 done
|
pankso@10
|
84 }
|
pankso@10
|
85
|
pankso@7
|
86 #
|
pankso@7
|
87 # xHTML functions
|
pankso@7
|
88 #
|
pankso@7
|
89
|
pankso@17
|
90 # ENTER will search but user may search for a button, so put one.
|
pankso@9
|
91 search_form() {
|
pankso@9
|
92 cat << EOT
|
pankso@9
|
93 <div class="search">
|
pankso@17
|
94 <form method="get" action="$SCRIPT_NAME">
|
pankso@17
|
95 <p>
|
pankso@17
|
96 <input type="text" name="search" size="20">
|
pankso@17
|
97 <input type="submit" value="`gettext "Search"`">
|
pankso@80
|
98 <input class="radius" type="submit" name="files"
|
pankso@80
|
99 value="`gettext "files"`">
|
pankso@17
|
100 </p>
|
pankso@17
|
101 </form>
|
pankso@9
|
102 </div>
|
pankso@9
|
103 EOT
|
pankso@9
|
104 }
|
pankso@9
|
105
|
pankso@17
|
106 table_head() {
|
pankso@7
|
107 cat << EOT
|
pankso@7
|
108 <tr id="thead">
|
pankso@7
|
109 <td>`gettext "Name"`</td>
|
pankso@7
|
110 <td>`gettext "Version"`</td>
|
pankso@7
|
111 <td>`gettext "Description"`</td>
|
pankso@7
|
112 <td>`gettext "Web"`</td>
|
pankso@7
|
113 </tr>
|
pankso@7
|
114 EOT
|
pankso@7
|
115 }
|
pankso@7
|
116
|
pankso@41
|
117 sidebar() {
|
pankso@7
|
118 cat << EOT
|
pankso@41
|
119 <div id="sidebar">
|
pankso@41
|
120 <h4>Categories</h4>
|
pankso@41
|
121 <a class="active_base-system" href="$SCRIPT_NAME?cat=base-system">Base-system</a>
|
pankso@41
|
122 <a class="active_x-window" href="$SCRIPT_NAME?cat=x-window">X window</a>
|
pankso@41
|
123 <a class="active_utilities" href="$SCRIPT_NAME?cat=utilities">Utilities</a>
|
pankso@41
|
124 <a class="active_network" href="$SCRIPT_NAME?cat=network">Network</a>
|
pankso@41
|
125 <a class="active_games" href="$SCRIPT_NAME?cat=games">Games</a>
|
pankso@41
|
126 <a class="active_graphics" href="$SCRIPT_NAME?cat=graphics">Graphics</a>
|
pankso@41
|
127 <a class="active_office" href="$SCRIPT_NAME?cat=office">Office</a>
|
pankso@41
|
128 <a class="active_multimedia" href="$SCRIPT_NAME?cat=multimedia">Multimedia</a>
|
pankso@41
|
129 <a class="active_developement" href="$SCRIPT_NAME?cat=development">Development</a>
|
pankso@41
|
130 <a class="active_system-tools" href="$SCRIPT_NAME?cat=system-tools">System tools</a>
|
pankso@41
|
131 <a class="active_security" href="$SCRIPT_NAME?cat=security">Security</a>
|
pankso@41
|
132 <a class="active_misc" href="$SCRIPT_NAME?cat=misc">Misc</a>
|
pankso@41
|
133 <a class="active_meta" href="$SCRIPT_NAME?cat=meta">Meta</a>
|
pankso@41
|
134 <a class="active_non-free" href="$SCRIPT_NAME?cat=non-free">Non free</a>
|
pascal@93
|
135 <a class="active_all" href="$SCRIPT_NAME?cat=all">All</a>
|
pankso@9
|
136 </div>
|
pankso@7
|
137 EOT
|
pankso@7
|
138 }
|
pankso@7
|
139
|
pankso@45
|
140 #
|
pankso@45
|
141 # Commands
|
pankso@45
|
142 #
|
pankso@45
|
143
|
pascal@81
|
144 case " $(GET) " in
|
pascal@81
|
145 *\ list\ *)
|
pankso@45
|
146 #
|
pankso@45
|
147 # List installed packages. This is the default because parsing
|
pankso@45
|
148 # the full packages.desc can be long and take some resources
|
pankso@45
|
149 #
|
pankso@45
|
150 cd $INSTALLED
|
pankso@45
|
151 search_form
|
pankso@45
|
152 sidebar
|
pankso@45
|
153 LOADING_MSG="Listing packages..."
|
pankso@45
|
154 loading_msg
|
pankso@45
|
155 cat << EOT
|
pankso@45
|
156 <h2>`gettext "My packages"`</h2>
|
pankso@45
|
157 <form method='get' action='$SCRIPT_NAME'>
|
pankso@45
|
158 <div id="actions">
|
pankso@46
|
159 <div class="float-left">
|
pankso@46
|
160 `gettext "Selection:"`
|
pankso@46
|
161 <input type="submit" name="do" value="Remove" />
|
pankso@46
|
162 </div>
|
pankso@46
|
163 <div class="float-right">
|
pankso@46
|
164 `gettext "List:"`
|
pankso@46
|
165 <input type="submit" name="recharge" value="Recharge" />
|
pankso@47
|
166 <input type="submit" name="up" value="Upgrade" />
|
pankso@46
|
167 </div>
|
pankso@41
|
168 </div>
|
pankso@7
|
169 EOT
|
pankso@7
|
170 table_start
|
pankso@41
|
171 table_head
|
pankso@7
|
172 for pkg in *
|
pankso@7
|
173 do
|
pankso@7
|
174 . $pkg/receipt
|
pankso@7
|
175 echo '<tr>'
|
pankso@7
|
176 # Use default tazpkg icon since all packages displayed are
|
pankso@7
|
177 # installed
|
pascal@92
|
178 colorpkg=$pkg
|
pascal@92
|
179 grep -qs "^$pkg$" $LOCALSTATE/blocked-packages.list &&
|
pascal@92
|
180 colorpkg="<span style='color: red;'>$pkg</span>"
|
pankso@7
|
181 echo "<td class='pkg'>
|
pankso@7
|
182 <input type='checkbox' name='pkg' value=\"$pkg\" />
|
pankso@7
|
183 <a href='$SCRIPT_NAME?info=$pkg'><img
|
pascal@92
|
184 src='$IMAGES/tazpkg-installed.png'/>$colorpkg</a></td>"
|
pankso@7
|
185 echo "<td>$VERSION</td>"
|
pankso@7
|
186 echo "<td class='desc'>$SHORT_DESC</td>"
|
pankso@7
|
187 echo "<td><a href='$WEB_SITE'>web</a></td>"
|
pankso@7
|
188 echo '</tr>'
|
pankso@7
|
189 done
|
pankso@7
|
190 table_end
|
pankso@7
|
191 echo '</form>' ;;
|
pascal@81
|
192 *\ cat\ *)
|
pankso@45
|
193 #
|
pankso@41
|
194 # List all available packages by category on mirror. Listing all
|
paul@52
|
195 # packages is too resource intensive and not useful.
|
pankso@45
|
196 #
|
pankso@9
|
197 cd $LOCALSTATE
|
pascal@81
|
198 category=$(GET cat)
|
pascal@81
|
199 [ "$category" == "cat" ] && category="base-system"
|
pascal@93
|
200 grep_category=$category
|
pascal@93
|
201 [ "$grep_category" == "all" ] && grep_category=".*"
|
pankso@9
|
202 search_form
|
pankso@41
|
203 sidebar | sed s/"active_${category}"/"active"/
|
pankso@45
|
204 LOADING_MSG="Listing packages..."
|
pankso@45
|
205 loading_msg
|
pankso@9
|
206 cat << EOT
|
pankso@41
|
207 <h2>`gettext "Category:"` $category</h2>
|
pankso@9
|
208 <form method='get' action='$SCRIPT_NAME'>
|
pankso@9
|
209 <div id="actions">
|
pankso@45
|
210 <div class="float-left">
|
pankso@45
|
211 `gettext "Selection:"`
|
pankso@45
|
212 <input type="submit" name="do" value="Install" />
|
pankso@45
|
213 <input type="submit" name="do" value="Remove" />
|
pankso@45
|
214 </div>
|
pankso@45
|
215 <div class="float-right">
|
pankso@45
|
216 `gettext "List:"`
|
pankso@45
|
217 <input type="submit" name="recharge" value="Recharge" />
|
pankso@47
|
218 <input type="submit" name="up" value="Upgrade" />
|
pankso@45
|
219 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@45
|
220 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@45
|
221 </div>
|
pankso@9
|
222 EOT
|
pankso@9
|
223 echo '</div>'
|
pankso@7
|
224 table_start
|
pankso@17
|
225 table_head
|
pascal@93
|
226 grep "| $grep_category |" packages.desc | parse_packages_desc
|
pankso@7
|
227 table_end
|
pankso@7
|
228 echo '</form>' ;;
|
pascal@81
|
229 *\ search\ *)
|
pankso@45
|
230 #
|
pankso@63
|
231 # Search for packages. Here default is to search in packages.desc
|
pankso@63
|
232 # and so get result including packages names and descriptions
|
pankso@45
|
233 #
|
pascal@81
|
234 pkg=$(GET search)
|
pankso@9
|
235 cd $LOCALSTATE
|
pankso@9
|
236 search_form
|
pankso@41
|
237 sidebar
|
pankso@45
|
238 LOADING_MSG="Searching packages..."
|
pankso@45
|
239 loading_msg
|
pankso@7
|
240 cat << EOT
|
pankso@17
|
241 <h2>`gettext "Search packages"`</h2>
|
pankso@7
|
242 <form method="get" action="$SCRIPT_NAME">
|
pankso@9
|
243 <div id="actions">
|
pankso@45
|
244 <div class="float-left">
|
pankso@45
|
245 `gettext "Selection:"`
|
pankso@45
|
246 <input type="submit" name="do" value="Install" />
|
pankso@45
|
247 <input type="submit" name="do" value="Remove" />
|
pankso@45
|
248 <a href="`cat $PANEL/lib/checkbox.js`">`gettext "Toogle all"`</a>
|
pankso@45
|
249 </div>
|
pankso@45
|
250 <div class="float-right">
|
pankso@45
|
251 `gettext "List:"`
|
pankso@45
|
252 <input type="submit" name="recharge" value="Recharge" />
|
pankso@47
|
253 <input type="submit" name="up" value="Upgrade" />
|
pankso@45
|
254 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@45
|
255 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@45
|
256 </div>
|
pankso@7
|
257 EOT
|
pankso@9
|
258 echo '</div>'
|
pankso@7
|
259 table_start
|
pascal@79
|
260 if [ "$(GET files)" ]; then
|
pascal@79
|
261 cat <<EOT
|
pascal@79
|
262 <tr id="thead">
|
pascal@79
|
263 <td>`gettext "Package"`</td>
|
pascal@79
|
264 <td>`gettext "File"`</td>
|
pascal@79
|
265 </tr>
|
pascal@83
|
266 $(unlzma -c files.list.lzma | grep -Ei ": .*$(GET search)" | \
|
pascal@84
|
267 while read PACKAGE FILE; do
|
pascal@84
|
268 PACKAGE=${PACKAGE%:}
|
pascal@84
|
269 image=tazpkg-installed.png
|
pascal@84
|
270 [ -d $INSTALLED/$PACKAGE ] || image=tazpkg.png
|
pascal@84
|
271 echo "<tr>
|
pascal@85
|
272 <td><input type='checkbox' name='pkg' value='$PACKAGE'>
|
pascal@85
|
273 <a href='$SCRIPT_NAME?info=$PACKAGE'><img src='$IMAGES/$image' />$PACKAGE</a></td>
|
pascal@84
|
274 <td>$FILE</td>
|
pascal@84
|
275 </tr>"
|
pascal@84
|
276 done)
|
pascal@79
|
277 EOT
|
pascal@79
|
278 else
|
pascal@79
|
279 table_head
|
pascal@79
|
280 grep -i $pkg packages.desc | parse_packages_desc
|
pascal@79
|
281 fi
|
pankso@7
|
282 table_end
|
pankso@7
|
283 echo '</form>' ;;
|
pascal@81
|
284 *\ recharge\ *)
|
pankso@45
|
285 #
|
pankso@7
|
286 # Let recharge the packages list
|
pankso@45
|
287 #
|
pankso@9
|
288 search_form
|
pankso@41
|
289 sidebar
|
pankso@45
|
290 LOADING_MSG="Recharging lists..."
|
pankso@45
|
291 loading_msg
|
pankso@8
|
292 cat << EOT
|
pankso@9
|
293 <h2>`gettext "Recharge"`</h2>
|
pankso@9
|
294 <form method='get' action='$SCRIPT_NAME'>
|
pankso@9
|
295 <div id="actions">
|
pankso@41
|
296 <div class="float-left">
|
pankso@41
|
297 <p>
|
pankso@45
|
298 `gettext "Recharge checks for new or updated packages"`
|
pankso@41
|
299 </p>
|
pankso@41
|
300 </div>
|
pankso@41
|
301 <div class="float-right">
|
pankso@41
|
302 <p>
|
pankso@47
|
303 <a class="button" href='$SCRIPT_NAME?up'>
|
pankso@45
|
304 `gettext "Check upgrade"`</a>
|
pankso@41
|
305 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@41
|
306 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@41
|
307 </p>
|
pankso@41
|
308 </div>
|
pankso@41
|
309 </div>
|
pankso@22
|
310 <pre>
|
pankso@8
|
311 EOT
|
pankso@94
|
312 gettext "Recharging packages list" | log
|
pascal@99
|
313 tazpkg recharge | filter_taztools_msgs
|
pankso@45
|
314 cat << EOT
|
pankso@45
|
315 </pre>
|
pankso@45
|
316 <p>
|
paul@52
|
317 `gettext "Packages lists are up-to-date. You should check for upgrades now."`
|
pankso@45
|
318 </p>
|
pankso@45
|
319 EOT
|
pankso@45
|
320 ;;
|
pascal@81
|
321 *\ up\ *)
|
pankso@45
|
322 #
|
pankso@45
|
323 # Ugrade packages
|
pankso@45
|
324 #
|
pankso@9
|
325 cd $LOCALSTATE
|
pankso@9
|
326 search_form
|
pankso@41
|
327 sidebar
|
paul@52
|
328 LOADING_MSG="Checking for upgrades..."
|
pankso@45
|
329 loading_msg
|
pankso@8
|
330 cat << EOT
|
paul@52
|
331 <h2>`gettext "Up packages"`</h2>
|
pankso@8
|
332 <form method="get" action="$SCRIPT_NAME">
|
pankso@9
|
333 <div id="actions">
|
pankso@47
|
334 <div class="float-left">
|
pankso@47
|
335 `gettext "Selection:"`
|
pankso@47
|
336 <input type="submit" name="do" value="Install" />
|
pankso@47
|
337 <input type="submit" name="do" value="Remove" />
|
pankso@47
|
338 <a href="`cat $PANEL/lib/checkbox.js`">`gettext "Toogle all"`</a>
|
pankso@47
|
339 </div>
|
pankso@47
|
340 <div class="float-right">
|
pankso@47
|
341 `gettext "List:"`
|
pankso@47
|
342 <input type="submit" name="recharge" value="Recharge" />
|
pankso@47
|
343 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@47
|
344 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@47
|
345 </div>
|
pankso@45
|
346 </div>
|
pankso@8
|
347 EOT
|
pankso@47
|
348 tazpkg up --check >/dev/null
|
pankso@8
|
349 table_start
|
pankso@17
|
350 table_head
|
pankso@47
|
351 for pkg in `cat packages.up`
|
pankso@8
|
352 do
|
pankso@8
|
353 grep "^$pkg |" $LOCALSTATE/packages.desc | parse_packages_desc
|
pankso@8
|
354 done
|
pankso@8
|
355 table_end
|
pankso@8
|
356 echo '</form>' ;;
|
pascal@81
|
357 *\ do\ *)
|
pankso@45
|
358 #
|
pankso@7
|
359 # Do an action on one or some packages
|
pankso@45
|
360 #
|
pascal@92
|
361 opt=""
|
pascal@81
|
362 pkgs=""
|
pankso@87
|
363 cmdline=`echo ${QUERY_STRING#do=} | sed s'/&/ /g'`
|
pankso@87
|
364 cmd=`echo ${cmdline} | awk '{print $1}'`
|
pankso@87
|
365 pkgs=`echo $cmdline | sed -e s'/+/ /g' -e s'/pkg=//g' -e s/$cmd//`
|
pascal@92
|
366 cmd=`echo $cmd | tr [A-Z] [a-z]`
|
pankso@87
|
367 case $cmd in
|
pascal@92
|
368 install)
|
pankso@41
|
369 cmd=get-install opt=--forced ;;
|
pankso@41
|
370 esac
|
pankso@9
|
371 search_form
|
pankso@41
|
372 sidebar
|
pankso@45
|
373 LOADING_MSG="${cmd}ing packages..."
|
pankso@45
|
374 loading_msg
|
pankso@9
|
375 cat << EOT
|
pankso@9
|
376 <h2>Tazpkg: $cmd</h2>
|
pankso@9
|
377 <form method="get" action="$SCRIPT_NAME">
|
pankso@9
|
378 <div id="actions">
|
pankso@41
|
379 <div class="float-left">
|
pankso@41
|
380 <p>
|
paul@52
|
381 `gettext "Performing tasks on packages"`
|
pankso@41
|
382 </p>
|
pankso@41
|
383 </div>
|
pankso@41
|
384 <div class="float-right">
|
pankso@41
|
385 <p>
|
pankso@41
|
386 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@41
|
387 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@41
|
388 </p>
|
pankso@41
|
389 </div>
|
pankso@41
|
390 </div>
|
pankso@9
|
391 EOT
|
pankso@45
|
392 echo '<div class="box">'
|
pankso@10
|
393 gettext "Executing $cmd for:$pkgs"
|
pankso@45
|
394 echo '</div>'
|
pankso@7
|
395 for pkg in $pkgs
|
pankso@7
|
396 do
|
pankso@10
|
397 echo '<pre>'
|
pascal@99
|
398 echo 'y' | tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs
|
pankso@7
|
399 echo '</pre>'
|
pankso@7
|
400 done ;;
|
pascal@81
|
401 *\ info\ *)
|
pankso@45
|
402 #
|
pankso@45
|
403 # Packages info
|
pankso@45
|
404 #
|
pascal@81
|
405 pkg=$(GET info)
|
pankso@9
|
406 search_form
|
pankso@41
|
407 sidebar
|
pascal@62
|
408 if [ -d $INSTALLED/$pkg ]; then
|
pascal@62
|
409 . $INSTALLED/$pkg/receipt
|
pascal@62
|
410 files=`cat $INSTALLED/$pkg/files.list | wc -l`
|
pankso@64
|
411 action=$(gettext "Remove")
|
pascal@62
|
412 else
|
pascal@62
|
413 cd $LOCALSTATE
|
pankso@64
|
414 LOADING_MSG=$(gettext "Getting package info...")
|
pankso@64
|
415 loading_msg
|
pascal@62
|
416 IFS='|'
|
pascal@62
|
417 set -- $(grep "^$pkg |" packages.desc)
|
pascal@62
|
418 unset IFS
|
pascal@62
|
419 PACKAGE=$1
|
pascal@62
|
420 VERSION="$(echo $2)"
|
pascal@62
|
421 SHORT_DESC="$(echo $3)"
|
pascal@62
|
422 CATEGORY="$(echo $4)"
|
pascal@62
|
423 WEB_SITE="$(echo $5)"
|
pankso@64
|
424 action=$(gettext "Install")
|
pascal@62
|
425 fi
|
pankso@7
|
426 cat << EOT
|
pankso@41
|
427 <h2>`gettext "Package"` $PACKAGE</h2>
|
pankso@9
|
428 <div id="actions">
|
pankso@41
|
429 <div class="float-left">
|
pankso@41
|
430 <p>
|
pankso@64
|
431 <a class="button" href='$SCRIPT_NAME?do=$action&$pkg'>$action</a>
|
pascal@92
|
432 EOT
|
pascal@92
|
433 if [ -d $INSTALLED/$pkg ]; then
|
pascal@92
|
434 if grep -qs "^$pkg$" $LOCALSTATE/blocked-packages.list; then
|
pascal@92
|
435 block=$(gettext "Unblock")
|
pascal@92
|
436 else
|
pascal@92
|
437 block=$(gettext "Block")
|
pascal@92
|
438 fi
|
pascal@92
|
439 cat << EOT
|
pascal@92
|
440 <a class="button" href='$SCRIPT_NAME?do=$block&$pkg'>$block</a>
|
pascal@92
|
441 <a class="button" href='$SCRIPT_NAME?do=Repack&$pkg'>Repack</a>
|
pascal@92
|
442 EOT
|
pascal@92
|
443 fi
|
pascal@92
|
444 cat << EOT
|
pankso@41
|
445 </p>
|
pankso@41
|
446 </div>
|
pankso@41
|
447 <div class="float-right">
|
pankso@41
|
448 <p>
|
pankso@41
|
449 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@41
|
450 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@41
|
451 </p>
|
pankso@41
|
452 </div>
|
pankso@9
|
453 </div>
|
pankso@22
|
454 <pre>
|
pankso@7
|
455 Name : $PACKAGE
|
pankso@7
|
456 Version : $VERSION
|
pankso@7
|
457 Description : $SHORT_DESC
|
pankso@41
|
458 Category : $CATEGORY
|
pascal@62
|
459 EOT
|
pascal@62
|
460 if [ -d $INSTALLED/$pkg ]; then
|
pascal@62
|
461 cat << EOT
|
pankso@10
|
462 Maintainer : $MAINTAINER
|
pankso@7
|
463 Website : <a href="$WEB_SITE">$WEB_SITE</a>
|
pankso@7
|
464 Sizes : $PACKED_SIZE/$UNPACKED_SIZE
|
pascal@92
|
465 EOT
|
pascal@92
|
466 if [ -n "$DEPENDS" ]; then
|
pascal@92
|
467 echo -n "Depends : "
|
pascal@92
|
468 for i in $DEPENDS; do
|
pascal@92
|
469 echo -n "<a href="$SCRIPT_NAME?info=$i">$i</a> "
|
pascal@92
|
470 done
|
pascal@92
|
471 echo ""
|
pascal@92
|
472 fi
|
pascal@92
|
473 if [ -n "$SUGGESTED" ]; then
|
pascal@92
|
474 echo -n "Suggested : "
|
pascal@92
|
475 for i in $SUGGESTED; do
|
pascal@92
|
476 echo -n "<a href="$SCRIPT_NAME?info=$i">$i</a> "
|
pascal@92
|
477 done
|
pascal@92
|
478 echo ""
|
pascal@92
|
479 fi
|
pascal@92
|
480 [ -n "$TAGS" ] && echo "Tags : $TAGS"
|
pascal@92
|
481 cat << EOT
|
pankso@7
|
482 </pre>
|
pankso@7
|
483
|
pankso@41
|
484 <p>`gettext "Installed files:"` `cat $INSTALLED/$pkg/files.list | wc -l`</p>
|
pankso@7
|
485 <pre>
|
pankso@7
|
486 `cat $INSTALLED/$pkg/files.list`
|
pankso@7
|
487 </pre>
|
pankso@7
|
488 EOT
|
pascal@62
|
489 else
|
pascal@62
|
490 cat << EOT
|
pascal@62
|
491 Website : <a href="$WEB_SITE">$WEB_SITE</a>
|
pascal@62
|
492 Sizes : `grep -A 3 ^$pkg$ packages.txt | tail -n 1 | sed 's/ *//'`
|
pascal@62
|
493 </pre>
|
pascal@62
|
494
|
pascal@62
|
495 <p>`gettext "Installed files:"`</p>
|
pascal@62
|
496 <pre>
|
pascal@62
|
497 `unlzma -c files.list.lzma | sed "/^$pkg: /!d;s/^$pkg: //"`
|
pascal@62
|
498 </pre>
|
pascal@62
|
499 EOT
|
pascal@62
|
500 fi
|
pankso@7
|
501 ;;
|
pankso@95
|
502 *\ admin\ * )
|
pankso@45
|
503 #
|
pankso@10
|
504 # Tazpkg configuration page
|
pankso@45
|
505 #
|
pankso@95
|
506 cmd=$(GET admin)
|
pankso@10
|
507 case "$cmd" in
|
pankso@10
|
508 clean)
|
pankso@10
|
509 rm -rf /var/cache/tazpkg/* ;;
|
pascal@81
|
510 add-mirror)
|
pankso@10
|
511 # Decode url
|
pascal@81
|
512 mirror=$(GET mirror)
|
pascal@81
|
513 case "$mirror" in
|
pascal@81
|
514 http://*|ftp://*)
|
pascal@81
|
515 echo "$mirror" >> $LOCALSTATE/mirrors ;;
|
pascal@81
|
516 esac ;;
|
pankso@10
|
517 rm-mirror=http://*|rm-mirror=ftp://*)
|
pascal@81
|
518 mirror=${cmd#rm-mirror=}
|
pankso@10
|
519 sed -i -e "s@$mirror@@" -e '/^$/d' $LOCALSTATE/mirrors ;;
|
pankso@10
|
520 esac
|
pankso@10
|
521 cache_files=`find /var/cache/tazpkg -name *.tazpkg | wc -l`
|
pankso@10
|
522 cache_size=`du -sh /var/cache/tazpkg`
|
pankso@41
|
523 sidebar
|
pankso@10
|
524 cat << EOT
|
pankso@95
|
525 <h2>$(gettext "Administration")</h2>
|
pankso@10
|
526 <div>
|
pankso@95
|
527 <p>$(gettext "Tazpkg administration and settings")</p>
|
pankso@10
|
528 </div>
|
pankso@95
|
529 <div id="actions">
|
pankso@95
|
530 <a class="button" href='$SCRIPT_NAME?admin=&action=saveconf'>
|
pankso@95
|
531 <img src="$IMAGES/tazpkg.png" />`gettext "Save configuration"`</a>
|
pankso@95
|
532 <a class="button" href='$SCRIPT_NAME?admin=&action=listconf'>
|
pankso@95
|
533 <img src="$IMAGES/edit.png" />`gettext "List configuration files"`</a>
|
pankso@95
|
534 <a class="button" href='$SCRIPT_NAME?admin=&action=quickcheck'>
|
pankso@95
|
535 <img src="$IMAGES/recharge.png" />`gettext "Quick check"`</a>
|
pankso@95
|
536 <a class="button" href='$SCRIPT_NAME?admin=&action=fullcheck'>
|
pankso@95
|
537 <img src="$IMAGES/recharge.png" />`gettext "Full check"`</a>
|
pankso@95
|
538 </div>
|
pankso@95
|
539 EOT
|
pankso@95
|
540 case "$(GET action)" in
|
pankso@95
|
541 saveconf)
|
pankso@95
|
542 LOADING_MSG=$(gettext "Creating the package...")
|
pankso@95
|
543 loading_msg
|
pankso@95
|
544 echo "<pre>"
|
pankso@95
|
545 cd $HOME
|
pascal@99
|
546 tazpkg repack-config | filter_taztools_msgs
|
pankso@95
|
547 gettext "Path : " && ls $HOME/config-*.tazpkg
|
pankso@95
|
548 echo "</pre>" ;;
|
pankso@95
|
549 listconf)
|
pankso@95
|
550 echo "<h4>`gettext "Configuration files"`</h4>"
|
pankso@95
|
551 echo "<ul>"
|
pascal@102
|
552 tazpkg list-config | while read file; do
|
pascal@102
|
553 [ "${file:0:1}" == "/" ] || continue
|
pascal@102
|
554 if [ -e $file ]; then
|
pascal@102
|
555 echo "<li><a href=\"index.cgi?file=$file\">$file</a></li>"
|
pascal@102
|
556 else
|
pascal@102
|
557 echo "<li>$file</li>"
|
pascal@102
|
558 fi
|
pascal@102
|
559 done
|
pankso@95
|
560 echo "</ul>"
|
pankso@95
|
561 echo "</pre>" ;;
|
pankso@95
|
562 quickcheck)
|
pankso@95
|
563 LOADING_MSG=$(gettext "Checking packages consitency...")
|
pankso@95
|
564 loading_msg
|
pankso@95
|
565 echo "<pre>"
|
pankso@95
|
566 tazpkg check
|
pankso@95
|
567 echo "</pre>" ;;
|
pankso@95
|
568 fullcheck)
|
pankso@95
|
569 LOADING_MSG=$(gettext "Full packages check...")
|
pankso@95
|
570 loading_msg
|
pankso@95
|
571 echo "<pre>"
|
pankso@95
|
572 tazpkg check --full
|
pankso@95
|
573 echo "</pre>" ;;
|
pankso@95
|
574 esac
|
pankso@95
|
575 cat << EOT
|
pankso@95
|
576 <h3>$(gettext "Packages cache")</h3>
|
pankso@10
|
577 <div>
|
pankso@10
|
578 <form method="get" action="$SCRIPT_NAME">
|
pankso@17
|
579 <p>
|
pankso@17
|
580 `gettext "Packages in the cache:"` $cache_files ($cache_size)
|
pankso@98
|
581 <input type="hidden" name="admin" value="clean" />
|
pankso@17
|
582 <input type="submit" value="Clean" />
|
pankso@17
|
583 </p>
|
pankso@10
|
584 </form>
|
pankso@10
|
585 </div>
|
pankso@17
|
586
|
pankso@10
|
587 <h3>`gettext "Current mirror list"`</h3>
|
pankso@10
|
588 <div class="box">
|
pankso@10
|
589 <ul>
|
pankso@10
|
590 `list_mirrors`
|
pankso@10
|
591 </ul>
|
pankso@10
|
592 </div>
|
pankso@10
|
593 <form method="get" action="$SCRIPT_NAME">
|
pankso@10
|
594 <p>
|
pankso@10
|
595 <input type="hidden" name="config" value="add-mirror" />
|
pankso@10
|
596 <input type="text" name="mirror" size="60">
|
pankso@10
|
597 <input type="submit" value="Add mirror" />
|
pankso@10
|
598 </p>
|
pankso@10
|
599 </form>
|
pankso@10
|
600 EOT
|
pascal@101
|
601 version=$(cat /etc/slitaz-release)
|
pascal@101
|
602 cat << EOT
|
pascal@101
|
603
|
pascal@101
|
604 <a name="DVD"></a>
|
pascal@101
|
605 <h3>`gettext "SliTaz packages DVD"`</h3>
|
pascal@101
|
606 <p>
|
pascal@101
|
607 $(gettext "A bootable DVD image of all available packages for \
|
pascal@101
|
608 the $version version is generated every day. It also contains a copy of \
|
pascal@101
|
609 the website and can be used without an internet connection. This image can be \
|
pascal@101
|
610 installed on a DVD or an USB key.")
|
pascal@101
|
611 </p>
|
pascal@101
|
612 <div id="actions">
|
pascal@101
|
613 <form method="post" class="button" action='$SCRIPT_NAME?admin&action=dvdimage#DVD'>
|
pascal@101
|
614 <a class="button" href='http://mirror.slitaz.org/iso/$version/packages-$version.iso'>
|
pascal@101
|
615 <img src="$IMAGES/tazpkg.png" />`gettext "Download DVD image"`</a>
|
pascal@101
|
616 <a class="button" href='$SCRIPT_NAME?admin&action=dvdusbkey#DVD'>
|
pascal@101
|
617 <img src="$IMAGES/tazpkg.png" />`gettext "Install DVD/USB key"`</a>
|
pascal@101
|
618 <img src="$IMAGES/tazpkg.png" />`gettext "Install image"`
|
pascal@101
|
619 <input type="text" name="dvdimage" value="/root/packages-$version.iso">
|
pascal@101
|
620 </form>
|
pascal@101
|
621 </div>
|
pascal@101
|
622 EOT
|
pascal@101
|
623 if [ "$(GET action)" == "dvdimage" ]; then
|
pascal@101
|
624 dev=$(POST dvdimage)
|
pascal@101
|
625 mkdir -p /mnt/packages 2> /dev/null
|
pascal@101
|
626 echo "<pre>"
|
pascal@101
|
627 mount -t iso9660 -o loop,ro $dev /mnt/packages &&
|
pascal@101
|
628 /mnt/packages/install.sh &&
|
pascal@101
|
629 echo "$dev is installed on /mnt/packages"
|
pascal@101
|
630 echo "</pre>"
|
pascal@101
|
631 fi
|
pascal@101
|
632 if [ "$(GET action)" == "dvdusbkey" ]; then
|
pascal@101
|
633 mkdir -p /mnt/packages 2> /dev/null
|
pascal@101
|
634 for tag in "LABEL=\"packages-$version\" TYPE=\"iso9660\"" \
|
pascal@101
|
635 "LABEL=\"sources-$version\" TYPE=\"iso9660\"" ; do
|
pascal@101
|
636 dev=$(blkid | grep "$tag" | cut -d: -f1)
|
pascal@101
|
637 [ -n "$dev" ] || continue
|
pascal@101
|
638 echo "<pre>"
|
pascal@101
|
639 mount -t iso9660 -o ro $dev /mnt/packages &&
|
pascal@101
|
640 /mnt/packages/install.sh &&
|
pascal@101
|
641 echo "$dev is installed on /mnt/packages"
|
pascal@101
|
642 echo "</pre>"
|
pascal@101
|
643 break
|
pascal@101
|
644 done
|
pascal@101
|
645 fi
|
pankso@10
|
646 ;;
|
pankso@7
|
647 *)
|
pankso@14
|
648 #
|
pankso@7
|
649 # Default to summary
|
pankso@14
|
650 #
|
pankso@10
|
651 search_form
|
pankso@41
|
652 sidebar
|
pascal@92
|
653 PAPY
|
pascal@92
|
654 [ -n "$(GET block)" ] && tazpkg block $(GET block)
|
pascal@92
|
655 [ -n "$(GET unblock)" ] && tazpkg unblock $(GET unblock)
|
pankso@7
|
656 cat << EOT
|
pankso@9
|
657 <h2>`gettext "Summary"`</h2>
|
pankso@9
|
658 <div id="actions">
|
pankso@45
|
659 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@45
|
660 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@45
|
661 <a class="button" href='$SCRIPT_NAME?recharge'>
|
pankso@45
|
662 <img src="$IMAGES/recharge.png" />`gettext "Recharge list"`</a>
|
pankso@47
|
663 <a class="button" href='$SCRIPT_NAME?up'>
|
pankso@45
|
664 <img src="$IMAGES/update.png" />`gettext "Check upgrade"`</a>
|
pankso@95
|
665 <a class="button" href='$SCRIPT_NAME?admin'>
|
pankso@95
|
666 <img src="$IMAGES/edit.png" />`gettext "Administration"`</a>
|
pankso@9
|
667 </div>
|
pankso@41
|
668 <pre class="pre-main">
|
pankso@7
|
669 `packages_summary`
|
pankso@7
|
670 </pre>
|
pankso@41
|
671
|
pankso@10
|
672 <h3>`gettext "Latest log entries"`</h3>
|
pankso@10
|
673 <pre>
|
pankso@45
|
674 `tail -n 5 /var/log/tazpkg.log | fgrep "-" | \
|
pankso@10
|
675 awk '{print $1, $2, $3, $4, $5, $6, $7}'`
|
pankso@10
|
676 </pre>
|
pankso@7
|
677 EOT
|
pankso@10
|
678 ;;
|
pankso@7
|
679 esac
|
pankso@7
|
680
|
pankso@7
|
681 # xHTML 5 footer
|
pankso@33
|
682 xhtml_footer
|
pankso@7
|
683 exit 0
|