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