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