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