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