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