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 # Remove status and ESC char from tazpkg commands output
|
pankso@7
|
52 filter_tazpkg_msgs() {
|
pankso@7
|
53 grep ^[a-zA-Z0-9] | sed s'/\.*\]//'
|
pankso@7
|
54 }
|
pankso@7
|
55
|
pankso@7
|
56 # Display a full summary of packages stats
|
pankso@7
|
57 packages_summary() {
|
pankso@37
|
58 gettext "Last recharge : "
|
pankso@37
|
59 stat=`stat -c %y $LOCALSTATE/packages.list | \
|
pankso@37
|
60 sed 's/\(:..\):.*/\1/' | awk '{print $1}'`
|
pankso@37
|
61 mtime=`find /var/lib/tazpkg/packages.list -mtime +10`
|
pankso@37
|
62 echo -n "$stat "
|
pankso@37
|
63 if [ "$mtime" ]; then
|
pankso@37
|
64 echo "(Older than 10 days)"
|
pankso@37
|
65 else
|
pankso@37
|
66 echo "(Not older than 10 days)"
|
pankso@37
|
67 fi
|
pankso@8
|
68 gettext "Installed packages : "
|
pankso@7
|
69 ls $INSTALLED | wc -l
|
pankso@8
|
70 gettext "Mirrored packages : "
|
pankso@7
|
71 cat $LOCALSTATE/packages.list | wc -l
|
pankso@49
|
72 gettext "Upgradeable packages : "
|
pankso@47
|
73 cat $LOCALSTATE/packages.up | wc -l
|
pankso@44
|
74 #gettext "Installed files : "
|
pankso@44
|
75 #cat $INSTALLED/*/files.list | wc -l
|
pankso@8
|
76 gettext "Blocked packages : "
|
pankso@8
|
77 cat $LOCALSTATE/blocked-packages.list | wc -l
|
pankso@7
|
78 }
|
pankso@7
|
79
|
pankso@10
|
80 # Parse mirrors list to be able to have an icon an remove link
|
pankso@10
|
81 list_mirrors() {
|
pankso@10
|
82 cat $LOCALSTATE/mirrors | while read line
|
pankso@10
|
83 do
|
pankso@10
|
84 cat << EOT
|
pankso@10
|
85 <li><a href="$SCRIPT_NAME?config=rm-mirror=$line"><img
|
pankso@10
|
86 src="$IMAGES/clear.png" /></a><a href="$line">$line</a></li>
|
pankso@10
|
87 EOT
|
pankso@10
|
88 done
|
pankso@10
|
89 }
|
pankso@10
|
90
|
pankso@7
|
91 #
|
pankso@7
|
92 # xHTML functions
|
pankso@7
|
93 #
|
pankso@7
|
94
|
pankso@17
|
95 # ENTER will search but user may search for a button, so put one.
|
pankso@9
|
96 search_form() {
|
pankso@9
|
97 cat << EOT
|
pankso@9
|
98 <div class="search">
|
pankso@17
|
99 <form method="get" action="$SCRIPT_NAME">
|
pankso@17
|
100 <p>
|
pankso@17
|
101 <input type="text" name="search" size="20">
|
pankso@17
|
102 <input type="submit" value="`gettext "Search"`">
|
pankso@80
|
103 <input class="radius" type="submit" name="files"
|
pankso@80
|
104 value="`gettext "files"`">
|
pankso@17
|
105 </p>
|
pankso@17
|
106 </form>
|
pankso@9
|
107 </div>
|
pankso@9
|
108 EOT
|
pankso@9
|
109 }
|
pankso@9
|
110
|
pankso@17
|
111 table_head() {
|
pankso@7
|
112 cat << EOT
|
pankso@7
|
113 <tr id="thead">
|
pankso@7
|
114 <td>`gettext "Name"`</td>
|
pankso@7
|
115 <td>`gettext "Version"`</td>
|
pankso@7
|
116 <td>`gettext "Description"`</td>
|
pankso@7
|
117 <td>`gettext "Web"`</td>
|
pankso@7
|
118 </tr>
|
pankso@7
|
119 EOT
|
pankso@7
|
120 }
|
pankso@7
|
121
|
pankso@41
|
122 sidebar() {
|
pankso@7
|
123 cat << EOT
|
pankso@41
|
124 <div id="sidebar">
|
pankso@41
|
125 <h4>Categories</h4>
|
pankso@41
|
126 <a class="active_base-system" href="$SCRIPT_NAME?cat=base-system">Base-system</a>
|
pankso@41
|
127 <a class="active_x-window" href="$SCRIPT_NAME?cat=x-window">X window</a>
|
pankso@41
|
128 <a class="active_utilities" href="$SCRIPT_NAME?cat=utilities">Utilities</a>
|
pankso@41
|
129 <a class="active_network" href="$SCRIPT_NAME?cat=network">Network</a>
|
pankso@41
|
130 <a class="active_games" href="$SCRIPT_NAME?cat=games">Games</a>
|
pankso@41
|
131 <a class="active_graphics" href="$SCRIPT_NAME?cat=graphics">Graphics</a>
|
pankso@41
|
132 <a class="active_office" href="$SCRIPT_NAME?cat=office">Office</a>
|
pankso@41
|
133 <a class="active_multimedia" href="$SCRIPT_NAME?cat=multimedia">Multimedia</a>
|
pankso@41
|
134 <a class="active_developement" href="$SCRIPT_NAME?cat=development">Development</a>
|
pankso@41
|
135 <a class="active_system-tools" href="$SCRIPT_NAME?cat=system-tools">System tools</a>
|
pankso@41
|
136 <a class="active_security" href="$SCRIPT_NAME?cat=security">Security</a>
|
pankso@41
|
137 <a class="active_misc" href="$SCRIPT_NAME?cat=misc">Misc</a>
|
pankso@41
|
138 <a class="active_meta" href="$SCRIPT_NAME?cat=meta">Meta</a>
|
pankso@41
|
139 <a class="active_non-free" href="$SCRIPT_NAME?cat=non-free">Non free</a>
|
pankso@9
|
140 </div>
|
pankso@7
|
141 EOT
|
pankso@7
|
142 }
|
pankso@7
|
143
|
pankso@45
|
144 #
|
pankso@45
|
145 # Commands
|
pankso@45
|
146 #
|
pankso@45
|
147
|
pascal@81
|
148 case " $(GET) " in
|
pascal@81
|
149 *\ list\ *)
|
pankso@45
|
150 #
|
pankso@45
|
151 # List installed packages. This is the default because parsing
|
pankso@45
|
152 # the full packages.desc can be long and take some resources
|
pankso@45
|
153 #
|
pankso@45
|
154 cd $INSTALLED
|
pankso@45
|
155 search_form
|
pankso@45
|
156 sidebar
|
pankso@45
|
157 LOADING_MSG="Listing packages..."
|
pankso@45
|
158 loading_msg
|
pankso@45
|
159 cat << EOT
|
pankso@45
|
160 <h2>`gettext "My packages"`</h2>
|
pankso@45
|
161 <form method='get' action='$SCRIPT_NAME'>
|
pankso@45
|
162 <div id="actions">
|
pankso@46
|
163 <div class="float-left">
|
pankso@46
|
164 `gettext "Selection:"`
|
pankso@46
|
165 <input type="submit" name="do" value="Remove" />
|
pankso@46
|
166 </div>
|
pankso@46
|
167 <div class="float-right">
|
pankso@46
|
168 `gettext "List:"`
|
pankso@46
|
169 <input type="submit" name="recharge" value="Recharge" />
|
pankso@47
|
170 <input type="submit" name="up" value="Upgrade" />
|
pankso@46
|
171 </div>
|
pankso@41
|
172 </div>
|
pankso@7
|
173 EOT
|
pankso@7
|
174 table_start
|
pankso@41
|
175 table_head
|
pankso@7
|
176 for pkg in *
|
pankso@7
|
177 do
|
pankso@7
|
178 . $pkg/receipt
|
pankso@7
|
179 echo '<tr>'
|
pankso@7
|
180 # Use default tazpkg icon since all packages displayed are
|
pankso@7
|
181 # installed
|
pankso@7
|
182 echo "<td class='pkg'>
|
pankso@7
|
183 <input type='checkbox' name='pkg' value=\"$pkg\" />
|
pankso@7
|
184 <a href='$SCRIPT_NAME?info=$pkg'><img
|
pankso@41
|
185 src='$IMAGES/tazpkg-installed.png'/>$pkg</a></td>"
|
pankso@7
|
186 echo "<td>$VERSION</td>"
|
pankso@7
|
187 echo "<td class='desc'>$SHORT_DESC</td>"
|
pankso@7
|
188 echo "<td><a href='$WEB_SITE'>web</a></td>"
|
pankso@7
|
189 echo '</tr>'
|
pankso@7
|
190 done
|
pankso@7
|
191 table_end
|
pankso@7
|
192 echo '</form>' ;;
|
pascal@81
|
193 *\ cat\ *)
|
pankso@45
|
194 #
|
pankso@41
|
195 # List all available packages by category on mirror. Listing all
|
paul@52
|
196 # packages is too resource intensive and not useful.
|
pankso@45
|
197 #
|
pankso@9
|
198 cd $LOCALSTATE
|
pascal@81
|
199 category=$(GET cat)
|
pascal@81
|
200 [ "$category" == "cat" ] && category="base-system"
|
pankso@9
|
201 search_form
|
pankso@41
|
202 sidebar | sed s/"active_${category}"/"active"/
|
pankso@45
|
203 LOADING_MSG="Listing packages..."
|
pankso@45
|
204 loading_msg
|
pankso@9
|
205 cat << EOT
|
pankso@41
|
206 <h2>`gettext "Category:"` $category</h2>
|
pankso@9
|
207 <form method='get' action='$SCRIPT_NAME'>
|
pankso@9
|
208 <div id="actions">
|
pankso@45
|
209 <div class="float-left">
|
pankso@45
|
210 `gettext "Selection:"`
|
pankso@45
|
211 <input type="submit" name="do" value="Install" />
|
pankso@45
|
212 <input type="submit" name="do" value="Remove" />
|
pankso@45
|
213 </div>
|
pankso@45
|
214 <div class="float-right">
|
pankso@45
|
215 `gettext "List:"`
|
pankso@45
|
216 <input type="submit" name="recharge" value="Recharge" />
|
pankso@47
|
217 <input type="submit" name="up" value="Upgrade" />
|
pankso@45
|
218 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@45
|
219 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@45
|
220 </div>
|
pankso@9
|
221 EOT
|
pankso@9
|
222 echo '</div>'
|
pankso@7
|
223 table_start
|
pankso@17
|
224 table_head
|
pankso@41
|
225 grep "| $category |" packages.desc | parse_packages_desc
|
pankso@7
|
226 table_end
|
pankso@7
|
227 echo '</form>' ;;
|
pascal@81
|
228 *\ search\ *)
|
pankso@45
|
229 #
|
pankso@63
|
230 # Search for packages. Here default is to search in packages.desc
|
pankso@63
|
231 # and so get result including packages names and descriptions
|
pankso@45
|
232 #
|
pascal@81
|
233 pkg=$(GET search)
|
pankso@9
|
234 cd $LOCALSTATE
|
pankso@9
|
235 search_form
|
pankso@41
|
236 sidebar
|
pankso@45
|
237 LOADING_MSG="Searching packages..."
|
pankso@45
|
238 loading_msg
|
pankso@7
|
239 cat << EOT
|
pankso@17
|
240 <h2>`gettext "Search packages"`</h2>
|
pankso@7
|
241 <form method="get" action="$SCRIPT_NAME">
|
pankso@9
|
242 <div id="actions">
|
pankso@45
|
243 <div class="float-left">
|
pankso@45
|
244 `gettext "Selection:"`
|
pankso@45
|
245 <input type="submit" name="do" value="Install" />
|
pankso@45
|
246 <input type="submit" name="do" value="Remove" />
|
pankso@45
|
247 <a href="`cat $PANEL/lib/checkbox.js`">`gettext "Toogle all"`</a>
|
pankso@45
|
248 </div>
|
pankso@45
|
249 <div class="float-right">
|
pankso@45
|
250 `gettext "List:"`
|
pankso@45
|
251 <input type="submit" name="recharge" value="Recharge" />
|
pankso@47
|
252 <input type="submit" name="up" value="Upgrade" />
|
pankso@45
|
253 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@45
|
254 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@45
|
255 </div>
|
pankso@7
|
256 EOT
|
pankso@9
|
257 echo '</div>'
|
pankso@7
|
258 table_start
|
pascal@79
|
259 if [ "$(GET files)" ]; then
|
pascal@79
|
260 cat <<EOT
|
pascal@79
|
261 <tr id="thead">
|
pascal@79
|
262 <td>`gettext "Package"`</td>
|
pascal@79
|
263 <td>`gettext "File"`</td>
|
pascal@79
|
264 </tr>
|
pascal@83
|
265 $(unlzma -c files.list.lzma | grep -Ei ": .*$(GET search)" | \
|
pascal@84
|
266 while read PACKAGE FILE; do
|
pascal@84
|
267 PACKAGE=${PACKAGE%:}
|
pascal@84
|
268 image=tazpkg-installed.png
|
pascal@84
|
269 [ -d $INSTALLED/$PACKAGE ] || image=tazpkg.png
|
pascal@84
|
270 echo "<tr>
|
pascal@85
|
271 <td><input type='checkbox' name='pkg' value='$PACKAGE'>
|
pascal@85
|
272 <a href='$SCRIPT_NAME?info=$PACKAGE'><img src='$IMAGES/$image' />$PACKAGE</a></td>
|
pascal@84
|
273 <td>$FILE</td>
|
pascal@84
|
274 </tr>"
|
pascal@84
|
275 done)
|
pascal@79
|
276 EOT
|
pascal@79
|
277 else
|
pascal@79
|
278 table_head
|
pascal@79
|
279 grep -i $pkg packages.desc | parse_packages_desc
|
pascal@79
|
280 fi
|
pankso@7
|
281 table_end
|
pankso@7
|
282 echo '</form>' ;;
|
pascal@81
|
283 *\ recharge\ *)
|
pankso@45
|
284 #
|
pankso@7
|
285 # Let recharge the packages list
|
pankso@45
|
286 #
|
pankso@9
|
287 search_form
|
pankso@41
|
288 sidebar
|
pankso@45
|
289 LOADING_MSG="Recharging lists..."
|
pankso@45
|
290 loading_msg
|
pankso@8
|
291 cat << EOT
|
pankso@9
|
292 <h2>`gettext "Recharge"`</h2>
|
pankso@9
|
293 <form method='get' action='$SCRIPT_NAME'>
|
pankso@9
|
294 <div id="actions">
|
pankso@41
|
295 <div class="float-left">
|
pankso@41
|
296 <p>
|
pankso@45
|
297 `gettext "Recharge checks for new or updated packages"`
|
pankso@41
|
298 </p>
|
pankso@41
|
299 </div>
|
pankso@41
|
300 <div class="float-right">
|
pankso@41
|
301 <p>
|
pankso@47
|
302 <a class="button" href='$SCRIPT_NAME?up'>
|
pankso@45
|
303 `gettext "Check upgrade"`</a>
|
pankso@41
|
304 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@41
|
305 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@41
|
306 </p>
|
pankso@41
|
307 </div>
|
pankso@41
|
308 </div>
|
pankso@22
|
309 <pre>
|
pankso@8
|
310 EOT
|
pankso@76
|
311 echo "$(date +%Y%M%d-%H:%M) Recharging packages list" | log
|
pankso@8
|
312 tazpkg recharge | filter_tazpkg_msgs
|
pankso@45
|
313 cat << EOT
|
pankso@45
|
314 </pre>
|
pankso@45
|
315 <p>
|
paul@52
|
316 `gettext "Packages lists are up-to-date. You should check for upgrades now."`
|
pankso@45
|
317 </p>
|
pankso@45
|
318 EOT
|
pankso@45
|
319 ;;
|
pascal@81
|
320 *\ up\ *)
|
pankso@45
|
321 #
|
pankso@45
|
322 # Ugrade packages
|
pankso@45
|
323 #
|
pankso@9
|
324 cd $LOCALSTATE
|
pankso@9
|
325 search_form
|
pankso@41
|
326 sidebar
|
paul@52
|
327 LOADING_MSG="Checking for upgrades..."
|
pankso@45
|
328 loading_msg
|
pankso@8
|
329 cat << EOT
|
paul@52
|
330 <h2>`gettext "Up packages"`</h2>
|
pankso@8
|
331 <form method="get" action="$SCRIPT_NAME">
|
pankso@9
|
332 <div id="actions">
|
pankso@47
|
333 <div class="float-left">
|
pankso@47
|
334 `gettext "Selection:"`
|
pankso@47
|
335 <input type="submit" name="do" value="Install" />
|
pankso@47
|
336 <input type="submit" name="do" value="Remove" />
|
pankso@47
|
337 <a href="`cat $PANEL/lib/checkbox.js`">`gettext "Toogle all"`</a>
|
pankso@47
|
338 </div>
|
pankso@47
|
339 <div class="float-right">
|
pankso@47
|
340 `gettext "List:"`
|
pankso@47
|
341 <input type="submit" name="recharge" value="Recharge" />
|
pankso@47
|
342 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@47
|
343 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@47
|
344 </div>
|
pankso@45
|
345 </div>
|
pankso@8
|
346 EOT
|
pankso@47
|
347 tazpkg up --check >/dev/null
|
pankso@8
|
348 table_start
|
pankso@17
|
349 table_head
|
pankso@47
|
350 for pkg in `cat packages.up`
|
pankso@8
|
351 do
|
pankso@8
|
352 grep "^$pkg |" $LOCALSTATE/packages.desc | parse_packages_desc
|
pankso@8
|
353 done
|
pankso@8
|
354 table_end
|
pankso@8
|
355 echo '</form>' ;;
|
pascal@81
|
356 *\ do\ *)
|
pankso@45
|
357 #
|
pankso@7
|
358 # Do an action on one or some packages
|
pankso@45
|
359 #
|
pascal@81
|
360 pkgs=""
|
pascal@81
|
361 for i in $(seq 1 $(GET pkg count)); do
|
pascal@81
|
362 pkgs="$pkgs$(GET pkg $i) "
|
pascal@81
|
363 done
|
pascal@81
|
364 case "$(GET do)" in
|
pankso@41
|
365 install|Install)
|
pankso@41
|
366 cmd=get-install opt=--forced ;;
|
pankso@41
|
367 remove|Remove)
|
pankso@41
|
368 cmd=remove ;;
|
pankso@41
|
369 esac
|
pankso@9
|
370 search_form
|
pankso@41
|
371 sidebar
|
pankso@45
|
372 LOADING_MSG="${cmd}ing packages..."
|
pankso@45
|
373 loading_msg
|
pankso@9
|
374 cat << EOT
|
pankso@9
|
375 <h2>Tazpkg: $cmd</h2>
|
pankso@9
|
376 <form method="get" action="$SCRIPT_NAME">
|
pankso@9
|
377 <div id="actions">
|
pankso@41
|
378 <div class="float-left">
|
pankso@41
|
379 <p>
|
paul@52
|
380 `gettext "Performing tasks on packages"`
|
pankso@41
|
381 </p>
|
pankso@41
|
382 </div>
|
pankso@41
|
383 <div class="float-right">
|
pankso@41
|
384 <p>
|
pankso@41
|
385 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@41
|
386 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@41
|
387 </p>
|
pankso@41
|
388 </div>
|
pankso@41
|
389 </div>
|
pankso@9
|
390 EOT
|
pankso@45
|
391 echo '<div class="box">'
|
pankso@10
|
392 gettext "Executing $cmd for:$pkgs"
|
pankso@45
|
393 echo '</div>'
|
pankso@7
|
394 for pkg in $pkgs
|
pankso@7
|
395 do
|
pankso@10
|
396 echo '<pre>'
|
pankso@45
|
397 echo 'o' | tazpkg $cmd $pkg $opt 2>/dev/null | filter_tazpkg_msgs
|
pankso@7
|
398 echo '</pre>'
|
pankso@7
|
399 done ;;
|
pascal@81
|
400 *\ info\ *)
|
pankso@45
|
401 #
|
pankso@45
|
402 # Packages info
|
pankso@45
|
403 #
|
pascal@81
|
404 pkg=$(GET info)
|
pankso@9
|
405 search_form
|
pankso@41
|
406 sidebar
|
pascal@62
|
407 if [ -d $INSTALLED/$pkg ]; then
|
pascal@62
|
408 . $INSTALLED/$pkg/receipt
|
pascal@62
|
409 files=`cat $INSTALLED/$pkg/files.list | wc -l`
|
pankso@64
|
410 action=$(gettext "Remove")
|
pascal@62
|
411 else
|
pascal@62
|
412 cd $LOCALSTATE
|
pankso@64
|
413 LOADING_MSG=$(gettext "Getting package info...")
|
pankso@64
|
414 loading_msg
|
pascal@62
|
415 IFS='|'
|
pascal@62
|
416 set -- $(grep "^$pkg |" packages.desc)
|
pascal@62
|
417 unset IFS
|
pascal@62
|
418 PACKAGE=$1
|
pascal@62
|
419 VERSION="$(echo $2)"
|
pascal@62
|
420 SHORT_DESC="$(echo $3)"
|
pascal@62
|
421 CATEGORY="$(echo $4)"
|
pascal@62
|
422 WEB_SITE="$(echo $5)"
|
pankso@64
|
423 action=$(gettext "Install")
|
pascal@62
|
424 fi
|
pankso@7
|
425 cat << EOT
|
pankso@41
|
426 <h2>`gettext "Package"` $PACKAGE</h2>
|
pankso@9
|
427 <div id="actions">
|
pankso@41
|
428 <div class="float-left">
|
pankso@41
|
429 <p>
|
pankso@64
|
430 <a class="button" href='$SCRIPT_NAME?do=$action&$pkg'>$action</a>
|
pankso@41
|
431 </p>
|
pankso@41
|
432 </div>
|
pankso@41
|
433 <div class="float-right">
|
pankso@41
|
434 <p>
|
pankso@41
|
435 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@41
|
436 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@41
|
437 </p>
|
pankso@41
|
438 </div>
|
pankso@9
|
439 </div>
|
pankso@22
|
440 <pre>
|
pankso@7
|
441 Name : $PACKAGE
|
pankso@7
|
442 Version : $VERSION
|
pankso@7
|
443 Description : $SHORT_DESC
|
pankso@41
|
444 Category : $CATEGORY
|
pascal@62
|
445 EOT
|
pascal@62
|
446 if [ -d $INSTALLED/$pkg ]; then
|
pascal@62
|
447 cat << EOT
|
pankso@10
|
448 Maintainer : $MAINTAINER
|
pankso@8
|
449 Depends : `for i in $DEPENDS; do echo -n \
|
pankso@8
|
450 "<a href="$SCRIPT_NAME?info=$i">$i</a> "; done`
|
pankso@7
|
451 Website : <a href="$WEB_SITE">$WEB_SITE</a>
|
pankso@7
|
452 Sizes : $PACKED_SIZE/$UNPACKED_SIZE
|
pankso@7
|
453 </pre>
|
pankso@7
|
454
|
pankso@41
|
455 <p>`gettext "Installed files:"` `cat $INSTALLED/$pkg/files.list | wc -l`</p>
|
pankso@7
|
456 <pre>
|
pankso@7
|
457 `cat $INSTALLED/$pkg/files.list`
|
pankso@7
|
458 </pre>
|
pankso@7
|
459 EOT
|
pascal@62
|
460 else
|
pascal@62
|
461 cat << EOT
|
pascal@62
|
462 Website : <a href="$WEB_SITE">$WEB_SITE</a>
|
pascal@62
|
463 Sizes : `grep -A 3 ^$pkg$ packages.txt | tail -n 1 | sed 's/ *//'`
|
pascal@62
|
464 </pre>
|
pascal@62
|
465
|
pascal@62
|
466 <p>`gettext "Installed files:"`</p>
|
pascal@62
|
467 <pre>
|
pascal@62
|
468 `unlzma -c files.list.lzma | sed "/^$pkg: /!d;s/^$pkg: //"`
|
pascal@62
|
469 </pre>
|
pascal@62
|
470 EOT
|
pascal@62
|
471 fi
|
pankso@7
|
472 ;;
|
pascal@81
|
473 *\ config\ *)
|
pankso@45
|
474 #
|
pankso@10
|
475 # Tazpkg configuration page
|
pankso@45
|
476 #
|
pascal@81
|
477 cmd=$(GET config)
|
pankso@10
|
478 case "$cmd" in
|
pankso@10
|
479 clean)
|
pankso@10
|
480 rm -rf /var/cache/tazpkg/* ;;
|
pascal@81
|
481 add-mirror)
|
pankso@10
|
482 # Decode url
|
pascal@81
|
483 mirror=$(GET mirror)
|
pascal@81
|
484 case "$mirror" in
|
pascal@81
|
485 http://*|ftp://*)
|
pascal@81
|
486 echo "$mirror" >> $LOCALSTATE/mirrors ;;
|
pascal@81
|
487 esac ;;
|
pankso@10
|
488 rm-mirror=http://*|rm-mirror=ftp://*)
|
pascal@81
|
489 mirror=${cmd#rm-mirror=}
|
pankso@10
|
490 sed -i -e "s@$mirror@@" -e '/^$/d' $LOCALSTATE/mirrors ;;
|
pankso@10
|
491 esac
|
pankso@10
|
492 cache_files=`find /var/cache/tazpkg -name *.tazpkg | wc -l`
|
pankso@10
|
493 cache_size=`du -sh /var/cache/tazpkg`
|
pankso@41
|
494 sidebar
|
pankso@10
|
495 cat << EOT
|
pankso@10
|
496 <h2>`gettext "Configuration"`</h2>
|
pankso@10
|
497 <div>
|
pankso@10
|
498 <p>`gettext "Tazpkg configuration and settings"`</p>
|
pankso@10
|
499 </div>
|
pankso@10
|
500 <div>
|
pankso@10
|
501 <form method="get" action="$SCRIPT_NAME">
|
pankso@17
|
502 <p>
|
pankso@17
|
503 `gettext "Packages in the cache:"` $cache_files ($cache_size)
|
pankso@17
|
504 <input type="hidden" name="config" value="clean" />
|
pankso@17
|
505 <input type="submit" value="Clean" />
|
pankso@17
|
506 </p>
|
pankso@10
|
507 </form>
|
pankso@10
|
508 </div>
|
pankso@17
|
509
|
pankso@10
|
510 <h3>`gettext "Current mirror list"`</h3>
|
pankso@10
|
511 <div class="box">
|
pankso@10
|
512 <ul>
|
pankso@10
|
513 `list_mirrors`
|
pankso@10
|
514 </ul>
|
pankso@10
|
515 </div>
|
pankso@10
|
516 <form method="get" action="$SCRIPT_NAME">
|
pankso@10
|
517 <p>
|
pankso@10
|
518 <input type="hidden" name="config" value="add-mirror" />
|
pankso@10
|
519 <input type="text" name="mirror" size="60">
|
pankso@10
|
520 <input type="submit" value="Add mirror" />
|
pankso@10
|
521 </p>
|
pankso@10
|
522 </form>
|
pankso@10
|
523 EOT
|
pankso@10
|
524 ;;
|
pankso@7
|
525 *)
|
pankso@14
|
526 #
|
pankso@7
|
527 # Default to summary
|
pankso@14
|
528 #
|
pankso@10
|
529 search_form
|
pankso@41
|
530 sidebar
|
pankso@7
|
531 cat << EOT
|
pankso@9
|
532 <h2>`gettext "Summary"`</h2>
|
pankso@9
|
533 <div id="actions">
|
pankso@45
|
534 <a class="button" href='$SCRIPT_NAME?list'>
|
pankso@45
|
535 <img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
|
pankso@45
|
536 <a class="button" href='$SCRIPT_NAME?recharge'>
|
pankso@45
|
537 <img src="$IMAGES/recharge.png" />`gettext "Recharge list"`</a>
|
pankso@47
|
538 <a class="button" href='$SCRIPT_NAME?up'>
|
pankso@45
|
539 <img src="$IMAGES/update.png" />`gettext "Check upgrade"`</a>
|
pankso@45
|
540 <a class="button" href='$SCRIPT_NAME?config'>
|
pankso@45
|
541 <img src="$IMAGES/edit.png" />`gettext "Configuration"`</a>
|
pankso@9
|
542 </div>
|
pankso@41
|
543 <pre class="pre-main">
|
pankso@7
|
544 `packages_summary`
|
pankso@7
|
545 </pre>
|
pankso@41
|
546
|
pankso@10
|
547 <h3>`gettext "Latest log entries"`</h3>
|
pankso@10
|
548 <pre>
|
pankso@45
|
549 `tail -n 5 /var/log/tazpkg.log | fgrep "-" | \
|
pankso@10
|
550 awk '{print $1, $2, $3, $4, $5, $6, $7}'`
|
pankso@10
|
551 </pre>
|
pankso@10
|
552
|
pascal@86
|
553 <a name="administration"></a>
|
pascal@86
|
554 <h3>`gettext "Administration"`</h3>
|
pascal@86
|
555 <div id="actions">
|
pascal@86
|
556 <a class="button" href='$SCRIPT_NAME?action=saveconf#administration'>
|
pascal@86
|
557 <img src="$IMAGES/tazpkg.png" />`gettext "Save configuration files"`</a>
|
pascal@86
|
558 <a class="button" href='$SCRIPT_NAME?action=listconf#administration'>
|
pascal@86
|
559 <img src="$IMAGES/edit.png" />`gettext "List configuration files"`</a>
|
pascal@86
|
560 <a class="button" href='$SCRIPT_NAME?action=quickcheck#administration'>
|
pascal@86
|
561 <img src="$IMAGES/recharge.png" />`gettext "Quick check"`</a>
|
pascal@86
|
562 <a class="button" href='$SCRIPT_NAME?action=fullcheck#administration'>
|
pascal@86
|
563 <img src="$IMAGES/recharge.png" />`gettext "Full check"`</a>
|
pascal@86
|
564 </div>
|
pascal@86
|
565
|
pankso@7
|
566 EOT
|
pascal@86
|
567 case "$(GET action)" in
|
pascal@86
|
568 saveconf)
|
pascal@86
|
569 echo "<pre>"
|
pascal@86
|
570 cd $HOME
|
pascal@86
|
571 tazpkg repack-config | sed 's/.\[[^mG]*.//g'
|
pascal@86
|
572 ls -l $HOME/config-*.tazpkg
|
pascal@86
|
573 echo "</pre>" ;;
|
pascal@86
|
574 listconf)
|
pascal@86
|
575 echo "<h4>`gettext "Configuration files"`</h4>"
|
pascal@86
|
576 echo "<ul>"
|
pascal@86
|
577 tazpkg list-config | sed \
|
pascal@86
|
578 '/^\//!d;s/.*/<li><a href="index.cgi?file=&">&<\/a><\/li>/'
|
pascal@86
|
579 echo "</ul>"
|
pascal@86
|
580 echo "</pre>" ;;
|
pascal@86
|
581 quickcheck)
|
pascal@86
|
582 echo "<pre>"
|
pascal@86
|
583 tazpkg check
|
pascal@86
|
584 echo "</pre>" ;;
|
pascal@86
|
585 fullcheck)
|
pascal@86
|
586 echo "<pre>"
|
pascal@86
|
587 tazpkg check --full
|
pascal@86
|
588 echo "</pre>" ;;
|
pascal@86
|
589 esac
|
pankso@10
|
590 ;;
|
pankso@7
|
591 esac
|
pankso@7
|
592
|
pankso@7
|
593 # xHTML 5 footer
|
pankso@33
|
594 xhtml_footer
|
pankso@7
|
595 exit 0
|