slitaz-forge rev 458

pkgs: add license, category, maintainer
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Feb 17 16:21:24 2014 +0000 (2014-02-17)
parents 5500764333d0
children a78d2dcb8893
files pkgs/search.sh
line diff
     1.1 --- a/pkgs/search.sh	Mon Feb 17 14:55:17 2014 +0000
     1.2 +++ b/pkgs/search.sh	Mon Feb 17 16:21:24 2014 +0000
     1.3 @@ -78,6 +78,9 @@
     1.4  			File)			NICE="file=$SEARCH";;
     1.5  			File_list)		NICE="filelist=$SEARCH";;
     1.6  			FileOverlap)	NICE="fileoverlap=$SEARCH";;
     1.7 +			Category)	NICE="category=$SEARCH";;
     1.8 +			Maintainer)	NICE="maintainer=$SEARCH";;
     1.9 +			License)	NICE="license=$SEARCH";;
    1.10  		esac
    1.11  		# version, if needed
    1.12  		version="$(GETPOST version)"
    1.13 @@ -145,6 +148,7 @@
    1.14  		fileoverlap=*)			SEARCH=${i#*=}; OBJECT=FileOverlap;;
    1.15  		category=*)				SEARCH=${i#*=}; OBJECT=Category;;
    1.16  		maintainer=*)			SEARCH=${i#*=}; OBJECT=Maintainer;;
    1.17 +		license=*)			SEARCH=${i#*=}; OBJECT=License;;
    1.18  		version=[1-9]*)			i=${i%%.*}; SLITAZ_VERSION=${i#*=}.0;;
    1.19  		version=s*|version=4*)	SLITAZ_VERSION=stable;;
    1.20  		version=u*)				SLITAZ_VERSION=undigest;;
    1.21 @@ -173,6 +177,9 @@
    1.22  	Depends)		selected_depends="selected";;
    1.23  	BuildDepends)	selected_build_depends="selected";;
    1.24  	FileOverlap)	selected_overlap="selected";;
    1.25 +	Category)	selected_category="selected";;
    1.26 +	Maintainer)	selected_maintainer="selected";;
    1.27 +	License)	selected_license="selected";;
    1.28  esac
    1.29  
    1.30  case "$SLITAZ_VERSION" in
    1.31 @@ -223,6 +230,9 @@
    1.32  			<option $selected_file value="File">$(gettext "File")</option>
    1.33  			<option $selected_file_list value="File_list">$(gettext "File list")</option>
    1.34  			<option $selected_overlap value="FileOverlap">$(gettext "common files")</option>
    1.35 +			<option $selected_category value="Category">$(gettext "Category")</option>
    1.36 +			<option $selected_maintainer value="Maintainer">$(gettext "Maintainer")</option>
    1.37 +			<option $selected_license value="License">$(gettext "License")</option>
    1.38  		</select>
    1.39  	</span>
    1.40  	<span class="stretch">
    1.41 @@ -321,7 +331,7 @@
    1.42  	<td class="first">$PACKAGE_HREF</td>
    1.43  	<td class="first">$(installed_size $PACKAGE)</td>
    1.44  	<td>$SHORT_DESC</td>
    1.45 -	<td><a href="?receipt=$PACKAGE&amp;version=$SLITAZ_VERSION">$(gettext "Receipt")</a> $COOKER</td>
    1.46 +	<td><a href="?receipt=$PACKAGE&amp;version=$SLITAZ_VERSION">$(gettext "Receipt")</a>&nbsp;$COOKER</td>
    1.47  _EOT_
    1.48  	fi
    1.49  	cat << EOT
    1.50 @@ -345,7 +355,7 @@
    1.51  		esac
    1.52  		cat << _EOT_
    1.53  $PACKAGE_HREF $(installed_size $PACKAGE) : $SHORT_DESC \
    1.54 -<a href="?receipt=$PACKAGE&amp;version=$SLITAZ_VERSION">$(gettext "Receipt")</a> $COOKER
    1.55 +<a href="?receipt=$PACKAGE&amp;version=$SLITAZ_VERSION">$(gettext "Receipt")</a>&nbsp;$COOKER
    1.56  _EOT_
    1.57  	fi
    1.58  }
    1.59 @@ -546,6 +556,34 @@
    1.60  			-e "s|~|</span>|g" < "$1"
    1.61  }
    1.62  
    1.63 +display_cloud() {
    1.64 +	arg=$1
    1.65 +	awk '
    1.66 +{
    1.67 +	for (i = 1; $i != ""; i++)
    1.68 +		count[$i]++
    1.69 +}
    1.70 +END {
    1.71 +	min=10000
    1.72 +	max=0
    1.73 +	for (i in count) {
    1.74 +		if (count[i] < min) min = count[i]
    1.75 +		if (count[i] > max) max = count[i]
    1.76 +	}
    1.77 +	for (i in count) 
    1.78 +		print count[i] " " min " " max " " i
    1.79 +}' | while read cnt min max tag ; do
    1.80 +			pct=$(((($cnt-$min)*100)/($max-$min)))
    1.81 +			pct=$(((10000 - ((100 - $pct)**2))/100))
    1.82 +			pct=$(((10000 - ((100 - $pct)**2))/100))
    1.83 +			cat <<EOT
    1.84 +<span style="color:#99f; font-size:9pt; padding-left:5px; padding-right:2px;">\
    1.85 +$cnt</span><a href="?$arg=$tag&amp;version=$SLITAZ_VERSION" style="\
    1.86 +font-size:$((8+($pct/10)))pt; font-weight:bold;
    1.87 +color:black; text-decoration:none">$tag</a>
    1.88 +EOT
    1.89 +		done
    1.90 +}
    1.91  
    1.92  #
    1.93  # page begins
    1.94 @@ -876,6 +914,87 @@
    1.95  _EOT_
    1.96  	;;
    1.97  
    1.98 +### Maintainer
    1.99 +Maintainer)
   1.100 +	if [ -n "$SEARCH" ]; then
   1.101 +		cat << _EOT_
   1.102 +
   1.103 +<h3>$(eval_gettext "Result for: \$SEARCH")</h3>
   1.104 +<table>
   1.105 +_EOT_
   1.106 +		unset last
   1.107 +		grep ^MAINTAINER= $WOK/*/receipt | grep -i "$SEARCH" | \
   1.108 +		sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
   1.109 +			. $WOK/$pkg/receipt
   1.110 +			package_entry
   1.111 +		done
   1.112 +		cat << _EOT_
   1.113 +</table>
   1.114 +_EOT_
   1.115 +	else
   1.116 +		# Display maintainer cloud
   1.117 +		grep -l ^MAINTAINER= $WOK/*/receipt | while read file; do
   1.118 +			MAINTAINER=
   1.119 +			. $file
   1.120 +			echo $MAINTAINER
   1.121 +			done | display_cloud maintainer
   1.122 +	fi
   1.123 +	;;
   1.124 +
   1.125 +### License
   1.126 +License)
   1.127 +	if [ -n "$SEARCH" ]; then
   1.128 +		cat << _EOT_
   1.129 +
   1.130 +<h3>$(eval_gettext "Result for: \$SEARCH")</h3>
   1.131 +<table>
   1.132 +_EOT_
   1.133 +		unset last
   1.134 +		grep ^LICENSE= $WOK/*/receipt | grep -i "$SEARCH" | \
   1.135 +		sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
   1.136 +			. $WOK/$pkg/receipt
   1.137 +			package_entry
   1.138 +		done
   1.139 +		cat << _EOT_
   1.140 +</table>
   1.141 +_EOT_
   1.142 +	else
   1.143 +		# Display license cloud
   1.144 +		grep -l ^LICENSE= $WOK/*/receipt | while read file; do
   1.145 +			LICENSE=
   1.146 +			. $file
   1.147 +			echo $LICENSE
   1.148 +			done | display_cloud license
   1.149 +	fi
   1.150 +	;;
   1.151 +
   1.152 +### Category
   1.153 +Category)
   1.154 +	if [ -n "$SEARCH" ]; then
   1.155 +		cat << _EOT_
   1.156 +
   1.157 +<h3>$(eval_gettext "Result for: \$SEARCH")</h3>
   1.158 +<table>
   1.159 +_EOT_
   1.160 +		unset last
   1.161 +		grep ^CATEGORY= $WOK/*/receipt | grep -i "$SEARCH" | \
   1.162 +		sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
   1.163 +			. $WOK/$pkg/receipt
   1.164 +			package_entry
   1.165 +		done
   1.166 +		cat << _EOT_
   1.167 +</table>
   1.168 +_EOT_
   1.169 +	else
   1.170 +		# Display category cloud
   1.171 +		grep -l ^CATEGORY= $WOK/*/receipt | while read file; do
   1.172 +			CATEGORY=
   1.173 +			. $file
   1.174 +			echo $CATEGORY
   1.175 +			done | display_cloud category
   1.176 +	fi
   1.177 +	;;
   1.178 +
   1.179  ### Tags
   1.180  Tags)
   1.181  	if [ -n "$SEARCH" ]; then
   1.182 @@ -899,28 +1018,7 @@
   1.183  			TAGS=
   1.184  			. $file
   1.185  			echo $TAGS
   1.186 -			done | awk '
   1.187 -{
   1.188 -	for (i = 1; $i != ""; i++)
   1.189 -		count[$i]++
   1.190 -}
   1.191 -END {
   1.192 -	min=10000
   1.193 -	max=0
   1.194 -	for (i in count) {
   1.195 -		if (count[i] < min) min = count[i]
   1.196 -		if (count[i] > max) max = count[i]
   1.197 -	}
   1.198 -	for (i in count) 
   1.199 -		print count[i] " " min " " max " " i
   1.200 -}' | while read cnt min max tag ; do
   1.201 -			cat <<EOT
   1.202 -<span style="color:#99f; font-size:9pt; padding-left:5px; padding-right:2px;">\
   1.203 -$cnt</span><a href="?tags=$tag&amp;version=$SLITAZ_VERSION" style="\
   1.204 -font-size:$((8+(($cnt-$min)*10)/($max-$min)))pt; font-weight:bold; \
   1.205 -color:black; text-decoration:none">$tag</a>
   1.206 -EOT
   1.207 -		done
   1.208 +			done | display_cloud args
   1.209  	fi
   1.210  	;;
   1.211