tazpkg rev 713

Move some sources to new "tazpanel" and "modules" folders.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Dec 15 04:43:04 2014 +0200 (2014-12-15)
parents 68b77b7f356c
children 5cfba8b15016
files Makefile modules/tazpkg-convert modules/tazpkg-find-depends pkgs pkgs.cgi tazpanel/pkgs tazpanel/pkgs.cgi tazpkg-convert tazpkg-find-depends
line diff
     1.1 --- a/Makefile	Mon Dec 15 04:33:27 2014 +0200
     1.2 +++ b/Makefile	Mon Dec 15 04:43:04 2014 +0200
     1.3 @@ -51,9 +51,9 @@
     1.4  	install -m 0755 -d                  $(DESTDIR)$(PREFIX)/bin
     1.5  	install -m 0777 tazpkg              $(DESTDIR)$(PREFIX)/bin
     1.6  	-[ "$(VERSION)" ] && sed -i 's/^VERSION=[0-9].*/VERSION=$(VERSION)/' $(DESTDIR)$(PREFIX)/bin/tazpkg
     1.7 -	install -m 0777 tazpkg-convert      $(DESTDIR)$(PREFIX)/bin
     1.8 -	install -m 0755 -d                  $(DESTDIR)$(PREFIX)/lib/tazpkg
     1.9 -	install -m 0777 tazpkg-find-depends $(DESTDIR)$(PREFIX)/lib/tazpkg
    1.10 +	install -m 0777 modules/tazpkg-convert      $(DESTDIR)$(PREFIX)/bin
    1.11 +	install -m 0755 -d                          $(DESTDIR)$(PREFIX)/lib/tazpkg
    1.12 +	install -m 0777 modules/tazpkg-find-depends $(DESTDIR)$(PREFIX)/lib/tazpkg
    1.13  
    1.14  	# TazPkg-box GUI
    1.15  	install -m 0777 tazpkg-notify $(DESTDIR)$(PREFIX)/bin
    1.16 @@ -68,9 +68,9 @@
    1.17  	cp -a doc/*        $(DESTDIR)$(DOCDIR)/tazpkg
    1.18  
    1.19  	# TazPanel files
    1.20 -	install -m 0755 -d $(DESTDIR)/var/www/tazpanel/menu.d
    1.21 -	cp -a pkgs.cgi     $(DESTDIR)/var/www/tazpanel
    1.22 -	cp -a pkgs         $(DESTDIR)/var/www/tazpanel/menu.d
    1.23 +	install -m 0755 -d      $(DESTDIR)/var/www/tazpanel/menu.d
    1.24 +	cp -a tazpanel/pkgs.cgi $(DESTDIR)/var/www/tazpanel
    1.25 +	cp -a tazpanel/pkgs     $(DESTDIR)/var/www/tazpanel/menu.d
    1.26  
    1.27  	# The i18n files
    1.28  	install -m 0755 -d $(DESTDIR)$(PREFIX)/share/locale
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/modules/tazpkg-convert	Mon Dec 15 04:43:04 2014 +0200
     2.3 @@ -0,0 +1,664 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +# This program is a part of TazPkg.
     2.7 +# /usr/bin/tazpkg-convert: toolset to convert alien package to the tazpkg format
     2.8 +
     2.9 +# Usage: tazpkg-convert alien_package [ target_directory ]
    2.10 +
    2.11 +
    2.12 +PACKAGE_FILE="$1"
    2.13 +TARGET_DIR="$2"
    2.14 +TMP_DIR=$(mktemp -d)
    2.15 +TOP_DIR="$(pwd)"
    2.16 +
    2.17 +. /etc/slitaz/slitaz.conf
    2.18 +. /lib/libtaz.sh
    2.19 +. /usr/lib/tazpkg/tazpkg-find-depends
    2.20 +
    2.21 +# Internationalization.
    2.22 +export TEXTDOMAIN='tazpkg'
    2.23 +
    2.24 +
    2.25 +# FIXME: what does this mean?
    2.26 +[ -n "$TARGET_DIR" -a -s "$TARGET_DIR/files.list.lzma" ] && TMPLOCALSTATE="$TARGET_DIR"
    2.27 +
    2.28 +
    2.29 +show_unresolved_lib()
    2.30 +{
    2.31 +	if [ -s $TMP_DIR/unresolved ]; then
    2.32 +		echo -e "BUGS=\"$(_n 'No dependency for:')" >> $1
    2.33 +		sort < $TMP_DIR/unresolved | uniq | \
    2.34 +		while read file; do
    2.35 +			_ 'WARNING: unknown dependency for %s' $lib
    2.36 +			echo -n " $file" >> $1
    2.37 +		done
    2.38 +		echo "\"" >> $1
    2.39 +	fi
    2.40 +}
    2.41 +
    2.42 +
    2.43 +# convert a .tar.bz2 package to .tazpkg
    2.44 +
    2.45 +convert_upkg()
    2.46 +{
    2.47 +	mkdir -p $TMP_DIR/fs
    2.48 +	tar xjf $PACKAGE_FILE -C $TMP_DIR/fs
    2.49 +	if [ -d $TMP_DIR/fs/var/lib/upkg/packages ]; then
    2.50 +		cd $TMP_DIR
    2.51 +		package="$(sed '/^Package:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)"
    2.52 +		version="$(sed '/^Version:/!d;s/.*: //' fs/var/lib/upkg/packages/*.info)"
    2.53 +		url="http://www.paldo.org/"
    2.54 +		file=$package-$version
    2.55 +		mkdir $file
    2.56 +		mv fs $file
    2.57 +		maintainer=nobody@slitaz.org
    2.58 +		descrip="$package package from paldo."
    2.59 +		cat > $file/receipt <<EOT
    2.60 +# SliTaz package receipt.
    2.61 +# generated by tazpkg from package $(basename $PACKAGE_FILE)
    2.62 +PACKAGE="$package"
    2.63 +VERSION="$version"
    2.64 +CATEGORY="misc"
    2.65 +SHORT_DESC="$descrip"
    2.66 +WEB_SITE="$url"
    2.67 +MAINTAINER="$maintainer"
    2.68 +DEPENDS="$(find_depends)"
    2.69 +EOT
    2.70 +		[ -s $file/var/lib/upkg/files/*.config.bz2 ] &&
    2.71 +			cat >> $file/receipt <<EOT
    2.72 +CONFIG_FILES="$(bzcat $file/var/lib/upkg/files/*.config.bz2)"
    2.73 +EOT
    2.74 +		while read ext func ; do
    2.75 +			[ -s $file/fs/var/lib/upkg/scripts/*.$ext ] || continue
    2.76 +			cat >> $file/receipt <<EOT
    2.77 +
    2.78 +$func()
    2.79 +{
    2.80 +$(cat $file/fs/var/lib/upkg/scripts/*.$ext)
    2.81 +}
    2.82 +EOT
    2.83 +		done <<EOT
    2.84 +prerm	pre_remove
    2.85 +EOT
    2.86 +
    2.87 +		tazpkg pack $file
    2.88 +		mv $TMP_DIR/$file.tazpkg $TOP_DIR
    2.89 +	else
    2.90 +		_ 'File "%s" does not look like %s package!' $PACKAGE_FILE 'upkg'
    2.91 +	fi
    2.92 +	cd $TOP_DIR
    2.93 +	rm -rf $TMP_DIR
    2.94 +}
    2.95 +
    2.96 +
    2.97 +# convert a .spack package to .tazpkg
    2.98 +
    2.99 +convert_spack()
   2.100 +{
   2.101 +	mkdir -p $TMP_DIR
   2.102 +	( cd $TMP_DIR ; cpio -i ) < $PACKAGE_FILE
   2.103 +	cd $TMP_DIR
   2.104 +	package="$(sed '$!d;s/:.*//' about.txt)"
   2.105 +	version="$(basename $PACKAGE_FILE | sed "s/$package-\([^-]*\).*/\1/")"
   2.106 +	descrip="$(sed '$!d;s/.*: //' about.txt)"
   2.107 +	url="http://0linux.org/"
   2.108 +	maintainer=nobody@slitaz.org
   2.109 +	file=$package-$version
   2.110 +	mkdir -p $file/fs
   2.111 +	xzcat files.xz | ( cd $file/fs ; cpio -idmu )
   2.112 +	cat > $file/receipt <<EOT
   2.113 +# SliTaz package receipt.
   2.114 +# generated by tazpkg from package $(basename $PACKAGE_FILE)
   2.115 +PACKAGE="$package"
   2.116 +VERSION="$version"
   2.117 +CATEGORY="misc"
   2.118 +SHORT_DESC="$descrip"
   2.119 +WEB_SITE="$url"
   2.120 +MAINTAINER="$maintainer"
   2.121 +DEPENDS="$(find_depends)"
   2.122 +EOT
   2.123 +	[ -s pre-install.sh ] && cat >> $file/receipt <<EOT
   2.124 +
   2.125 +pre_install()
   2.126 +{
   2.127 +	cd /
   2.128 +$(sed 1d pre-install.sh)
   2.129 +}
   2.130 +EOT
   2.131 +	[ -s post-install.sh ] && cat >> $file/receipt <<EOT
   2.132 +
   2.133 +post_install()
   2.134 +{
   2.135 +	cd /
   2.136 +$(sed '1,/^}/d' post-install.sh)
   2.137 +}
   2.138 +EOT
   2.139 +	tazpkg pack $file
   2.140 +	cd $TOP_DIR
   2.141 +	mv $TMP_DIR/$file.tazpkg .
   2.142 +	rm -rf $TMP_DIR
   2.143 +}
   2.144 +
   2.145 +
   2.146 +# convert a .ipk package to .tazpkg
   2.147 +
   2.148 +convert_ipk()
   2.149 +{
   2.150 +	mkdir -p $TMP_DIR
   2.151 +	tar xOzf $PACKAGE_FILE ./control.tar.gz | tar xzf - -C $TMP_DIR
   2.152 +	package=$(sed '/^Package/!d;s/.*: //' $TMP_DIR/control)
   2.153 +	version=$(sed '/^Version/!d;s/.*: //' $TMP_DIR/control)
   2.154 +	maintainer="$(sed '/^Maintainer/!d;s/.*: //' $TMP_DIR/control)"
   2.155 +	target="$(sed '/^Architecture/!d;s/.*: //' $TMP_DIR/control)"
   2.156 +	descrip=$(sed '/^Description/!d;s/.*: //' $TMP_DIR/control)
   2.157 +	homepage=$(sed '/^Homepage/!d;s/.*: //' $TMP_DIR/control)
   2.158 +	url="http://openwrt.org/"
   2.159 +	case "$target" in
   2.160 +	i386|all)
   2.161 +		file=$package-$version
   2.162 +		mkdir -p $TMP_DIR/$file/fs
   2.163 +		tar xOzf $PACKAGE_FILE ./data.tar.gz | tar xzf - -C $TMP_DIR/$file/fs
   2.164 +		cd $TMP_DIR
   2.165 +		cat > $file/receipt <<EOT
   2.166 +# SliTaz package receipt.
   2.167 +# generated by tazpkg from package $(basename $PACKAGE_FILE)
   2.168 +PACKAGE="$package"
   2.169 +VERSION="$version"
   2.170 +CATEGORY="misc"
   2.171 +SHORT_DESC="$descrip"
   2.172 +WEB_SITE="${homepage:-$url}"
   2.173 +MAINTAINER="$maintainer"
   2.174 +DEPENDS="$(find_depends)"
   2.175 +EOT
   2.176 +		show_unresolved_lib $file/receipt
   2.177 +		[ -s conffiles ] && cat >> $file/receipt <<EOT
   2.178 +CONFIG_FILES="$(cat conffiles)"
   2.179 +EOT
   2.180 +		show_unresolved_lib $file/receipt
   2.181 +		while read script func; do
   2.182 +			[ -s $script ] && cat >> $file/receipt <<EOT
   2.183 +
   2.184 +$func()
   2.185 +{
   2.186 +$(cat $script)
   2.187 +}
   2.188 +EOT
   2.189 +		done <<EOT
   2.190 +preinst		pre_install
   2.191 +postinst	post_install
   2.192 +prerm		pre_remove
   2.193 +postrm		post_remove
   2.194 +EOT
   2.195 +		awk '
   2.196 +{
   2.197 +   if (/^ / && show) print substr($0,2);
   2.198 +   else show=0;
   2.199 +   if (/^Description/) show=1;
   2.200 +}' < $TMP_DIR/control > $file/description.txt
   2.201 +		sed -i 's/^\.$//' $file/description.txt
   2.202 +		[ -s $file/description.txt ] || rm -f $file/description.txt
   2.203 +		tazpkg pack $file
   2.204 +		cd $TOP_DIR
   2.205 +		mv $TMP_DIR/$file.tazpkg .
   2.206 +		;;
   2.207 +	*)
   2.208 +		_ 'Invalid target: %s (expected i386)' $target
   2.209 +		;;
   2.210 +	esac
   2.211 +	rm -rf $TMP_DIR
   2.212 +}
   2.213 +
   2.214 +
   2.215 +# convert a .pkg.tar.gz/.pkg.tar.xz/.apk package to .tazpkg
   2.216 +
   2.217 +convert_arch()
   2.218 +{
   2.219 +	mkdir -p $TMP_DIR/fs
   2.220 +	busybox tar xf $PACKAGE_FILE -C $TMP_DIR/fs
   2.221 +	if [ -f $TMP_DIR/fs/.PKGINFO ]; then
   2.222 +		cd $TMP_DIR
   2.223 +		package="$(sed '/^pkgname/!d;s/.*= //' fs/.PKGINFO)"
   2.224 +		version="$(sed '/^pkgver/!d;s/.*= //'  fs/.PKGINFO)"
   2.225 +		descrip="$(sed '/^pkgdesc/!d;s/.*= //' fs/.PKGINFO)"
   2.226 +		url="$(sed '/^url/!d;s/.*= //' fs/.PKGINFO)"
   2.227 +		maintainer="$(sed '/^packager/!d;s/.*= //' fs/.PKGINFO)"
   2.228 +		file=$package-$version
   2.229 +		mkdir $file
   2.230 +		mv fs $file
   2.231 +		cat > $file/receipt <<EOT
   2.232 +# SliTaz package receipt.
   2.233 +# generated by tazpkg from Archlinux package $(basename $PACKAGE_FILE)
   2.234 +PACKAGE="$package"
   2.235 +VERSION="$version"
   2.236 +CATEGORY="misc"
   2.237 +SHORT_DESC="$descrip"
   2.238 +WEB_SITE="$url"
   2.239 +MAINTAINER="$maintainer"
   2.240 +DEPENDS="$(find_depends)"
   2.241 +EOT
   2.242 +		show_unresolved_lib $file/receipt
   2.243 +		rm -f $file/fs/.[A-Z]*
   2.244 +		tazpkg pack $file
   2.245 +		mv $file.tazpkg $TOP_DIR
   2.246 +	else
   2.247 +		_ 'File "%s" does not look like %s package!' $PACKAGE_FILE 'Archlinux/Alpine'
   2.248 +	fi
   2.249 +	cd $TOP_DIR
   2.250 +	rm -rf $TMP_DIR
   2.251 +}
   2.252 +
   2.253 +
   2.254 +# get package and version from PACKAGE_FILE
   2.255 +
   2.256 +parse_pkgname()
   2.257 +{
   2.258 +	package=$(basename ${2:-$PACKAGE_FILE} $1)
   2.259 +	IFS='-'
   2.260 +	set -- $package
   2.261 +	unset IFS
   2.262 +	package=$1
   2.263 +	version=$2
   2.264 +	if [ -z "$version" ]; then
   2.265 +		package=${1%%[0-9\.]*}
   2.266 +		version=${1#$package}
   2.267 +	fi
   2.268 +	file="$package-$version"
   2.269 +	mkdir $file
   2.270 +}
   2.271 +
   2.272 +
   2.273 +finish_convert_puppy()
   2.274 +{
   2.275 +	rm -f fs/*.specs
   2.276 +	mv fs $file
   2.277 +	cat > $file/receipt <<EOT
   2.278 +# SliTaz package receipt.
   2.279 +# generated by tazpkg from puppy package $(basename $PACKAGE_FILE)
   2.280 +PACKAGE="$package"
   2.281 +VERSION="$version"
   2.282 +CATEGORY="misc"
   2.283 +SHORT_DESC="$desc"
   2.284 +WEB_SITE="http://puppylinux.org/"
   2.285 +MAINTAINER="nobody@slitaz.org"
   2.286 +DEPENDS="$(find_depends)"
   2.287 +EOT
   2.288 +	show_unresolved_lib $file/receipt
   2.289 +	for i in install uninstall ; do
   2.290 +		[ -f $file/fs/p$i.sh ] && cat >> $file/receipt <<EOM
   2.291 +
   2.292 +post_$i()
   2.293 +{
   2.294 +chroot \$1/ sh - << EOT
   2.295 +cd /
   2.296 +$(sed -e 's/\\/\\\\/g' -e 's/\$/\\$/g' < $file/fs/p$i.sh ; rm -f $file/fs/p$i.sh)
   2.297 +EOT
   2.298 +}
   2.299 +EOM
   2.300 +	done
   2.301 +	sed -i 's/post_uninstall/post_remove/' $file/receipt
   2.302 +	tazpkg pack $file
   2.303 +	mv $file.tazpkg $TOP_DIR
   2.304 +	cd $TOP_DIR
   2.305 +	rm -rf $TMP_DIR
   2.306 +}
   2.307 +
   2.308 +
   2.309 +# convert a .sfs package to .tazpkg
   2.310 +
   2.311 +convert_sfs()
   2.312 +{
   2.313 +	[ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs 
   2.314 +	if ! unsquashfs -l $PACKAGE_FILE | grep -q squashfs-root/pet.specs$ ; then
   2.315 +		_ 'File "%s" does not look like %s package!' $PACKAGE_FILE 'Puppy'
   2.316 +		return 1
   2.317 +	fi
   2.318 +	mkdir -p $TMP_DIR 
   2.319 +	cd $TMP_DIR
   2.320 +	parse_pkgname .sfs
   2.321 +	unsquashfs $PACKAGE_FILE
   2.322 +	mv squashfs-root fs
   2.323 +	set -- $(cat fs/pet.specs)
   2.324 +	desc="$10"
   2.325 +	finish_convert_puppy
   2.326 +}
   2.327 +
   2.328 +
   2.329 +# convert a .pet package to .tazpkg
   2.330 +
   2.331 +convert_pet()
   2.332 +{
   2.333 +	mkdir -p $TMP_DIR 
   2.334 +	cd $TMP_DIR
   2.335 +	parse_pkgname .pet
   2.336 +	tar xzf $PACKAGE_FILE 2> /dev/null
   2.337 +	. $package*/*.specs
   2.338 +	desc="$PETMENUDESCR"
   2.339 +	mv $package*/ fs
   2.340 +	finish_convert_puppy
   2.341 +}
   2.342 +
   2.343 +
   2.344 +# convert a .sb package to .tazpkg
   2.345 +
   2.346 +convert_sb()
   2.347 +{
   2.348 +	[ -n "$(which unsquashfs)" ] || tazpkg get-install squashfs 
   2.349 +	if ! unsquashfs -l $PACKAGE_FILE | grep -q squashfs-root/var/log/removed_scripts ; then
   2.350 +		_ 'File "%s" does not look like %s package!' $PACKAGE_FILE 'Slax'
   2.351 +		return 1
   2.352 +	fi
   2.353 +	mkdir -p $TMP_DIR 
   2.354 +	cd $TMP_DIR
   2.355 +	unsquashfs $PACKAGE_FILE
   2.356 +	mv squashfs-root fs
   2.357 +	parse_pkgname '' $(cat fs/var/log/packages/* | sed '/PACKAGE NAME:/!d;s/.*: *//')
   2.358 +	desc="$(cat fs/var/log/packages/* | sed '/^PACKAGE DESCRIPTION:/,$!d;N;s/.*: //;q')"
   2.359 +	cat fs/var/log/packages/* | sed '/^PACKAGE DESCRIPTION:/,/FILE LIST/!d;s/.*://;/^$/d' > $file/description.txt
   2.360 +	mv fs $file
   2.361 +	cat > $file/receipt <<EOT
   2.362 +# SliTaz package receipt.
   2.363 +# generated by tazpkg from slax package $(basename $PACKAGE_FILE)
   2.364 +PACKAGE="$package"
   2.365 +VERSION="$version"
   2.366 +CATEGORY="misc"
   2.367 +SHORT_DESC="$desc"
   2.368 +WEB_SITE="http://www.slax.org/"
   2.369 +MAINTAINER="nobody@slitaz.org"
   2.370 +DEPENDS="$(find_depends)"
   2.371 +EOT
   2.372 +	show_unresolved_lib $file/receipt
   2.373 +	[ -f $file/fs/var/log/scripts/$package* ] && cat >> $file/receipt <<EOM
   2.374 +
   2.375 +post_install()
   2.376 +{
   2.377 +chroot \$1/ sh - << EOT
   2.378 +cd /
   2.379 +$(cat $file/fs/var/log/scripts/$package* | sed -e 's/\\/\\\\/g' | sed -e 's/\$/\\$/g')
   2.380 +EOT
   2.381 +}
   2.382 +EOM
   2.383 +	tazpkg pack $file
   2.384 +	mv $file.tazpkg $TOP_DIR
   2.385 +	cd $TOP_DIR
   2.386 +	rm -rf $TMP_DIR
   2.387 +}
   2.388 +
   2.389 +
   2.390 +# convert a .tgz package to .tazpkg
   2.391 +
   2.392 +convert_tgz()
   2.393 +{
   2.394 +	parse_pkgname
   2.395 +	mkdir -p $TMP_DIR/$file/fs
   2.396 +	tar xzf $PACKAGE_FILE -C $TMP_DIR/$file/fs
   2.397 +	cd $TMP_DIR
   2.398 +	if [ -d $file/fs/install ]; then
   2.399 +		descrip=$(sed "/^$package/!d;s/.*(\\(.*\\)).*/\\1/;q" \
   2.400 +			  $file/fs/install/slack-desc)
   2.401 +		cat > $file/receipt <<EOT
   2.402 +# SliTaz package receipt.
   2.403 +# generated by tazpkg from slackware package $(basename $PACKAGE_FILE)
   2.404 +PACKAGE="$package"
   2.405 +VERSION="$version"
   2.406 +CATEGORY="misc"
   2.407 +SHORT_DESC="$descrip"
   2.408 +WEB_SITE="http://www.slackware.com/packages/"
   2.409 +MAINTAINER="nobody@slitaz.org"
   2.410 +DEPENDS="$(find_depends)"
   2.411 +EOT
   2.412 +		show_unresolved_lib $file/receipt
   2.413 +		[ -f $file/fs/install/doinst.sh ] && cat >> $file/receipt <<EOM
   2.414 +
   2.415 +post_install()
   2.416 +{
   2.417 +chroot \$1/ sh - << EOT
   2.418 +cd /
   2.419 +$(sed -e 's/\\/\\\\/g' -e 's/\$/\\$/g' < $file/fs/install/doinst.sh)
   2.420 +EOT
   2.421 +}
   2.422 +EOM
   2.423 +		sed "/^$package/:d;s/^$package://" \
   2.424 +			$file/fs/install/slack-desc > $file/description.txt
   2.425 +		[ -s $file/description.txt ] || rm -f $file/description.txt
   2.426 +		rm -rf $file/fs/install
   2.427 +		tazpkg pack $file
   2.428 +		mv $file.tazpkg $TOP_DIR
   2.429 +	else
   2.430 +		_ 'File "%s" does not look like %s package!' $PACKAGE_FILE 'Slackware'
   2.431 +	fi
   2.432 +	cd $TOP_DIR
   2.433 +	rm -rf $TMP_DIR
   2.434 +}
   2.435 +
   2.436 +
   2.437 +# convert a .deb package to .tazpkg
   2.438 +
   2.439 +convert_deb()
   2.440 +{
   2.441 +	mkdir -p $TMP_DIR
   2.442 +	dpkg-deb -e $PACKAGE_FILE $TMP_DIR
   2.443 +	package=$(sed '/^ *Package:/!d;s/.*: //' $TMP_DIR/control)
   2.444 +	version=$(sed '/^ *Version:/!d;s/.*: //' $TMP_DIR/control)
   2.445 +	descrip=$(sed '/^ *Description:/!d;s/.*: //' $TMP_DIR/control)
   2.446 +	homepage=$(sed '/^ *Homepage:/!d;s/.*: //' $TMP_DIR/control)
   2.447 +	target="$(sed '/^ *Architecture:/!d;s/.*: //' $TMP_DIR/control)"
   2.448 +	case "$target" in
   2.449 +	i386|all)
   2.450 +		file="$package-$version"
   2.451 +		mkdir -p $TMP_DIR/$file/fs/
   2.452 +		dpkg-deb -x $PACKAGE_FILE $TMP_DIR/$file/fs
   2.453 +		cd $TMP_DIR
   2.454 +		cat > $file/receipt <<EOT
   2.455 +# SliTaz package receipt.
   2.456 +# generated by tazpkg from debian package $(basename $PACKAGE_FILE)
   2.457 +PACKAGE="$package"
   2.458 +VERSION="$version"
   2.459 +CATEGORY="misc"
   2.460 +SHORT_DESC="$descrip"
   2.461 +WEB_SITE="${homepage:-http://packages.debian.org/search?keywords=$package}"
   2.462 +MAINTAINER="nobody@slitaz.org"
   2.463 +EOT
   2.464 +		LICENSE="$(grep /usr/share/common-licenses/ \
   2.465 +		  $PACKAGE_FILE $TMP_DIR/$file/fs/usr/share/doc/*/copyright | \
   2.466 +		  sed 's|.*common-licenses/\([-\.A-Za-z0-9]*\).*|\1|;s|[-\.]$||q')"
   2.467 +		[ -n "$LICENSE" ] && echo "LICENSE=\"$LICENSE\"" >> $file/receipt
   2.468 +		echo "DEPENDS=\"$(find_depends)\"" >> $file/receipt
   2.469 +		[ -s conffiles ] && cat >> $file/receipt <<EOT
   2.470 +CONFIG_FILES="$(cat conffiles)"
   2.471 +EOT
   2.472 +		show_unresolved_lib $file/receipt
   2.473 +		awk '
   2.474 +{
   2.475 +   if (/^ / && show) print substr($0,2);
   2.476 +   else show=0;
   2.477 +   if (/^Description/) show=1;
   2.478 +}' < $TMP_DIR/control > $file/description.txt
   2.479 +		sed -i 's/^\.$//' $file/description.txt
   2.480 +		[ -s $file/description.txt ] || rm -f $file/description.txt
   2.481 +		tazpkg pack $file
   2.482 +		mv $file.tazpkg $TOP_DIR
   2.483 +		;;
   2.484 +	*)
   2.485 +		_ 'Invalid target: %s (expected i386)' $target
   2.486 +		;;
   2.487 +	esac
   2.488 +	cd $TOP_DIR
   2.489 +	rm -rf $TMP_DIR
   2.490 +}
   2.491 +
   2.492 +
   2.493 +# convert a .rpm package to .tazpkg
   2.494 +
   2.495 +convert_rpm()
   2.496 +{
   2.497 +	mkdir -p $TMP_DIR
   2.498 +	cp $PACKAGE_FILE $TMP_DIR
   2.499 +	PACKAGE_FILE=$TMP_DIR/$(basename $PACKAGE_FILE)
   2.500 +	rpm -qip $PACKAGE_FILE | awk -v pkg=$(basename $PACKAGE_FILE) '
   2.501 +BEGIN {
   2.502 +	goturl=0;
   2.503 +	printf "# SliTaz package receipt.\n";
   2.504 +	printf "# generated by tazpkg from rpm package %s\n",pkg;
   2.505 +}
   2.506 +{
   2.507 +	if (/^Name/) { name=$3; printf "PACKAGE=\"%s\"\n",$3; }
   2.508 +	if (/^Version/) printf "VERSION=\"%s-",$3;
   2.509 +	if (/^Release/) printf "%s\"\n",$3;
   2.510 +	if (/^Summary/) printf "SHORT_DESC=\"%s\"\n",substr($0,15);
   2.511 +	if (/^URL/) { goturl=1; printf "WEB_SITE=\"%s\"\n",$3; }
   2.512 +}
   2.513 +END {
   2.514 +	if (goturl == 0)
   2.515 +		printf "WEB_SITE=\"http://rpmfind.net/linux/rpm2html/search.php?query=%s\"\n",name;
   2.516 +	printf "CATEGORY=\"misc\"\n";
   2.517 +	printf "MAINTAINER=\"nobody@slitaz.org\"\n";
   2.518 +}
   2.519 +' > $TMP_DIR/receipt
   2.520 +	. $TMP_DIR/receipt
   2.521 +	file=$PACKAGE-$VERSION
   2.522 +	mkdir -p $TMP_DIR/$file/fs/
   2.523 +	mv $TMP_DIR/receipt $TMP_DIR/$file
   2.524 +	rpm -qip $PACKAGE_FILE | awk '
   2.525 +BEGIN { show=0 }
   2.526 +{
   2.527 +  if (show) print;
   2.528 +  if (/^Description/) show=1;
   2.529 +}
   2.530 +' > $TMP_DIR/$file/description.txt
   2.531 +	cd $TMP_DIR/$file/fs/
   2.532 +	rpm2cpio $PACKAGE_FILE | cpio -idm --quiet
   2.533 +	# rpm2cpio can't extract some new RPMs
   2.534 +	if [ $? == 1 ]; then
   2.535 +		if [ ! -e $INSTALLED/p7zip-full/receipt ]; then
   2.536 +			boldify "$(_ 'Unable to extract the RPM using standard tools (rpm2cpio).')"
   2.537 +			confirm "$(_n 'Do you want to install "%s" package? (y/N)' 'p7zip-full')"
   2.538 +			if [ $? = 0 ]; then
   2.539 +				tazpkg -gi p7zip-full
   2.540 +			else
   2.541 +				rm -rf $TMP_DIR
   2.542 +				exit 1
   2.543 +			fi
   2.544 +		fi
   2.545 +		# we may already have 7z or may have just installed it in the step above
   2.546 +		if [ -e $INSTALLED/p7zip-full/receipt ]; then
   2.547 +			7z x -so $PACKAGE_FILE | cpio -idm --quiet
   2.548 +		fi
   2.549 +	fi
   2.550 +	cd ../..
   2.551 +	echo "DEPENDS=\"$(find_depends)\"" >> $TMP_DIR/$file/receipt
   2.552 +	show_unresolved_lib $TMP_DIR/$file/receipt
   2.553 +	tazpkg pack $file
   2.554 +	mv $file.tazpkg $TOP_DIR
   2.555 +	cd $TOP_DIR
   2.556 +	rm -rf $TMP_DIR
   2.557 +}
   2.558 +
   2.559 +# convert a .xbps package to .tazpkg (http://repo.voidlinux.eu/current/)
   2.560 +xbpstag()
   2.561 +{
   2.562 +	sed "/<key>$1<\/key>/!d{n;s/.*>\\(.*\\)<.*/\\1/}" \
   2.563 +		< fs/props.plist | sed \$!d
   2.564 +}
   2.565 +
   2.566 +convert_xbps()
   2.567 +{
   2.568 +	mkdir -p $TMP_DIR/fs
   2.569 +	( xzcat $PACKAGE_FILE || bzcat $PACKAGE_FILE || zcat $PACKAGE_FILE ) | \
   2.570 +		tar xf - -C $TMP_DIR/fs
   2.571 +
   2.572 +	cd $TMP_DIR
   2.573 +	HOST_ARCH="$(xbpstag architecture)"
   2.574 +	case "$HOST_ARCH" in
   2.575 +	i686)	HOST_ARCH="i486" ;;
   2.576 +	*)	_ 'Arch "%s" not supported.' $HOST_ARCH
   2.577 +		HOST_ARCH=
   2.578 +	esac
   2.579 +
   2.580 +	if [ "$HOST_ARCH" ]; then
   2.581 +		package="$(xbpstag pkgname)"
   2.582 +		version="$(xbpstag version)"
   2.583 +		file=$package-$version
   2.584 +		mkdir $file
   2.585 +		cat > $file/receipt <<EOT
   2.586 +# SliTaz package receipt.
   2.587 +# generated by tazpkg from package $(basename $PACKAGE_FILE)
   2.588 +PACKAGE="$package"
   2.589 +VERSION="$version"
   2.590 +CATEGORY="misc"
   2.591 +SHORT_DESC="$(xbpstag short_desc)"
   2.592 +WEB_SITE="$(xbpstag homepage)"
   2.593 +MAINTAINER="$(xbpstag maintainer | sed 's/&gt;/>/;s/&lt;/</')"
   2.594 +LICENSE="$(xbpstag license | sed 's/-//g')"
   2.595 +HOST_ARCH="$HOST_ARCH"
   2.596 +CONFIG_FILES="$(sed '/<key>conf_files<\/key>/,/<key>/!d;/array>/d;/<key>/d;s/.*>\(.*\)<.*/\1/' fs/props.plist)"
   2.597 +
   2.598 +DEPENDS="$(find_depends)"
   2.599 +
   2.600 +EOT
   2.601 +		while read script func ; do
   2.602 +			[ -s fs/$script  ] && cat >> $file/receipt <<EOT
   2.603 +xbps_$func()
   2.604 +{
   2.605 +set +e
   2.606 +$(cat fs/$script)
   2.607 +}
   2.608 +
   2.609 +pre_$func()
   2.610 +{
   2.611 +	xbps_$func pre $package $version yes /etc/xbps.conf $HOST_ARCH
   2.612 +}
   2.613 +
   2.614 +post_$func()
   2.615 +{
   2.616 +	xbps_$func post $package $version yes /etc/xbps.conf $HOST_ARCH
   2.617 +}
   2.618 +
   2.619 +EOT
   2.620 +			rm -f fs/$script
   2.621 +		done << EOT
   2.622 +INSTALL		install
   2.623 +REMOVE		remove
   2.624 +EOT
   2.625 +		rm -f fs/*.plist
   2.626 +		mv fs $package-$version
   2.627 +		tazpkg pack $package-$version
   2.628 +		mv $package-$version.tazpkg $TOP_DIR
   2.629 +	fi
   2.630 +	cd $TOP_DIR
   2.631 +	rm -rf $TMP_DIR
   2.632 +}
   2.633 +
   2.634 +
   2.635 +
   2.636 +if [ "$(dd if=$PACKAGE_FILE bs=8 count=1 skip=1 2> /dev/null)"  == "debian-b" ]; then
   2.637 +	convert_deb
   2.638 +else
   2.639 +	case "$PACKAGE_FILE" in
   2.640 +		*.deb|*.udeb)
   2.641 +			convert_deb;;
   2.642 +		*.rpm)
   2.643 +			convert_rpm;;
   2.644 +		*.sb)
   2.645 +			convert_sb;;
   2.646 +		*.sfs)
   2.647 +			convert_sfs;;
   2.648 +		*.pet)
   2.649 +			convert_pet;;
   2.650 +		*.tgz)
   2.651 +			convert_tgz;;
   2.652 +		*.apk|*.pkg.tar.gz|*.pkg.tar.xz)
   2.653 +			convert_arch;;
   2.654 +		*.ipk|*.opk)
   2.655 +			convert_ipk;;
   2.656 +		*.spack)
   2.657 +			convert_spack;;
   2.658 +		*.tar.bz2)
   2.659 +			convert_upkg;;
   2.660 +		*.xbps)
   2.661 +			convert_xbps;;
   2.662 +		*)
   2.663 +			_ 'Unsupported format' ;;
   2.664 +	esac
   2.665 +fi
   2.666 +
   2.667 +exit 0
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/modules/tazpkg-find-depends	Mon Dec 15 04:43:04 2014 +0200
     3.3 @@ -0,0 +1,77 @@
     3.4 +# /usr/lib/tazpkg/tazpkg-find-depends: this program is a part of TazPkg.
     3.5 +# This file contains the functions that are common to tazpkg and tazpkg-convert,
     3.6 +# and sourced by them.
     3.7 +
     3.8 +
     3.9 +# Need by check_depends
    3.10 +TMPLOCALSTATE=
    3.11 +
    3.12 +
    3.13 +# Check for ELF file
    3.14 +
    3.15 +is_elf()
    3.16 +{
    3.17 +	[ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
    3.18 +}
    3.19 +
    3.20 +
    3.21 +# Print shared library dependencies
    3.22 +
    3.23 +ldd()
    3.24 +{
    3.25 +	LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
    3.26 +}
    3.27 +
    3.28 +
    3.29 +# search dependencies for files in $TMP_DIR/$file/fs
    3.30 +
    3.31 +find_depends()
    3.32 +{
    3.33 +	DEFAULT_DEPENDS="glibc-base gcc-lib-base"
    3.34 +
    3.35 +	[ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$PKGS_DB
    3.36 +	[ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge > /dev/null
    3.37 +	for i in $TMPLOCALSTATE/files.list.lzma \
    3.38 +		$TMPLOCALSTATE/undigest/*/files.list.lzma ; do
    3.39 +		[ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list
    3.40 +	done
    3.41 +
    3.42 +	find ${1:-$TMP_DIR/$file/fs} -type f | \
    3.43 +	while read chkfile ; do
    3.44 +		is_elf $chkfile || continue
    3.45 +		case "$chkfile" in
    3.46 +			*.o|*.ko|*.ko.gz) continue;;
    3.47 +		esac
    3.48 +
    3.49 +		ldd $chkfile | \
    3.50 +		while read lib rem; do
    3.51 +			case "$lib" in
    3.52 +				statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;;
    3.53 +			esac
    3.54 +			find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue
    3.55 +
    3.56 +			for dep in $(fgrep $lib files.list | cut -d: -f1); do
    3.57 +				case " $DEFAULT_DEPENDS " in
    3.58 +					*\ $dep\ *) continue 2;;
    3.59 +				esac
    3.60 +				grep -qs "^$dep$" $TMP_DIR/depends && continue 2
    3.61 +			done
    3.62 +
    3.63 +			if [ -n "$dep" ]; then
    3.64 +				echo "$dep" >> $TMP_DIR/depends
    3.65 +			else
    3.66 +				grep -qs ^$lib$ $TMP_DIR/unresolved ||
    3.67 +					echo "$lib" >> $TMP_DIR/unresolved
    3.68 +			fi
    3.69 +		done
    3.70 +	done
    3.71 +
    3.72 +	spc=""
    3.73 +	sort < $TMP_DIR/depends 2> /dev/null | uniq | \
    3.74 +	while read file; do
    3.75 +		echo -n "$spc$file"
    3.76 +		spc=" "
    3.77 +	done
    3.78 +}
    3.79 +
    3.80 +
     4.1 --- a/pkgs	Mon Dec 15 04:33:27 2014 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,19 +0,0 @@
     4.4 -TEXTDOMAIN_original=$TEXTDOMAIN
     4.5 -export TEXTDOMAIN='tazpkg'
     4.6 -
     4.7 -cat <<EOT
     4.8 -<li><a href="/pkgs.cgi">$(gettext 'Packages')</a>
     4.9 -	<ul>
    4.10 -		<li><a href="/pkgs.cgi?list"><img
    4.11 -			src="/styles/default/images/tazpkg.png" />$(gettext 'My packages')</a></li>
    4.12 -		<li><a href="/pkgs.cgi?recharge"><img
    4.13 -			src="/styles/default/images/update.png" />$(gettext 'Recharge list')</a></li>
    4.14 -		<li><a href="/pkgs.cgi?up"><img
    4.15 -			src="/styles/default/images/update.png" />$(gettext 'Check updates')</a></li>
    4.16 -		<li><a href="/pkgs.cgi?admin"><img
    4.17 -			src="/styles/default/images/edit.png" />$(gettext 'Administration')</a></li>
    4.18 -	</ul>
    4.19 -</li>
    4.20 -EOT
    4.21 -
    4.22 -export TEXTDOMAIN=$TEXTDOMAIN_original
     5.1 --- a/pkgs.cgi	Mon Dec 15 04:33:27 2014 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,1029 +0,0 @@
     5.4 -#!/bin/sh
     5.5 -#
     5.6 -# TazPkg CGI interface - Manage packages via a browser
     5.7 -#
     5.8 -# This CGI interface extensively uses tazpkg to manage packages and have
     5.9 -# its own code for some tasks. Please KISS, it is important and keep speed
    5.10 -# in mind. Thanks, Pankso.
    5.11 -#
    5.12 -# (C) 2011-2014 SliTaz GNU/Linux - BSD License
    5.13 -#
    5.14 -
    5.15 -. /lib/libtaz.sh
    5.16 -. lib/libtazpanel
    5.17 -get_config
    5.18 -header
    5.19 -
    5.20 -
    5.21 -# xHTML 5 header with special side bar for categories.
    5.22 -TITLE=$(TEXTDOMAIN='tazpkg'; _ 'TazPanel - Packages')
    5.23 -xhtml_header | sed 's/id="content"/id="content-sidebar"/'
    5.24 -
    5.25 -export TEXTDOMAIN='tazpkg'
    5.26 -
    5.27 -
    5.28 -pkg_info_link()
    5.29 -{
    5.30 -	echo "$SCRIPT_NAME?info=$1" | sed 's/+/%2B/g'
    5.31 -}
    5.32 -
    5.33 -
    5.34 -i18n_desc() {
    5.35 -	# Display localized short description
    5.36 -	if [ -e "$PKGS_DB/packages-desc.$LANG" ]; then
    5.37 -		LOCDESC=$(grep -e "^$pkg	" $PKGS_DB/packages-desc.$LANG | cut -d'	' -f2)
    5.38 -	[ "x$LOCDESC" != "x" ] && SHORT_DESC="$LOCDESC"
    5.39 -	fi
    5.40 -}
    5.41 -
    5.42 -
    5.43 -# We need packages information for list and search
    5.44 -
    5.45 -parse_packages_desc() {
    5.46 -	IFS="|"
    5.47 -	cut -f 1,2,3,5 -d "|" | while read PACKAGE VERSION SHORT_DESC WEB_SITE
    5.48 -	do
    5.49 -		image=tazpkg-installed.png
    5.50 -		[ -d $INSTALLED/${PACKAGE% } ] || image=tazpkg.png
    5.51 -		i18n_desc
    5.52 -		cat << EOT
    5.53 -<tr>
    5.54 -<td><input type="checkbox" name="pkg" value="$PACKAGE">
    5.55 -	<a href="$(pkg_info_link $PACKAGE)"><img
    5.56 -		src="$IMAGES/$image"/>$PACKAGE</a></td>
    5.57 -<td>$VERSION</td>
    5.58 -<td class="desc">$SHORT_DESC</td>
    5.59 -<td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
    5.60 -</tr>
    5.61 -EOT
    5.62 -	done
    5.63 -	unset IFS
    5.64 -}
    5.65 -
    5.66 -
    5.67 -# Display a full summary of packages stats
    5.68 -
    5.69 -packages_summary() {
    5.70 -	cat << EOT
    5.71 -<table class="zebra outbox">
    5.72 -<tbody>
    5.73 -<tr><td>$(_ 'Last recharge:')</td>
    5.74 -EOT
    5.75 -	stat=$(stat -c %y $PKGS_DB/packages.list | \
    5.76 -		sed 's/\(:..\):.*/\1/' | awk '{print $1}')
    5.77 -	mtime=$(find $PKGS_DB/packages.list -mtime +10)
    5.78 -	echo -n "<td>$stat "
    5.79 -	if [ "$mtime" ]; then
    5.80 -		_ '(Older than 10 days)'
    5.81 -	else
    5.82 -		_ '(Not older than 10 days)'
    5.83 -	fi
    5.84 -	cat << EOT
    5.85 -</td></tr>
    5.86 -<tr><td>$(_ 'Installed packages:')</td>
    5.87 -	<td>$(ls $INSTALLED | wc -l)</td></tr>
    5.88 -<tr><td>$(_ 'Mirrored packages:')</td>
    5.89 -	<td>$(cat $PKGS_DB/packages.list | wc -l)</td></tr>
    5.90 -<tr><td>$(_ 'Upgradeable packages:')</td>
    5.91 -	<td>$(cat $PKGS_DB/packages.up | wc -l)</td></tr>
    5.92 -<tr><td>$(_ 'Installed files:')</td>
    5.93 -	<td>$(cat $INSTALLED/*/files.list | wc -l)</td></tr>
    5.94 -<tr><td>$(_ 'Blocked packages:')</td>
    5.95 -	<td>$(cat $PKGS_DB/blocked-packages.list | wc -l)</td></tr>
    5.96 -</tbody>
    5.97 -</table>
    5.98 -EOT
    5.99 -}
   5.100 -
   5.101 -
   5.102 -# Parse mirrors list to be able to have an icon and remove link
   5.103 -
   5.104 -list_mirrors() {
   5.105 -	while read line
   5.106 -	do
   5.107 -		cat << EOT
   5.108 -<li>
   5.109 -	<a href="$SCRIPT_NAME?admin=rm-mirror=$line&amp;file=$(httpd -e $1)">
   5.110 -		<img src="$IMAGES/clear.png" title="$(_ 'Delete')" />
   5.111 -	</a>
   5.112 -	<a href="$SCRIPT_NAME?admin=select-mirror&amp;mirror=$line">
   5.113 -		<img src="$IMAGES/start.png" title="$(_ 'Use as default')" />
   5.114 -	</a>
   5.115 -	<a href="$line">$line</a>
   5.116 -</li>
   5.117 -EOT
   5.118 -	done < $1
   5.119 -}
   5.120 -
   5.121 -
   5.122 -# Parse repositories list to be able to have an icon and remove link
   5.123 -
   5.124 -list_repos() {
   5.125 -	ls $PKGS_DB/undigest 2> /dev/null | while read repo ; do
   5.126 -		cat <<EOT
   5.127 -	<li><a href="$SCRIPT_NAME?admin=rm-repo=$repo">
   5.128 -		<img src="$IMAGES/clear.png">$repo</a></li>
   5.129 -EOT
   5.130 -	done
   5.131 -}
   5.132 -
   5.133 -
   5.134 -
   5.135 -#
   5.136 -# xHTML functions
   5.137 -#
   5.138 -
   5.139 -
   5.140 -# ENTER will search but user may search for a button, so put one.
   5.141 -
   5.142 -search_form() {
   5.143 -	[ -n "$repo" ] || repo="$(GET repo)"
   5.144 -	[ -n "$repo" ] || repo=Any
   5.145 -	cat << EOT
   5.146 -<div class="search">
   5.147 -	<form method="get" action="$SCRIPT_NAME">
   5.148 -		<p>
   5.149 -			<input type="text" name="search" size="20">
   5.150 -			<input type="submit" value="$(gettext 'Search')">
   5.151 -			<input class="radius" type="submit" name="files"
   5.152 -				value="$(_n 'Files')">
   5.153 -			<input type="hidden" name="repo" value="$repo" />
   5.154 -		</p>
   5.155 -	</form>
   5.156 -</div>
   5.157 -EOT
   5.158 -}
   5.159 -
   5.160 -
   5.161 -table_head() {
   5.162 -	cat << EOT
   5.163 -		<thead>
   5.164 -		<tr>
   5.165 -			<td>$(_ 'Name')</td>
   5.166 -			<td>$(_ 'Version')</td>
   5.167 -			<td>$(_ 'Description')</td>
   5.168 -			<td>$(_ 'Web')</td>
   5.169 -		</tr>
   5.170 -		</thead>
   5.171 -EOT
   5.172 -}
   5.173 -
   5.174 -
   5.175 -sidebar() {
   5.176 -	[ -n "$repo" ] || repo=Public
   5.177 -	cat << EOT
   5.178 -<div id="sidebar">
   5.179 -	<h4>$(_ 'Categories')</h4>
   5.180 -	<a class="active_base-system"  href="$SCRIPT_NAME?cat=base-system&repo=$repo" >$(_ 'base-system')</a>
   5.181 -	<a class="active_x-window"     href="$SCRIPT_NAME?cat=x-window&repo=$repo"    >$(_ 'x-window')</a>
   5.182 -	<a class="active_utilities"    href="$SCRIPT_NAME?cat=utilities&repo=$repo"   >$(_ 'utilities')</a>
   5.183 -	<a class="active_network"      href="$SCRIPT_NAME?cat=network&repo=$repo"     >$(_ 'network')</a>
   5.184 -	<a class="active_games"        href="$SCRIPT_NAME?cat=games&repo=$repo"       >$(_ 'games')</a>
   5.185 -	<a class="active_graphics"     href="$SCRIPT_NAME?cat=graphics&repo=$repo"    >$(_ 'graphics')</a>
   5.186 -	<a class="active_office"       href="$SCRIPT_NAME?cat=office&repo=$repo"      >$(_ 'office')</a>
   5.187 -	<a class="active_multimedia"   href="$SCRIPT_NAME?cat=multimedia&repo=$repo"  >$(_ 'multimedia')</a>
   5.188 -	<a class="active_development"  href="$SCRIPT_NAME?cat=development&repo=$repo" >$(_ 'development')</a>
   5.189 -	<a class="active_system-tools" href="$SCRIPT_NAME?cat=system-tools&repo=$repo">$(_ 'system-tools')</a>
   5.190 -	<a class="active_security"     href="$SCRIPT_NAME?cat=security&repo=$repo"    >$(_ 'security')</a>
   5.191 -	<a class="active_misc"         href="$SCRIPT_NAME?cat=misc&repo=$repo"        >$(_ 'misc')</a>
   5.192 -	<a class="active_meta"         href="$SCRIPT_NAME?cat=meta&repo=$repo"        >$(_ 'meta')</a>
   5.193 -	<a class="active_non-free"     href="$SCRIPT_NAME?cat=non-free&repo=$repo"    >$(_ 'non-free')</a>
   5.194 -	<a class="active_all"          href="$SCRIPT_NAME?cat=all&repo=$repo"         >$(_ 'all')</a>
   5.195 -	<a class="active_extra"        href="$SCRIPT_NAME?cat=extra&repo=$repo"       >$(_ 'extra')</a>
   5.196 -EOT
   5.197 -
   5.198 -	if [ -d $PKGS_DB/undigest ]; then
   5.199 -		[ -n "$category" ] || category="base-system"
   5.200 -		cat << EOT
   5.201 -	<h4>$(_ 'Repositories')</h4>
   5.202 -	<a class="repo_Public" href="$SCRIPT_NAME?repo=Public&cat=$category">$(_ 'Public')</a>
   5.203 -EOT
   5.204 -
   5.205 -		for i in $(ls $PKGS_DB/undigest); do
   5.206 -			cat << EOT
   5.207 -	<a class="repo_$i" href="$SCRIPT_NAME?repo=$i&cat=$category">$i</a>
   5.208 -EOT
   5.209 -		done
   5.210 -
   5.211 -		cat << EOT
   5.212 -	<a class="repo_Any" href="$SCRIPT_NAME?repo=Any&cat=$category">$(_ 'Any')</a>
   5.213 -EOT
   5.214 -	fi
   5.215 -	echo "</div>"
   5.216 -}
   5.217 -
   5.218 -
   5.219 -repo_list() {
   5.220 -	if [ -n "$(ls $PKGS_DB/undigest/ 2> /dev/null)" ]; then
   5.221 -		case "$repo" in
   5.222 -			Public)
   5.223 -				;;
   5.224 -			""|Any)
   5.225 -				for i in $PKGS_DB/undigest/* ; do
   5.226 -					[ -d "$i" ] && echo "$i$1"
   5.227 -				done ;;
   5.228 -			*)
   5.229 -				echo "$PKGS_DB/undigest/$repo$1"
   5.230 -				return ;;
   5.231 -		esac
   5.232 -	fi
   5.233 -	echo "$PKGS_DB$1"
   5.234 -}
   5.235 -
   5.236 -
   5.237 -repo_name() {
   5.238 -	case "$1" in
   5.239 -		$PKGS_DB)
   5.240 -			echo "Public" ;;
   5.241 -		$PKGS_DB/undigest/*)
   5.242 -			echo ${1#$PKGS_DB/undigest/} ;;
   5.243 -	esac
   5.244 -}
   5.245 -
   5.246 -
   5.247 -
   5.248 -#
   5.249 -# Commands
   5.250 -#
   5.251 -
   5.252 -
   5.253 -case " $(GET) " in
   5.254 -	*\ list\ *)
   5.255 -		#
   5.256 -		# List installed packages. This is the default because parsing
   5.257 -		# the full packages.desc can be long and take up some resources
   5.258 -		#
   5.259 -		cd $INSTALLED
   5.260 -		search_form
   5.261 -		sidebar
   5.262 -		LOADING_MSG="$(_ 'Listing packages...')"
   5.263 -		loading_msg
   5.264 -		cat << EOT
   5.265 -<h2>$(_ 'My packages')</h2>
   5.266 -<form method='get' action='$SCRIPT_NAME'>
   5.267 -	<input type="hidden" name="do" value="Remove" />
   5.268 -<div id="actions">
   5.269 -	<div class="float-left">
   5.270 -		$(_ 'Selection:')
   5.271 -		<input type="submit" value="$(_ 'Remove')" />
   5.272 -	</div>
   5.273 -	<div class="float-right">
   5.274 -		<a class="button" href="$SCRIPT_NAME?recharge">
   5.275 -			<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   5.276 -		<a class="button" href='$SCRIPT_NAME?up'>
   5.277 -			<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   5.278 -	</div>
   5.279 -</div>
   5.280 -EOT
   5.281 -		cat << EOT
   5.282 -<table class="zebra outbox">
   5.283 -$(table_head)
   5.284 -<tbody>
   5.285 -EOT
   5.286 -		for pkg in *; do
   5.287 -			. $pkg/receipt
   5.288 -			echo '<tr>'
   5.289 -			# Use default tazpkg icon since all packages displayed are
   5.290 -			# installed
   5.291 -			colorpkg=$pkg
   5.292 -			grep -qs "^$pkg$" $PKGS_DB/blocked-packages.list &&
   5.293 -				colorpkg="<span style='color: red;'>$pkg</span>"
   5.294 -			i18n_desc
   5.295 -			cat << EOT
   5.296 -<td class="pkg">
   5.297 -	<input type="checkbox" name="pkg" value="$pkg" />
   5.298 -		<a href="$(pkg_info_link $pkg)"><img
   5.299 -			src="$IMAGES/tazpkg-installed.png"/>$colorpkg</a></td>
   5.300 -<td>$VERSION</td>
   5.301 -<td class="desc">$SHORT_DESC</td>
   5.302 -<td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
   5.303 -</tr>
   5.304 -EOT
   5.305 -		done
   5.306 -		cat << EOT
   5.307 -</tbody>
   5.308 -</table>
   5.309 -</form>
   5.310 -EOT
   5.311 -		;;
   5.312 -
   5.313 -
   5.314 -	*\ linkable\ *)
   5.315 -		#
   5.316 -		# List linkable packages.
   5.317 -		#
   5.318 -		cd $INSTALLED
   5.319 -		search_form
   5.320 -		sidebar
   5.321 -		LOADING_MSG=$(_ 'Listing linkable packages...')
   5.322 -		loading_msg
   5.323 -		cat << EOT
   5.324 -<h2>$(_ 'Linkable packages')</h2>
   5.325 -
   5.326 -<form method='get' action='$SCRIPT_NAME'>
   5.327 -	<input type="hidden" name="do" value="Link" />
   5.328 -<div id="actions">
   5.329 -	<div class="float-left">
   5.330 -		$(_ 'Selection:')
   5.331 -		<input type="submit" value="$(_ 'Link')" />
   5.332 -	</div>
   5.333 -	<div class="float-right">
   5.334 -		<a class="button" href="$SCRIPT_NAME?recharge">
   5.335 -			<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   5.336 -		<a class="button" href="$SCRIPT_NAME?up">
   5.337 -			<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   5.338 -	</div>
   5.339 -</div>
   5.340 -EOT
   5.341 -		cat << EOT
   5.342 -<table class="zebra outbox">
   5.343 -$(table_head)
   5.344 -<tbody>
   5.345 -EOT
   5.346 -		target=$(readlink $PKGS_DB/fslink)
   5.347 -		for pkg in $(ls $target/$INSTALLED); do
   5.348 -			[ -s $pkg/receipt ] && continue
   5.349 -			. $target/$INSTALLED/$pkg/receipt
   5.350 -			i18n_desc
   5.351 -			cat << EOT
   5.352 -<tr>
   5.353 -	<td class="pkg">
   5.354 -		<input type="checkbox" name="pkg" value="$pkg" />
   5.355 -			<a href="$(pkg_info_link $pkg)"><img
   5.356 -				src="$IMAGES/tazpkg.png"/>$pkg</a>
   5.357 -	</td>
   5.358 -	<td>$VERSION</td>
   5.359 -	<td class="desc">$SHORT_DESC</td>
   5.360 -	<td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
   5.361 -</tr>
   5.362 -EOT
   5.363 -		done
   5.364 -		cat << EOT
   5.365 -</tbody>
   5.366 -</table>
   5.367 -</form>
   5.368 -EOT
   5.369 -		;;
   5.370 -
   5.371 -
   5.372 -	*\ cat\ *)
   5.373 -		#
   5.374 -		# List all available packages by category on mirror. Listing all
   5.375 -		# packages is too resource intensive and not useful.
   5.376 -		#
   5.377 -		cd  $PKGS_DB
   5.378 -		repo=$(GET repo)
   5.379 -		category=$(GET cat)
   5.380 -		[ "$category" == "cat" ] && category="base-system"
   5.381 -		grep_category=$category
   5.382 -		[ "$grep_category" == "all" ] && grep_category=".*"
   5.383 -		search_form
   5.384 -		sidebar | sed "s/active_$category/active/;s/repo_$repo/active/"
   5.385 -		LOADING_MSG="$(_ 'Listing packages...')"
   5.386 -		loading_msg
   5.387 -		cat << EOT
   5.388 -<h2>$(_ 'Category: %s' $category)</h2>
   5.389 -
   5.390 -<form method='get' action='$SCRIPT_NAME'>
   5.391 -<div id="actions">
   5.392 -<div class="float-left">
   5.393 -	$(_ 'Selection:')
   5.394 -	<input type="submit" name="do" value="Install" />
   5.395 -	<input type="submit" name="do" value="Remove" />
   5.396 -	<input type="hidden" name="repo" value="$repo" />
   5.397 -</div>
   5.398 -<div class="float-right">
   5.399 -	<a class="button" href="$SCRIPT_NAME?recharge">
   5.400 -		<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   5.401 -	<a class="button" href="$SCRIPT_NAME?up">
   5.402 -		<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   5.403 -	<a class="button" href='$SCRIPT_NAME?list'>
   5.404 -		<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   5.405 -</div>
   5.406 -</div>
   5.407 -EOT
   5.408 -		for i in $(repo_list ""); do
   5.409 -			if [ "$repo" != "Public" ]; then
   5.410 -				Repo_Name="$(repo_name $i)"
   5.411 -				cat << EOT
   5.412 -<h3>$(_ 'Repository: %s' $Repo_Name)</h3>
   5.413 -EOT
   5.414 -			fi
   5.415 -			cat << EOT
   5.416 -<table class="zebra outbox">
   5.417 -$(table_head)
   5.418 -<tbody>
   5.419 -EOT
   5.420 -			if [ "$category" == "extra" ]; then
   5.421 -				sed 's,.*,&|--|--|--|http://mirror.slitaz.org/packages/get/&,' $i/extra.list
   5.422 -			else
   5.423 -				grep "| $grep_category |" $i/packages.desc
   5.424 -			fi | parse_packages_desc
   5.425 -			cat << EOT
   5.426 -</tbody>
   5.427 -</table>
   5.428 -EOT
   5.429 -		done
   5.430 -		echo '</form>' ;;
   5.431 -
   5.432 -
   5.433 -	*\ search\ *)
   5.434 -		#
   5.435 -		# Search for packages. Here default is to search in packages.desc
   5.436 -		# and so get result including packages names and descriptions
   5.437 -		#
   5.438 -		pkg=$(GET search)
   5.439 -		repo=$(GET repo)
   5.440 -		cd  $PKGS_DB
   5.441 -		search_form
   5.442 -		sidebar | sed "s/repo_$repo/active/"
   5.443 -		LOADING_MSG="$(_ 'Searching packages...')"
   5.444 -		loading_msg
   5.445 -		cat << EOT
   5.446 -<h2>$(_ 'Search packages')</h2>
   5.447 -<form method="get" action="$SCRIPT_NAME">
   5.448 -<div id="actions">
   5.449 -<div class="float-left">
   5.450 -	$(_ 'Selection:')
   5.451 -	<input type="submit" name="do" value="Install" />
   5.452 -	<input type="submit" name="do" value="Remove" />
   5.453 -	<a href="$(cat $PANEL/lib/checkbox.js)">$(_ 'Toogle all')</a>
   5.454 -</div>
   5.455 -<div class="float-right">
   5.456 -	<a class="button" href="$SCRIPT_NAME?recharge">
   5.457 -		<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   5.458 -	<a class="button" href="$SCRIPT_NAME?up">
   5.459 -		<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   5.460 -	<a class="button" href='$SCRIPT_NAME?list'>
   5.461 -		<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   5.462 -</div>
   5.463 -</div>
   5.464 -	<input type="hidden" name="repo" value="$repo" />
   5.465 -
   5.466 -	<table class="zebra outbox">
   5.467 -EOT
   5.468 -		if [ "$(GET files)" ]; then
   5.469 -			cat <<EOT
   5.470 -	<thead>
   5.471 -		<tr>
   5.472 -			<td>$(_ 'Package')</td>
   5.473 -			<td>$(_ 'File')</td>
   5.474 -		</tr>
   5.475 -	<thead>
   5.476 -	<tbody>
   5.477 -EOT
   5.478 -			unlzma -c $(repo_list /files.list.lzma) \
   5.479 -				| grep -Ei ": .*$(GET search)" | \
   5.480 -				while read PACKAGE FILE; do
   5.481 -					PACKAGE=${PACKAGE%:}
   5.482 -					image=tazpkg-installed.png
   5.483 -					[ -d $INSTALLED/$PACKAGE ] || image=tazpkg.png
   5.484 -					cat << EOT
   5.485 -<tr>
   5.486 -	<td><input type="checkbox" name="pkg" value="$PACKAGE">
   5.487 -		<a href="$(pkg_info_link $PACKAGE)"><img src="$IMAGES/$image" />$PACKAGE</a></td>
   5.488 -	<td>$FILE</td>
   5.489 -</tr>
   5.490 -EOT
   5.491 -				done
   5.492 -		else
   5.493 -			cat << EOT
   5.494 -$(table_head)
   5.495 -	<tbody>
   5.496 -EOT
   5.497 -			grep -ih $pkg $(repo_list /packages.desc) | \
   5.498 -				parse_packages_desc
   5.499 -		fi
   5.500 -		cat << EOT
   5.501 -	</tbody>
   5.502 -	</table>
   5.503 -</form>
   5.504 -EOT
   5.505 -		;;
   5.506 -
   5.507 -
   5.508 -	*\ recharge\ *)
   5.509 -		#
   5.510 -		# Lets recharge the packages list
   5.511 -		#
   5.512 -		search_form
   5.513 -		sidebar
   5.514 -		LOADING_MSG="$(_ 'Recharging lists...')"
   5.515 -		loading_msg
   5.516 -		cat << EOT
   5.517 -<h2>$(_ 'Recharge')</h2>
   5.518 -
   5.519 -<form method='get' action='$SCRIPT_NAME'>
   5.520 -<div id="actions">
   5.521 -	<div class="float-left">
   5.522 -		<p>$(_ 'Recharge checks for new or updated packages')</p>
   5.523 -	</div>
   5.524 -	<div class="float-right">
   5.525 -		<a class="button" href='$SCRIPT_NAME?up'>
   5.526 -			<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   5.527 -		<a class="button" href='$SCRIPT_NAME?list'>
   5.528 -			<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   5.529 -	</div>
   5.530 -</div>
   5.531 -<div class="wrapper">
   5.532 -<pre>
   5.533 -EOT
   5.534 -		echo $(_ 'Recharging packages list') | log
   5.535 -		tazpkg recharge | filter_taztools_msgs
   5.536 -		cat << EOT
   5.537 -</pre>
   5.538 -</div>
   5.539 -<p>$(_ 'Packages lists are up-to-date. You should check for upgrades now.')</p>
   5.540 -EOT
   5.541 -		;;
   5.542 -
   5.543 -
   5.544 -	*\ up\ *)
   5.545 -		#
   5.546 -		# Upgrade packages
   5.547 -		#
   5.548 -		cd $PKGS_DB
   5.549 -		search_form
   5.550 -		sidebar
   5.551 -		LOADING_MSG="$(_ 'Checking for upgrades...')"
   5.552 -		loading_msg
   5.553 -		cat << EOT
   5.554 -<h2>$(_ 'Up packages')</h2>
   5.555 -
   5.556 -<form method="get" action="$SCRIPT_NAME">
   5.557 -<div id="actions">
   5.558 -	<div class="float-left">
   5.559 -		$(_ 'Selection:')
   5.560 -		<input type="submit" name="do" value="Install" />
   5.561 -		<input type="submit" name="do" value="Remove" />
   5.562 -		<a href="$(cat $PANEL/lib/checkbox.js)">$(_ 'Toogle all')</a>
   5.563 -	</div>
   5.564 -	<div class="float-right">
   5.565 -		<a class="button" href="$SCRIPT_NAME?recharge">
   5.566 -			<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   5.567 -		<a class="button" href="$SCRIPT_NAME?list">
   5.568 -			<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   5.569 -	</div>
   5.570 -</div>
   5.571 -EOT
   5.572 -		tazpkg up --check >/dev/null
   5.573 -		cat << EOT
   5.574 -<table class="zebra outbox">
   5.575 -$(table_head)
   5.576 -<tbody>
   5.577 -EOT
   5.578 -		for pkg in `cat packages.up`
   5.579 -		do
   5.580 -			grep -hs "^$pkg |" $PKGS_DB/packages.desc \
   5.581 -				$PKGS_DB/undigest/*/packages.desc | \
   5.582 -				parse_packages_desc
   5.583 -		done
   5.584 -		cat << EOT
   5.585 -</tbody>
   5.586 -</table>
   5.587 -</form>
   5.588 -EOT
   5.589 -		;;
   5.590 -
   5.591 -
   5.592 -	*\ do\ *)
   5.593 -		#
   5.594 -		# Do an action on one or some packages
   5.595 -		#
   5.596 -		opt=""
   5.597 -		pkgs=""
   5.598 -		cmdline=$(echo ${QUERY_STRING#do=} | sed s'/&/ /g')
   5.599 -		cmd=$(echo ${cmdline} | awk '{print $1}')
   5.600 -		cmdline=${cmdline#*repo=* }
   5.601 -		pkgs=$(echo $cmdline | sed -e s'/+/ /g' -e s'/pkg=//g' -e s/$cmd//)
   5.602 -		pkgs="$(httpd -d "$pkgs")"
   5.603 -		cmd=$(echo $cmd | tr [:upper:] [:lower:])
   5.604 -		case $cmd in
   5.605 -			install)
   5.606 -				cmd=get-install opt=--forced
   5.607 -				LOADING_MSG="get-installing packages..."
   5.608 -				;;
   5.609 -			link)
   5.610 -				opt=$(readlink $PKGS_DB/fslink)
   5.611 -				LOADING_MSG="linking packages..."
   5.612 -				;;
   5.613 -		esac
   5.614 -		search_form
   5.615 -		sidebar
   5.616 -		loading_msg
   5.617 -		cat << EOT
   5.618 -<h2>TazPkg: $cmd</h2>
   5.619 -
   5.620 -<form method="get" action="$SCRIPT_NAME">
   5.621 -<div id="actions">
   5.622 -	<div class="float-left">
   5.623 -		<p>$(_ 'Performing tasks on packages')</p>
   5.624 -	</div>
   5.625 -	<div class="float-right">
   5.626 -		<p>
   5.627 -			<a class="button" href="$SCRIPT_NAME?list">
   5.628 -				<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   5.629 -		</p>
   5.630 -	</div>
   5.631 -</div>
   5.632 -<div class="box">
   5.633 -$(_ 'Executing %s for: %s' $cmd $pkgs)
   5.634 -</div>
   5.635 -EOT
   5.636 -		for pkg in $pkgs; do
   5.637 -			echo '<pre>'
   5.638 -				echo $(_n 'y') | tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs
   5.639 -			echo '</pre>'
   5.640 -		done ;;
   5.641 -
   5.642 -
   5.643 -	*\ info\ *)
   5.644 -		#
   5.645 -		# Packages info
   5.646 -		#
   5.647 -		pkg=$(GET info)
   5.648 -		search_form
   5.649 -		sidebar
   5.650 -		if [ -d $INSTALLED/$pkg ]; then
   5.651 -			. $INSTALLED/$pkg/receipt
   5.652 -			files=$(cat $INSTALLED/$pkg/files.list | wc -l)
   5.653 -			action="Remove"
   5.654 -			action_i18n=$(_ 'Remove')
   5.655 -		else
   5.656 -			cd  $PKGS_DB
   5.657 -			LOADING_MSG=$(_ 'Getting package info...')
   5.658 -			loading_msg
   5.659 -			IFS='|'
   5.660 -			set -- $(grep -hs "^$pkg |" packages.desc undigest/*/packages.desc)
   5.661 -			unset IFS
   5.662 -			PACKAGE=$1
   5.663 -			VERSION="$(echo $2)"
   5.664 -			SHORT_DESC="$(echo $3)"
   5.665 -			CATEGORY="$(echo $4)"
   5.666 -			WEB_SITE="$(echo $5)"
   5.667 -			action="Install"
   5.668 -			action_i18n=$(_ 'Install')
   5.669 -			temp="$(echo $pkg | sed 's/get-//g')"
   5.670 -		fi
   5.671 -		cat << EOT
   5.672 -<h2>$(_ 'Package %s' $PACKAGE)</h2>
   5.673 -
   5.674 -<div id="actions">
   5.675 -	<div class="float-left">
   5.676 -		<p>
   5.677 -EOT
   5.678 -		if [ "$temp" != "$pkg" -a "$action" == "Install" ]; then
   5.679 -			temp="$(echo $pkg | sed 's/get-//g')"
   5.680 -			echo "<a class='button' href='$SCRIPT_NAME?do=Install&$temp'>$(_ 'Install (Non Free)')</a>"
   5.681 -		else
   5.682 -			echo "<a class='button' href='$SCRIPT_NAME?do=$action&$pkg'>$action_i18n</a>"
   5.683 -		fi
   5.684 -
   5.685 -		if [ -d $INSTALLED/$pkg ]; then
   5.686 -			if grep -qs "^$pkg$" $PKGS_DB/blocked-packages.list; then
   5.687 -				cat << EOT
   5.688 -			<a class="button" href="$SCRIPT_NAME?do=Unblock&$pkg">$(_ 'Unblock')</a>
   5.689 -EOT
   5.690 -			else
   5.691 -				cat << EOT
   5.692 -			<a class="button" href='$SCRIPT_NAME?do=Block&$pkg'>$(_ 'Block')</a>
   5.693 -EOT
   5.694 -			fi
   5.695 -			cat << EOT
   5.696 -			<a class="button" href='$SCRIPT_NAME?do=Repack&$pkg'>$(_ 'Repack')</a>
   5.697 -EOT
   5.698 -		fi
   5.699 -		i18n_desc
   5.700 -		cat << EOT
   5.701 -		</p>
   5.702 -	</div>
   5.703 -	<div class="float-right">
   5.704 -		<p>
   5.705 -			<a class="button" href='$SCRIPT_NAME?list'>
   5.706 -				<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   5.707 -		</p>
   5.708 -	</div>
   5.709 -</div>
   5.710 -<table class="zebra outbox">
   5.711 -<tbody>
   5.712 -	<tr><td><b>$(_ 'Name')</b></td><td>$PACKAGE</td></tr>
   5.713 -	<tr><td><b>$(_ 'Version')</b></td><td>$VERSION</td></tr>
   5.714 -	<tr><td><b>$(_ 'Description')</b></td><td>$SHORT_DESC</td></tr>
   5.715 -	<tr><td><b>$(_ 'Category')</b></td><td>$CATEGORY</td></tr>
   5.716 -EOT
   5.717 -		if [ -d $INSTALLED/$pkg ]; then
   5.718 -			cat << EOT
   5.719 -	<tr><td><b>$(_ 'Maintainer')</b></td><td>$MAINTAINER</td></tr>
   5.720 -	<tr><td><b>$(_ 'Website')</b></td><td><a href="$WEB_SITE">$WEB_SITE</a></td></tr>
   5.721 -	<tr><td><b>$(_ 'Sizes')</b></td><td>$PACKED_SIZE/$UNPACKED_SIZE</td></tr>
   5.722 -EOT
   5.723 -			if [ -n "$DEPENDS" ]; then
   5.724 -				echo "<tr><td><b>$(_ 'Depends')</b></td><td>"
   5.725 -				for i in $DEPENDS; do
   5.726 -					echo -n "<a href="$(pkg_info_link $i)">$i</a> "
   5.727 -				done
   5.728 -				echo "</td></tr>"
   5.729 -			fi
   5.730 -			if [ -n "$SUGGESTED" ]; then
   5.731 -				echo "<tr><td><b>$(_ 'Suggested')</b></td><td>"
   5.732 -				for i in $SUGGESTED; do
   5.733 -					echo -n "<a href="$(pkg_info_link $i)">$i</a> "
   5.734 -				done
   5.735 -				echo "</td></tr>"
   5.736 -			fi
   5.737 -			[ -n "$TAGS" ] && echo "<tr><td><b>$(_ 'Tags')</b></td><td>$TAGS</td></tr>"
   5.738 -			I_FILES=$(cat $INSTALLED/$pkg/files.list | wc -l)
   5.739 -			cat << EOT
   5.740 -</tbody>
   5.741 -</table>
   5.742 -
   5.743 -<p>$(_ 'Installed files: %s' $I_FILES)</p>
   5.744 -
   5.745 -<pre>$(cat $INSTALLED/$pkg/files.list)</pre>
   5.746 -EOT
   5.747 -		else
   5.748 -			cat << EOT
   5.749 -<tr><td><b>$(_ 'Website')</b></td><td><a href="$WEB_SITE">$WEB_SITE</a></td></tr>
   5.750 -<tr><td><b>$(_ 'Sizes')</b></td><td>$(grep -hsA 3 ^$pkg$ packages.txt undigest/*/packages.txt | \
   5.751 -		tail -n 1 | sed 's/ *//')</td></tr>
   5.752 -</table>
   5.753 -
   5.754 -<p>$(_ 'Installed files:')</p>
   5.755 -
   5.756 -<pre>
   5.757 -`unlzma -c files.list.lzma undigest/*/files.list.lzma 2> /dev/null | \
   5.758 - sed "/^$pkg: /!d;s/^$pkg: //"`
   5.759 -</pre>
   5.760 -EOT
   5.761 -		fi
   5.762 -		;;
   5.763 -
   5.764 -
   5.765 -	*\ admin\ * )
   5.766 -		#
   5.767 -		# TazPkg configuration page
   5.768 -		#
   5.769 -		cmd=$(GET admin)
   5.770 -		case "$cmd" in
   5.771 -			clean)
   5.772 -				rm -rf /var/cache/tazpkg/* ;;
   5.773 -			add-mirror)
   5.774 -				# Decode url
   5.775 -				mirror=$(GET mirror)
   5.776 -				case "$mirror" in
   5.777 -				http://*|ftp://*)
   5.778 -					echo "$mirror" >> $(GET file) ;;
   5.779 -				esac ;;
   5.780 -			rm-mirror=http://*|rm-mirror=ftp://*)
   5.781 -				mirror=${cmd#rm-mirror=}
   5.782 -				sed -i -e "s@$mirror@@" -e '/^$/d' $(GET file) ;;
   5.783 -			select-mirror*)
   5.784 -				release=$(cat /etc/slitaz-release)
   5.785 -				mirror="$(GET mirror)packages/$release/"
   5.786 -				tazpkg setup-mirror $mirror | log
   5.787 -				;;
   5.788 -			add-repo)
   5.789 -				# Decode url
   5.790 -				mirror=$(GET mirror)
   5.791 -				repository=$PKGS_DB/undigest/$(GET repository)
   5.792 -				case "$mirror" in
   5.793 -				http://*|ftp://*)
   5.794 -					mkdir -p $repository
   5.795 -					echo "$mirror" > $repository/mirror
   5.796 -					echo "$mirror" > $repository/mirrors ;;
   5.797 -				esac ;;
   5.798 -			rm-repo=*)
   5.799 -				repository=${cmd#rm-repo=}
   5.800 -				rm -rf $PKGS_DB/undigest/$repository ;;
   5.801 -		esac
   5.802 -		[ "$cmd" == "$(_n 'Set link')" ] &&
   5.803 -			[ -d "$(GET link)/$INSTALLED" ] &&
   5.804 -			ln -fs $(GET link) $PKGS_DB/fslink
   5.805 -		[ "$cmd" == "$(_n 'Remove link')" ] &&
   5.806 -			rm -f $PKGS_DB/fslink
   5.807 -		cache_files=$(find /var/cache/tazpkg -name *.tazpkg | wc -l)
   5.808 -		cache_size=$(du -sh /var/cache/tazpkg | cut -f1 | sed 's|\.0||')
   5.809 -		sidebar
   5.810 -		cat << EOT
   5.811 -<h2>$(_ 'Administration')</h2>
   5.812 -<div>
   5.813 -	<p>$(_ 'TazPkg administration and settings')</p>
   5.814 -</div>
   5.815 -<div id="actions">
   5.816 -	<a class="button" href='$SCRIPT_NAME?admin=&action=saveconf'>
   5.817 -		<img src="$IMAGES/tazpkg.png" />$(_ 'Save configuration')</a>
   5.818 -	<a class="button" href='$SCRIPT_NAME?admin=&action=listconf'>
   5.819 -		<img src="$IMAGES/edit.png" />$(_ 'List configuration files')</a>
   5.820 -	<a class="button" href='$SCRIPT_NAME?admin=&action=quickcheck'>
   5.821 -		<img src="$IMAGES/recharge.png" />$(_ 'Quick check')</a>
   5.822 -	<a class="button" href='$SCRIPT_NAME?admin=&action=fullcheck'>
   5.823 -		<img src="$IMAGES/recharge.png" />$(_ 'Full check')</a>
   5.824 -</div>
   5.825 -EOT
   5.826 -		case "$(GET action)" in
   5.827 -				saveconf)
   5.828 -					LOADING_MSG=$(_ 'Creating the package...')
   5.829 -					loading_msg
   5.830 -					echo "<pre>"
   5.831 -					cd $HOME
   5.832 -					tazpkg repack-config | filter_taztools_msgs
   5.833 -					echo -n "$(_ 'Path:') "; ls $HOME/config-*.tazpkg
   5.834 -					echo "</pre>" ;;
   5.835 -				listconf)
   5.836 -					echo "<h4>$(_ 'Configuration files')</h4>"
   5.837 -					echo "<ul>"
   5.838 -					tazpkg list-config | while read file; do
   5.839 -						[ "${file:0:1}" == "/" ] || continue
   5.840 -						if [ -e $file ]; then
   5.841 -							echo "<li><a href=\"index.cgi?file=$file\">$file</a></li>"
   5.842 -						else
   5.843 -							echo "<li>$file</li>"
   5.844 -						fi
   5.845 -					done
   5.846 -					echo "</ul>"
   5.847 -					echo "</pre>" ;;
   5.848 -				quickcheck)
   5.849 -					LOADING_MSG=$(_ 'Checking packages consistency...')
   5.850 -					loading_msg
   5.851 -					echo "<pre>"
   5.852 -					tazpkg check
   5.853 -					echo "</pre>" ;;
   5.854 -				fullcheck)
   5.855 -					LOADING_MSG=$(_ 'Full packages check...')
   5.856 -					loading_msg
   5.857 -					echo "<pre>"
   5.858 -					tazpkg check --full
   5.859 -					echo "</pre>" ;;
   5.860 -				esac
   5.861 -		cat << EOT
   5.862 -<h3>$(_ 'Packages cache')</h3>
   5.863 -
   5.864 -<div>
   5.865 -	<form method="get" action="$SCRIPT_NAME">
   5.866 -		<p>
   5.867 -			$(_ 'Packages in the cache: %s (%s)' $cache_files $cache_size)
   5.868 -			<input type="hidden" name="admin" value="clean" />
   5.869 -			<input type="submit" value="Clean" />
   5.870 -		</p>
   5.871 -	</form>
   5.872 -</div>
   5.873 -
   5.874 -<h3>$(_ 'Default mirror')</h3>
   5.875 -
   5.876 -<pre>$(cat /var/lib/tazpkg/mirror)</pre>
   5.877 -
   5.878 -<h3>$(_ 'Current mirror list')</h3>
   5.879 -EOT
   5.880 -		for i in $PKGS_DB/mirrors $PKGS_DB/undigest/*/mirrors; do
   5.881 -			[ -s $i ] || continue
   5.882 -			echo '<div class="box">'
   5.883 -			if [ $i != $PKGS_DB/mirrors ]; then
   5.884 -				Repo_Name="$(repo_name $(dirname $i))"
   5.885 -				echo "<h4>$(_ 'Repository: %s' $Repo_Name)</h4>"
   5.886 -			fi
   5.887 -			echo "<ul>"
   5.888 -			list_mirrors $i
   5.889 -			echo "</ul>"
   5.890 -			cat << EOT
   5.891 -</div>
   5.892 -<form method="get" action="$SCRIPT_NAME">
   5.893 -	<p>
   5.894 -		<input type="hidden" name="admin" value="add-mirror" />
   5.895 -		<input type="hidden" name="file" value="$i" />
   5.896 -		<input type="text" name="mirror" size="60">
   5.897 -		<input type="submit" value="Add mirror" />
   5.898 -	</p>
   5.899 -</form>
   5.900 -EOT
   5.901 -		done
   5.902 -		echo "<h3>$(_ 'Private repositories')</h3>"
   5.903 -		[ -n "$(ls $PKGS_DB/undigest 2> /dev/null)" ] && cat << EOT
   5.904 -<div class="box">
   5.905 -	<ul>
   5.906 -		$(list_repos)
   5.907 -	</ul>
   5.908 -</div>
   5.909 -EOT
   5.910 -		cat << EOT
   5.911 -<form method="get" action="$SCRIPT_NAME">
   5.912 -	<p>
   5.913 -		<input type="hidden" name="admin" value="add-repo" />
   5.914 -		$(_ 'Name') <input type="text" name="repository" size="10">
   5.915 -		$(_ 'mirror')
   5.916 -		<input type="text" name="mirror" value="http://" size="50">
   5.917 -		<input type="submit" value="Add repository" />
   5.918 -	</p>
   5.919 -</form>
   5.920 -
   5.921 -<h3>$(_ 'Link to another SliTaz installation')</h3>
   5.922 -
   5.923 -<p>$(_ "This link points to the root of another SliTaz installation. \
   5.924 -You will be able to install packages using soft links to it.")</p>
   5.925 -
   5.926 -<form method="get" action="$SCRIPT_NAME">
   5.927 -<p>
   5.928 -	<input type="hidden" name="admin" value="add-link" />
   5.929 -	<input type="text" name="link"
   5.930 -	 value="$(readlink $PKGS_DB/fslink 2> /dev/null)" size="50">
   5.931 -	<input type="submit" name="admin" value="$(_ 'Set link')" />
   5.932 -	<input type="submit" name="admin" value="$(_ 'Remove link')" />
   5.933 -</p>
   5.934 -</form>
   5.935 -EOT
   5.936 -		version=$(cat /etc/slitaz-release)
   5.937 -		cat << EOT
   5.938 -
   5.939 -<h3 id="dvd">$(_ 'SliTaz packages DVD')</h3>
   5.940 -
   5.941 -<p>$(_ "A bootable DVD image of all available packages for the %s version is \
   5.942 -generated every day. It also contains a copy of the website and can be used \
   5.943 -without an internet connection. This image can be installed on a DVD or a USB \
   5.944 -key." $version)</p>
   5.945 -
   5.946 -<div>
   5.947 -	<form method="post" action='$SCRIPT_NAME?admin&action=dvdimage#dvd'>
   5.948 -	<p>
   5.949 -		<a class="button"
   5.950 -			href='http://mirror.slitaz.org/iso/$version/packages-$version.iso'>
   5.951 -			<img src="$IMAGES/tazpkg.png" />$(_ 'Download DVD image')</a>
   5.952 -		<a class="button" href='$SCRIPT_NAME?admin&action=dvdusbkey#dvd'>
   5.953 -			<img src="$IMAGES/tazpkg.png" />$(_ 'Install from DVD/USB key')</a>
   5.954 -	</p>
   5.955 -	<div class="box">
   5.956 -		$(_ 'Install from ISO image:')
   5.957 -		<input type="text" name="dvdimage" size="40" value="/root/packages-$version.iso">
   5.958 -	</div>
   5.959 -	</form>
   5.960 -</div>
   5.961 -EOT
   5.962 -		if [ "$(GET action)" == "dvdimage" ]; then
   5.963 -			dev=$(POST dvdimage)
   5.964 -			mkdir -p /mnt/packages 2> /dev/null
   5.965 -			echo "<pre>"
   5.966 -			mount -t iso9660 -o loop,ro $dev /mnt/packages &&
   5.967 -			/mnt/packages/install.sh &&
   5.968 -			_ '%s is installed on /mnt/packages' $dev
   5.969 -			echo "</pre>"
   5.970 -		fi
   5.971 -		if [ "$(GET action)" == "dvdusbkey" ]; then
   5.972 -			mkdir -p /mnt/packages 2> /dev/null
   5.973 -			for tag in "LABEL=\"packages-$version\" TYPE=\"iso9660\"" \
   5.974 -				"LABEL=\"sources-$version\" TYPE=\"iso9660\"" ; do
   5.975 -				dev=$(blkid | grep "$tag" | cut -d: -f1)
   5.976 -				[ -n "$dev" ] || continue
   5.977 -				echo "<pre>"
   5.978 -				mount -t iso9660 -o ro $dev /mnt/packages &&
   5.979 -				/mnt/packages/install.sh &&
   5.980 -				_ '%s is installed on /mnt/packages' $dev
   5.981 -				echo "</pre>"
   5.982 -				break
   5.983 -			done
   5.984 -		fi
   5.985 -		 ;;
   5.986 -	*)
   5.987 -		#
   5.988 -		# Default to summary
   5.989 -		#
   5.990 -		search_form
   5.991 -		sidebar
   5.992 -		[ -n "$(GET block)" ] && tazpkg block $(GET block)
   5.993 -		[ -n "$(GET unblock)" ] && tazpkg unblock $(GET unblock)
   5.994 -		cat << EOT
   5.995 -<h2>$(_ 'Summary')</h2>
   5.996 -
   5.997 -<div id="actions">
   5.998 -	<a class="button" href="$SCRIPT_NAME?list">
   5.999 -		<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
  5.1000 -EOT
  5.1001 -		fslink=$(readlink $PKGS_DB/fslink)
  5.1002 -		[ -n "$fslink" -a -d "$fslink/$INSTALLED" ] &&
  5.1003 -			cat << EOT
  5.1004 -	<a class="button" href="$SCRIPT_NAME?linkable">
  5.1005 -		<img src="$IMAGES/tazpkg.png" />$(_ 'Linkable packages')</a>
  5.1006 -EOT
  5.1007 -		cat << EOT
  5.1008 -	<a class="button" href="$SCRIPT_NAME?recharge">
  5.1009 -		<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
  5.1010 -	<a class="button" href="$SCRIPT_NAME?up">
  5.1011 -		<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
  5.1012 -	<a class="button" href="$SCRIPT_NAME?admin">
  5.1013 -		<img src="$IMAGES/edit.png" />$(_ 'Administration')</a>
  5.1014 -</div>
  5.1015 -
  5.1016 -$(packages_summary)
  5.1017 -
  5.1018 -
  5.1019 -<h3>$(_ 'Latest log entries')</h3>
  5.1020 -
  5.1021 -<pre>
  5.1022 -$(tail -n 5 /var/log/slitaz/tazpkg.log | fgrep "-" | \
  5.1023 -	awk '{print $1, $2, $3, $4, $5, $6, $7}')
  5.1024 -</pre>
  5.1025 -EOT
  5.1026 -		;;
  5.1027 -esac
  5.1028 -
  5.1029 -# xHTML 5 footer
  5.1030 -export TEXTDOMAIN='tazpkg'
  5.1031 -xhtml_footer
  5.1032 -exit 0
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tazpanel/pkgs	Mon Dec 15 04:43:04 2014 +0200
     6.3 @@ -0,0 +1,19 @@
     6.4 +TEXTDOMAIN_original=$TEXTDOMAIN
     6.5 +export TEXTDOMAIN='tazpkg'
     6.6 +
     6.7 +cat <<EOT
     6.8 +<li><a href="/pkgs.cgi">$(gettext 'Packages')</a>
     6.9 +	<ul>
    6.10 +		<li><a href="/pkgs.cgi?list"><img
    6.11 +			src="/styles/default/images/tazpkg.png" />$(gettext 'My packages')</a></li>
    6.12 +		<li><a href="/pkgs.cgi?recharge"><img
    6.13 +			src="/styles/default/images/update.png" />$(gettext 'Recharge list')</a></li>
    6.14 +		<li><a href="/pkgs.cgi?up"><img
    6.15 +			src="/styles/default/images/update.png" />$(gettext 'Check updates')</a></li>
    6.16 +		<li><a href="/pkgs.cgi?admin"><img
    6.17 +			src="/styles/default/images/edit.png" />$(gettext 'Administration')</a></li>
    6.18 +	</ul>
    6.19 +</li>
    6.20 +EOT
    6.21 +
    6.22 +export TEXTDOMAIN=$TEXTDOMAIN_original
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/tazpanel/pkgs.cgi	Mon Dec 15 04:43:04 2014 +0200
     7.3 @@ -0,0 +1,1029 @@
     7.4 +#!/bin/sh
     7.5 +#
     7.6 +# TazPkg CGI interface - Manage packages via a browser
     7.7 +#
     7.8 +# This CGI interface extensively uses tazpkg to manage packages and have
     7.9 +# its own code for some tasks. Please KISS, it is important and keep speed
    7.10 +# in mind. Thanks, Pankso.
    7.11 +#
    7.12 +# (C) 2011-2014 SliTaz GNU/Linux - BSD License
    7.13 +#
    7.14 +
    7.15 +. /lib/libtaz.sh
    7.16 +. lib/libtazpanel
    7.17 +get_config
    7.18 +header
    7.19 +
    7.20 +
    7.21 +# xHTML 5 header with special side bar for categories.
    7.22 +TITLE=$(TEXTDOMAIN='tazpkg'; _ 'TazPanel - Packages')
    7.23 +xhtml_header | sed 's/id="content"/id="content-sidebar"/'
    7.24 +
    7.25 +export TEXTDOMAIN='tazpkg'
    7.26 +
    7.27 +
    7.28 +pkg_info_link()
    7.29 +{
    7.30 +	echo "$SCRIPT_NAME?info=$1" | sed 's/+/%2B/g'
    7.31 +}
    7.32 +
    7.33 +
    7.34 +i18n_desc() {
    7.35 +	# Display localized short description
    7.36 +	if [ -e "$PKGS_DB/packages-desc.$LANG" ]; then
    7.37 +		LOCDESC=$(grep -e "^$pkg	" $PKGS_DB/packages-desc.$LANG | cut -d'	' -f2)
    7.38 +	[ "x$LOCDESC" != "x" ] && SHORT_DESC="$LOCDESC"
    7.39 +	fi
    7.40 +}
    7.41 +
    7.42 +
    7.43 +# We need packages information for list and search
    7.44 +
    7.45 +parse_packages_desc() {
    7.46 +	IFS="|"
    7.47 +	cut -f 1,2,3,5 -d "|" | while read PACKAGE VERSION SHORT_DESC WEB_SITE
    7.48 +	do
    7.49 +		image=tazpkg-installed.png
    7.50 +		[ -d $INSTALLED/${PACKAGE% } ] || image=tazpkg.png
    7.51 +		i18n_desc
    7.52 +		cat << EOT
    7.53 +<tr>
    7.54 +<td><input type="checkbox" name="pkg" value="$PACKAGE">
    7.55 +	<a href="$(pkg_info_link $PACKAGE)"><img
    7.56 +		src="$IMAGES/$image"/>$PACKAGE</a></td>
    7.57 +<td>$VERSION</td>
    7.58 +<td class="desc">$SHORT_DESC</td>
    7.59 +<td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
    7.60 +</tr>
    7.61 +EOT
    7.62 +	done
    7.63 +	unset IFS
    7.64 +}
    7.65 +
    7.66 +
    7.67 +# Display a full summary of packages stats
    7.68 +
    7.69 +packages_summary() {
    7.70 +	cat << EOT
    7.71 +<table class="zebra outbox">
    7.72 +<tbody>
    7.73 +<tr><td>$(_ 'Last recharge:')</td>
    7.74 +EOT
    7.75 +	stat=$(stat -c %y $PKGS_DB/packages.list | \
    7.76 +		sed 's/\(:..\):.*/\1/' | awk '{print $1}')
    7.77 +	mtime=$(find $PKGS_DB/packages.list -mtime +10)
    7.78 +	echo -n "<td>$stat "
    7.79 +	if [ "$mtime" ]; then
    7.80 +		_ '(Older than 10 days)'
    7.81 +	else
    7.82 +		_ '(Not older than 10 days)'
    7.83 +	fi
    7.84 +	cat << EOT
    7.85 +</td></tr>
    7.86 +<tr><td>$(_ 'Installed packages:')</td>
    7.87 +	<td>$(ls $INSTALLED | wc -l)</td></tr>
    7.88 +<tr><td>$(_ 'Mirrored packages:')</td>
    7.89 +	<td>$(cat $PKGS_DB/packages.list | wc -l)</td></tr>
    7.90 +<tr><td>$(_ 'Upgradeable packages:')</td>
    7.91 +	<td>$(cat $PKGS_DB/packages.up | wc -l)</td></tr>
    7.92 +<tr><td>$(_ 'Installed files:')</td>
    7.93 +	<td>$(cat $INSTALLED/*/files.list | wc -l)</td></tr>
    7.94 +<tr><td>$(_ 'Blocked packages:')</td>
    7.95 +	<td>$(cat $PKGS_DB/blocked-packages.list | wc -l)</td></tr>
    7.96 +</tbody>
    7.97 +</table>
    7.98 +EOT
    7.99 +}
   7.100 +
   7.101 +
   7.102 +# Parse mirrors list to be able to have an icon and remove link
   7.103 +
   7.104 +list_mirrors() {
   7.105 +	while read line
   7.106 +	do
   7.107 +		cat << EOT
   7.108 +<li>
   7.109 +	<a href="$SCRIPT_NAME?admin=rm-mirror=$line&amp;file=$(httpd -e $1)">
   7.110 +		<img src="$IMAGES/clear.png" title="$(_ 'Delete')" />
   7.111 +	</a>
   7.112 +	<a href="$SCRIPT_NAME?admin=select-mirror&amp;mirror=$line">
   7.113 +		<img src="$IMAGES/start.png" title="$(_ 'Use as default')" />
   7.114 +	</a>
   7.115 +	<a href="$line">$line</a>
   7.116 +</li>
   7.117 +EOT
   7.118 +	done < $1
   7.119 +}
   7.120 +
   7.121 +
   7.122 +# Parse repositories list to be able to have an icon and remove link
   7.123 +
   7.124 +list_repos() {
   7.125 +	ls $PKGS_DB/undigest 2> /dev/null | while read repo ; do
   7.126 +		cat <<EOT
   7.127 +	<li><a href="$SCRIPT_NAME?admin=rm-repo=$repo">
   7.128 +		<img src="$IMAGES/clear.png">$repo</a></li>
   7.129 +EOT
   7.130 +	done
   7.131 +}
   7.132 +
   7.133 +
   7.134 +
   7.135 +#
   7.136 +# xHTML functions
   7.137 +#
   7.138 +
   7.139 +
   7.140 +# ENTER will search but user may search for a button, so put one.
   7.141 +
   7.142 +search_form() {
   7.143 +	[ -n "$repo" ] || repo="$(GET repo)"
   7.144 +	[ -n "$repo" ] || repo=Any
   7.145 +	cat << EOT
   7.146 +<div class="search">
   7.147 +	<form method="get" action="$SCRIPT_NAME">
   7.148 +		<p>
   7.149 +			<input type="text" name="search" size="20">
   7.150 +			<input type="submit" value="$(gettext 'Search')">
   7.151 +			<input class="radius" type="submit" name="files"
   7.152 +				value="$(_n 'Files')">
   7.153 +			<input type="hidden" name="repo" value="$repo" />
   7.154 +		</p>
   7.155 +	</form>
   7.156 +</div>
   7.157 +EOT
   7.158 +}
   7.159 +
   7.160 +
   7.161 +table_head() {
   7.162 +	cat << EOT
   7.163 +		<thead>
   7.164 +		<tr>
   7.165 +			<td>$(_ 'Name')</td>
   7.166 +			<td>$(_ 'Version')</td>
   7.167 +			<td>$(_ 'Description')</td>
   7.168 +			<td>$(_ 'Web')</td>
   7.169 +		</tr>
   7.170 +		</thead>
   7.171 +EOT
   7.172 +}
   7.173 +
   7.174 +
   7.175 +sidebar() {
   7.176 +	[ -n "$repo" ] || repo=Public
   7.177 +	cat << EOT
   7.178 +<div id="sidebar">
   7.179 +	<h4>$(_ 'Categories')</h4>
   7.180 +	<a class="active_base-system"  href="$SCRIPT_NAME?cat=base-system&repo=$repo" >$(_ 'base-system')</a>
   7.181 +	<a class="active_x-window"     href="$SCRIPT_NAME?cat=x-window&repo=$repo"    >$(_ 'x-window')</a>
   7.182 +	<a class="active_utilities"    href="$SCRIPT_NAME?cat=utilities&repo=$repo"   >$(_ 'utilities')</a>
   7.183 +	<a class="active_network"      href="$SCRIPT_NAME?cat=network&repo=$repo"     >$(_ 'network')</a>
   7.184 +	<a class="active_games"        href="$SCRIPT_NAME?cat=games&repo=$repo"       >$(_ 'games')</a>
   7.185 +	<a class="active_graphics"     href="$SCRIPT_NAME?cat=graphics&repo=$repo"    >$(_ 'graphics')</a>
   7.186 +	<a class="active_office"       href="$SCRIPT_NAME?cat=office&repo=$repo"      >$(_ 'office')</a>
   7.187 +	<a class="active_multimedia"   href="$SCRIPT_NAME?cat=multimedia&repo=$repo"  >$(_ 'multimedia')</a>
   7.188 +	<a class="active_development"  href="$SCRIPT_NAME?cat=development&repo=$repo" >$(_ 'development')</a>
   7.189 +	<a class="active_system-tools" href="$SCRIPT_NAME?cat=system-tools&repo=$repo">$(_ 'system-tools')</a>
   7.190 +	<a class="active_security"     href="$SCRIPT_NAME?cat=security&repo=$repo"    >$(_ 'security')</a>
   7.191 +	<a class="active_misc"         href="$SCRIPT_NAME?cat=misc&repo=$repo"        >$(_ 'misc')</a>
   7.192 +	<a class="active_meta"         href="$SCRIPT_NAME?cat=meta&repo=$repo"        >$(_ 'meta')</a>
   7.193 +	<a class="active_non-free"     href="$SCRIPT_NAME?cat=non-free&repo=$repo"    >$(_ 'non-free')</a>
   7.194 +	<a class="active_all"          href="$SCRIPT_NAME?cat=all&repo=$repo"         >$(_ 'all')</a>
   7.195 +	<a class="active_extra"        href="$SCRIPT_NAME?cat=extra&repo=$repo"       >$(_ 'extra')</a>
   7.196 +EOT
   7.197 +
   7.198 +	if [ -d $PKGS_DB/undigest ]; then
   7.199 +		[ -n "$category" ] || category="base-system"
   7.200 +		cat << EOT
   7.201 +	<h4>$(_ 'Repositories')</h4>
   7.202 +	<a class="repo_Public" href="$SCRIPT_NAME?repo=Public&cat=$category">$(_ 'Public')</a>
   7.203 +EOT
   7.204 +
   7.205 +		for i in $(ls $PKGS_DB/undigest); do
   7.206 +			cat << EOT
   7.207 +	<a class="repo_$i" href="$SCRIPT_NAME?repo=$i&cat=$category">$i</a>
   7.208 +EOT
   7.209 +		done
   7.210 +
   7.211 +		cat << EOT
   7.212 +	<a class="repo_Any" href="$SCRIPT_NAME?repo=Any&cat=$category">$(_ 'Any')</a>
   7.213 +EOT
   7.214 +	fi
   7.215 +	echo "</div>"
   7.216 +}
   7.217 +
   7.218 +
   7.219 +repo_list() {
   7.220 +	if [ -n "$(ls $PKGS_DB/undigest/ 2> /dev/null)" ]; then
   7.221 +		case "$repo" in
   7.222 +			Public)
   7.223 +				;;
   7.224 +			""|Any)
   7.225 +				for i in $PKGS_DB/undigest/* ; do
   7.226 +					[ -d "$i" ] && echo "$i$1"
   7.227 +				done ;;
   7.228 +			*)
   7.229 +				echo "$PKGS_DB/undigest/$repo$1"
   7.230 +				return ;;
   7.231 +		esac
   7.232 +	fi
   7.233 +	echo "$PKGS_DB$1"
   7.234 +}
   7.235 +
   7.236 +
   7.237 +repo_name() {
   7.238 +	case "$1" in
   7.239 +		$PKGS_DB)
   7.240 +			echo "Public" ;;
   7.241 +		$PKGS_DB/undigest/*)
   7.242 +			echo ${1#$PKGS_DB/undigest/} ;;
   7.243 +	esac
   7.244 +}
   7.245 +
   7.246 +
   7.247 +
   7.248 +#
   7.249 +# Commands
   7.250 +#
   7.251 +
   7.252 +
   7.253 +case " $(GET) " in
   7.254 +	*\ list\ *)
   7.255 +		#
   7.256 +		# List installed packages. This is the default because parsing
   7.257 +		# the full packages.desc can be long and take up some resources
   7.258 +		#
   7.259 +		cd $INSTALLED
   7.260 +		search_form
   7.261 +		sidebar
   7.262 +		LOADING_MSG="$(_ 'Listing packages...')"
   7.263 +		loading_msg
   7.264 +		cat << EOT
   7.265 +<h2>$(_ 'My packages')</h2>
   7.266 +<form method='get' action='$SCRIPT_NAME'>
   7.267 +	<input type="hidden" name="do" value="Remove" />
   7.268 +<div id="actions">
   7.269 +	<div class="float-left">
   7.270 +		$(_ 'Selection:')
   7.271 +		<input type="submit" value="$(_ 'Remove')" />
   7.272 +	</div>
   7.273 +	<div class="float-right">
   7.274 +		<a class="button" href="$SCRIPT_NAME?recharge">
   7.275 +			<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   7.276 +		<a class="button" href='$SCRIPT_NAME?up'>
   7.277 +			<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   7.278 +	</div>
   7.279 +</div>
   7.280 +EOT
   7.281 +		cat << EOT
   7.282 +<table class="zebra outbox">
   7.283 +$(table_head)
   7.284 +<tbody>
   7.285 +EOT
   7.286 +		for pkg in *; do
   7.287 +			. $pkg/receipt
   7.288 +			echo '<tr>'
   7.289 +			# Use default tazpkg icon since all packages displayed are
   7.290 +			# installed
   7.291 +			colorpkg=$pkg
   7.292 +			grep -qs "^$pkg$" $PKGS_DB/blocked-packages.list &&
   7.293 +				colorpkg="<span style='color: red;'>$pkg</span>"
   7.294 +			i18n_desc
   7.295 +			cat << EOT
   7.296 +<td class="pkg">
   7.297 +	<input type="checkbox" name="pkg" value="$pkg" />
   7.298 +		<a href="$(pkg_info_link $pkg)"><img
   7.299 +			src="$IMAGES/tazpkg-installed.png"/>$colorpkg</a></td>
   7.300 +<td>$VERSION</td>
   7.301 +<td class="desc">$SHORT_DESC</td>
   7.302 +<td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
   7.303 +</tr>
   7.304 +EOT
   7.305 +		done
   7.306 +		cat << EOT
   7.307 +</tbody>
   7.308 +</table>
   7.309 +</form>
   7.310 +EOT
   7.311 +		;;
   7.312 +
   7.313 +
   7.314 +	*\ linkable\ *)
   7.315 +		#
   7.316 +		# List linkable packages.
   7.317 +		#
   7.318 +		cd $INSTALLED
   7.319 +		search_form
   7.320 +		sidebar
   7.321 +		LOADING_MSG=$(_ 'Listing linkable packages...')
   7.322 +		loading_msg
   7.323 +		cat << EOT
   7.324 +<h2>$(_ 'Linkable packages')</h2>
   7.325 +
   7.326 +<form method='get' action='$SCRIPT_NAME'>
   7.327 +	<input type="hidden" name="do" value="Link" />
   7.328 +<div id="actions">
   7.329 +	<div class="float-left">
   7.330 +		$(_ 'Selection:')
   7.331 +		<input type="submit" value="$(_ 'Link')" />
   7.332 +	</div>
   7.333 +	<div class="float-right">
   7.334 +		<a class="button" href="$SCRIPT_NAME?recharge">
   7.335 +			<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   7.336 +		<a class="button" href="$SCRIPT_NAME?up">
   7.337 +			<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   7.338 +	</div>
   7.339 +</div>
   7.340 +EOT
   7.341 +		cat << EOT
   7.342 +<table class="zebra outbox">
   7.343 +$(table_head)
   7.344 +<tbody>
   7.345 +EOT
   7.346 +		target=$(readlink $PKGS_DB/fslink)
   7.347 +		for pkg in $(ls $target/$INSTALLED); do
   7.348 +			[ -s $pkg/receipt ] && continue
   7.349 +			. $target/$INSTALLED/$pkg/receipt
   7.350 +			i18n_desc
   7.351 +			cat << EOT
   7.352 +<tr>
   7.353 +	<td class="pkg">
   7.354 +		<input type="checkbox" name="pkg" value="$pkg" />
   7.355 +			<a href="$(pkg_info_link $pkg)"><img
   7.356 +				src="$IMAGES/tazpkg.png"/>$pkg</a>
   7.357 +	</td>
   7.358 +	<td>$VERSION</td>
   7.359 +	<td class="desc">$SHORT_DESC</td>
   7.360 +	<td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
   7.361 +</tr>
   7.362 +EOT
   7.363 +		done
   7.364 +		cat << EOT
   7.365 +</tbody>
   7.366 +</table>
   7.367 +</form>
   7.368 +EOT
   7.369 +		;;
   7.370 +
   7.371 +
   7.372 +	*\ cat\ *)
   7.373 +		#
   7.374 +		# List all available packages by category on mirror. Listing all
   7.375 +		# packages is too resource intensive and not useful.
   7.376 +		#
   7.377 +		cd  $PKGS_DB
   7.378 +		repo=$(GET repo)
   7.379 +		category=$(GET cat)
   7.380 +		[ "$category" == "cat" ] && category="base-system"
   7.381 +		grep_category=$category
   7.382 +		[ "$grep_category" == "all" ] && grep_category=".*"
   7.383 +		search_form
   7.384 +		sidebar | sed "s/active_$category/active/;s/repo_$repo/active/"
   7.385 +		LOADING_MSG="$(_ 'Listing packages...')"
   7.386 +		loading_msg
   7.387 +		cat << EOT
   7.388 +<h2>$(_ 'Category: %s' $category)</h2>
   7.389 +
   7.390 +<form method='get' action='$SCRIPT_NAME'>
   7.391 +<div id="actions">
   7.392 +<div class="float-left">
   7.393 +	$(_ 'Selection:')
   7.394 +	<input type="submit" name="do" value="Install" />
   7.395 +	<input type="submit" name="do" value="Remove" />
   7.396 +	<input type="hidden" name="repo" value="$repo" />
   7.397 +</div>
   7.398 +<div class="float-right">
   7.399 +	<a class="button" href="$SCRIPT_NAME?recharge">
   7.400 +		<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   7.401 +	<a class="button" href="$SCRIPT_NAME?up">
   7.402 +		<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   7.403 +	<a class="button" href='$SCRIPT_NAME?list'>
   7.404 +		<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   7.405 +</div>
   7.406 +</div>
   7.407 +EOT
   7.408 +		for i in $(repo_list ""); do
   7.409 +			if [ "$repo" != "Public" ]; then
   7.410 +				Repo_Name="$(repo_name $i)"
   7.411 +				cat << EOT
   7.412 +<h3>$(_ 'Repository: %s' $Repo_Name)</h3>
   7.413 +EOT
   7.414 +			fi
   7.415 +			cat << EOT
   7.416 +<table class="zebra outbox">
   7.417 +$(table_head)
   7.418 +<tbody>
   7.419 +EOT
   7.420 +			if [ "$category" == "extra" ]; then
   7.421 +				sed 's,.*,&|--|--|--|http://mirror.slitaz.org/packages/get/&,' $i/extra.list
   7.422 +			else
   7.423 +				grep "| $grep_category |" $i/packages.desc
   7.424 +			fi | parse_packages_desc
   7.425 +			cat << EOT
   7.426 +</tbody>
   7.427 +</table>
   7.428 +EOT
   7.429 +		done
   7.430 +		echo '</form>' ;;
   7.431 +
   7.432 +
   7.433 +	*\ search\ *)
   7.434 +		#
   7.435 +		# Search for packages. Here default is to search in packages.desc
   7.436 +		# and so get result including packages names and descriptions
   7.437 +		#
   7.438 +		pkg=$(GET search)
   7.439 +		repo=$(GET repo)
   7.440 +		cd  $PKGS_DB
   7.441 +		search_form
   7.442 +		sidebar | sed "s/repo_$repo/active/"
   7.443 +		LOADING_MSG="$(_ 'Searching packages...')"
   7.444 +		loading_msg
   7.445 +		cat << EOT
   7.446 +<h2>$(_ 'Search packages')</h2>
   7.447 +<form method="get" action="$SCRIPT_NAME">
   7.448 +<div id="actions">
   7.449 +<div class="float-left">
   7.450 +	$(_ 'Selection:')
   7.451 +	<input type="submit" name="do" value="Install" />
   7.452 +	<input type="submit" name="do" value="Remove" />
   7.453 +	<a href="$(cat $PANEL/lib/checkbox.js)">$(_ 'Toogle all')</a>
   7.454 +</div>
   7.455 +<div class="float-right">
   7.456 +	<a class="button" href="$SCRIPT_NAME?recharge">
   7.457 +		<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   7.458 +	<a class="button" href="$SCRIPT_NAME?up">
   7.459 +		<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   7.460 +	<a class="button" href='$SCRIPT_NAME?list'>
   7.461 +		<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   7.462 +</div>
   7.463 +</div>
   7.464 +	<input type="hidden" name="repo" value="$repo" />
   7.465 +
   7.466 +	<table class="zebra outbox">
   7.467 +EOT
   7.468 +		if [ "$(GET files)" ]; then
   7.469 +			cat <<EOT
   7.470 +	<thead>
   7.471 +		<tr>
   7.472 +			<td>$(_ 'Package')</td>
   7.473 +			<td>$(_ 'File')</td>
   7.474 +		</tr>
   7.475 +	<thead>
   7.476 +	<tbody>
   7.477 +EOT
   7.478 +			unlzma -c $(repo_list /files.list.lzma) \
   7.479 +				| grep -Ei ": .*$(GET search)" | \
   7.480 +				while read PACKAGE FILE; do
   7.481 +					PACKAGE=${PACKAGE%:}
   7.482 +					image=tazpkg-installed.png
   7.483 +					[ -d $INSTALLED/$PACKAGE ] || image=tazpkg.png
   7.484 +					cat << EOT
   7.485 +<tr>
   7.486 +	<td><input type="checkbox" name="pkg" value="$PACKAGE">
   7.487 +		<a href="$(pkg_info_link $PACKAGE)"><img src="$IMAGES/$image" />$PACKAGE</a></td>
   7.488 +	<td>$FILE</td>
   7.489 +</tr>
   7.490 +EOT
   7.491 +				done
   7.492 +		else
   7.493 +			cat << EOT
   7.494 +$(table_head)
   7.495 +	<tbody>
   7.496 +EOT
   7.497 +			grep -ih $pkg $(repo_list /packages.desc) | \
   7.498 +				parse_packages_desc
   7.499 +		fi
   7.500 +		cat << EOT
   7.501 +	</tbody>
   7.502 +	</table>
   7.503 +</form>
   7.504 +EOT
   7.505 +		;;
   7.506 +
   7.507 +
   7.508 +	*\ recharge\ *)
   7.509 +		#
   7.510 +		# Lets recharge the packages list
   7.511 +		#
   7.512 +		search_form
   7.513 +		sidebar
   7.514 +		LOADING_MSG="$(_ 'Recharging lists...')"
   7.515 +		loading_msg
   7.516 +		cat << EOT
   7.517 +<h2>$(_ 'Recharge')</h2>
   7.518 +
   7.519 +<form method='get' action='$SCRIPT_NAME'>
   7.520 +<div id="actions">
   7.521 +	<div class="float-left">
   7.522 +		<p>$(_ 'Recharge checks for new or updated packages')</p>
   7.523 +	</div>
   7.524 +	<div class="float-right">
   7.525 +		<a class="button" href='$SCRIPT_NAME?up'>
   7.526 +			<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
   7.527 +		<a class="button" href='$SCRIPT_NAME?list'>
   7.528 +			<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   7.529 +	</div>
   7.530 +</div>
   7.531 +<div class="wrapper">
   7.532 +<pre>
   7.533 +EOT
   7.534 +		echo $(_ 'Recharging packages list') | log
   7.535 +		tazpkg recharge | filter_taztools_msgs
   7.536 +		cat << EOT
   7.537 +</pre>
   7.538 +</div>
   7.539 +<p>$(_ 'Packages lists are up-to-date. You should check for upgrades now.')</p>
   7.540 +EOT
   7.541 +		;;
   7.542 +
   7.543 +
   7.544 +	*\ up\ *)
   7.545 +		#
   7.546 +		# Upgrade packages
   7.547 +		#
   7.548 +		cd $PKGS_DB
   7.549 +		search_form
   7.550 +		sidebar
   7.551 +		LOADING_MSG="$(_ 'Checking for upgrades...')"
   7.552 +		loading_msg
   7.553 +		cat << EOT
   7.554 +<h2>$(_ 'Up packages')</h2>
   7.555 +
   7.556 +<form method="get" action="$SCRIPT_NAME">
   7.557 +<div id="actions">
   7.558 +	<div class="float-left">
   7.559 +		$(_ 'Selection:')
   7.560 +		<input type="submit" name="do" value="Install" />
   7.561 +		<input type="submit" name="do" value="Remove" />
   7.562 +		<a href="$(cat $PANEL/lib/checkbox.js)">$(_ 'Toogle all')</a>
   7.563 +	</div>
   7.564 +	<div class="float-right">
   7.565 +		<a class="button" href="$SCRIPT_NAME?recharge">
   7.566 +			<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
   7.567 +		<a class="button" href="$SCRIPT_NAME?list">
   7.568 +			<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   7.569 +	</div>
   7.570 +</div>
   7.571 +EOT
   7.572 +		tazpkg up --check >/dev/null
   7.573 +		cat << EOT
   7.574 +<table class="zebra outbox">
   7.575 +$(table_head)
   7.576 +<tbody>
   7.577 +EOT
   7.578 +		for pkg in `cat packages.up`
   7.579 +		do
   7.580 +			grep -hs "^$pkg |" $PKGS_DB/packages.desc \
   7.581 +				$PKGS_DB/undigest/*/packages.desc | \
   7.582 +				parse_packages_desc
   7.583 +		done
   7.584 +		cat << EOT
   7.585 +</tbody>
   7.586 +</table>
   7.587 +</form>
   7.588 +EOT
   7.589 +		;;
   7.590 +
   7.591 +
   7.592 +	*\ do\ *)
   7.593 +		#
   7.594 +		# Do an action on one or some packages
   7.595 +		#
   7.596 +		opt=""
   7.597 +		pkgs=""
   7.598 +		cmdline=$(echo ${QUERY_STRING#do=} | sed s'/&/ /g')
   7.599 +		cmd=$(echo ${cmdline} | awk '{print $1}')
   7.600 +		cmdline=${cmdline#*repo=* }
   7.601 +		pkgs=$(echo $cmdline | sed -e s'/+/ /g' -e s'/pkg=//g' -e s/$cmd//)
   7.602 +		pkgs="$(httpd -d "$pkgs")"
   7.603 +		cmd=$(echo $cmd | tr [:upper:] [:lower:])
   7.604 +		case $cmd in
   7.605 +			install)
   7.606 +				cmd=get-install opt=--forced
   7.607 +				LOADING_MSG="get-installing packages..."
   7.608 +				;;
   7.609 +			link)
   7.610 +				opt=$(readlink $PKGS_DB/fslink)
   7.611 +				LOADING_MSG="linking packages..."
   7.612 +				;;
   7.613 +		esac
   7.614 +		search_form
   7.615 +		sidebar
   7.616 +		loading_msg
   7.617 +		cat << EOT
   7.618 +<h2>TazPkg: $cmd</h2>
   7.619 +
   7.620 +<form method="get" action="$SCRIPT_NAME">
   7.621 +<div id="actions">
   7.622 +	<div class="float-left">
   7.623 +		<p>$(_ 'Performing tasks on packages')</p>
   7.624 +	</div>
   7.625 +	<div class="float-right">
   7.626 +		<p>
   7.627 +			<a class="button" href="$SCRIPT_NAME?list">
   7.628 +				<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   7.629 +		</p>
   7.630 +	</div>
   7.631 +</div>
   7.632 +<div class="box">
   7.633 +$(_ 'Executing %s for: %s' $cmd $pkgs)
   7.634 +</div>
   7.635 +EOT
   7.636 +		for pkg in $pkgs; do
   7.637 +			echo '<pre>'
   7.638 +				echo $(_n 'y') | tazpkg $cmd $pkg $opt 2>/dev/null | filter_taztools_msgs
   7.639 +			echo '</pre>'
   7.640 +		done ;;
   7.641 +
   7.642 +
   7.643 +	*\ info\ *)
   7.644 +		#
   7.645 +		# Packages info
   7.646 +		#
   7.647 +		pkg=$(GET info)
   7.648 +		search_form
   7.649 +		sidebar
   7.650 +		if [ -d $INSTALLED/$pkg ]; then
   7.651 +			. $INSTALLED/$pkg/receipt
   7.652 +			files=$(cat $INSTALLED/$pkg/files.list | wc -l)
   7.653 +			action="Remove"
   7.654 +			action_i18n=$(_ 'Remove')
   7.655 +		else
   7.656 +			cd  $PKGS_DB
   7.657 +			LOADING_MSG=$(_ 'Getting package info...')
   7.658 +			loading_msg
   7.659 +			IFS='|'
   7.660 +			set -- $(grep -hs "^$pkg |" packages.desc undigest/*/packages.desc)
   7.661 +			unset IFS
   7.662 +			PACKAGE=$1
   7.663 +			VERSION="$(echo $2)"
   7.664 +			SHORT_DESC="$(echo $3)"
   7.665 +			CATEGORY="$(echo $4)"
   7.666 +			WEB_SITE="$(echo $5)"
   7.667 +			action="Install"
   7.668 +			action_i18n=$(_ 'Install')
   7.669 +			temp="$(echo $pkg | sed 's/get-//g')"
   7.670 +		fi
   7.671 +		cat << EOT
   7.672 +<h2>$(_ 'Package %s' $PACKAGE)</h2>
   7.673 +
   7.674 +<div id="actions">
   7.675 +	<div class="float-left">
   7.676 +		<p>
   7.677 +EOT
   7.678 +		if [ "$temp" != "$pkg" -a "$action" == "Install" ]; then
   7.679 +			temp="$(echo $pkg | sed 's/get-//g')"
   7.680 +			echo "<a class='button' href='$SCRIPT_NAME?do=Install&$temp'>$(_ 'Install (Non Free)')</a>"
   7.681 +		else
   7.682 +			echo "<a class='button' href='$SCRIPT_NAME?do=$action&$pkg'>$action_i18n</a>"
   7.683 +		fi
   7.684 +
   7.685 +		if [ -d $INSTALLED/$pkg ]; then
   7.686 +			if grep -qs "^$pkg$" $PKGS_DB/blocked-packages.list; then
   7.687 +				cat << EOT
   7.688 +			<a class="button" href="$SCRIPT_NAME?do=Unblock&$pkg">$(_ 'Unblock')</a>
   7.689 +EOT
   7.690 +			else
   7.691 +				cat << EOT
   7.692 +			<a class="button" href='$SCRIPT_NAME?do=Block&$pkg'>$(_ 'Block')</a>
   7.693 +EOT
   7.694 +			fi
   7.695 +			cat << EOT
   7.696 +			<a class="button" href='$SCRIPT_NAME?do=Repack&$pkg'>$(_ 'Repack')</a>
   7.697 +EOT
   7.698 +		fi
   7.699 +		i18n_desc
   7.700 +		cat << EOT
   7.701 +		</p>
   7.702 +	</div>
   7.703 +	<div class="float-right">
   7.704 +		<p>
   7.705 +			<a class="button" href='$SCRIPT_NAME?list'>
   7.706 +				<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
   7.707 +		</p>
   7.708 +	</div>
   7.709 +</div>
   7.710 +<table class="zebra outbox">
   7.711 +<tbody>
   7.712 +	<tr><td><b>$(_ 'Name')</b></td><td>$PACKAGE</td></tr>
   7.713 +	<tr><td><b>$(_ 'Version')</b></td><td>$VERSION</td></tr>
   7.714 +	<tr><td><b>$(_ 'Description')</b></td><td>$SHORT_DESC</td></tr>
   7.715 +	<tr><td><b>$(_ 'Category')</b></td><td>$CATEGORY</td></tr>
   7.716 +EOT
   7.717 +		if [ -d $INSTALLED/$pkg ]; then
   7.718 +			cat << EOT
   7.719 +	<tr><td><b>$(_ 'Maintainer')</b></td><td>$MAINTAINER</td></tr>
   7.720 +	<tr><td><b>$(_ 'Website')</b></td><td><a href="$WEB_SITE">$WEB_SITE</a></td></tr>
   7.721 +	<tr><td><b>$(_ 'Sizes')</b></td><td>$PACKED_SIZE/$UNPACKED_SIZE</td></tr>
   7.722 +EOT
   7.723 +			if [ -n "$DEPENDS" ]; then
   7.724 +				echo "<tr><td><b>$(_ 'Depends')</b></td><td>"
   7.725 +				for i in $DEPENDS; do
   7.726 +					echo -n "<a href="$(pkg_info_link $i)">$i</a> "
   7.727 +				done
   7.728 +				echo "</td></tr>"
   7.729 +			fi
   7.730 +			if [ -n "$SUGGESTED" ]; then
   7.731 +				echo "<tr><td><b>$(_ 'Suggested')</b></td><td>"
   7.732 +				for i in $SUGGESTED; do
   7.733 +					echo -n "<a href="$(pkg_info_link $i)">$i</a> "
   7.734 +				done
   7.735 +				echo "</td></tr>"
   7.736 +			fi
   7.737 +			[ -n "$TAGS" ] && echo "<tr><td><b>$(_ 'Tags')</b></td><td>$TAGS</td></tr>"
   7.738 +			I_FILES=$(cat $INSTALLED/$pkg/files.list | wc -l)
   7.739 +			cat << EOT
   7.740 +</tbody>
   7.741 +</table>
   7.742 +
   7.743 +<p>$(_ 'Installed files: %s' $I_FILES)</p>
   7.744 +
   7.745 +<pre>$(cat $INSTALLED/$pkg/files.list)</pre>
   7.746 +EOT
   7.747 +		else
   7.748 +			cat << EOT
   7.749 +<tr><td><b>$(_ 'Website')</b></td><td><a href="$WEB_SITE">$WEB_SITE</a></td></tr>
   7.750 +<tr><td><b>$(_ 'Sizes')</b></td><td>$(grep -hsA 3 ^$pkg$ packages.txt undigest/*/packages.txt | \
   7.751 +		tail -n 1 | sed 's/ *//')</td></tr>
   7.752 +</table>
   7.753 +
   7.754 +<p>$(_ 'Installed files:')</p>
   7.755 +
   7.756 +<pre>
   7.757 +`unlzma -c files.list.lzma undigest/*/files.list.lzma 2> /dev/null | \
   7.758 + sed "/^$pkg: /!d;s/^$pkg: //"`
   7.759 +</pre>
   7.760 +EOT
   7.761 +		fi
   7.762 +		;;
   7.763 +
   7.764 +
   7.765 +	*\ admin\ * )
   7.766 +		#
   7.767 +		# TazPkg configuration page
   7.768 +		#
   7.769 +		cmd=$(GET admin)
   7.770 +		case "$cmd" in
   7.771 +			clean)
   7.772 +				rm -rf /var/cache/tazpkg/* ;;
   7.773 +			add-mirror)
   7.774 +				# Decode url
   7.775 +				mirror=$(GET mirror)
   7.776 +				case "$mirror" in
   7.777 +				http://*|ftp://*)
   7.778 +					echo "$mirror" >> $(GET file) ;;
   7.779 +				esac ;;
   7.780 +			rm-mirror=http://*|rm-mirror=ftp://*)
   7.781 +				mirror=${cmd#rm-mirror=}
   7.782 +				sed -i -e "s@$mirror@@" -e '/^$/d' $(GET file) ;;
   7.783 +			select-mirror*)
   7.784 +				release=$(cat /etc/slitaz-release)
   7.785 +				mirror="$(GET mirror)packages/$release/"
   7.786 +				tazpkg setup-mirror $mirror | log
   7.787 +				;;
   7.788 +			add-repo)
   7.789 +				# Decode url
   7.790 +				mirror=$(GET mirror)
   7.791 +				repository=$PKGS_DB/undigest/$(GET repository)
   7.792 +				case "$mirror" in
   7.793 +				http://*|ftp://*)
   7.794 +					mkdir -p $repository
   7.795 +					echo "$mirror" > $repository/mirror
   7.796 +					echo "$mirror" > $repository/mirrors ;;
   7.797 +				esac ;;
   7.798 +			rm-repo=*)
   7.799 +				repository=${cmd#rm-repo=}
   7.800 +				rm -rf $PKGS_DB/undigest/$repository ;;
   7.801 +		esac
   7.802 +		[ "$cmd" == "$(_n 'Set link')" ] &&
   7.803 +			[ -d "$(GET link)/$INSTALLED" ] &&
   7.804 +			ln -fs $(GET link) $PKGS_DB/fslink
   7.805 +		[ "$cmd" == "$(_n 'Remove link')" ] &&
   7.806 +			rm -f $PKGS_DB/fslink
   7.807 +		cache_files=$(find /var/cache/tazpkg -name *.tazpkg | wc -l)
   7.808 +		cache_size=$(du -sh /var/cache/tazpkg | cut -f1 | sed 's|\.0||')
   7.809 +		sidebar
   7.810 +		cat << EOT
   7.811 +<h2>$(_ 'Administration')</h2>
   7.812 +<div>
   7.813 +	<p>$(_ 'TazPkg administration and settings')</p>
   7.814 +</div>
   7.815 +<div id="actions">
   7.816 +	<a class="button" href='$SCRIPT_NAME?admin=&action=saveconf'>
   7.817 +		<img src="$IMAGES/tazpkg.png" />$(_ 'Save configuration')</a>
   7.818 +	<a class="button" href='$SCRIPT_NAME?admin=&action=listconf'>
   7.819 +		<img src="$IMAGES/edit.png" />$(_ 'List configuration files')</a>
   7.820 +	<a class="button" href='$SCRIPT_NAME?admin=&action=quickcheck'>
   7.821 +		<img src="$IMAGES/recharge.png" />$(_ 'Quick check')</a>
   7.822 +	<a class="button" href='$SCRIPT_NAME?admin=&action=fullcheck'>
   7.823 +		<img src="$IMAGES/recharge.png" />$(_ 'Full check')</a>
   7.824 +</div>
   7.825 +EOT
   7.826 +		case "$(GET action)" in
   7.827 +				saveconf)
   7.828 +					LOADING_MSG=$(_ 'Creating the package...')
   7.829 +					loading_msg
   7.830 +					echo "<pre>"
   7.831 +					cd $HOME
   7.832 +					tazpkg repack-config | filter_taztools_msgs
   7.833 +					echo -n "$(_ 'Path:') "; ls $HOME/config-*.tazpkg
   7.834 +					echo "</pre>" ;;
   7.835 +				listconf)
   7.836 +					echo "<h4>$(_ 'Configuration files')</h4>"
   7.837 +					echo "<ul>"
   7.838 +					tazpkg list-config | while read file; do
   7.839 +						[ "${file:0:1}" == "/" ] || continue
   7.840 +						if [ -e $file ]; then
   7.841 +							echo "<li><a href=\"index.cgi?file=$file\">$file</a></li>"
   7.842 +						else
   7.843 +							echo "<li>$file</li>"
   7.844 +						fi
   7.845 +					done
   7.846 +					echo "</ul>"
   7.847 +					echo "</pre>" ;;
   7.848 +				quickcheck)
   7.849 +					LOADING_MSG=$(_ 'Checking packages consistency...')
   7.850 +					loading_msg
   7.851 +					echo "<pre>"
   7.852 +					tazpkg check
   7.853 +					echo "</pre>" ;;
   7.854 +				fullcheck)
   7.855 +					LOADING_MSG=$(_ 'Full packages check...')
   7.856 +					loading_msg
   7.857 +					echo "<pre>"
   7.858 +					tazpkg check --full
   7.859 +					echo "</pre>" ;;
   7.860 +				esac
   7.861 +		cat << EOT
   7.862 +<h3>$(_ 'Packages cache')</h3>
   7.863 +
   7.864 +<div>
   7.865 +	<form method="get" action="$SCRIPT_NAME">
   7.866 +		<p>
   7.867 +			$(_ 'Packages in the cache: %s (%s)' $cache_files $cache_size)
   7.868 +			<input type="hidden" name="admin" value="clean" />
   7.869 +			<input type="submit" value="Clean" />
   7.870 +		</p>
   7.871 +	</form>
   7.872 +</div>
   7.873 +
   7.874 +<h3>$(_ 'Default mirror')</h3>
   7.875 +
   7.876 +<pre>$(cat /var/lib/tazpkg/mirror)</pre>
   7.877 +
   7.878 +<h3>$(_ 'Current mirror list')</h3>
   7.879 +EOT
   7.880 +		for i in $PKGS_DB/mirrors $PKGS_DB/undigest/*/mirrors; do
   7.881 +			[ -s $i ] || continue
   7.882 +			echo '<div class="box">'
   7.883 +			if [ $i != $PKGS_DB/mirrors ]; then
   7.884 +				Repo_Name="$(repo_name $(dirname $i))"
   7.885 +				echo "<h4>$(_ 'Repository: %s' $Repo_Name)</h4>"
   7.886 +			fi
   7.887 +			echo "<ul>"
   7.888 +			list_mirrors $i
   7.889 +			echo "</ul>"
   7.890 +			cat << EOT
   7.891 +</div>
   7.892 +<form method="get" action="$SCRIPT_NAME">
   7.893 +	<p>
   7.894 +		<input type="hidden" name="admin" value="add-mirror" />
   7.895 +		<input type="hidden" name="file" value="$i" />
   7.896 +		<input type="text" name="mirror" size="60">
   7.897 +		<input type="submit" value="Add mirror" />
   7.898 +	</p>
   7.899 +</form>
   7.900 +EOT
   7.901 +		done
   7.902 +		echo "<h3>$(_ 'Private repositories')</h3>"
   7.903 +		[ -n "$(ls $PKGS_DB/undigest 2> /dev/null)" ] && cat << EOT
   7.904 +<div class="box">
   7.905 +	<ul>
   7.906 +		$(list_repos)
   7.907 +	</ul>
   7.908 +</div>
   7.909 +EOT
   7.910 +		cat << EOT
   7.911 +<form method="get" action="$SCRIPT_NAME">
   7.912 +	<p>
   7.913 +		<input type="hidden" name="admin" value="add-repo" />
   7.914 +		$(_ 'Name') <input type="text" name="repository" size="10">
   7.915 +		$(_ 'mirror')
   7.916 +		<input type="text" name="mirror" value="http://" size="50">
   7.917 +		<input type="submit" value="Add repository" />
   7.918 +	</p>
   7.919 +</form>
   7.920 +
   7.921 +<h3>$(_ 'Link to another SliTaz installation')</h3>
   7.922 +
   7.923 +<p>$(_ "This link points to the root of another SliTaz installation. \
   7.924 +You will be able to install packages using soft links to it.")</p>
   7.925 +
   7.926 +<form method="get" action="$SCRIPT_NAME">
   7.927 +<p>
   7.928 +	<input type="hidden" name="admin" value="add-link" />
   7.929 +	<input type="text" name="link"
   7.930 +	 value="$(readlink $PKGS_DB/fslink 2> /dev/null)" size="50">
   7.931 +	<input type="submit" name="admin" value="$(_ 'Set link')" />
   7.932 +	<input type="submit" name="admin" value="$(_ 'Remove link')" />
   7.933 +</p>
   7.934 +</form>
   7.935 +EOT
   7.936 +		version=$(cat /etc/slitaz-release)
   7.937 +		cat << EOT
   7.938 +
   7.939 +<h3 id="dvd">$(_ 'SliTaz packages DVD')</h3>
   7.940 +
   7.941 +<p>$(_ "A bootable DVD image of all available packages for the %s version is \
   7.942 +generated every day. It also contains a copy of the website and can be used \
   7.943 +without an internet connection. This image can be installed on a DVD or a USB \
   7.944 +key." $version)</p>
   7.945 +
   7.946 +<div>
   7.947 +	<form method="post" action='$SCRIPT_NAME?admin&action=dvdimage#dvd'>
   7.948 +	<p>
   7.949 +		<a class="button"
   7.950 +			href='http://mirror.slitaz.org/iso/$version/packages-$version.iso'>
   7.951 +			<img src="$IMAGES/tazpkg.png" />$(_ 'Download DVD image')</a>
   7.952 +		<a class="button" href='$SCRIPT_NAME?admin&action=dvdusbkey#dvd'>
   7.953 +			<img src="$IMAGES/tazpkg.png" />$(_ 'Install from DVD/USB key')</a>
   7.954 +	</p>
   7.955 +	<div class="box">
   7.956 +		$(_ 'Install from ISO image:')
   7.957 +		<input type="text" name="dvdimage" size="40" value="/root/packages-$version.iso">
   7.958 +	</div>
   7.959 +	</form>
   7.960 +</div>
   7.961 +EOT
   7.962 +		if [ "$(GET action)" == "dvdimage" ]; then
   7.963 +			dev=$(POST dvdimage)
   7.964 +			mkdir -p /mnt/packages 2> /dev/null
   7.965 +			echo "<pre>"
   7.966 +			mount -t iso9660 -o loop,ro $dev /mnt/packages &&
   7.967 +			/mnt/packages/install.sh &&
   7.968 +			_ '%s is installed on /mnt/packages' $dev
   7.969 +			echo "</pre>"
   7.970 +		fi
   7.971 +		if [ "$(GET action)" == "dvdusbkey" ]; then
   7.972 +			mkdir -p /mnt/packages 2> /dev/null
   7.973 +			for tag in "LABEL=\"packages-$version\" TYPE=\"iso9660\"" \
   7.974 +				"LABEL=\"sources-$version\" TYPE=\"iso9660\"" ; do
   7.975 +				dev=$(blkid | grep "$tag" | cut -d: -f1)
   7.976 +				[ -n "$dev" ] || continue
   7.977 +				echo "<pre>"
   7.978 +				mount -t iso9660 -o ro $dev /mnt/packages &&
   7.979 +				/mnt/packages/install.sh &&
   7.980 +				_ '%s is installed on /mnt/packages' $dev
   7.981 +				echo "</pre>"
   7.982 +				break
   7.983 +			done
   7.984 +		fi
   7.985 +		 ;;
   7.986 +	*)
   7.987 +		#
   7.988 +		# Default to summary
   7.989 +		#
   7.990 +		search_form
   7.991 +		sidebar
   7.992 +		[ -n "$(GET block)" ] && tazpkg block $(GET block)
   7.993 +		[ -n "$(GET unblock)" ] && tazpkg unblock $(GET unblock)
   7.994 +		cat << EOT
   7.995 +<h2>$(_ 'Summary')</h2>
   7.996 +
   7.997 +<div id="actions">
   7.998 +	<a class="button" href="$SCRIPT_NAME?list">
   7.999 +		<img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a>
  7.1000 +EOT
  7.1001 +		fslink=$(readlink $PKGS_DB/fslink)
  7.1002 +		[ -n "$fslink" -a -d "$fslink/$INSTALLED" ] &&
  7.1003 +			cat << EOT
  7.1004 +	<a class="button" href="$SCRIPT_NAME?linkable">
  7.1005 +		<img src="$IMAGES/tazpkg.png" />$(_ 'Linkable packages')</a>
  7.1006 +EOT
  7.1007 +		cat << EOT
  7.1008 +	<a class="button" href="$SCRIPT_NAME?recharge">
  7.1009 +		<img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a>
  7.1010 +	<a class="button" href="$SCRIPT_NAME?up">
  7.1011 +		<img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a>
  7.1012 +	<a class="button" href="$SCRIPT_NAME?admin">
  7.1013 +		<img src="$IMAGES/edit.png" />$(_ 'Administration')</a>
  7.1014 +</div>
  7.1015 +
  7.1016 +$(packages_summary)
  7.1017 +
  7.1018 +
  7.1019 +<h3>$(_ 'Latest log entries')</h3>
  7.1020 +
  7.1021 +<pre>
  7.1022 +$(tail -n 5 /var/log/slitaz/tazpkg.log | fgrep "-" | \
  7.1023 +	awk '{print $1, $2, $3, $4, $5, $6, $7}')
  7.1024 +</pre>
  7.1025 +EOT
  7.1026 +		;;
  7.1027 +esac
  7.1028 +
  7.1029 +# xHTML 5 footer
  7.1030 +export TEXTDOMAIN='tazpkg'
  7.1031 +xhtml_footer
  7.1032 +exit 0