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