rev |
line source |
pascal@627
|
1 #!/bin/sh
|
pascal@627
|
2 #
|
al@633
|
3 # TazPkg CGI interface - Manage packages via a browser
|
pascal@627
|
4 #
|
pascal@627
|
5 # This CGI interface extensively uses tazpkg to manage packages and have
|
pascal@627
|
6 # its own code for some tasks. Please KISS, it is important and keep speed
|
pascal@627
|
7 # in mind. Thanks, Pankso.
|
pascal@627
|
8 #
|
al@755
|
9 # (C) 2011-2015 SliTaz GNU/Linux - BSD License
|
pascal@627
|
10 #
|
pascal@627
|
11
|
pascal@627
|
12 . lib/libtazpanel
|
al@725
|
13
|
al@725
|
14 . /etc/slitaz/slitaz.conf
|
al@725
|
15 . /etc/slitaz/tazpkg.conf
|
al@725
|
16
|
al@776
|
17 export TEXTDOMAIN='tazpkg'
|
al@776
|
18
|
pascal@627
|
19 get_config
|
pascal@627
|
20
|
al@741
|
21 _() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; echo; }
|
al@741
|
22 _n() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; }
|
al@741
|
23 _p() {
|
al@763
|
24 local S="$1" P="$2" N="$3"; shift 3;
|
al@741
|
25 printf "$(ngettext "$S" "$P" "$N")" "$@"; }
|
al@741
|
26
|
al@776
|
27
|
pascal@764
|
28 #------
|
pascal@764
|
29 # menu
|
pascal@764
|
30 #------
|
al@776
|
31
|
pascal@764
|
32 case "$1" in
|
pascal@764
|
33 menu)
|
pascal@764
|
34 TEXTDOMAIN_original=$TEXTDOMAIN
|
pascal@764
|
35 export TEXTDOMAIN='tazpkg'
|
pascal@764
|
36
|
pascal@764
|
37 cat <<EOT
|
pascal@764
|
38 <li tabindex="0">
|
pascal@764
|
39 <span>$(gettext 'Packages')</span>
|
pascal@764
|
40 <menu>
|
pascal@771
|
41 <li><a data-icon="info" href="pkgs.cgi">$(gettext 'Summary')</a></li>
|
pascal@771
|
42 <li><a data-icon="list" href="pkgs.cgi?list&my=my&cat=all&repo=Any">$(gettext 'My packages')</a></li>
|
pascal@771
|
43 <li><a data-icon="refresh" href="pkgs.cgi?recharge" data-root>$(gettext 'Recharge list')</a></li>
|
pascal@771
|
44 <li><a data-icon="upgrade" href="pkgs.cgi?up" data-root>$(gettext 'Check updates')</a></li>
|
pascal@771
|
45 <li><a data-icon="admin" href="pkgs.cgi?admin" data-root>$(gettext 'Administration')</a></li>
|
pascal@764
|
46 </menu>
|
pascal@764
|
47 </li>
|
pascal@764
|
48 EOT
|
pascal@764
|
49 export TEXTDOMAIN=$TEXTDOMAIN_original
|
pascal@764
|
50 exit
|
pascal@764
|
51 esac
|
pascal@764
|
52
|
al@776
|
53
|
al@707
|
54
|
al@786
|
55 #
|
al@776
|
56 # AJAX commands
|
al@786
|
57 #
|
al@776
|
58
|
al@776
|
59 case " $(GET) " in
|
al@776
|
60
|
al@776
|
61
|
al@776
|
62 *\ filelist\ * )
|
al@776
|
63 # Show installed files list
|
al@776
|
64 pkg=$(GET pkg)
|
al@776
|
65 cd $PKGS_DB
|
al@776
|
66
|
al@786
|
67 header
|
al@776
|
68 if [ -d $INSTALLED/$pkg ]; then
|
al@776
|
69 files="$(wc -l < $INSTALLED/$pkg/files.list)"
|
al@785
|
70 cat <<EOT
|
al@776
|
71 <pre class="scroll">$(sort $INSTALLED/$pkg/files.list)</pre>
|
al@776
|
72 <footer>$(_p '%s file' '%s files' $files $files)</footer>
|
al@776
|
73 EOT
|
al@776
|
74 else
|
al@785
|
75 cat <<EOT
|
al@776
|
76 <pre class="scroll">$(lzcat files.list.lzma undigest/*/files.list.lzma \
|
al@776
|
77 2>/dev/null | awk -vp="$pkg:" '$1==p{print $2}' | sort)</pre>
|
al@776
|
78 EOT
|
al@776
|
79 fi
|
al@776
|
80 exit 0 ;;
|
al@776
|
81
|
al@776
|
82
|
al@776
|
83 *\ status\ * )
|
al@776
|
84 # Show package status
|
al@776
|
85 pkg=$(GET pkg)
|
al@776
|
86 class='pkg'
|
al@776
|
87
|
al@778
|
88 if grep -q "^$pkg"$'\t' $PKGS_DB/installed.info; then
|
al@776
|
89 class='pkgi'
|
al@778
|
90 grep -q "^$pkg$" $PKGS_DB/blocked-packages.list && class='pkgib'
|
al@776
|
91 fi
|
al@776
|
92
|
al@786
|
93 header
|
al@779
|
94 echo -n "<a data-icon=\"$class\" href=\"?info=${pkg//+/%2B}\">$pkg</a>"
|
al@776
|
95 exit 0 ;;
|
al@776
|
96
|
al@786
|
97 *\ app_img\ * )
|
al@786
|
98 # Show application image
|
al@786
|
99 pkg=$(GET app_img)
|
al@786
|
100 current_user="$(who | cut -d' ' -f1)"
|
al@786
|
101 if [ -n "$current_user" ]; then
|
al@786
|
102 current_user_home="$(awk -F: -vu=$current_user '{if($1==u) print $6}' /etc/passwd)"
|
al@786
|
103 current_icon_theme="/usr/share/icons/$(grep gtk-icon-theme-name $current_user_home/.gtkrc-2.0 | cut -d'"' -f2)"
|
al@786
|
104 default_pkg_icon="$(find -L $current_icon_theme -type f -path '*48*' -name 'package-x-generic.png' | head -n1)"
|
al@786
|
105 pkg_icon="$(find -L $current_icon_theme -type f -path '*48*' -name "$pkg.png" | head -n1)"
|
al@786
|
106 if [ -z "$pkg_icon" ]; then
|
al@786
|
107 pkg_icon="$(find -L /usr/share/pixmaps -type f -name "$pkg.png" | head -n1)"
|
al@786
|
108 fi
|
al@786
|
109
|
al@786
|
110 header "Content-Type: image/png"
|
al@786
|
111 cat "${pkg_icon:-$default_pkg_icon}"
|
al@786
|
112 else
|
al@786
|
113 default_pkg_icon="$(find -L /usr/share/icons -type f -name 'package-x-generic.png' | sort | tail -n1)"
|
al@786
|
114 fi
|
al@786
|
115 exit 0 ;;
|
al@786
|
116
|
al@786
|
117 *\ show_receipt\ * )
|
al@786
|
118 # Show package receipt
|
al@786
|
119 pkg=$(GET show_receipt)
|
al@786
|
120 if [ -d "$INSTALLED/$pkg" ]; then
|
al@786
|
121 # Redirects to the receipt view
|
al@786
|
122 header "HTTP/1.1 301 Moved Permanently" "Location: index.cgi?file=$INSTALLED/$pkg/receipt"
|
al@786
|
123 exit 0
|
al@786
|
124 else
|
al@786
|
125 temp_receipt=$(mktemp -d)
|
al@786
|
126 wget -O $temp_receipt/receipt -T 5 http://hg.slitaz.org/wok/raw-file/tip/$pkg/receipt
|
al@786
|
127 if [ -e "$temp_receipt" ]; then
|
al@786
|
128 # Redirects to the receipt view
|
al@786
|
129 header "HTTP/1.1 301 Moved Permanently" "Location: index.cgi?file=$temp_receipt/receipt"
|
al@786
|
130 exit 0
|
al@786
|
131 else
|
al@786
|
132 header; xhtml_header
|
al@786
|
133 msg err "$(_ 'Receipt for package %s unavailable' $pkg)"
|
al@786
|
134 xhtml_footer
|
al@786
|
135 exit 0
|
al@786
|
136 fi
|
al@786
|
137 fi
|
al@786
|
138 ;;
|
al@786
|
139
|
al@776
|
140 esac
|
al@776
|
141
|
al@776
|
142
|
al@786
|
143 header
|
al@786
|
144
|
al@786
|
145
|
pascal@627
|
146 # xHTML 5 header with special side bar for categories.
|
al@707
|
147 TITLE=$(TEXTDOMAIN='tazpkg'; _ 'TazPanel - Packages')
|
pascal@627
|
148 xhtml_header | sed 's/id="content"/id="content-sidebar"/'
|
pascal@627
|
149
|
al@707
|
150
|
al@761
|
151 pkg_info_link() {
|
al@758
|
152 echo "<a data-icon=\"$2\" href=\"?info=${1//+/%2B}\">$1</a>" | sed 's| data-icon=""||'
|
pascal@627
|
153 }
|
pascal@627
|
154
|
al@707
|
155
|
al@718
|
156 # Display localized short description
|
al@718
|
157
|
pascal@627
|
158 i18n_desc() {
|
al@717
|
159 for L in $LANG ${LANG%%_*}; do
|
al@717
|
160 if [ -e "$PKGS_DB/packages-desc.$L" ]; then
|
al@718
|
161 LOCDESC=$(awk -F$'\t' -vp=$1 '{if ($1 == p) print $2}' $PKGS_DB/packages-desc.$L)
|
al@717
|
162 if [ -n "$LOCDESC" ]; then
|
al@717
|
163 SHORT_DESC="$LOCDESC"
|
al@717
|
164 break
|
al@717
|
165 fi
|
al@717
|
166 fi
|
al@717
|
167 done
|
pascal@627
|
168 }
|
pascal@627
|
169
|
al@707
|
170
|
pascal@627
|
171 # We need packages information for list and search
|
al@707
|
172
|
pascal@627
|
173 parse_packages_desc() {
|
pascal@627
|
174 IFS="|"
|
al@762
|
175 cut -f 1,2,3 -d "|" | while read PACKAGE VERSION SHORT_DESC
|
pascal@627
|
176 do
|
al@718
|
177 class=pkg; [ -d $INSTALLED/${PACKAGE% } ] && class=pkgi
|
al@718
|
178 i18n_desc $PACKAGE
|
al@785
|
179 cat <<EOT
|
pascal@627
|
180 <tr>
|
al@755
|
181 <td><input type="checkbox" name="pkg" value="$PACKAGE">$(pkg_info_link $PACKAGE $class)</td>
|
al@755
|
182 <td>$VERSION</td>
|
al@755
|
183 <td>$SHORT_DESC</td>
|
al@718
|
184 </tr>
|
al@718
|
185 EOT
|
al@718
|
186 done
|
al@718
|
187 unset IFS
|
al@718
|
188 }
|
al@718
|
189
|
al@718
|
190
|
al@718
|
191 parse_packages_info() {
|
al@718
|
192 IFS=$'\t'
|
al@718
|
193 while read PACKAGE VERSION CATEGORY SHORT_DESC WEB_SITE TAGS SIZES DEPENDS; do
|
al@763
|
194 class='pkg'
|
al@763
|
195 if grep -q "^$PACKAGE"$'\t' $PKGS_DB/installed.info; then
|
al@763
|
196 class='pkgi'
|
al@763
|
197 grep -q "^$PACKAGE$" $PKGS_DB/blocked-packages.list && class='pkgib'
|
al@763
|
198 fi
|
al@718
|
199 i18n_desc $PACKAGE
|
al@785
|
200 cat <<EOT
|
al@718
|
201 <tr>
|
al@755
|
202 <td><input type="checkbox" name="pkg" value="$PACKAGE">$(pkg_info_link $PACKAGE $class)</td>
|
al@755
|
203 <td>$VERSION</td>
|
al@755
|
204 <td>$SHORT_DESC</td>
|
pascal@627
|
205 </tr>
|
pascal@627
|
206 EOT
|
pascal@627
|
207 done
|
pascal@627
|
208 unset IFS
|
pascal@627
|
209 }
|
pascal@627
|
210
|
al@707
|
211
|
al@724
|
212 # Show button
|
al@724
|
213 show_button() {
|
al@747
|
214 for button in $@; do
|
al@768
|
215 class=''; misc=''
|
al@747
|
216 case $button in
|
al@768
|
217 recharge) class='refresh'; label="$(_ 'Recharge list')"; misc=' data-root' ;;
|
al@768
|
218 up) class='upgrade'; label="$(_ 'Check upgrades')"; misc=' data-root' ;;
|
al@755
|
219 list) class='list'; label="$(_ 'My packages')" ;;
|
al@755
|
220 tags) class='tags'; label="$(_ 'Tags')" ;;
|
al@755
|
221 linkable) class='link'; label="$(_ 'Linkable packages')" ;;
|
al@768
|
222 admin) class='admin'; label="$(_ 'Administration')"; misc=' data-root' ;;
|
al@755
|
223 *Install*nf*) class='install'; label="$(_ 'Install (Non Free)')" ;;
|
al@755
|
224 *Install*) class='install'; label="$(_ 'Install')" ;;
|
al@755
|
225 *Remove*) class='remove'; label="$(_ 'Remove')" ;;
|
al@755
|
226 *Link*) class='link'; label="$(_ 'Link')" ;;
|
al@755
|
227 *Block*) class='lock'; label="$(_ 'Block')" ;;
|
al@755
|
228 *Unblock*) class='unlock'; label="$(_ 'Unblock')" ;;
|
al@762
|
229 *Chblock*) class='chlock'; label="$(_ '(Un)block')" ;;
|
al@755
|
230 *Repack*) class='repack'; label="$(_ 'Repack')" ;;
|
al@755
|
231 *saveconf*) class='save'; label="$(_ 'Save configuration')" ;;
|
al@755
|
232 *listconf*) class='list'; label="$(_ 'List configuration files')" ;;
|
al@755
|
233 *quickcheck*) class='check'; label="$(_ 'Quick check')" ;;
|
al@755
|
234 *fullcheck*) class='check'; label="$(_ 'Full check')" ;;
|
al@755
|
235 *clean*) class='remove'; label="$(_ 'Clean')" ;;
|
al@755
|
236 *setlink*) class='link'; label="$(_ 'Set link')" ;;
|
al@755
|
237 *removelink*) class='unlink'; label="$(_ 'Remove link')" ;;
|
al@755
|
238 *add-mirror) class='add'; label="$(_n 'Add mirror')" ;;
|
al@755
|
239 *add-repo) class='add'; label="$(_n 'Add repository')" ;;
|
al@762
|
240 toggle) class='toggle'; label="$(_n 'Toggle all')" ;;
|
al@747
|
241 esac
|
al@762
|
242 if [ "$button" == 'toggle' ]; then
|
al@762
|
243 echo -n "<span class=\"float-right\"><button data-icon=\"$class\" onclick=\"checkBoxes()\">$label</button></span>"
|
al@762
|
244 else
|
al@768
|
245 echo -n "<button data-icon=\"$class\" name=\"${button%%=*}\" value=\"${button#*=}\"$misc>$label</button>"
|
al@755
|
246 fi
|
al@747
|
247 done
|
al@724
|
248 }
|
al@724
|
249
|
al@724
|
250
|
al@707
|
251
|
pascal@627
|
252 #
|
pascal@627
|
253 # xHTML functions
|
pascal@627
|
254 #
|
pascal@627
|
255
|
al@707
|
256
|
pascal@627
|
257 # ENTER will search but user may search for a button, so put one.
|
al@707
|
258
|
pascal@627
|
259 search_form() {
|
al@785
|
260 cat <<EOT
|
al@755
|
261 <form class="search"><!--
|
al@755
|
262 --><input type="search" name="search" results="5" autosave="pkgsearch" autocomplete="on"><!--
|
al@755
|
263 --><button type="submit">$(_n 'Search')</button><!--
|
al@759
|
264 --><button name="files" value="yes">$(_n 'Files')</button><!--
|
al@755
|
265 --></form>
|
pascal@627
|
266 EOT
|
pascal@627
|
267 }
|
pascal@627
|
268
|
al@707
|
269
|
pascal@627
|
270 table_head() {
|
al@785
|
271 cat <<EOT
|
al@755
|
272 <table class="wide zebra pkglist" id="head1">
|
al@755
|
273 <thead id="head2">
|
pascal@627
|
274 <tr>
|
al@707
|
275 <td>$(_ 'Name')</td>
|
al@707
|
276 <td>$(_ 'Version')</td>
|
al@707
|
277 <td>$(_ 'Description')</td>
|
pascal@627
|
278 </tr>
|
al@736
|
279 </thead>
|
al@736
|
280 <tbody>
|
pascal@627
|
281 EOT
|
pascal@627
|
282 }
|
pascal@627
|
283
|
al@707
|
284
|
pascal@627
|
285 sidebar() {
|
al@744
|
286 repo=$(COOKIE repo); repo=${repo:-Public}; [ -n "$(GET repo)" ] && repo=$(GET repo)
|
al@744
|
287 my=$(COOKIE my); my=${my:-my}; [ -n "$(GET my)" ] && my=$(GET my)
|
al@744
|
288 cat=$(COOKIE cat); cat=${cat:-all}; [ -n "$(GET cat)" ] && cat=$(GET cat)
|
al@737
|
289
|
al@785
|
290 cat <<EOT
|
al@744
|
291 <script type="text/javascript">
|
al@744
|
292 function setCookie(name) {
|
al@763
|
293 if (name=='cat') {
|
al@763
|
294 var cats = document.getElementsByName('cat');
|
al@763
|
295 for (var i = 0; i < cats.length; i++) {
|
al@763
|
296 if (cats[i].checked) {
|
al@763
|
297 document.cookie = name + "=" + cats[i].value;
|
al@763
|
298 break;
|
al@763
|
299 }
|
al@763
|
300 }
|
al@763
|
301 } else {
|
al@763
|
302 document.cookie = name+"="+document.getElementById(name).value;
|
al@763
|
303 }
|
al@763
|
304 }
|
al@744
|
305 function setValue(name, value) {
|
al@744
|
306 document.getElementById(name).value=value;
|
al@763
|
307 setCookie(name);
|
al@763
|
308 }
|
al@744
|
309 </script>
|
al@744
|
310 <form method="post" action="?list">
|
al@737
|
311
|
pascal@627
|
312 <div id="sidebar">
|
al@744
|
313 <select id="my" value="$my" onchange="setCookie('my'); this.form.submit()">
|
al@738
|
314 <option value="my">$(_ 'My packages')</option>
|
al@741
|
315 <option value="no">$(_ 'All packages')</option>
|
al@737
|
316 </select>
|
al@763
|
317 <script type="text/javascript">setValue('my', "$my")</script>
|
al@737
|
318
|
al@737
|
319 <h4>$(_ 'Categories')</h4>
|
al@737
|
320
|
al@763
|
321 <div class="wide zebra">
|
al@763
|
322 $(echo 'base-system x-window utilities network games graphics office
|
al@763
|
323 multimedia development system-tools security misc meta non-free all
|
al@763
|
324 extra' | tr ' ' '\n' | awk -vcat="$cat" -vn="1" '{
|
al@763
|
325 system("gettext " $1 | getline tr)
|
al@763
|
326 printf "<input type=\"radio\" name=\"cat\" id=\"c%s\" ", n
|
al@763
|
327 printf "value=\"%s\"%s ", $1, $1==cat?" checked":""
|
al@763
|
328 printf "onclick=\"setCookie('cat'); this.form.submit()\">"
|
al@763
|
329 printf "<label for=\"c%s\">%s</label>\n", n, tr
|
al@763
|
330 n++
|
al@763
|
331 }')
|
al@738
|
332 </div>
|
pascal@627
|
333 EOT
|
pascal@783
|
334 #reminder; gettext 'all'; gettext 'extra'
|
pascal@627
|
335
|
al@700
|
336 if [ -d $PKGS_DB/undigest ]; then
|
al@785
|
337 cat <<EOT
|
al@737
|
338 <h4>$(_ 'Repository')</h4>
|
al@707
|
339
|
al@744
|
340 <select id="repo" onchange="setCookie('repo')">
|
al@738
|
341 <option value="Public">$(_ 'Public')</option>
|
al@737
|
342 $(for i in $(ls $PKGS_DB/undigest); do
|
al@738
|
343 echo "<option value=\"$i\">$i</option>"
|
al@737
|
344 done)
|
al@738
|
345 <option value="Any">$(_ 'Any')</option>
|
al@737
|
346 </select>
|
al@744
|
347 <script type="text/javascript">setValue('repo', "$repo")</script>
|
al@741
|
348 EOT
|
al@741
|
349 fi
|
al@785
|
350 cat <<EOT
|
al@755
|
351 <a data-icon="tags" href="?tags">$(_ 'All tags...')</a><br/>
|
al@755
|
352 <a data-icon="list" href="?cats">$(_ 'All categories...')</a>
|
al@741
|
353 </div>
|
al@742
|
354 </form>
|
pascal@627
|
355 EOT
|
pascal@627
|
356 }
|
pascal@627
|
357
|
al@707
|
358
|
pascal@627
|
359 repo_list() {
|
al@700
|
360 if [ -n "$(ls $PKGS_DB/undigest/ 2> /dev/null)" ]; then
|
pascal@627
|
361 case "$repo" in
|
al@707
|
362 Public)
|
al@707
|
363 ;;
|
al@707
|
364 ""|Any)
|
al@707
|
365 for i in $PKGS_DB/undigest/* ; do
|
al@707
|
366 [ -d "$i" ] && echo "$i$1"
|
al@707
|
367 done ;;
|
al@707
|
368 *)
|
al@707
|
369 echo "$PKGS_DB/undigest/$repo$1"
|
al@707
|
370 return ;;
|
pascal@627
|
371 esac
|
pascal@627
|
372 fi
|
al@700
|
373 echo "$PKGS_DB$1"
|
pascal@627
|
374 }
|
pascal@627
|
375
|
al@707
|
376
|
pascal@627
|
377 repo_name() {
|
pascal@627
|
378 case "$1" in
|
al@707
|
379 $PKGS_DB)
|
al@707
|
380 echo "Public" ;;
|
al@707
|
381 $PKGS_DB/undigest/*)
|
al@707
|
382 echo ${1#$PKGS_DB/undigest/} ;;
|
pascal@627
|
383 esac
|
pascal@627
|
384 }
|
pascal@627
|
385
|
al@726
|
386
|
al@744
|
387 header_repo_name() {
|
al@744
|
388 [ -d $PKGS_DB/undigest ] && [ "$repo" != "Public" ] && \
|
al@755
|
389 _ 'Repository: %s' $(repo_name $1)
|
al@744
|
390 }
|
al@744
|
391
|
al@744
|
392
|
al@726
|
393 # Print links to the pages
|
al@726
|
394
|
al@726
|
395 pager() {
|
al@747
|
396 PAGE_SIZE=${PAGE_SIZE:-100}
|
al@747
|
397 [ "$PAGE_SIZE" != "0" ] && \
|
al@747
|
398 awk -F'"' -vpage="$page" -vsize="$PAGE_SIZE" -vnum_lines="$(wc -l < $1)" -vtext="$(_ 'Pages:') " -vurl="?list&page=" '
|
al@726
|
399 BEGIN{
|
al@747
|
400 num_pages = int(num_lines / size) + (num_lines % size != 0)
|
al@726
|
401 if (num_pages != 1) printf "<p>%s", text
|
al@726
|
402 }
|
al@726
|
403 {
|
al@726
|
404 if (num_pages == 1) exit
|
al@747
|
405 r = NR % size
|
al@728
|
406 if (r == 1) {
|
al@747
|
407 p = int(NR / size) + 1
|
al@761
|
408 printf "<button class=\"pages%s\" name=\"page\" value=\"%s\" title=\"%s\n···\n", p==page?" current":"", p, $6
|
al@728
|
409 } else if (r == 0)
|
al@761
|
410 printf "%s\">%s</button> ", $6, int(NR / size)
|
al@726
|
411 }
|
al@726
|
412 END{
|
al@726
|
413 if (num_pages == 1) exit
|
al@761
|
414 if (r != 0) printf "%s\">%s</button>", $6, int(NR / size) + 1
|
al@726
|
415 print "</p>"
|
al@726
|
416 }' $1
|
al@726
|
417 }
|
al@726
|
418
|
al@726
|
419
|
al@736
|
420 # Show packages list by category or tag
|
al@736
|
421
|
al@736
|
422 show_list() {
|
al@747
|
423 PAGE_SIZE=${PAGE_SIZE:-100}
|
al@747
|
424 page=$(GET page); page=${page:-1}
|
al@736
|
425 cached=$(mktemp)
|
al@744
|
426 [ -n "$tag" ] && cat=''
|
al@736
|
427 {
|
al@736
|
428 for L in $LANG ${LANG%%_*}; do
|
al@736
|
429 if [ -e "$PKGS_DB/packages-desc.$L" ]; then
|
al@736
|
430 sed '/^#/d' $PKGS_DB/packages-desc.$L; break
|
al@736
|
431 fi
|
al@736
|
432 done
|
al@736
|
433 [ -e "$i/blocked-packages.list" ] && cat $i/blocked-packages.list
|
al@736
|
434 sed 's|.*|&\ti|' $i/installed.info
|
al@744
|
435 [ "$cat" == 'extra' ] || [ $1 == 'my' ] || cat $i/packages.info
|
pascal@760
|
436 [ "$cat" == 'extra' ] &&
|
pascal@760
|
437 sed 's,\([^|]*\)|*\([^|]*\).*,\1\t-\textra\t\2\thttp://mirror.slitaz.org/packages/get/\1\t-\t-\t-,' $PKGS_DB/extra.list
|
al@744
|
438 } | sort -t$'\t' -k1,1 | sed '/^$/d' | awk -F$'\t' -vc="${cat:--}" -vt="${tag:--}" '
|
al@736
|
439 {
|
al@736
|
440 if (PKG && PKG != $1) {
|
al@736
|
441 if (SEL) {
|
al@736
|
442 if (DSCL) DSC = DSCL
|
al@761
|
443 printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\" id=\"%s\">", PKG, PKG
|
al@761
|
444 printf "<a data-icon=\"pkg%s%s\" href=\"?info=%s\">%s</a></td>", INS, BLK, gensub(/\+/, "%2B", "g", PKG), PKG
|
al@761
|
445 printf "<td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", VER, DSC, WEB
|
al@736
|
446 }
|
al@736
|
447 VER = DSC = WEB = DSCL = INS = BLK = SEL = ""
|
al@736
|
448 }
|
al@736
|
449
|
al@736
|
450 PKG = $1
|
al@736
|
451 if (NF == 1) { BLK = "b"; next }
|
al@736
|
452 if (NF == 2) { DSCL = $2; next }
|
al@736
|
453 if (c == "all" || $3 == c || index(" "$6" ", " "t" ")) { SEL = 1 }
|
al@736
|
454 if (SEL) {
|
al@736
|
455 if ($9 == "i") { VER = $2; DSC = $4; WEB = $5; INS = "i"; next}
|
al@736
|
456 if (! INS) { VER = $2; DSC = $4; WEB = $5 }
|
al@736
|
457 }
|
al@736
|
458 }' > $cached
|
al@736
|
459
|
al@736
|
460 pager="$(pager $cached)"
|
al@747
|
461 case $PAGE_SIZE in
|
al@747
|
462 0) list="$(cat $cached)";;
|
al@747
|
463 *) list="$(tail -n+$((($page-1)*$PAGE_SIZE+1)) $cached | head -n$PAGE_SIZE)";;
|
al@747
|
464 esac
|
al@747
|
465
|
al@747
|
466 if [ "$pager" != "<p>$(_ 'Pages:') </p>" ] && [ -n "${list:1:1}" ]; then
|
al@785
|
467 cat <<EOT
|
al@755
|
468 <h3>$(header_repo_name $i)</h3>
|
al@744
|
469 $pager
|
al@744
|
470 $(table_head)
|
al@744
|
471 $list
|
al@744
|
472 </tbody></table>
|
al@744
|
473 $pager
|
al@744
|
474 EOT
|
al@737
|
475 fi
|
al@736
|
476 rm -f $cached
|
al@761
|
477
|
al@761
|
478
|
al@761
|
479 ### Re-select packages when you return to the page
|
al@761
|
480
|
al@761
|
481 # Find the packages list
|
al@761
|
482 pkgs=$(echo "$QUERY_STRING&" | awk 'BEGIN{RS="&";FS="="}
|
al@761
|
483 {if ($1=="pkg") printf "\"%s\", ", $2}')
|
al@761
|
484 pkgs=$(httpd -d "${pkgs%, }")
|
al@761
|
485 # now pkgs='"pkg1", "pkg2", ... "pkgn"'
|
al@761
|
486
|
al@761
|
487 if [ -n "$pkgs" ]; then
|
al@785
|
488 cat <<EOT
|
al@761
|
489 <script type="text/javascript">
|
al@761
|
490 var pkgs = [$pkgs];
|
al@761
|
491 var theForm = document.getElementById('pkglist');
|
al@761
|
492 for (index = 0; index < pkgs.length; index++) {
|
al@761
|
493 if (document.getElementById(pkgs[index])) {
|
al@761
|
494 // check existing
|
al@761
|
495 document.getElementById(pkgs[index]).checked = 'true';
|
al@761
|
496 }
|
al@761
|
497 else {
|
al@761
|
498 // add other as hidden
|
al@761
|
499 var hInput = document.createElement('input');
|
al@761
|
500 hInput.type = 'hidden';
|
al@761
|
501 hInput.name = 'pkg';
|
al@761
|
502 hInput.value = pkgs[index];
|
al@761
|
503 theForm.appendChild(hInput);
|
al@761
|
504 }
|
al@761
|
505 }
|
al@762
|
506 document.getElementById('countSelected').innerText = pkgs.length;
|
al@761
|
507 </script>
|
al@761
|
508 EOT
|
al@761
|
509 fi
|
al@736
|
510 }
|
al@736
|
511
|
al@736
|
512
|
al@727
|
513 # Show links for "info" page
|
al@727
|
514
|
al@727
|
515 show_info_links() {
|
al@727
|
516 if [ -n "$1" ]; then
|
al@778
|
517 if [ "$3" == 'tag' ]; then icon='tag'; else icon='clock'; fi
|
al@727
|
518 echo -n "<tr><td><b>$2</b></td><td>"
|
al@778
|
519 echo $1 | tr ' ' $'\n' | awk -vt="$3" -vi="$icon" '{
|
al@778
|
520 printf "<span><a data-icon=\"%s\" ", i;
|
al@778
|
521 printf "href=\"?%s=%s\">%s</a></span>Â Â ", t, gensub(/\+/, "%2B", "g", $1), $1
|
al@727
|
522 }'
|
al@727
|
523 echo "</td></tr>"
|
al@727
|
524 fi
|
al@727
|
525 }
|
al@727
|
526
|
al@727
|
527
|
al@707
|
528
|
pascal@627
|
529 #
|
pascal@627
|
530 # Commands
|
pascal@627
|
531 #
|
pascal@627
|
532
|
al@707
|
533
|
pascal@627
|
534 case " $(GET) " in
|
al@741
|
535
|
al@741
|
536
|
pascal@627
|
537 *\ linkable\ *)
|
pascal@627
|
538 #
|
pascal@627
|
539 # List linkable packages.
|
pascal@627
|
540 #
|
al@744
|
541 search_form; sidebar
|
al@744
|
542 LOADING_MSG=$(_ 'Listing linkable packages...'); loading_msg
|
al@744
|
543
|
al@785
|
544 cat <<EOT
|
al@707
|
545 <h2>$(_ 'Linkable packages')</h2>
|
pascal@627
|
546
|
al@755
|
547 <form class="wide">
|
al@755
|
548 $(_ 'Selection:') $(show_button do=Link)
|
pascal@627
|
549 EOT
|
al@736
|
550 table_head
|
al@700
|
551 target=$(readlink $PKGS_DB/fslink)
|
al@707
|
552 for pkg in $(ls $target/$INSTALLED); do
|
pascal@627
|
553 [ -s $pkg/receipt ] && continue
|
pascal@627
|
554 . $target/$INSTALLED/$pkg/receipt
|
al@718
|
555 i18n_desc $pkg
|
al@785
|
556 cat <<EOT
|
pascal@627
|
557 <tr>
|
al@758
|
558 <td><input type="checkbox" name="pkg" value="$pkg" /><a data-icon="pkg" href="?info=${pkg//+/%2B}">$pkg</a></td>
|
pascal@627
|
559 <td>$VERSION</td>
|
al@719
|
560 <td>$SHORT_DESC</td>
|
al@758
|
561 <td><a data-img="web" href="$WEB_SITE"></a></td>
|
pascal@627
|
562 </tr>
|
pascal@627
|
563 EOT
|
pascal@627
|
564 done
|
al@785
|
565 cat <<EOT
|
al@736
|
566 </tbody>
|
al@736
|
567 </table>
|
pascal@627
|
568 </form>
|
pascal@627
|
569 EOT
|
pascal@627
|
570 ;;
|
pascal@627
|
571
|
pascal@627
|
572
|
al@744
|
573 *\ cats\ *)
|
pascal@627
|
574 #
|
al@744
|
575 # List of all categories.
|
pascal@627
|
576 #
|
al@744
|
577 search_form; sidebar
|
al@744
|
578
|
al@744
|
579 echo "<h2>$(_ 'Categories list')</h2>"
|
al@744
|
580
|
al@744
|
581 for pkgsinfo in $(repo_list /packages.info); do
|
al@785
|
582 cat <<EOT
|
al@755
|
583 <section>
|
al@755
|
584 <header>$(header_repo_name $(dirname $pkgsinfo))</header>
|
al@755
|
585 <table class="wide zebra center">
|
al@755
|
586 <thead>
|
al@755
|
587 <tr>
|
al@755
|
588 <td>$(_ 'Category')</td>
|
al@755
|
589 <td>$(_ 'Available packages')</td>
|
al@755
|
590 <td>$(_ 'Installed packages')</td>
|
al@755
|
591 </tr>
|
al@755
|
592 </thead>
|
al@755
|
593 <tbody>
|
al@728
|
594 EOT
|
al@728
|
595 {
|
al@744
|
596 awk -F$'\t' '{print $3}' $pkgsinfo | sort | uniq -c
|
al@728
|
597 awk -F$'\t' '{print $3}' $PKGS_DB/installed.info | sed 's|.*|& i|' | sort | uniq -c
|
al@728
|
598 } | sort -k2,2 | awk '
|
al@728
|
599 {
|
al@728
|
600 c [$2] = "."
|
al@728
|
601 if ($3) { i[$2] = $1; } else { m[$2] = $1; }
|
al@728
|
602 }
|
al@728
|
603 END {
|
al@728
|
604 for (n in c) print n, m[n], i[n]
|
al@744
|
605 }' | sort | awk '{
|
al@744
|
606 printf "<tr><td><a href=\"?list&cat=%s\">%s</a></td><td>%d</td><td>%d</td></tr>", $1, $1, $2, $3
|
al@728
|
607 }'
|
al@785
|
608 cat <<EOT
|
al@755
|
609 </tbody>
|
al@755
|
610 </table>
|
al@755
|
611 </section>
|
al@755
|
612 EOT
|
al@744
|
613 done
|
al@744
|
614 ;;
|
al@744
|
615
|
al@744
|
616
|
al@761
|
617 *\ list\ *|*\ page\ *)
|
al@744
|
618 #
|
al@744
|
619 # List all packages by category.
|
al@744
|
620 #
|
al@744
|
621 search_form; sidebar
|
al@744
|
622 LOADING_MSG="$(_ 'Listing packages...')"; loading_msg
|
al@744
|
623
|
al@744
|
624 bcat="<b>$cat</b>"; brepo="<b>$repo</b>"
|
al@744
|
625 case $repo in
|
al@744
|
626 Any)
|
al@744
|
627 case $my in
|
al@744
|
628 my) title="$(_ 'Installed packages of category "%s"' "$bcat")" ;;
|
al@744
|
629 *) title="$(_ 'All packages of category "%s"' "$bcat")" ;;
|
al@744
|
630 esac ;;
|
al@744
|
631 *)
|
al@744
|
632 case $my in
|
al@744
|
633 my) title="$(_ 'Installed packages of category "%s" in repository "%s"' "$bcat" "$brepo")" ;;
|
al@744
|
634 *) title="$(_ 'All packages of category "%s" in repository "%s"' "$bcat" "$brepo")" ;;
|
al@744
|
635 esac ;;
|
al@744
|
636 esac
|
al@744
|
637
|
al@785
|
638 cat <<EOT
|
al@744
|
639 <h2>$(_ 'Packages list')</h2>
|
al@744
|
640 <p>$title</p>
|
pascal@627
|
641
|
pascal@764
|
642 EOT
|
al@782
|
643
|
al@782
|
644 [ ! -f $PKGS_DB/packages.info ] && msg warn \
|
al@782
|
645 "$(_ 'You can not view a list of all packages until recharging lists.')"
|
al@782
|
646
|
al@785
|
647 [ "$REMOTE_USER" == "root" ] && cat <<EOT
|
al@762
|
648 <section>
|
al@762
|
649 <div>$(_ 'Selected packages:') <span id="countSelected"></span></div>
|
al@762
|
650 <footer>
|
al@762
|
651 $({
|
al@762
|
652 [ "$my" != 'my' ] && show_button do=Install
|
al@762
|
653 show_button do=Chblock do=Remove
|
al@762
|
654 } | sed 's|button |button form="pkglist" |g')
|
al@762
|
655 $(show_button toggle)
|
al@762
|
656 </footer>
|
al@762
|
657 </section>
|
pascal@764
|
658 EOT
|
al@785
|
659 cat <<EOT
|
al@758
|
660
|
al@758
|
661 <form id="pkglist" class="wide">
|
pascal@627
|
662 EOT
|
al@744
|
663 for i in $(repo_list ""); do
|
al@744
|
664 show_list ${my#no}
|
al@744
|
665 done
|
al@785
|
666 cat <<EOT
|
al@755
|
667 </form>
|
al@762
|
668 <script type="text/javascript">window.onscroll = scrollHandler; setCountSelPkgs();</script>
|
al@755
|
669 EOT
|
al@728
|
670 ;;
|
pascal@627
|
671
|
pascal@627
|
672
|
pascal@627
|
673 *\ search\ *)
|
pascal@627
|
674 #
|
pascal@627
|
675 # Search for packages. Here default is to search in packages.desc
|
pascal@627
|
676 # and so get result including packages names and descriptions
|
pascal@627
|
677 #
|
al@725
|
678 pkg=$(GET search); [ -z "$pkg" ] && xhtml_footer && exit
|
al@718
|
679 cd $PKGS_DB
|
al@744
|
680
|
al@759
|
681 search_form | sed "s|name=\"search\"|& value=\"$pkg\"|"
|
al@759
|
682 sidebar
|
al@744
|
683 LOADING_MSG="$(_ 'Searching packages...')"; loading_msg
|
al@744
|
684
|
al@785
|
685 cat <<EOT
|
al@707
|
686 <h2>$(_ 'Search packages')</h2>
|
al@736
|
687
|
al@762
|
688 <section>
|
al@762
|
689 <div>$(_ 'Selected packages:') <span id="countSelected"></span></div>
|
al@762
|
690 <footer>
|
al@762
|
691 $(show_button do=Install do=Chblock do=Remove | sed 's|button |button form="pkglist" |g')
|
al@762
|
692 $(show_button toggle)
|
al@762
|
693 </footer>
|
al@762
|
694 </section>
|
al@758
|
695
|
al@758
|
696 <form id="pkglist" class="wide">
|
pascal@627
|
697 EOT
|
al@763
|
698 if [ -n "$(GET files)" -o -n "$(echo $pkg | grep '/')" ]; then
|
pascal@627
|
699 cat <<EOT
|
al@759
|
700 <table class="wide zebra filelist">
|
pascal@627
|
701 <thead>
|
pascal@627
|
702 <tr>
|
al@707
|
703 <td>$(_ 'Package')</td>
|
al@707
|
704 <td>$(_ 'File')</td>
|
pascal@627
|
705 </tr>
|
pascal@627
|
706 <thead>
|
pascal@627
|
707 <tbody>
|
pascal@627
|
708 EOT
|
al@718
|
709 lzcat $(repo_list /files.list.lzma) | grep -Ei ": .*$(GET search)" | \
|
al@718
|
710 while read PACKAGE FILE; do
|
al@718
|
711 PACKAGE=${PACKAGE%:}
|
al@763
|
712 class='pkg'
|
al@763
|
713 if [ -d $INSTALLED/$PACKAGE ]; then
|
al@763
|
714 class='pkgi'
|
al@763
|
715 grep -q "^$PACKAGE$" $PKGS_DB/blocked-packages.list && class='pkgib'
|
al@763
|
716 fi
|
al@785
|
717 cat <<EOT
|
pascal@627
|
718 <tr>
|
al@719
|
719 <td><input type="checkbox" name="pkg" value="$PACKAGE">$(pkg_info_link $PACKAGE $class)</td>
|
al@759
|
720 <td>$(echo "$FILE" | sed "s|$pkg|<span class=\"diff-add\">&</span>|gI")</td>
|
pascal@627
|
721 </tr>
|
pascal@627
|
722 EOT
|
al@718
|
723 done
|
pascal@627
|
724 else
|
al@718
|
725 table_head
|
al@718
|
726 awk -F$'\t' 'BEGIN{IGNORECASE = 1}
|
al@755
|
727 $1 " " $4 ~ /'$pkg'/{print $0}' $(repo_list /packages.info) | parse_packages_info
|
pascal@627
|
728 fi
|
al@785
|
729 cat <<EOT
|
pascal@627
|
730 </tbody>
|
pascal@627
|
731 </table>
|
pascal@627
|
732 </form>
|
al@762
|
733 <script type="text/javascript">window.onscroll = scrollHandler; setCountSelPkgs();</script>
|
pascal@627
|
734 EOT
|
pascal@627
|
735 ;;
|
pascal@627
|
736
|
pascal@627
|
737
|
pascal@627
|
738 *\ recharge\ *)
|
pascal@627
|
739 #
|
pascal@627
|
740 # Lets recharge the packages list
|
pascal@627
|
741 #
|
al@744
|
742 search_form; sidebar
|
al@744
|
743 LOADING_MSG="$(_ 'Recharging lists...')"; loading_msg
|
al@744
|
744
|
al@785
|
745 cat <<EOT
|
al@707
|
746 <h2>$(_ 'Recharge')</h2>
|
al@781
|
747 <p>$(_ 'Recharge checks for new or updated packages')</p>
|
pascal@627
|
748
|
al@781
|
749 <section>
|
al@781
|
750 <header>
|
al@781
|
751 $(_ 'Recharging log')
|
al@781
|
752 <form>$(show_button up)</form>
|
al@781
|
753 </header>
|
al@755
|
754
|
al@781
|
755 <pre class="scroll">
|
pascal@627
|
756 EOT
|
al@707
|
757 echo $(_ 'Recharging packages list') | log
|
pascal@627
|
758 tazpkg recharge | filter_taztools_msgs
|
al@785
|
759 cat <<EOT
|
al@781
|
760 </pre>
|
al@755
|
761
|
al@781
|
762 <footer>$(_ 'Packages lists are up-to-date. You should check for upgrades now.')</footer>
|
al@781
|
763 </section>
|
pascal@627
|
764 EOT
|
pascal@627
|
765 ;;
|
pascal@627
|
766
|
pascal@627
|
767
|
pascal@627
|
768 *\ up\ *)
|
pascal@627
|
769 #
|
pascal@627
|
770 # Upgrade packages
|
pascal@627
|
771 #
|
al@744
|
772 search_form; sidebar
|
al@744
|
773 LOADING_MSG="$(_ 'Checking for upgrades...')"; loading_msg
|
al@744
|
774
|
al@785
|
775 cat <<EOT
|
al@707
|
776 <h2>$(_ 'Up packages')</h2>
|
pascal@627
|
777
|
al@762
|
778 <section>
|
al@762
|
779 <div>$(_ 'Selected packages:') <span id="countSelected"></span></div>
|
al@762
|
780 <footer>
|
al@762
|
781 $(show_button do=Install do=Chblock do=Remove | sed 's|button |button form="pkglist" |g')
|
al@762
|
782 $(show_button toggle)
|
al@762
|
783 </footer>
|
al@762
|
784 </section>
|
al@758
|
785
|
al@758
|
786 <form id="pkglist" class="wide">
|
pascal@627
|
787 EOT
|
al@747
|
788 # Ask tazpkg to make "packages.up" file
|
pascal@627
|
789 tazpkg up --check >/dev/null
|
al@736
|
790 table_head
|
al@747
|
791
|
al@747
|
792 for pkg in $(cat $PKGS_DB/packages.up); do
|
al@747
|
793 grep -hs "^$pkg " $PKGS_DB/packages.info $PKGS_DB/undigest/*/packages.info | parse_packages_info
|
pascal@627
|
794 done
|
al@747
|
795
|
al@785
|
796 cat <<EOT
|
al@762
|
797 </tbody>
|
al@762
|
798 </table>
|
al@762
|
799 </form>
|
al@762
|
800 <script type="text/javascript">window.onscroll = scrollHandler; setCountSelPkgs();</script>
|
al@762
|
801 EOT
|
pascal@627
|
802 ;;
|
pascal@627
|
803
|
pascal@627
|
804
|
pascal@627
|
805 *\ do\ *)
|
pascal@627
|
806 #
|
pascal@627
|
807 # Do an action on one or some packages
|
pascal@627
|
808 #
|
al@744
|
809 search_form; sidebar
|
al@747
|
810 loading_msg
|
al@744
|
811
|
al@747
|
812 # Find the command
|
al@744
|
813 cmd=$(echo $(GET do) | tr [:upper:] [:lower:])
|
al@747
|
814
|
al@747
|
815 # Find the packages list
|
al@744
|
816 pkgs=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="pkg")print $2}')
|
al@744
|
817 pkgs=$(httpd -d "$pkgs")
|
al@747
|
818
|
al@747
|
819 # Describe the command
|
al@747
|
820 bpkgs="<b>$pkgs</b>"; opt=''
|
pascal@627
|
821 case $cmd in
|
al@762
|
822 install) MSG="$(_ 'Installing: %s' "$bpkgs")"; opt=--forced; cmd=get-install ;;
|
al@762
|
823 remove) MSG="$(_ 'Removing: %s' "$bpkgs")" ;;
|
al@762
|
824 link) MSG="$(_ 'Linking: %s' "$bpkgs")"; opt=$(readlink $PKGS_DB/fslink) ;;
|
al@762
|
825 block) MSG="$(_ 'Blocking: %s' "$bpkgs")" ;;
|
al@762
|
826 unblock) MSG="$(_ 'Unblocking: %s' "$bpkgs")" ;;
|
al@762
|
827 chblock) MSG="$(_ '(Un)blocking: %s' "$bpkgs")" ;;
|
al@762
|
828 repack) MSG="$(_ 'Repacking: %s' "$bpkgs")" ;;
|
pascal@627
|
829 esac
|
al@747
|
830
|
al@785
|
831 cat <<EOT
|
al@744
|
832 <h2>TazPkg: $(GET do)</h2>
|
al@784
|
833 <section>
|
al@784
|
834 <div>$MSG</div>
|
al@784
|
835 <pre class="scroll">
|
pascal@627
|
836 EOT
|
al@747
|
837 # Do the command for all asked packages
|
pascal@774
|
838 cd /tmp
|
al@707
|
839 for pkg in $pkgs; do
|
al@747
|
840 echo $(_n 'y') | tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs
|
al@784
|
841 done
|
al@784
|
842 echo '</pre></section>' ;;
|
pascal@627
|
843
|
pascal@627
|
844
|
pascal@627
|
845 *\ info\ *)
|
pascal@627
|
846 #
|
pascal@627
|
847 # Packages info
|
pascal@627
|
848 #
|
pascal@627
|
849 pkg=$(GET info)
|
al@744
|
850 search_form; sidebar
|
al@744
|
851 LOADING_MSG=$(_ 'Getting package info...'); loading_msg
|
al@744
|
852
|
al@785
|
853 cat <<EOT
|
al@755
|
854 <section>
|
al@755
|
855 <header>
|
al@755
|
856 $(_ 'Package %s' $pkg)
|
al@755
|
857 <form>
|
al@755
|
858 <input type="hidden" name="pkg" value="${pkg#get-}"/>
|
al@747
|
859 EOT
|
al@747
|
860
|
al@747
|
861 # Get receipt variables, show Install/Remove buttons
|
pascal@627
|
862 if [ -d $INSTALLED/$pkg ]; then
|
pascal@627
|
863 . $INSTALLED/$pkg/receipt
|
al@718
|
864 files=$(wc -l < $INSTALLED/$pkg/files.list)
|
pascal@767
|
865 [ "$REMOTE_USER" == "root" ] &&
|
al@747
|
866 show_button do=Remove
|
pascal@627
|
867 else
|
al@718
|
868 cd $PKGS_DB
|
al@727
|
869 eval "$(awk -F$'\t' -vp=$pkg '
|
al@727
|
870 $1==p{
|
al@727
|
871 printf "PACKAGE=\"%s\"; VERSION=\"%s\"; CATEGORY=\"%s\"; ", $1, $2, $3
|
al@727
|
872 printf "SHORT_DESC=\"%s\"; WEB_SITE=\"%s\"; TAGS=\"%s\"; ", $4, $5, $6
|
al@727
|
873 printf "SIZES=\"%s\"; DEPENDS=\"%s\"", $7, $8
|
al@727
|
874 }' packages.info undigest/*/packages.info)"
|
al@727
|
875 PACKED_SIZE=${SIZES% *}
|
al@727
|
876 UNPACKED_SIZE=${SIZES#* }
|
pascal@767
|
877 [ "$REMOTE_USER" == "root" ] &&
|
al@747
|
878 if [ "${pkg#get-}" != "$pkg" ]; then
|
al@747
|
879 show_button "do=Install&nf"
|
al@747
|
880 else
|
al@747
|
881 show_button do=Install
|
al@747
|
882 fi
|
pascal@627
|
883 fi
|
pascal@627
|
884
|
al@747
|
885 # Show Block/Unblock, and Repack buttons
|
pascal@767
|
886 [ "$REMOTE_USER" == "root" ] &&
|
pascal@627
|
887 if [ -d $INSTALLED/$pkg ]; then
|
al@700
|
888 if grep -qs "^$pkg$" $PKGS_DB/blocked-packages.list; then
|
al@744
|
889 show_button do=Unblock
|
pascal@627
|
890 else
|
al@744
|
891 show_button do=Block
|
pascal@627
|
892 fi
|
al@744
|
893 show_button do=Repack
|
pascal@627
|
894 fi
|
al@747
|
895
|
al@747
|
896 # Translate short description
|
al@718
|
897 i18n_desc $pkg
|
al@747
|
898
|
al@747
|
899 # Show info table
|
al@785
|
900 cat <<EOT
|
al@755
|
901 </form>
|
al@755
|
902 </header>
|
al@755
|
903
|
al@786
|
904 <table class="wide summary">
|
al@786
|
905 <tr><td id="appImg"><img src="pkgs.cgi?app_img=$PACKAGE"/></td><td>
|
al@778
|
906 <table class="wide zebra summary" id="infoTable">
|
pascal@627
|
907 <tbody>
|
al@707
|
908 <tr><td><b>$(_ 'Name')</b></td><td>$PACKAGE</td></tr>
|
al@707
|
909 <tr><td><b>$(_ 'Version')</b></td><td>$VERSION</td></tr>
|
al@758
|
910 <tr><td><b>$(_ 'Category')</b></td><td><a href="?list&cat=$CATEGORY">$CATEGORY</a></td></tr>
|
al@707
|
911 <tr><td><b>$(_ 'Description')</b></td><td>$SHORT_DESC</td></tr>
|
al@727
|
912 $([ -n "$MAINTAINER" ] && echo "<tr><td><b>$(_ 'Maintainer')</b></td><td>$MAINTAINER</td></tr>")
|
al@727
|
913 $([ -n "$LICENSE" ] && echo "<tr><td><b>$(_ 'License')</b></td><td><a href=\"?license=$pkg\">$LICENSE</a></td></tr>")
|
al@747
|
914 <tr><td><b>$(_ 'Website')</b></td><td><a href="$WEB_SITE" target="_blank">$WEB_SITE</a></td></tr>
|
al@727
|
915 $(show_info_links "$TAGS" "$(_ 'Tags')" 'tag')
|
al@707
|
916 <tr><td><b>$(_ 'Sizes')</b></td><td>$PACKED_SIZE/$UNPACKED_SIZE</td></tr>
|
al@727
|
917 $(show_info_links "$DEPENDS" "$(_ 'Depends')" 'info')
|
al@727
|
918 $(show_info_links "$SUGGESTED" "$(_ 'Suggested')" 'info')
|
pascal@627
|
919 </tbody>
|
pascal@627
|
920 </table>
|
al@786
|
921 </td></tr></table>
|
al@786
|
922
|
al@786
|
923 <footer>
|
al@786
|
924 <a data-icon="text" href="?show_receipt=$pkg">$(_ 'View receipt')</a>
|
al@786
|
925 <a data-icon="slitaz" href="?improve=$pkg">$(_ 'Improve package')</a>
|
al@786
|
926 </footer>
|
al@755
|
927 </section>
|
al@778
|
928 <span id="ajaxStatus" style="display:none"></span>
|
al@778
|
929
|
al@778
|
930 <script type="text/javascript">
|
al@778
|
931 var links = document.getElementById('infoTable').getElementsByTagName('a');
|
al@778
|
932 for (var i = 0; i < links.length; i++) {
|
al@778
|
933 console.log('i=%s, icon=%s.', i, links[i].dataset.icon);
|
al@778
|
934 if (links[i].dataset.icon == 'clock') {
|
al@778
|
935 links[i].parentNode.id = 'link' + i;
|
al@778
|
936 pkg = links[i].innerText.replace(/\+/g, '%2B');
|
al@778
|
937 ajax('pkgs.cgi?status&pkg=' + pkg, '1', 'link' + i);
|
al@778
|
938 }
|
al@778
|
939 }
|
al@778
|
940
|
al@778
|
941 </script>
|
al@717
|
942 EOT
|
al@747
|
943
|
al@747
|
944 # Show description
|
al@727
|
945 DESC="$(tazpkg desc $pkg)"
|
al@778
|
946 [ -n "$DESC" ] && echo "<section><pre class="pre-wrap">$DESC</pre></section>"
|
pascal@627
|
947
|
al@747
|
948 # Show configuration files list
|
al@747
|
949 CONFIGS="$(tazpkg list-config $pkg | sed 's|\(.*\)|\1 \1|')"
|
al@785
|
950 [ -n "$CONFIGS" ] && cat <<EOT
|
al@755
|
951 <section>
|
al@755
|
952 <header>$(_ 'Configuration files')</header>
|
al@755
|
953 <pre>$(printf '<a href="index.cgi?file=%s">%s</a>\n' $CONFIGS)</pre>
|
al@755
|
954 </section>
|
al@755
|
955 EOT
|
al@747
|
956
|
al@747
|
957 # Show installed files list
|
al@781
|
958 pkg=${pkg//+/%2B}
|
al@776
|
959 cat <<EOT
|
al@755
|
960 <section>
|
al@776
|
961 <header>$(_ 'Installed files')</header>
|
al@776
|
962 <span id="fileList">
|
al@776
|
963 <div style="text-align: center;"><span id="ajaxStatus"></span>$(_ 'Please wait')</div>
|
al@776
|
964 </span>
|
al@755
|
965 </section>
|
al@776
|
966 <script type="text/javascript">ajax('pkgs.cgi?filelist&pkg=$pkg', '1', 'fileList');</script>
|
pascal@627
|
967 EOT
|
pascal@627
|
968 ;;
|
pascal@627
|
969
|
pascal@627
|
970
|
pascal@627
|
971 *\ admin\ * )
|
pascal@627
|
972 #
|
al@633
|
973 # TazPkg configuration page
|
pascal@627
|
974 #
|
pascal@627
|
975 cmd=$(GET admin)
|
al@747
|
976 pager="$(GET pager)"; pager=${pager:-$PAGE_SIZE}; pager=${pager:-100}
|
al@747
|
977 mirror="$(GET mirror)"; mirror="${mirror%/}/"
|
al@747
|
978 repository="$PKGS_DB/undigest/$(GET repository)"
|
al@747
|
979 link="$(GET link)"; link=${link%/}
|
al@744
|
980 search_form; sidebar
|
al@747
|
981 loading_msg
|
al@744
|
982
|
pascal@627
|
983 case "$cmd" in
|
pascal@627
|
984 clean)
|
al@725
|
985 rm -rf $CACHE_DIR/* ;;
|
pascal@627
|
986 add-mirror)
|
al@747
|
987 echo "$mirror" >> $(GET file) ;;
|
al@747
|
988 rm-mirror)
|
al@747
|
989 sed -i "/^"$(echo $mirror | sed 's|/|\\/|g')"$/d" $(GET file) ;;
|
al@747
|
990 select-mirror)
|
al@747
|
991 tazpkg setup-mirror "${mirror}packages/$(cat /etc/slitaz-release)/" | log ;;
|
pascal@627
|
992 add-repo)
|
al@747
|
993 mkdir -p $repository
|
al@747
|
994 echo "$mirror" > $repository/mirror
|
al@747
|
995 echo "$mirror" > $repository/mirrors ;;
|
al@747
|
996 rm-repo)
|
al@747
|
997 rm -rf $repository ;;
|
al@744
|
998 setlink)
|
al@747
|
999 [ -d "$link/$INSTALLED" ] && ln -fs $link $PKGS_DB/fslink ;;
|
al@744
|
1000 removelink)
|
al@744
|
1001 rm -f $PKGS_DB/fslink ;;
|
al@747
|
1002 pager)
|
al@747
|
1003 TP_CONF=/etc/slitaz/tazpanel.conf
|
al@747
|
1004 if [ -z "$PAGE_SIZE" ]; then
|
al@747
|
1005 echo -e "\n# Size of packages list page\nPAGE_SIZE=\"$pager\"" >> $TP_CONF
|
al@747
|
1006 else
|
al@747
|
1007 sed -i "s|PAGE_SIZE=.*|PAGE_SIZE=\"$pager\"|" $TP_CONF
|
al@747
|
1008 fi ;;
|
pascal@627
|
1009 esac
|
al@736
|
1010
|
al@785
|
1011 cat <<EOT
|
al@707
|
1012 <h2>$(_ 'Administration')</h2>
|
al@742
|
1013
|
al@747
|
1014 <p>$(_ 'TazPkg administration and settings')</p>
|
al@747
|
1015
|
al@755
|
1016 <form id="actions">
|
al@755
|
1017 <input type="hidden" name="admin"/>
|
al@747
|
1018 $(show_button action=saveconf action=listconf action=quickcheck action=fullcheck)
|
al@742
|
1019 </form>
|
pascal@627
|
1020 EOT
|
pascal@627
|
1021 case "$(GET action)" in
|
al@747
|
1022 saveconf)
|
al@747
|
1023 LOADING_MSG=$(_ 'Creating the package...'); loading_msg
|
al@747
|
1024 echo "<pre>"
|
al@747
|
1025 cd /tmp
|
al@747
|
1026 tazpkg repack-config | filter_taztools_msgs
|
al@747
|
1027 echo -n "$(_ 'Path:') "; ls /tmp/config-*.tazpkg
|
al@747
|
1028 echo "</pre>" ;;
|
al@747
|
1029 listconf)
|
al@747
|
1030 echo "<h4>$(_ 'Configuration files')</h4>"
|
al@747
|
1031 echo "<ul>"
|
al@747
|
1032 tazpkg list-config | while read file; do
|
al@747
|
1033 if [ -e $file ]; then
|
al@747
|
1034 echo "<li><a href=\"index.cgi?file=$file\">$file</a></li>"
|
al@747
|
1035 else
|
al@747
|
1036 echo "<li>$file</li>"
|
al@747
|
1037 fi
|
al@747
|
1038 done
|
al@747
|
1039 echo "</ul>" ;;
|
al@747
|
1040 quickcheck)
|
al@747
|
1041 LOADING_MSG=$(_ 'Checking packages consistency...'); loading_msg
|
al@747
|
1042 echo "<pre>"
|
al@747
|
1043 tazpkg check
|
al@747
|
1044 echo "</pre>" ;;
|
al@747
|
1045 fullcheck)
|
al@747
|
1046 LOADING_MSG=$(_ 'Full packages check...'); loading_msg
|
al@747
|
1047 echo "<pre>"
|
al@747
|
1048 tazpkg check --full
|
al@747
|
1049 echo "</pre>" ;;
|
al@747
|
1050 dvdimage)
|
al@747
|
1051 dev=$(POST dvdimage)
|
al@747
|
1052 mkdir -p /mnt/packages 2> /dev/null
|
al@747
|
1053 echo "<pre>"
|
al@747
|
1054 mount -t iso9660 -o loop,ro $dev /mnt/packages &&
|
al@747
|
1055 /mnt/packages/install.sh &&
|
al@747
|
1056 _ '%s is installed on /mnt/packages' $dev
|
al@747
|
1057 echo "</pre>" ;;
|
al@747
|
1058 dvdusbkey)
|
al@747
|
1059 mkdir -p /mnt/packages 2> /dev/null
|
al@747
|
1060 for tag in "LABEL=\"packages-$version\" TYPE=\"iso9660\"" \
|
al@747
|
1061 "LABEL=\"sources-$version\" TYPE=\"iso9660\"" ; do
|
al@747
|
1062 dev=$(blkid | grep "$tag" | cut -d: -f1)
|
al@747
|
1063 [ -n "$dev" ] || continue
|
pascal@627
|
1064 echo "<pre>"
|
al@747
|
1065 mount -t iso9660 -o ro $dev /mnt/packages &&
|
al@747
|
1066 /mnt/packages/install.sh &&
|
al@747
|
1067 _ '%s is installed on /mnt/packages' $dev
|
al@747
|
1068 echo "</pre>"
|
al@747
|
1069 break
|
al@747
|
1070 done ;;
|
al@747
|
1071 esac
|
al@744
|
1072
|
al@747
|
1073 cache_files=$(find $CACHE_DIR -name '*.tazpkg' | wc -l)
|
al@744
|
1074 cache_size=$(du -sh $CACHE_DIR | cut -f1 | sed 's|\.0||')
|
al@744
|
1075 [ "$cache_files" == 0 ] && cache_size="0K"
|
al@747
|
1076 mirror=$(cat $PKGS_DB/mirror)
|
al@747
|
1077 default_mirror=${mirror%/packages/*}
|
al@785
|
1078 cat <<EOT
|
al@755
|
1079 <section>
|
al@755
|
1080 <header>$(_ 'Packages cache')</header>
|
al@755
|
1081 <form class="wide">
|
al@755
|
1082 <div>$(_ 'Packages in the cache: %s (%s)' $cache_files $cache_size)</div>
|
al@755
|
1083 <footer>$(show_button admin=clean)</footer>
|
al@755
|
1084 </form>
|
al@755
|
1085 </section>
|
pascal@627
|
1086
|
pascal@627
|
1087
|
al@755
|
1088 <section>
|
al@755
|
1089 <header>$(_ 'Current mirror list')</header>
|
pascal@627
|
1090 EOT
|
al@747
|
1091
|
al@747
|
1092 # List mirrors
|
al@747
|
1093 version=$(cat /etc/slitaz-release)
|
al@700
|
1094 for i in $PKGS_DB/mirrors $PKGS_DB/undigest/*/mirrors; do
|
pascal@627
|
1095 [ -s $i ] || continue
|
al@700
|
1096 if [ $i != $PKGS_DB/mirrors ]; then
|
al@747
|
1097 echo "<h4>$(_ 'Repository: %s' "$(repo_name $(dirname $i))")</h4>"
|
pascal@627
|
1098 fi
|
al@785
|
1099 cat <<EOT
|
al@755
|
1100 <form class="wide">
|
al@755
|
1101 <input type="hidden" name="admin" value="select-mirror"/>
|
al@755
|
1102 <table class="wide zebra">
|
al@747
|
1103 EOT
|
al@747
|
1104 while read line; do
|
al@785
|
1105 cat <<EOT
|
al@755
|
1106 <tr>
|
al@755
|
1107 <td>
|
al@755
|
1108 <input type="radio" name="mirror" id="$line" value="$line" onchange="this.form.submit()"
|
al@755
|
1109 $([ "$line" == "$default_mirror/" ] && echo -n 'checked="checked"')>
|
al@755
|
1110 <label for="$line"><code>$line</code></label></td>
|
al@755
|
1111 <td><a data-img="web" href="$line" target="_blank"></a></td>
|
al@755
|
1112 <td><a data-img="remove" href="?admin=rm-mirror&mirror=$line&file=$i" title="$(_ 'Delete')"></a></td>
|
al@755
|
1113 </tr>
|
al@747
|
1114 EOT
|
al@747
|
1115 done < $i
|
al@785
|
1116 cat <<EOT
|
al@755
|
1117 </table>
|
al@755
|
1118 </form>
|
al@747
|
1119
|
al@755
|
1120 <form class="wide">
|
al@755
|
1121 <footer>
|
al@755
|
1122 <input type="hidden" name="file" value="$i" />
|
al@755
|
1123 <input type="text" name="mirror" size="40" />
|
al@755
|
1124 $(show_button admin=add-mirror)
|
al@755
|
1125 </footer>
|
al@755
|
1126 </form>
|
pascal@627
|
1127 EOT
|
pascal@627
|
1128 done
|
al@785
|
1129 cat <<EOT
|
al@755
|
1130 </section>
|
al@755
|
1131
|
al@755
|
1132
|
al@755
|
1133 <section>
|
al@755
|
1134 <header>$(_ 'Private repositories')</header>
|
al@755
|
1135 EOT
|
al@747
|
1136 if [ -n "$(ls $PKGS_DB/undigest 2> /dev/null)" ]; then
|
al@785
|
1137 cat <<EOT
|
al@755
|
1138 <table class="wide zebra">
|
al@755
|
1139 EOT
|
al@747
|
1140 ls $PKGS_DB/undigest 2> /dev/null | while read repo ; do
|
al@747
|
1141 cat <<EOT
|
al@755
|
1142 <tr>
|
al@755
|
1143 <td><code>$repo</code></td>
|
al@755
|
1144 <td><a data-img="remove" href="?admin=rm-repo&repository=$repo" title="$(_ 'Delete')"></a></td>
|
al@755
|
1145 </tr>
|
pascal@627
|
1146 EOT
|
al@747
|
1147 done
|
al@785
|
1148 cat <<EOT
|
al@755
|
1149 </table>
|
al@755
|
1150 EOT
|
al@747
|
1151 fi
|
al@747
|
1152
|
al@785
|
1153 cat <<EOT
|
al@755
|
1154 <form class="wide">
|
al@755
|
1155 <table>
|
al@755
|
1156 <tr><td>$(_ 'Name')</td><td><input type="text" name="repository" size="10"/></td></tr>
|
al@755
|
1157 <tr><td>$(_ 'URL:')</td><td><input type="text" name="mirror" value="http://"></td></tr>
|
al@755
|
1158 </table>
|
al@755
|
1159 <footer>
|
al@755
|
1160 $(show_button admin=add-repo)
|
al@755
|
1161 </footer>
|
al@755
|
1162 </form>
|
al@755
|
1163 </section>
|
pascal@627
|
1164
|
al@747
|
1165
|
al@755
|
1166 <section>
|
al@755
|
1167 <header>$(_ 'Link to another SliTaz installation')</header>
|
al@755
|
1168 <form class="wide">
|
al@755
|
1169 <div>
|
al@755
|
1170 $(_ "This link points to the root of another SliTaz installation. You will be able to install packages using soft links to it.")
|
al@755
|
1171 </div>
|
al@755
|
1172 <input type="text" name="link" value="$(readlink $PKGS_DB/fslink 2> /dev/null)"/>
|
al@755
|
1173 <footer>
|
al@755
|
1174 $(show_button admin=setlink admin=removelink)
|
al@755
|
1175 </footer>
|
al@755
|
1176 </form>
|
al@755
|
1177 </section>
|
pascal@627
|
1178
|
pascal@627
|
1179
|
al@755
|
1180 <section>
|
al@755
|
1181 <header id="dvd">$(_ 'SliTaz packages DVD')</header>
|
pascal@627
|
1182
|
al@755
|
1183 <div>
|
al@755
|
1184 $(_ "A bootable DVD image of all available packages for the %s version is generated every day. It also contains a copy of the website and can be used without an internet connection. This image can be installed on a DVD or a USB key." $version)
|
al@747
|
1185
|
al@755
|
1186 <form method="post" action='?admin&action=dvdimage'>
|
al@755
|
1187 $(_ 'Install from ISO image:')
|
al@755
|
1188 <input type="text" name="dvdimage" size="40" value="/root/packages-$version.iso" />
|
al@755
|
1189 </form>
|
al@755
|
1190 </div>
|
pascal@627
|
1191
|
al@755
|
1192 <footer>
|
al@755
|
1193 <button data-icon="download" onclick='http://mirror.slitaz.org/iso/$version/packages-$version.iso'>
|
al@755
|
1194 $(_ 'Download DVD image')</button>
|
al@755
|
1195 <button data-icon="link" onclick='?admin&action=dvdusbkey'>
|
al@755
|
1196 $(_ 'Install from DVD/USB key')</button>
|
al@755
|
1197 </footer>
|
al@755
|
1198 </section>
|
pascal@627
|
1199
|
al@747
|
1200
|
al@755
|
1201 <section>
|
al@755
|
1202 <header>$(_ 'Packages list')</header>
|
al@755
|
1203 <form class="wide">
|
al@755
|
1204 <div>
|
al@755
|
1205 $(_ 'Long list of packages is paginated. Here you can set the page size (default: 100, turning off the pager: 0).')
|
al@755
|
1206 </div>
|
al@755
|
1207 <input type="hidden" name="admin" value="pager"/>
|
al@755
|
1208 <input type="number" name="pager" value="$pager" min="0" step="10" size="4"/>
|
al@755
|
1209 <footer>
|
al@755
|
1210 <button data-icon="ok" type="submit">$(_ 'Set')</button>
|
al@755
|
1211 </footer>
|
al@755
|
1212 </form>
|
al@755
|
1213 </section>
|
pascal@627
|
1214 EOT
|
al@727
|
1215 ;;
|
al@727
|
1216
|
al@727
|
1217
|
al@727
|
1218 *\ license\ *)
|
al@727
|
1219 #
|
al@727
|
1220 # Show licenses for installed packages
|
al@727
|
1221 #
|
al@744
|
1222 search_form; sidebar
|
al@744
|
1223
|
al@727
|
1224 pkg=$(GET license)
|
al@727
|
1225 case $pkg in
|
al@747
|
1226 /*) [ -e $pkg ] && {
|
al@727
|
1227 echo "<h2>${pkg#/usr/share/licenses/}</h2>"
|
al@727
|
1228 case $pkg in
|
al@747
|
1229 *.htm*) cat $pkg ;;
|
al@747
|
1230 *) echo "<pre style=\"white-space: pre-wrap\">"
|
al@727
|
1231 cat $pkg | htmlize | sed 's|\([hf]t*t*ps*://[a-zA-Z0-9./_-]*[a-zA-Z0-9/_-]\)|<a href="\1">\1</a>|'
|
al@727
|
1232 echo "</pre>"
|
al@727
|
1233 ;;
|
al@727
|
1234 esac
|
al@727
|
1235 } ;;
|
al@747
|
1236 *) echo "<h2>$(_ 'Licenses for package %s' $pkg)</h2>"
|
al@747
|
1237 OFFLINE=''
|
al@727
|
1238 if [ -e "$PKGS_DB/installed/$pkg" ]; then
|
al@727
|
1239 for lic in $(grep /usr/share/licenses/ $PKGS_DB/installed/$pkg/files.list); do
|
al@727
|
1240 OFFLINE="$OFFLINE <li><a href=\"?license=$lic\">licenses/<b>${lic#/usr/share/licenses/}</b></a></li>\n"
|
al@727
|
1241 done
|
al@747
|
1242 echo "\
|
al@747
|
1243 Apache|Apache-2.0||||http://www.apache.org/licenses/#Artistic|Artistic-2.0||||#\
|
al@747
|
1244 BSD|BSD-2-Clause||||#BSD3|BSD-3-Clause||||#CC-BY-SA||by-sa/4.0/|||#\
|
al@747
|
1245 CC-SA||by-sa/4.0/|||#CC-BY-ND||by-nd/4.0/|||#CC-BY-NC-SA||by-nc-sa/4.0/|||#\
|
al@747
|
1246 CC-BY-NC-ND||by-nc-nd/4.0/|||#CC-BY-NC||by-nc/4.0/|||#CC-BY||by/4.0/|||#\
|
al@747
|
1247 cc-pd|||||http://creativecommons.org/publicdomain/#CDDL|CDDL-1.0||||#\
|
al@747
|
1248 CECILL|CECILL-2.1||||#Eclipse|EPL-1.0||||#EPL|EPL-1.0||||#FDL|||fdl||#\
|
al@747
|
1249 GPL|gpl-license||gpl|gpl.txt|#GPL2|GPL-2.0||old-licenses/gpl-2.0||#\
|
al@747
|
1250 GPL3|GPL-3.0||gpl|gpl.txt|#ISC|ISC||||#LGPL|lgpl-license||lgpl||#\
|
al@747
|
1251 LGPL2|||old-licenses/lgpl-2.0||#\
|
al@747
|
1252 LGPL2.1|LGPL-2.1||old-licenses/lgpl-2.1|lgpl.txt|#LGPL3|LGPL-3.0||lgpl||#\
|
al@747
|
1253 LPPL|LPPL-1.3c||||#MIT|MIT|||mit.txt|#MPL|MPL-2.0|||mozilla.txt|#\
|
al@747
|
1254 MPL2|MPL-2.0||||#PublicDomain|||||http://creativecommons.org/publicdomain/#\
|
al@747
|
1255 QPL|QPL-1.0||||#SIL_OFL|OFL-1.1||||#OFL|OFL-1.1||||#zlib/libpng|Zlib||||" | \
|
al@747
|
1256 awk -vlicenses="$(. $PKGS_DB/installed/$pkg/receipt; echo "$LICENSE")" \
|
al@747
|
1257 -vtext="$(_ '%s license on %s website' %s %s)" \
|
al@747
|
1258 -vro="$(_ 'Read online:')" -vrl="$(_ 'Read local:')" \
|
al@747
|
1259 -vofflic="$OFFLINE" '
|
al@747
|
1260 BEGIN{ FS="|"; RS="#"; split(licenses, lic, " "); if (offlic) OFFLINE[0]=offlic }
|
al@747
|
1261 function link1(u, l, ll, w) {
|
al@747
|
1262 return sprintf("\t<li><a href=\"%s%s\">" text "</a></li>", u, l, "<b>" ll "</b>", w) }
|
al@747
|
1263 function link2(u, l, ll) {
|
al@747
|
1264 return sprintf("\t<li><a href=\"%s%s\">%s</b></a></li>", u, l, ll) }
|
al@747
|
1265 function link_osl(n) {
|
al@747
|
1266 return link1("http://opensource.org/licenses/", n, n, "OSL") }
|
al@747
|
1267 function link_cc(n) {
|
al@747
|
1268 split(n, ll, "/")
|
al@747
|
1269 return link1("http://creativecommons.org/licenses/", n, ll[1], "Creative Commons") }
|
al@747
|
1270 function link_gnu(n) {
|
al@747
|
1271 split(n, ll, "/")
|
al@747
|
1272 return link1("https://www.gnu.org/licenses/", n ".html", ll[2] ? ll[2] : ll[1], "GNU") }
|
al@747
|
1273 function link_loc(n) {
|
al@747
|
1274 return link2("?license=/usr/share/licenses/", n, "licenses/<b>" n "</b>") }
|
al@747
|
1275 function link_url(n) {
|
al@747
|
1276 return link2(n, "", n) }
|
al@747
|
1277 {
|
al@747
|
1278 if ($1 == lic[1] || $1 == lic[2] || $1 == lic[3] || $1 == lic[4]) {
|
al@747
|
1279 if ($2) ONLINE[$2]=link_osl($2)
|
al@747
|
1280 if ($3) ONLINE[$3]=link_cc($3)
|
al@747
|
1281 if ($4) ONLINE[$4]=link_gnu($4)
|
al@747
|
1282 if ($5) OFFLINE[$5]=link_loc($5)
|
al@747
|
1283 if ($6) OFFLINE[$6]=link_url($6)
|
al@747
|
1284 }
|
al@747
|
1285 }
|
al@747
|
1286 END{
|
al@747
|
1287 if (length(ONLINE) > 0) { print "<p>" ro "</p>\n<ul>"; for (o in ONLINE) print ONLINE[o]; print "</ul>" }
|
al@747
|
1288 if (length(OFFLINE) > 0) { print "<p>" rl "</p>\n<ul>"; for (o in OFFLINE) print OFFLINE[o]; print "</ul>" }
|
al@747
|
1289 }'
|
al@747
|
1290 fi ;;
|
al@727
|
1291 esac
|
al@727
|
1292 ;;
|
al@727
|
1293
|
al@727
|
1294
|
al@744
|
1295 *\ tags\ *)
|
al@744
|
1296 #
|
al@744
|
1297 # Show tag cloud
|
al@744
|
1298 #
|
al@744
|
1299 search_form; sidebar
|
al@744
|
1300
|
al@744
|
1301 echo "<h2>$(_ 'Tags list')</h2>"
|
al@744
|
1302 brepo="<b>$repo</b>"
|
al@744
|
1303 case $repo in
|
al@744
|
1304 Any) title="$(_ 'List of tags in all repositories')" ;;
|
al@744
|
1305 *) title="$(_ 'List of tags in repository "%s"' "$brepo")" ;;
|
al@744
|
1306 esac
|
al@747
|
1307 echo "<p>$title</p><p id=\"tags\">"
|
al@744
|
1308 to_read=""
|
al@744
|
1309 for i in $(repo_list ""); do
|
al@747
|
1310 if [ ! -e $i/packages.info ]; then
|
al@747
|
1311 list=installed
|
al@747
|
1312 else
|
al@747
|
1313 list=packages
|
al@747
|
1314 fi
|
al@744
|
1315 to_read="$to_read $i/$list.info"
|
al@744
|
1316 done
|
al@744
|
1317 TAGS="$(awk -F$'\t' '{if($6){print $6}}' $to_read | tr ' ' $'\n' | sort | uniq -c)"
|
al@744
|
1318 MAX="$(echo "$TAGS" | awk '{if ($1 > MAX) MAX = $1} END{print MAX}')"
|
al@744
|
1319 echo "$TAGS" | awk -vMAX="$MAX" '{
|
al@744
|
1320 printf "<a class=\"tag%s\" href=\"?tag=%s\" title=\"%s\">%s</a> ", int($1 * 7 / MAX + 1), $2, $1, $2
|
al@744
|
1321 }'
|
al@744
|
1322 echo "</p>"
|
al@744
|
1323 ;;
|
al@744
|
1324
|
al@744
|
1325
|
al@728
|
1326 *\ tag\ *)
|
al@728
|
1327 #
|
al@744
|
1328 # Show packages with matching tag
|
al@728
|
1329 #
|
al@744
|
1330 search_form; sidebar
|
al@744
|
1331
|
al@744
|
1332 tag=$(GET tag)
|
al@785
|
1333 cat <<EOT
|
al@755
|
1334 <h2 data-icon="tag">$(_ 'Tag "%s"' $tag)</h2>
|
pascal@770
|
1335 EOT
|
al@785
|
1336 [ "$REMOTE_USER" == "root" ] && cat <<EOT
|
al@762
|
1337 <section>
|
al@762
|
1338 <div>$(_ 'Selected packages:') <span id="countSelected"></span></div>
|
al@762
|
1339 <footer>
|
al@762
|
1340 $(show_button do=Install do=Chblock do=Remove | sed 's|button |button form="pkglist" |g')
|
al@762
|
1341 $(show_button toggle)
|
al@762
|
1342 </footer>
|
al@762
|
1343 </section>
|
pascal@770
|
1344 EOT
|
al@785
|
1345 cat <<EOT
|
al@758
|
1346 <form id="pkglist" class="wide">
|
al@732
|
1347 EOT
|
al@744
|
1348 for i in $(repo_list ""); do
|
al@744
|
1349 show_list all
|
al@744
|
1350 done
|
al@785
|
1351 cat <<EOT
|
al@762
|
1352 </form>
|
al@762
|
1353 <script type="text/javascript">window.onscroll = scrollHandler; setCountSelPkgs();</script>
|
al@762
|
1354 EOT
|
al@744
|
1355 ;;
|
al@732
|
1356
|
al@744
|
1357
|
al@744
|
1358 *\ blocked\ *)
|
al@744
|
1359 #
|
al@744
|
1360 # Show blocked packages list
|
al@744
|
1361 #
|
al@744
|
1362 search_form; sidebar
|
al@744
|
1363
|
al@785
|
1364 cat <<EOT
|
al@744
|
1365 <h2>$(_ 'Blocked packages list')</h2>
|
al@744
|
1366
|
al@762
|
1367 <section>
|
al@762
|
1368 <div>$(_ 'Selected packages:') <span id="countSelected"></span></div>
|
al@762
|
1369 <footer>
|
al@762
|
1370 $(show_button do=Unblock | sed 's|button |button form="pkglist" |g')
|
al@762
|
1371 $(show_button toggle)
|
al@762
|
1372 </footer>
|
al@762
|
1373 </section>
|
al@762
|
1374
|
al@762
|
1375 <form id="pkglist" class="wide">
|
al@744
|
1376 EOT
|
al@744
|
1377 table_head
|
al@744
|
1378 for i in $(cat $PKGS_DB/blocked-packages.list); do
|
al@744
|
1379 awk -F$'\t' -vp="$i" '{
|
al@744
|
1380 if ($1 == p)
|
al@758
|
1381 printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\"><a data-icon=\"pkgib\" href=\"?info=%s\">%s</a></td><td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", $1, gensub(/\+/, "%2B", "g", $1), $1, $2, $4, $5
|
al@744
|
1382 }' $PKGS_DB/installed.info
|
al@744
|
1383 done
|
al@785
|
1384 cat <<EOT
|
al@762
|
1385 </tbody>
|
al@762
|
1386 </table>
|
al@762
|
1387 </form>
|
al@762
|
1388 <script type="text/javascript">window.onscroll = scrollHandler; setCountSelPkgs();</script>
|
al@762
|
1389 EOT
|
al@728
|
1390 ;;
|
al@728
|
1391
|
al@728
|
1392
|
al@786
|
1393 *\ improve\ *)
|
al@786
|
1394 #
|
al@786
|
1395 # Improving packages by the community effort
|
al@786
|
1396 #
|
al@786
|
1397 search_form; sidebar
|
al@786
|
1398 msg warn 'Under construction!<br/>It is only imitation of working'
|
al@786
|
1399
|
al@786
|
1400 pkg=$(GET improve)
|
al@786
|
1401 user=$(POST user); type=$(POST type); text="$(POST text)"
|
al@786
|
1402 login=$(POST login); password=$(POST password)
|
al@786
|
1403
|
al@786
|
1404 login_c=$(COOKIE login); password_c=$(COOKIE password)
|
al@786
|
1405 mail_hash=$(COOKIE mail_hash); user_name=$(COOKIE user_name)
|
al@786
|
1406
|
al@786
|
1407 n=$'\n'
|
al@786
|
1408
|
al@786
|
1409 if [ -n "$login" ]; then
|
al@786
|
1410 # Get mail hash and user Name from bugs.slitaz.org
|
al@786
|
1411 page="$(busybox wget --post-data "auth=${login}&pass=${password}&id=" \
|
al@786
|
1412 -O- "http://bugs.slitaz.org/bugs.cgi?user=${login}")"
|
al@786
|
1413 # Parse page and get:
|
al@786
|
1414 mail_hash="$(echo "$page" | fgrep '<h2>' | cut -d/ -f5 | cut -c 1-32)"
|
al@786
|
1415 user_name="$(echo "$page" | fgrep '<h2>' | cut -d'>' -f3 | cut -d'<' -f1)"
|
al@786
|
1416
|
al@786
|
1417 # Put variables to the session Cookies (they clean in browser close)
|
al@786
|
1418 cat <<EOT
|
al@786
|
1419 <script type="text/javascript">
|
al@786
|
1420 document.cookie = "login=$login";
|
al@786
|
1421 document.cookie = "password=$password";
|
al@786
|
1422 document.cookie = "mail_hash=$mail_hash";
|
al@786
|
1423 document.cookie = "user_name=$user_name";
|
al@786
|
1424 </script>
|
al@786
|
1425 EOT
|
al@786
|
1426 login_c="$login"; password_c="$password"
|
al@786
|
1427 fi
|
al@786
|
1428
|
al@786
|
1429 if [ -z "$login_c" ]; then
|
al@786
|
1430 cat <<EOT
|
al@786
|
1431 <section>
|
al@786
|
1432 <div>$(_ 'Please log in using your TazBug account.')</div>
|
al@786
|
1433 <form method="post">
|
al@786
|
1434 <input type="hidden" name="improve" value="$pkg"/>
|
al@786
|
1435 <table>
|
al@786
|
1436 <tr><td>$(_ 'Login:')</td>
|
al@786
|
1437 <td><input type="text" name="login"/></td></tr>
|
al@786
|
1438 <tr><td>$(_ 'Password:')</td>
|
al@786
|
1439 <td><input type="password" name="password"/></td></tr>
|
al@786
|
1440 <tr><td colspan="2">
|
al@786
|
1441 <button type="submit" data-icon="user">$(_ 'Log in')</button></td></tr>
|
al@786
|
1442 </table>
|
al@786
|
1443 </form>
|
al@786
|
1444 <footer>
|
al@786
|
1445 <a href="http://bugs.slitaz.org/bugs.cgi?signup&online" target="_blank">$(_ 'Create new account')</a>
|
al@786
|
1446 </footer>
|
al@786
|
1447 </section>
|
al@786
|
1448 EOT
|
al@786
|
1449 xhtml_footer; exit 0
|
al@786
|
1450 fi
|
al@786
|
1451
|
al@786
|
1452
|
al@786
|
1453 # Get receipt variables, show Install/Remove buttons
|
al@786
|
1454 if [ -d $INSTALLED/$pkg ]; then
|
al@786
|
1455 . $INSTALLED/$pkg/receipt
|
al@786
|
1456 else
|
al@786
|
1457 cd $PKGS_DB
|
al@786
|
1458 eval "$(awk -F$'\t' -vp=$pkg '
|
al@786
|
1459 $1==p{
|
al@786
|
1460 printf "VERSION=\"%s\"; SHORT_DESC=\"%s\"; TAGS=\"%s\"; ", $2, $4, $6
|
al@786
|
1461 }' packages.info undigest/*/packages.info)"
|
al@786
|
1462 fi
|
al@786
|
1463
|
al@786
|
1464 RECEIPT="$(wget -O - http://hg.slitaz.org/wok/raw-file/tip/$pkg/receipt | htmlize)"
|
al@786
|
1465 DESCRIPTION="$(wget -O - http://hg.slitaz.org/wok/raw-file/tip/$pkg/description.txt | htmlize)"
|
al@786
|
1466 DESCRIPTION="$(separator)$n${DESCRIPTION:-(empty)}$n$(separator)"
|
al@786
|
1467
|
al@786
|
1468 if [ -z "$type" ]; then
|
al@786
|
1469 cat <<EOT
|
al@786
|
1470 <section>
|
al@786
|
1471 <header>
|
al@786
|
1472 $(_ 'Improve package "%s"' $pkg)
|
al@786
|
1473 <form><button name="info" value="$pkg" data-icon="back">$(_ 'Back')</button></form>
|
al@786
|
1474 </header>
|
al@786
|
1475
|
al@786
|
1476 <div style="display:none">
|
al@786
|
1477 <span id="newVersion">Current version: $VERSION${n}New version: $VERSION${n}Link to announce: http://</span>
|
al@786
|
1478 <span id="improveShortDesc">Short description (English):$n$SHORT_DESC</span>
|
al@786
|
1479 <span id="translateShortDesc">Short description (English):$n$SHORT_DESC$n${n}Language: $LANG${n}Short description:$n$SHORT_DESC</span>
|
al@786
|
1480 <span id="improveDesc">Description (English):$n$DESCRIPTION</span>
|
al@786
|
1481 <span id="translateDesc">Language: $LANG${n}Description:$n$DESCRIPTION</span>
|
al@786
|
1482 <span id="improveCategory">Old category: $CATEGORY${n}New category: $CATEGORY</span>
|
al@786
|
1483 <span id="improveTags">Tags: $TAGS</span>
|
al@786
|
1484 <span id="addIcon">Link to application icon (48x48px): http://</span>
|
al@786
|
1485 <span id="addScreenshot">Link to application screenshot: http://</span>
|
al@786
|
1486 <span id="improveReceipt">$RECEIPT</span>
|
al@786
|
1487 <span id="improveOther"></span>
|
al@786
|
1488 </div>
|
al@786
|
1489
|
al@786
|
1490 <form method="post" class="wide">
|
al@786
|
1491
|
al@786
|
1492 <table class="wide">
|
al@786
|
1493 <tr><td style="vertical-align:bottom">
|
al@786
|
1494 <input type="hidden" name="improve" value="$pkg"/>
|
al@786
|
1495 <input type="hidden" name="user" value="$login_c"/>
|
al@786
|
1496 $(_ 'How can you help:')<br/>
|
al@786
|
1497 <select name='type' id="improveType" onchange="improveAction()">
|
al@786
|
1498 <option value=''>$(_ 'Please select an action')
|
al@786
|
1499 <option value='newVersion'>$(_ 'Report new version')
|
al@786
|
1500 <option value='improveShortDesc'>$(_ 'Improve short description')
|
al@786
|
1501 <option value='translateShortDesc'>$(_ 'Translate short description')
|
al@786
|
1502 <option value='improveDesc'>$(_ 'Add or improve description')
|
al@786
|
1503 <option value='translateDesc'>$(_ 'Translate description')
|
al@786
|
1504 <option value='improveCategory'>$(_ 'Improve category')
|
al@786
|
1505 <option value='improveTags'>$(_ 'Add or improve tags')
|
al@786
|
1506 <option value='addIcon'>$(_ 'Add application icon')
|
al@786
|
1507 <option value='addScreenshot'>$(_ 'Add application screenshot')
|
al@786
|
1508 <option value='improveReceipt'>$(_ 'Improve receipt')
|
al@786
|
1509 <option value='improveOther'>$(_ 'Other')
|
al@786
|
1510 </select>
|
al@786
|
1511 </td>
|
al@786
|
1512 <td id="user_info">$user_name
|
al@786
|
1513 <img src="http://www.gravatar.com/avatar/$mail_hash?s=48&d=identicon"
|
al@786
|
1514 style="border-radius: 0.3rem"/>
|
al@786
|
1515 </td></tr>
|
al@786
|
1516 </table>
|
al@786
|
1517
|
al@786
|
1518 <textarea name="text" id="improveText" style="width:100%; resize: vertical; min-height:10rem"></textarea>
|
al@786
|
1519 <button type="submit" data-icon="slitaz">$(_ 'Send')</button>
|
al@786
|
1520 </form>
|
al@786
|
1521 </section>
|
al@786
|
1522 EOT
|
al@786
|
1523 else
|
al@786
|
1524 cat <<EOT
|
al@786
|
1525 <section>
|
al@786
|
1526 <header>
|
al@786
|
1527 $(_ 'Thank you!')
|
al@786
|
1528 <form><button name="info" value="$pkg" data-icon="back">$(_ 'Back')</button></form>
|
al@786
|
1529 </header>
|
al@786
|
1530 <div>The following information was sent to SliTaz developers:</div>
|
al@786
|
1531 <pre class="scroll"><b>User:</b> $user
|
al@786
|
1532 <b>Type:</b> $type
|
al@786
|
1533 <b>Package:</b> $pkg
|
al@786
|
1534 <b>Message:</b>
|
al@786
|
1535 $(echo "$text" | htmlize)</pre>
|
al@786
|
1536 </section>
|
al@786
|
1537 EOT
|
al@786
|
1538 fi
|
al@786
|
1539 ;;
|
al@786
|
1540
|
al@786
|
1541
|
al@786
|
1542 *)
|
pascal@627
|
1543 #
|
pascal@627
|
1544 # Default to summary
|
pascal@627
|
1545 #
|
al@744
|
1546 search_form; sidebar
|
al@744
|
1547
|
al@785
|
1548 cat <<EOT
|
al@755
|
1549 <form id="actions2">
|
pascal@627
|
1550 EOT
|
al@700
|
1551 fslink=$(readlink $PKGS_DB/fslink)
|
al@724
|
1552 [ -n "$fslink" -a -d "$fslink/$INSTALLED" ] && show_button linkable
|
al@747
|
1553 show_button recharge up admin
|
al@785
|
1554 cat <<EOT
|
al@755
|
1555 </form>
|
pascal@627
|
1556
|
al@755
|
1557 <section>
|
al@755
|
1558 <header>$(_ 'Summary')</header>
|
al@755
|
1559
|
al@755
|
1560 <table class="wide zebra">
|
al@755
|
1561 <tr>
|
al@755
|
1562 <td>$(_ 'Last recharge:')</td>
|
al@755
|
1563 <td>$(list=$PKGS_DB/ID
|
al@745
|
1564 if [ -e $list ]; then
|
al@755
|
1565 # Timezone offset as string, ex. '+0200' for EET (+2 hours)
|
al@755
|
1566 ohhmm="$(date +%z)"
|
al@755
|
1567 # Timezone offset in the seconds
|
al@755
|
1568 offset=$(( 60 * (60 * ${ohhmm:0:3} + ${ohhmm:3:2}) ))
|
al@747
|
1569 daynow=$(( ($(date +%s) + $offset) / 86400 ))
|
al@747
|
1570 dayupd=$(( ($(date -r $list +%s) + $offset) / 86400 ))
|
al@747
|
1571 days=$(( $daynow - $dayupd ))
|
al@745
|
1572 time=$(date -r $list +%R)
|
al@745
|
1573 ago="$(_p '%d day ago.' '%d days ago.' $days $days)"
|
al@745
|
1574 case $days in
|
al@745
|
1575 0) _ 'Today at %s.' $time;;
|
al@745
|
1576 1) _ 'Yesterday at %s.' $time;;
|
al@745
|
1577 [2-9]) echo $ago;;
|
al@745
|
1578 *) echo "<span style='color:red'>$ago</span>"
|
al@745
|
1579 _ 'It is recommended to [recharge] the lists.' | \
|
al@755
|
1580 sed 's|\[|<a data-icon="refresh" href="?recharge">|;s|\]|</a>|';;
|
al@745
|
1581 esac
|
al@745
|
1582 else
|
al@745
|
1583 _ 'never.'
|
al@745
|
1584 _ 'You need to [download] the lists for further work.' | \
|
al@768
|
1585 sed 's|\[|<a data-icon="download" href="?recharge" data-root>|;s|\]|</a>|'
|
al@745
|
1586 fi)</td></tr>
|
al@755
|
1587 <tr>
|
al@755
|
1588 <td>$(_ 'Installed packages:')</td>
|
al@755
|
1589 <td><a href="?list&my=my&cat=all&repo=Any">
|
al@755
|
1590 <b>$(cat $PKGS_DB/installed.info | wc -l)</b>
|
al@755
|
1591 </a></td></tr>
|
al@755
|
1592 <tr>
|
al@755
|
1593 <td>$(_ 'Mirrored packages:')</td>
|
al@755
|
1594 <td><a href="?list&my=no&cat=all&repo=Any">
|
al@755
|
1595 <b>$(cat $PKGS_DB/packages.list | wc -l)</b>
|
al@755
|
1596 </a></td></tr>
|
al@755
|
1597 <tr>
|
al@755
|
1598 <td>$(_ 'Upgradeable packages:')</td>
|
al@755
|
1599 <td><a href="?up">
|
al@755
|
1600 <b>$(cat $PKGS_DB/packages.up | wc -l)</b>
|
al@755
|
1601 </a></td></tr>
|
al@755
|
1602 <tr>
|
al@755
|
1603 <td>$(_ 'Installed files:')</td>
|
al@755
|
1604 <td><b>$(cat $INSTALLED/*/files.list | wc -l)</b></td></tr>
|
al@755
|
1605 <tr>
|
al@755
|
1606 <td>$(_ 'Blocked packages:')</td>
|
al@755
|
1607 <td><a href="?blocked">
|
al@755
|
1608 <b>$(cat $PKGS_DB/blocked-packages.list | wc -l)</b>
|
al@755
|
1609 </a></td></tr>
|
al@755
|
1610 </table>
|
al@755
|
1611 </section>
|
pascal@627
|
1612
|
pascal@627
|
1613
|
al@755
|
1614 <section>
|
al@755
|
1615 <header>
|
al@755
|
1616 $(_ 'Latest log entries')
|
al@755
|
1617 <form action="index.cgi">
|
al@755
|
1618 <button name="file" value="$LOG" data-icon="view">$(_ 'Show')</button>
|
al@755
|
1619 </form>
|
al@755
|
1620 </header>
|
al@755
|
1621 <pre>$(tail -n 5 $LOG | tac | fgrep "-" | awk '{print $1, $2, $3, $4, $5, "<a href=\"?info=" $6 "\">" $6 "</a>", $7}')</pre>
|
al@755
|
1622 </section>
|
pascal@627
|
1623 EOT
|
pascal@627
|
1624 ;;
|
pascal@627
|
1625 esac
|
pascal@627
|
1626
|
pascal@627
|
1627 # xHTML 5 footer
|
al@633
|
1628 export TEXTDOMAIN='tazpkg'
|
pascal@627
|
1629 xhtml_footer
|
pascal@627
|
1630 exit 0
|