tazpkg rev 627

Add tazpanel files
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jun 29 20:18:19 2013 +0200 (2013-06-29)
parents 785703fb2975
children 3a1edf27791c
files COPYING Makefile pkgs pkgs.cgi
line diff
     1.1 --- a/COPYING	Wed Mar 20 16:50:02 2013 +0000
     1.2 +++ b/COPYING	Sat Jun 29 20:18:19 2013 +0200
     1.3 @@ -2,7 +2,7 @@
     1.4  ===============================================================================
     1.5  
     1.6  
     1.7 -Copyright (c)  2007-2011  SliTaz GNU/Linux
     1.8 +Copyright (c)  2007-2013  SliTaz GNU/Linux
     1.9  
    1.10  
    1.11  Franšais
     2.1 --- a/Makefile	Wed Mar 20 16:50:02 2013 +0000
     2.2 +++ b/Makefile	Sat Jun 29 20:18:19 2013 +0200
     2.3 @@ -68,6 +68,10 @@
     2.4  	# Documentation
     2.5  	install -m 0755 -d $(DESTDIR)$(DOCDIR)/tazpkg
     2.6  	cp -a doc/* $(DESTDIR)$(DOCDIR)/tazpkg
     2.7 +	# tazpanel files
     2.8 +	install -m 0755 -d $(DESTDIR)/var/www/tazpanel/menu.d
     2.9 +	cp -a pkgs.cgi $(DESTDIR)/var/www/tazpanel
    2.10 +	cp -a pkgs $(DESTDIR)/var/www/tazpanel/menu.d
    2.11  	# The i18n files
    2.12  	install -m 0755 -d $(DESTDIR)$(PREFIX)/share/locale
    2.13  	cp -a po/mo/* $(DESTDIR)$(PREFIX)/share/locale
    2.14 @@ -82,6 +86,8 @@
    2.15  uninstall:
    2.16  	rm -f $(DESTDIR)$(PREFIX)/bin/tazpkg
    2.17  	rm -f $(DESTDIR)$(PREFIX)/bin/tazpkg-box
    2.18 +	rm -f $(DESTDIR)$(PREFIX)/var/www/tazpanel/menu.d/pkgs
    2.19 +	rm -f $(DESTDIR)$(PREFIX)/var/www/tazpanel/pkgs.cgi
    2.20  	rm -rf $(DESTDIR)$(PREFIX)/tazpkg-notify
    2.21  	rm -rf $(DESTDIR)$(DOCDIR)/tazpkg
    2.22  	rm -f $(DESTDIR)$(SYSCONFDIR)/tazpkg.conf 
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pkgs	Sat Jun 29 20:18:19 2013 +0200
     3.3 @@ -0,0 +1,14 @@
     3.4 +cat <<EOT
     3.5 +<li><a href="/pkgs.cgi">$(gettext 'Packages')</a>
     3.6 +	<ul>
     3.7 +		<li><a href="/pkgs.cgi?list"><img
     3.8 +			src="/styles/default/images/tazpkg.png" />$(gettext 'My packages')</a></li>
     3.9 +		<li><a href="/pkgs.cgi?recharge"><img
    3.10 +			src="/styles/default/images/update.png" />$(gettext 'Recharge list')</a></li>
    3.11 +		<li><a href="/pkgs.cgi?up"><img
    3.12 +			src="/styles/default/images/update.png" />$(gettext 'Check updates')</a></li>
    3.13 +		<li><a href="/pkgs.cgi?admin"><img
    3.14 +			src="/styles/default/images/edit.png" />$(gettext 'Administration')</a></li>
    3.15 +	</ul>
    3.16 +</li>
    3.17 +EOT
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pkgs.cgi	Sat Jun 29 20:18:19 2013 +0200
     4.3 @@ -0,0 +1,996 @@
     4.4 +#!/bin/sh
     4.5 +#
     4.6 +# TazPKG CGI interface - Manage packages via a browser
     4.7 +#
     4.8 +# This CGI interface extensively uses tazpkg to manage packages and have
     4.9 +# its own code for some tasks. Please KISS, it is important and keep speed
    4.10 +# in mind. Thanks, Pankso.
    4.11 +#
    4.12 +# (C) 2011 SliTaz GNU/Linux - BSD License
    4.13 +#
    4.14 +
    4.15 +. lib/libtazpanel
    4.16 +get_config
    4.17 +header
    4.18 +
    4.19 +# xHTML 5 header with special side bar for categories.
    4.20 +TITLE=$(gettext 'TazPanel - Packages')
    4.21 +xhtml_header | sed 's/id="content"/id="content-sidebar"/'
    4.22 +
    4.23 +pkg_info_link()
    4.24 +{
    4.25 +	echo "$SCRIPT_NAME?info=$1" | sed 's/+/%2B/g'
    4.26 +}
    4.27 +
    4.28 +i18n_desc() {
    4.29 +	# Display localized short description
    4.30 +	if [ -e "$LOCALSTATE/packages-desc.$LANG" ]; then
    4.31 +		LOCDESC=$(grep -e "^$pkg	" $LOCALSTATE/packages-desc.$LANG | cut -d'	' -f2)
    4.32 +	[ "x$LOCDESC" != "x" ] && SHORT_DESC="$LOCDESC"
    4.33 +	fi
    4.34 +}
    4.35 +
    4.36 +# We need packages information for list and search
    4.37 +parse_packages_desc() {
    4.38 +	IFS="|"
    4.39 +	cut -f 1,2,3,5 -d "|" | while read PACKAGE VERSION SHORT_DESC WEB_SITE
    4.40 +	do
    4.41 +		image=tazpkg-installed.png
    4.42 +		[ -d $INSTALLED/${PACKAGE% } ] || image=tazpkg.png
    4.43 +		i18n_desc
    4.44 +		cat << EOT
    4.45 +<tr>
    4.46 +<td><input type="checkbox" name="pkg" value="$PACKAGE">
    4.47 +	<a href="$(pkg_info_link $PACKAGE)"><img
    4.48 +		src="$IMAGES/$image"/>$PACKAGE</a></td>
    4.49 +<td>$VERSION</td>
    4.50 +<td class="desc">$SHORT_DESC</td>
    4.51 +<td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
    4.52 +</tr>
    4.53 +EOT
    4.54 +	done
    4.55 +	unset IFS
    4.56 +}
    4.57 +
    4.58 +# Display a full summary of packages stats
    4.59 +packages_summary() {
    4.60 +	cat << EOT
    4.61 +<table class="zebra outbox">
    4.62 +<tbody>
    4.63 +<tr><td>$(gettext 'Last recharge:')</td>
    4.64 +EOT
    4.65 +	stat=$(stat -c %y $LOCALSTATE/packages.list | \
    4.66 +		sed 's/\(:..\):.*/\1/' | awk '{print $1}')
    4.67 +	mtime=$(find $LOCALSTATE/packages.list -mtime +10)
    4.68 +	echo -n "<td>$stat "
    4.69 +	if [ "$mtime" ]; then
    4.70 +		gettext '(Older than 10 days)'; echo
    4.71 +	else
    4.72 +		gettext '(Not older than 10 days)'; echo
    4.73 +	fi
    4.74 +	cat << EOT
    4.75 +</td></tr>
    4.76 +<tr><td>$(gettext 'Installed packages:')</td>
    4.77 +	<td>$(ls $INSTALLED | wc -l)</td></tr>
    4.78 +<tr><td>$(gettext 'Mirrored packages:')</td>
    4.79 +	<td>$(cat $LOCALSTATE/packages.list | wc -l)</td></tr>
    4.80 +<tr><td>$(gettext 'Upgradeable packages:')</td>
    4.81 +	<td>$(cat $LOCALSTATE/packages.up | wc -l)</td></tr>
    4.82 +<tr><td>$(gettext 'Installed files:')</td>
    4.83 +	<td>$(cat $INSTALLED/*/files.list | wc -l)</td></tr>
    4.84 +<tr><td>$(gettext 'Blocked packages:')</td>
    4.85 +	<td>$(cat $LOCALSTATE/blocked-packages.list | wc -l)</td></tr>
    4.86 +</tbody>
    4.87 +</table>
    4.88 +EOT
    4.89 +}
    4.90 +
    4.91 +# Parse mirrors list to be able to have an icon and remove link
    4.92 +list_mirrors() {
    4.93 +	while read line
    4.94 +	do
    4.95 +		cat << EOT
    4.96 +<li>
    4.97 +	<a href="$SCRIPT_NAME?admin=rm-mirror=$line&amp;file=$(httpd -e $1)">
    4.98 +		<img src="$IMAGES/clear.png" title="$(gettext 'Delete')" />
    4.99 +	</a>
   4.100 +	<a href="$SCRIPT_NAME?admin=select-mirror&amp;mirror=$line">
   4.101 +		<img src="$IMAGES/start.png" title="$(gettext 'Use as default')" />
   4.102 +	</a>
   4.103 +	<a href="$line">$line</a>
   4.104 +</li>
   4.105 +EOT
   4.106 +	done < $1
   4.107 +}
   4.108 +
   4.109 +# Parse repositories list to be able to have an icon and remove link
   4.110 +list_repos() {
   4.111 +	ls $LOCALSTATE/undigest 2> /dev/null | while read repo ; do
   4.112 +		cat <<EOT
   4.113 +	<li><a href="$SCRIPT_NAME?admin=rm-repo=$repo">
   4.114 +	    <img src="$IMAGES/clear.png">$repo</a></li>
   4.115 +EOT
   4.116 +	done
   4.117 +}
   4.118 +
   4.119 +#
   4.120 +# xHTML functions
   4.121 +#
   4.122 +
   4.123 +# ENTER will search but user may search for a button, so put one.
   4.124 +search_form() {
   4.125 +	[ -n "$repo" ] || repo="$(GET repo)"
   4.126 +	[ -n "$repo" ] || repo=Any
   4.127 +	cat << EOT
   4.128 +<div class="search">
   4.129 +	<form method="get" action="$SCRIPT_NAME">
   4.130 +		<p>
   4.131 +			<input type="text" name="search" size="20">
   4.132 +			<input type="submit" value="$(gettext 'Search')">
   4.133 +			<input class="radius" type="submit" name="files"
   4.134 +				value="$(gettext 'Files')">
   4.135 +			<input type="hidden" name="repo" value="$repo" />
   4.136 +		</p>
   4.137 +	</form>
   4.138 +</div>
   4.139 +EOT
   4.140 +}
   4.141 +
   4.142 +table_head() {
   4.143 +	cat << EOT
   4.144 +		<thead>
   4.145 +		<tr>
   4.146 +			<td>$(gettext 'Name')</td>
   4.147 +			<td>$(gettext 'Version')</td>
   4.148 +			<td>$(gettext 'Description')</td>
   4.149 +			<td>$(gettext 'Web')</td>
   4.150 +		</tr>
   4.151 +		</thead>
   4.152 +EOT
   4.153 +}
   4.154 +
   4.155 +sidebar() {
   4.156 +	[ -n "$repo" ] || repo=Public
   4.157 +	cat << EOT
   4.158 +<div id="sidebar">
   4.159 +	<h4>$(gettext 'Categories')</h4>
   4.160 +	<a class="active_base-system" href="$SCRIPT_NAME?cat=base-system&repo=$repo">$(gettext 'Base-system')</a>
   4.161 +	<a class="active_x-window" href="$SCRIPT_NAME?cat=x-window&repo=$repo">$(gettext 'X window')</a>
   4.162 +	<a class="active_utilities" href="$SCRIPT_NAME?cat=utilities&repo=$repo">$(gettext 'Utilities')</a>
   4.163 +	<a class="active_network" href="$SCRIPT_NAME?cat=network&repo=$repo">$(gettext 'Network')</a>
   4.164 +	<a class="active_games" href="$SCRIPT_NAME?cat=games&repo=$repo">$(gettext 'Games')</a>
   4.165 +	<a class="active_graphics" href="$SCRIPT_NAME?cat=graphics&repo=$repo">$(gettext 'Graphics')</a>
   4.166 +	<a class="active_office" href="$SCRIPT_NAME?cat=office&repo=$repo">$(gettext 'Office')</a>
   4.167 +	<a class="active_multimedia" href="$SCRIPT_NAME?cat=multimedia&repo=$repo">$(gettext 'Multimedia')</a>
   4.168 +	<a class="active_development" href="$SCRIPT_NAME?cat=development&repo=$repo">$(gettext 'Development')</a>
   4.169 +	<a class="active_system-tools" href="$SCRIPT_NAME?cat=system-tools&repo=$repo">$(gettext 'System tools')</a>
   4.170 +	<a class="active_security" href="$SCRIPT_NAME?cat=security&repo=$repo">$(gettext 'Security')</a>
   4.171 +	<a class="active_misc" href="$SCRIPT_NAME?cat=misc&repo=$repo">$(gettext 'Misc')</a>
   4.172 +	<a class="active_meta" href="$SCRIPT_NAME?cat=meta&repo=$repo">$(gettext 'Meta')</a>
   4.173 +	<a class="active_non-free" href="$SCRIPT_NAME?cat=non-free&repo=$repo">$(gettext 'Non free')</a>
   4.174 +	<a class="active_all" href="$SCRIPT_NAME?cat=all&repo=$repo">$(gettext 'All')</a>
   4.175 +EOT
   4.176 +
   4.177 +	if [ -d $LOCALSTATE/undigest ]; then
   4.178 +		[ -n "$category" ] || category="base-system"
   4.179 +		cat << EOT
   4.180 +	<h4>$(gettext 'Repositories')</h4>
   4.181 +	<a class="repo_Public" href="$SCRIPT_NAME?repo=Public&cat=$category">$(gettext 'Public')</a>
   4.182 +EOT
   4.183 +		for i in $(ls $LOCALSTATE/undigest); do
   4.184 +			cat << EOT
   4.185 +	<a class="repo_$i" href="$SCRIPT_NAME?repo=$i&cat=$category">$i</a>
   4.186 +EOT
   4.187 +		done
   4.188 +		cat << EOT
   4.189 +	<a class="repo_Any" href="$SCRIPT_NAME?repo=Any&cat=$category">$(gettext 'Any')</a>
   4.190 +EOT
   4.191 +	fi
   4.192 +	echo "</div>"
   4.193 +}
   4.194 +
   4.195 +repo_list() {
   4.196 +	if [ -n "$(ls $LOCALSTATE/undigest/ 2> /dev/null)" ]; then
   4.197 +		case "$repo" in
   4.198 +		Public)	;;
   4.199 +		""|Any) for i in $LOCALSTATE/undigest/* ; do
   4.200 +				[ -d "$i" ] && echo "$i$1"
   4.201 +			done ;;
   4.202 +		*)	echo "$LOCALSTATE/undigest/$repo$1"
   4.203 +			return ;;
   4.204 +		esac
   4.205 +	fi
   4.206 +	echo "$LOCALSTATE$1"
   4.207 +}
   4.208 +
   4.209 +repo_name() {
   4.210 +	case "$1" in
   4.211 +	$LOCALSTATE)		echo "Public" ;;
   4.212 +	$LOCALSTATE/undigest/*)	echo ${1#$LOCALSTATE/undigest/} ;;
   4.213 +	esac
   4.214 +}
   4.215 +
   4.216 +#
   4.217 +# Commands
   4.218 +#
   4.219 +
   4.220 +case " $(GET) " in
   4.221 +	*\ list\ *)
   4.222 +		#
   4.223 +		# List installed packages. This is the default because parsing
   4.224 +		# the full packages.desc can be long and take up some resources
   4.225 +		#
   4.226 +		cd $INSTALLED
   4.227 +		search_form
   4.228 +		sidebar
   4.229 +		LOADING_MSG="$(gettext 'Listing packages...')"
   4.230 +		loading_msg
   4.231 +		cat << EOT
   4.232 +<h2>$(gettext 'My packages')</h2>
   4.233 +<form method='get' action='$SCRIPT_NAME'>
   4.234 +	<input type="hidden" name="do" value="Remove" />
   4.235 +<div id="actions">
   4.236 +	<div class="float-left">
   4.237 +		$(gettext 'Selection:')
   4.238 +		<input type="submit" value="$(gettext 'Remove')" />
   4.239 +	</div>
   4.240 +	<div class="float-right">
   4.241 +		<a class="button" href="$SCRIPT_NAME?recharge">
   4.242 +			<img src="$IMAGES/recharge.png" />$(gettext 'Recharge list')</a>
   4.243 +		<a class="button" href='$SCRIPT_NAME?up'>
   4.244 +			<img src="$IMAGES/update.png" />$(gettext 'Check upgrades')</a>
   4.245 +	</div>
   4.246 +</div>
   4.247 +EOT
   4.248 +		cat << EOT
   4.249 +<table class="zebra outbox">
   4.250 +$(table_head)
   4.251 +<tbody>
   4.252 +EOT
   4.253 +		for pkg in *
   4.254 +		do
   4.255 +			. $pkg/receipt
   4.256 +			echo '<tr>'
   4.257 +			# Use default tazpkg icon since all packages displayed are
   4.258 +			# installed
   4.259 +			colorpkg=$pkg
   4.260 +			grep -qs "^$pkg$" $LOCALSTATE/blocked-packages.list &&
   4.261 +				colorpkg="<span style='color: red;'>$pkg</span>"
   4.262 +			i18n_desc
   4.263 +			cat << EOT
   4.264 +<td class="pkg">
   4.265 +	<input type="checkbox" name="pkg" value="$pkg" />
   4.266 +		<a href="$(pkg_info_link $pkg)"><img
   4.267 +			src="$IMAGES/tazpkg-installed.png"/>$colorpkg</a></td>
   4.268 +<td>$VERSION</td>
   4.269 +<td class="desc">$SHORT_DESC</td>
   4.270 +<td><a href="$WEB_SITE"><img src="$IMAGES/browser.png"/></a></td>
   4.271 +</tr>
   4.272 +EOT
   4.273 +		done
   4.274 +		cat << EOT
   4.275 +</tbody>
   4.276 +</table>
   4.277 +</form>
   4.278 +EOT
   4.279 +		;;
   4.280 +
   4.281 +	*\ linkable\ *)
   4.282 +		#
   4.283 +		# List linkable packages.
   4.284 +		#
   4.285 +		cd $INSTALLED
   4.286 +		search_form
   4.287 +		sidebar
   4.288 +		LOADING_MSG=$(gettext 'Listing linkable packages...')
   4.289 +		loading_msg
   4.290 +		cat << EOT
   4.291 +<h2>$(gettext 'Linkable packages')</h2>