cookutils rev 1089

lighttpd/index.cgi: [ For maintainers ]: you can use regexp now to list packages
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Aug 25 17:30:05 2018 +0300 (2018-08-25)
parents 461c3da71257
children 77291d41f21a
files lighttpd/index.cgi
line diff
     1.1 --- a/lighttpd/index.cgi	Sat Aug 18 15:38:13 2018 +0300
     1.2 +++ b/lighttpd/index.cgi	Sat Aug 25 17:30:05 2018 +0300
     1.3 @@ -1146,11 +1146,13 @@
     1.4  EOT
     1.5  				;;
     1.6  			maintainer*)
     1.7 -				maintainer=$(GET maintainer)
     1.8 +				maintainer=$(GET maintainer); maintainer=${maintainer/maintainer/}
     1.9 +				regexp=$(GET regexp); regexp=${regexp/regexp/}
    1.10 +				[ -n "$regexp" ] && maintainer=''
    1.11  				cat <<EOT
    1.12  <section>
    1.13  	<h2>For maintainers</h2>
    1.14 -	<p>Check your packages version: ${maintainer:-maintainer}.</p>
    1.15 +	<p>Check packages version either for specified maintainer or using regular expression:</p>
    1.16  	<form>
    1.17  		<select name="maintainer">
    1.18  			<option value=''>--- select maintainer ---
    1.19 @@ -1158,23 +1160,30 @@
    1.20  				cut -d$'\t' -f1 $maintdb | sort -u \
    1.21  				| awk -vm=$maintainer '{
    1.22  					selected=$0==m?"selected":""
    1.23 -					printf("<option %s value='%s'>%s\n", selected, $0, $0)
    1.24 +					printf("<option %s value=\"%s\">%s\n", selected, $0, $0)
    1.25  				}'
    1.26  				cat <<EOT
    1.27  
    1.28  		</select>
    1.29 +		or
    1.30 +		<input type="text" name="regexp" value="$regexp"/>
    1.31  		<button type="submit">Go</button>
    1.32  	</form>
    1.33  EOT
    1.34 -
    1.35 -				if [ "$maintainer" != 'maintainer' ]; then
    1.36 +				if [ -n "$maintainer" -o -n "$regexp" ]; then
    1.37  					tmp_status=$(mktemp)
    1.38  					cat <<EOT
    1.39  	<table class="maint">
    1.40  		<thead><tr><th>Package</th><th>Version</th><th>Repology</th></tr></thead>
    1.41  EOT
    1.42 -					awk -vm=$maintainer '{if ($1 == m) print $2}' $maintdb \
    1.43 -					| while read pkg; do
    1.44 +					{
    1.45 +						if [ -n "$maintainer" ]; then
    1.46 +							awk -vm=$maintainer '{if ($1 == m) print $2}' $maintdb
    1.47 +						fi
    1.48 +						if [ -n "$regexp" ]; then
    1.49 +							cd $wok; ls | grep "$regexp"
    1.50 +						fi
    1.51 +					} | while read pkg; do
    1.52  						unset VERSION; REPOLOGY=$pkg
    1.53  						. $wok/$pkg/receipt
    1.54  						ver=$(awk -F$'\t' -vpkg="$pkg" '{if ($1 == pkg) {print $2; exit}}' $PKGS/packages.info)