tazpanel rev 140

pkgs.cgi: add link support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Apr 17 02:07:00 2011 +0200 (2011-04-17)
parents ec6dbf6b07e3
children 02bac4e0fafe
files pkgs.cgi
line diff
     1.1 --- a/pkgs.cgi	Sun Apr 17 01:10:18 2011 +0200
     1.2 +++ b/pkgs.cgi	Sun Apr 17 02:07:00 2011 +0200
     1.3 @@ -234,6 +234,49 @@
     1.4  		done
     1.5  		table_end
     1.6  		echo '</form>' ;;
     1.7 +	*\ linkable\ *)
     1.8 +		#
     1.9 +		# List linkable packages.
    1.10 +		#
    1.11 +		cd $INSTALLED
    1.12 +		search_form
    1.13 +		sidebar
    1.14 +		LOADING_MSG="Listing linkable packages..."
    1.15 +		loading_msg
    1.16 +		cat << EOT
    1.17 +<h2>`gettext "Linkable packages"`</h2>
    1.18 +<form method='get' action='$SCRIPT_NAME'>
    1.19 +<div id="actions">
    1.20 +	<div class="float-left">
    1.21 +		`gettext "Selection:"`
    1.22 +		<input type="submit" name="do" value="Link" />
    1.23 +	</div>
    1.24 +	<div class="float-right">
    1.25 +		`gettext "List:"`
    1.26 +		<input type="submit" name="recharge" value="Recharge" />
    1.27 +		<input type="submit" name="up" value="Upgrade" />
    1.28 +	</div>
    1.29 +</div>
    1.30 +EOT
    1.31 +		table_start
    1.32 +		table_head
    1.33 +		target=$(readlink $LOCALSTATE/fslink)
    1.34 +		for pkg in $(ls $target/$INSTALLED)
    1.35 +		do
    1.36 +			[ -s $pkg/receipt ] && continue
    1.37 +			. $target/$INSTALLED/$pkg/receipt
    1.38 +			echo '<tr>'
    1.39 +			echo "<td class='pkg'>
    1.40 +				<input type='checkbox' name='pkg' value=\"$pkg\" />
    1.41 +				<a href='$SCRIPT_NAME?info=$pkg'><img
    1.42 +					src='$IMAGES/tazpkg.png'/>$pkg</a></td>"
    1.43 +			echo "<td>$VERSION</td>"
    1.44 +			echo "<td class='desc'>$SHORT_DESC</td>"
    1.45 +			echo "<td><a href='$WEB_SITE'><img src='$IMAGES/browser.png'/></a></td>"
    1.46 +			echo '</tr>'
    1.47 +		done
    1.48 +		table_end
    1.49 +		echo '</form>' ;;
    1.50  	*\ cat\ *)
    1.51  		#
    1.52  		# List all available packages by category on mirror. Listing all
    1.53 @@ -425,6 +468,8 @@
    1.54  		case $cmd in
    1.55  			install)
    1.56  				cmd=get-install opt=--forced ;;
    1.57 +			link)
    1.58 +				opt=$(readlink $LOCALSTATE/fslink) ;;
    1.59  		esac
    1.60  		search_form
    1.61  		sidebar
    1.62 @@ -592,6 +637,11 @@
    1.63  				repository=${cmd#rm-repo=}
    1.64  				rm -rf $LOCALSTATE/undigest/$repository ;;
    1.65  		esac
    1.66 +		[ "$cmd" == "$(gettext "Set link")" ] &&
    1.67 +			[ -d "$(GET link)/$INSTALLED" ] &&
    1.68 +			ln -fs $(GET link) $LOCALSTATE/fslink
    1.69 +		[ "$cmd" == "$(gettext "Remove link")" ] &&
    1.70 +			rm -f $LOCALSTATE/fslink
    1.71  		cache_files=`find /var/cache/tazpkg -name *.tazpkg | wc -l`
    1.72  		cache_size=`du -sh /var/cache/tazpkg`
    1.73  		sidebar
    1.74 @@ -700,6 +750,20 @@
    1.75  		<input type="submit" value="Add repository" />
    1.76  	</p>
    1.77  </form>
    1.78 +<h3>`gettext "Link to another SliTaz installation"`</h3>
    1.79 +<p>
    1.80 +$(gettext "This link point to the root of another SliTaz installation. \
    1.81 +You will be able to install packages using soft links to it.")
    1.82 +</p>
    1.83 +<form method="get" action="$SCRIPT_NAME">
    1.84 +<p>
    1.85 +	<input type="hidden" name="admin" value="add-link" />
    1.86 +	<input type="text" name="link" 
    1.87 +	 value="$(readlink $LOCALSTATE/fslink 2> /dev/null)" size="50">
    1.88 +	<input type="submit" name="admin" value="$(gettext "Set link")" />
    1.89 +	<input type="submit" name="admin" value="$(gettext "Remove link")" />
    1.90 +</p>
    1.91 +</form>
    1.92  EOT
    1.93  		version=$(cat /etc/slitaz-release)
    1.94  		cat << EOT
    1.95 @@ -765,6 +829,13 @@
    1.96  <div id="actions">
    1.97  	<a class="button" href='$SCRIPT_NAME?list'>
    1.98  		<img src="$IMAGES/tazpkg.png" />`gettext "My packages"`</a>
    1.99 +EOT
   1.100 +		[ -d "$(readlink $LOCALSTATE/fslink)/$INSTALLED" ] &&
   1.101 +			cat << EOT
   1.102 +	<a class="button" href='$SCRIPT_NAME?linkable'>
   1.103 +		<img src="$IMAGES/tazpkg.png" />`gettext "Linkable packages"`</a>
   1.104 +EOT
   1.105 +		cat << EOT
   1.106  	<a class="button" href='$SCRIPT_NAME?recharge'>
   1.107  		<img src="$IMAGES/recharge.png" />`gettext "Recharge list"`</a>
   1.108  	<a class="button" href='$SCRIPT_NAME?up'>