wok-current rev 4840

tazpkg-web: add BuildDepends & FileOverlap
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jan 28 19:12:08 2010 +0100 (2010-01-28)
parents cb9b7275be7a
children 173285738cb3
files tazpkg-web/stuff/search.cgi
line diff
     1.1 --- a/tazpkg-web/stuff/search.cgi	Thu Jan 28 16:26:39 2010 +0100
     1.2 +++ b/tazpkg-web/stuff/search.cgi	Thu Jan 28 19:12:08 2010 +0100
     1.3 @@ -15,9 +15,12 @@
     1.4  VERSION=cooking
     1.5  if [ "$REQUEST_METHOD" = "GET" ]; then
     1.6  	SEARCH=""
     1.7 +	VERBOSE=0
     1.8  	for i in $(echo $REQUEST_URI | sed 's/[?&]/ /g'); do
     1.9  		SLITAZ_VERSION=cooking
    1.10  		case "$i" in
    1.11 +		verbose=*)
    1.12 +			VERBOSE=${i#*=};;
    1.13  		lang=*)
    1.14  			LANG=${i#*=};;
    1.15  		file=*)
    1.16 @@ -41,6 +44,12 @@
    1.17  		depends=*)
    1.18  			SEARCH=${i#*=}
    1.19  			OBJECT=Depends;;
    1.20 +		BuildDepends=*)
    1.21 +			SEARCH=${i#*=}
    1.22 +			OBJECT=BuildDepends;;
    1.23 +		FileOverlap=*)
    1.24 +			SEARCH=${i#*=}
    1.25 +			OBJECT=FileOverlap;;
    1.26  		version=s*|version=2*)
    1.27  			SLITAZ_VERSION=stable;;
    1.28  		version=1*)
    1.29 @@ -57,6 +66,8 @@
    1.30  Receipt) 	selected_receipt="selected";;
    1.31  File_list) 	selected_file_list="selected";;
    1.32  Depends)	selected_depends="selected";;
    1.33 +BuildDepends)	selected_build_depends="selected";;
    1.34 +FileOverlap)	selected_overlap="selected";;
    1.35  esac
    1.36  
    1.37  case "$SLITAZ_VERSION" in
    1.38 @@ -84,6 +95,7 @@
    1.39  receipt="Receipt"
    1.40  file_list="File list"
    1.41  depends="Depends"
    1.42 +bdepends="Build depends"
    1.43  search="Search"
    1.44  cooking="cooking"
    1.45  stable="stable"
    1.46 @@ -91,6 +103,10 @@
    1.47  noresult="No package $SEARCH"
    1.48  deptree="Dependency tree for : $SEARCH"
    1.49  rdeptree="Reverse dependency tree for : $SEARCH"
    1.50 +bdeplist="$SEARCH needs these packages to be built"
    1.51 +rbdeplist="Packages who need $SEARCH to be built"
    1.52 +overloading="Theses packages may overload files of "
    1.53 +overlap="common files"
    1.54  charset="ISO-8859-1"
    1.55  
    1.56  case "$LANG" in
    1.57 @@ -98,11 +114,16 @@
    1.58  fr)	package="Paquet"
    1.59  	receipt="Recette"
    1.60  	depends="Dépendances"
    1.61 +	bdepends="Fabrication"
    1.62  	search="Recherche"
    1.63  	result="Recherche de : $SEARCH"
    1.64  	noresult="Paquet $SEARCH introuvable"
    1.65  	deptree="Arbre des dépendances de $SEARCH"
    1.66  	rdeptree="Arbre inversé des dépendances de $SEARCH"
    1.67 +	bdeplist="$SEARCH a besion de ces paquets pour être fabriqué"
    1.68 +	rbdeplist="Paquets ayant besion de $SEARCH pour être fabriqués"
    1.69 +	overloading="Paquets pouvant écraser des fichiers de "
    1.70 +	overlap="Fichiers communs"
    1.71  	file_list="Liste des fichiers"
    1.72  	file="Fichier";;
    1.73  
    1.74 @@ -171,11 +192,13 @@
    1.75  		<option $selected_tags value="Tags">$tags</option>
    1.76  		<option $selected_receipt value="Receipt">$receipt</option>
    1.77  		<option $selected_depends value="Depends">$depends</option>
    1.78 +		<option $selected_build_depends value="BuildDepends">$bdepends</option>
    1.79  		<option $selected_file value="File">$file</option>
    1.80  		<option $selected_file_list value="File_list">$file_list</option>
    1.81 +		<option $selected_overlap value="FileOverlap">$overlap</option>
    1.82  	</select>
    1.83  	<strong>:</strong>
    1.84 -	<input type="text" name="query" size="32" value="$SEARCH" />
    1.85 +	<input type="text" name="query" size="20" value="$SEARCH" />
    1.86  	<select name="version">
    1.87  		<option value="cooking">$cooking</option>
    1.88  		<option $selected_stable value="stable">$stable</option>
    1.89 @@ -270,6 +293,13 @@
    1.90  _EOT_
    1.91  }
    1.92  
    1.93 +installed_size()
    1.94 +{
    1.95 +[ $VERBOSE -gt 0 ] &&
    1.96 +grep -A 3 "^$1\$" /home/slitaz/$SLITAZ_VERSION/packages/packages.txt | \
    1.97 +       grep installed | sed 's/.*(\(.*\) installed.*/(\1) /'
    1.98 +}
    1.99 +
   1.100  # recursive dependencies scan
   1.101  dep_scan()
   1.102  {
   1.103 @@ -283,7 +313,7 @@
   1.104  		(
   1.105  		. $WOK/$i/receipt
   1.106  		cat << _EOT_
   1.107 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.108 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
   1.109  _EOT_
   1.110  		)
   1.111  	fi
   1.112 @@ -332,7 +362,7 @@
   1.113  ' | while read pkg; do
   1.114  		. $WOK/${pkg##*/}/receipt
   1.115  		cat << _EOT_
   1.116 -$(echo ${pkg%/*} | sed 's|/| |g') <a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.117 +$(echo ${pkg%/*} | sed 's|/| |g') <a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
   1.118  _EOT_
   1.119  done
   1.120  }
   1.121 @@ -355,6 +385,23 @@
   1.122  	sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'
   1.123  }
   1.124  
   1.125 +display_packages_and_files()
   1.126 +{
   1.127 +last=""
   1.128 +while read pkg file; do
   1.129 +	pkg=${pkg%:}
   1.130 +	if [ "$pkg" != "$last" ]; then
   1.131 +		. $WOK/$pkg/receipt
   1.132 +		cat << _EOT_
   1.133 +
   1.134 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
   1.135 +_EOT_
   1.136 +		last=$pkg
   1.137 +	fi
   1.138 +	echo "    $file"
   1.139 +done
   1.140 +}
   1.141 +
   1.142  # Display search form and result if requested.
   1.143  if [ "$REQUEST_METHOD" != "POST" ]; then
   1.144  	xhtml_header
   1.145 @@ -422,6 +469,68 @@
   1.146  _EOT_
   1.147  			ALL_DEPS=""
   1.148  			rdep_scan $SEARCH
   1.149 +			cat << _EOT_
   1.150 +</pre>
   1.151 +_EOT_
   1.152 +		fi
   1.153 +	elif [ "$OBJECT" = "BuildDepends" ]; then
   1.154 +		if package_exist $SEARCH ; then
   1.155 +			cat << _EOT_
   1.156 +
   1.157 +<h3>$bdeplist</h3>
   1.158 +<pre class="package">
   1.159 +_EOT_
   1.160 +			BUILD_DEPENDS=""
   1.161 +			. $WOK/$SEARCH/receipt
   1.162 +			[ -n "$BUILD_DEPENDS" ] && for dep in $BUILD_DEPENDS ; do
   1.163 +				if [ ! -s $WOK/$dep/receipt ]; then
   1.164 +					cat << _EOT_
   1.165 +$dep: not found !
   1.166 +_EOT_
   1.167 +					continue
   1.168 +				fi
   1.169 +				. $WOK/$dep/receipt
   1.170 +				cat << _EOT_
   1.171 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
   1.172 +_EOT_
   1.173 +			done
   1.174 +			cat << _EOT_
   1.175 +</pre>
   1.176 +
   1.177 +<h3>$rbdeplist</h3>
   1.178 +<pre class="package">
   1.179 +_EOT_
   1.180 +			for dep in $(grep -l $SEARCH $WOK/*/receipt); do
   1.181 +				BUILD_DEPENDS=""
   1.182 +				. $dep
   1.183 +				echo " $BUILD_DEPENDS " | grep -q " $SEARCH " &&
   1.184 +				cat << _EOT_
   1.185 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
   1.186 +_EOT_
   1.187 +			done
   1.188 +			cat << _EOT_
   1.189 +</pre>
   1.190 +_EOT_
   1.191 +		fi
   1.192 +	elif [ "$OBJECT" = "FileOverlap" ]; then
   1.193 +		if package_exist $SEARCH ; then
   1.194 +			cat << _EOT_
   1.195 +
   1.196 +<h3>$overloading $SEARCH</h3>
   1.197 +<pre class="package">
   1.198 +_EOT_
   1.199 +			( unlzma -c $PACKAGES_REPOSITORY/files.list.lzma | grep ^$SEARCH: ;
   1.200 +			  unlzma -c $PACKAGES_REPOSITORY/files.list.lzma | grep -v ^$SEARCH: ) | awk '
   1.201 +BEGIN { pkg="" }
   1.202 +{
   1.203 +	if (pkg == "") pkg=$1
   1.204 +	if ($1 == pkg) file[$2]=$1
   1.205 +	else if (file[$2] == pkg) print
   1.206 +}
   1.207 +' | display_packages_and_files
   1.208 +			cat << _EOT_
   1.209 +</pre>
   1.210 +_EOT_
   1.211  		fi
   1.212  	elif [ "$OBJECT" = "File" ]; then
   1.213  		cat << _EOT_
   1.214 @@ -475,7 +584,7 @@
   1.215  			sort | while read pkg extras ; do
   1.216  				. $WOK/$pkg/receipt
   1.217  				cat << _EOT_
   1.218 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.219 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
   1.220  _EOT_
   1.221  			done
   1.222  		fi
   1.223 @@ -490,7 +599,7 @@
   1.224  		sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
   1.225  				. $WOK/$pkg/receipt
   1.226  				cat << _EOT_
   1.227 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.228 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
   1.229  _EOT_
   1.230  			done
   1.231  	elif [ "$OBJECT" = "Receipt" ]; then
   1.232 @@ -512,13 +621,13 @@
   1.233  <h3>$result</h3>
   1.234  <pre class="package">
   1.235  _EOT_
   1.236 -		for pkg in `ls $WOK | grep $SEARCH`
   1.237 +		for pkg in `ls $WOK/ | grep $SEARCH`
   1.238  		do
   1.239  			. $WOK/$pkg/receipt
   1.240  			DESC=" <a href=\"?desc=$pkg\">description</a>"
   1.241  			[ -f $WOK/$pkg/description.txt ] || DESC=""
   1.242  			cat << _EOT_
   1.243 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC$DESC
   1.244 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC$DESC
   1.245  _EOT_
   1.246  		done
   1.247  		equiv=$PACKAGES_REPOSITORY/packages.equiv
   1.248 @@ -533,7 +642,7 @@
   1.249  			for pkg in $(grep $vpkg= $equiv | sed "s/$vpkg=//"); do
   1.250  				. $WOK/${pkg#*:}/receipt
   1.251  				cat << _EOT_
   1.252 -<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> : $SHORT_DESC
   1.253 +<a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
   1.254  _EOT_
   1.255  			done
   1.256  		done