cookutils rev 1081

lighttpd/index.cgi: add simple page for maintainers
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Jul 10 20:11:48 2018 +0300 (2018-07-10)
parents 9583c9709f51
children de3264a4a756
files cook lighttpd/cooker.css lighttpd/index.cgi
line diff
     1.1 --- a/cook	Tue Jul 10 10:30:03 2018 +0300
     1.2 +++ b/cook	Tue Jul 10 20:11:48 2018 +0300
     1.3 @@ -1657,16 +1657,30 @@
     1.4  recreate_split_db() {
     1.5  	# Clean
     1.6  	local db="$cache/split.db"
     1.7 -	touch $db
     1.8 -	> $db
     1.9  
    1.10  	cd $WOK
    1.11  	for pkg in *; do
    1.12  		[ -f "$WOK/$pkg/receipt" ] || continue
    1.13  		unset PACKAGE SPLIT
    1.14  		. $WOK/$pkg/receipt
    1.15 -		echo -e "$PACKAGE\t$(all_names)" >> $db
    1.16 -	done
    1.17 +		echo -e "$PACKAGE\t$(all_names)"
    1.18 +	done > $db
    1.19 +}
    1.20 +
    1.21 +
    1.22 +# Recreate whole maint.db from scratch
    1.23 +
    1.24 +recreate_maint_db() {
    1.25 +	# Clean
    1.26 +	local db="$cache/maint.db"
    1.27 +
    1.28 +	cd $WOK
    1.29 +	for pkg in *; do
    1.30 +		[ -f "$WOK/$pkg/receipt" ] || continue
    1.31 +		unset PACKAGE MAINTAINER
    1.32 +		. $WOK/$pkg/receipt
    1.33 +		echo -e "$MAINTAINER\t$PACKAGE"
    1.34 +	done | sort > $db
    1.35  }
    1.36  
    1.37  
    1.38 @@ -2031,6 +2045,7 @@
    1.39  		# as well as flavors files for TazLiTo. We don't need logs since we do it
    1.40  		# manually to ensure everything is fine before syncing the mirror.
    1.41  		recreate_split_db
    1.42 +		recreate_maint_db
    1.43  		@@PREFIX@@/libexec/cookutils/pkgdb "$2"
    1.44  		;;
    1.45  
    1.46 @@ -2039,6 +2054,11 @@
    1.47  		recreate_split_db
    1.48  		;;
    1.49  
    1.50 +	maintdb)
    1.51 +		# File maint.db is useful for searching maintainer's packages.
    1.52 +		recreate_maint_db
    1.53 +		;;
    1.54 +
    1.55  	*)
    1.56  		# Just cook and generate a package.
    1.57  		check_root
     2.1 --- a/lighttpd/cooker.css	Tue Jul 10 10:30:03 2018 +0300
     2.2 +++ b/lighttpd/cooker.css	Tue Jul 10 20:11:48 2018 +0300
     2.3 @@ -353,6 +353,7 @@
     2.4  .icon.log::before { content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><path d='m8 2c-7 .4-7 7-7 7s0 6.6 7 7c7-.4 7-7 7-7s0-6.6-7-7zm0 2c5 .3 5 5 5 5s0 4.7-5 5c-5-.3-5-5-5-5s0-4.7 5-5zm-1 1v4.4l2.8 2.8 1.4-1.4-2.2-2.2v-3.6z'/></svg>"); }
     2.5  .icon.more::before { content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='16' width='16'><path d='m3 7c-2 .1-2 2-2 2s0 1.9 2 2c2-.1 2-2 2-2s0-1.9-2-2zm5 0c-2 .1-2 2-2 2s0 1.9 2 2c2-.1 2-2 2-2s0-1.9-2-2zm5 0c-2 .1-2 2-2 2s0 1.9 2 2c2-.1 2-2 2-2s0-1.9-2-2z'/></svg>"); }
     2.6  .icon.bell::before { content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='16' width='16'><path d='m9.6 2.7s-3.4-.2-4.5 3c-1.9 4.6-2.5 3.8-2.8 4.4-.2.6.4.8.4.8l9.3 3.3s.5.2.8-.3-.9-.5.7-5.2c1-3.5-1.6-5.1-1.6-5.1s.3-1.1-.8-1.5c-1-.4-1.5.6-1.5.6zm-2.9 11s-.4 1.4 1.3 2.2c2 .4 2.3-.9 2.3-.9z'/></svg>"); }
     2.7 +.icon.maintainers::before { content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' height='16' width='16'><path d='m6 2c-4 0-4 6 0 6s4-6 0-6zm3.9 2.2c.4 1.3-.3 2.8-1.1 3.5 0 0 .7 1.3 2.2 1.3 3.4 0 3.4-5 0-5-.5 0-1.1.2-1.1.2zm-3.9 5.8c-6 0-6 4-6 4v1h12v-1s0-4-6-4zm4.4 0c1.6 1 2.6 2.5 2.6 4h3v-1c0-1.5-1.5-3-5.6-3z'/></svg>"); }
     2.8  
     2.9  .bigicon-i {
    2.10  	background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32'><path d='m16 2c-14 .7-14 14-14 14s0 13.3 14 14c14-.7 14-14 14-14s0-13.3-14-14zm0 5.5c2.5 0 2.5 2.5 2.5 2.5s0 2.5-2.5 2.5-2.5-2.5-2.5-2.5 0-2.5 2.5-2.5zm-2 6.5h4v10h-4z' fill='%2329F'/></svg>") no-repeat 0.5rem 50%;
    2.11 @@ -401,6 +402,8 @@
    2.12  .webstat td { text-align: center; width: 16%; }
    2.13  .webstat td:first-child { text-align: unset; width: unset; }
    2.14  
    2.15 +.maint { width: unset; }
    2.16 +
    2.17  div.list td, div.list th { padding: 5px 2px; }
    2.18  
    2.19  .texinfo pre { display: none; }
     3.1 --- a/lighttpd/index.cgi	Tue Jul 10 10:30:03 2018 +0300
     3.2 +++ b/lighttpd/index.cgi	Tue Jul 10 20:11:48 2018 +0300
     3.3 @@ -39,6 +39,7 @@
     3.4  wokrev="$CACHE/wokrev"
     3.5  webstat="$CACHE/webstat"
     3.6  splitdb="$CACHE/split.db"
     3.7 +maintdb="$CACHE/maint.db"
     3.8  
     3.9  # Path to markdown to html convertor
    3.10  cmark_opts='--smart -e table -e strikethrough -e autolink -e tagfilter'
    3.11 @@ -1110,6 +1111,62 @@
    3.12  </div>
    3.13  EOT
    3.14  				;;
    3.15 +				maintainer*)
    3.16 +					maintainer=$(GET maintainer)
    3.17 +					cat <<EOT
    3.18 +<section>
    3.19 +	<h2>For maintainers</h2>
    3.20 +	<p>Check your packages version, ${maintainer:-maintainer}.</p>
    3.21 +	<form>
    3.22 +		<select name="maintainer">
    3.23 +			<option value=''>--- select maintainer ---
    3.24 +EOT
    3.25 +					cut -d$'\t' -f1 $maintdb | sort -u \
    3.26 +					| awk -vm=$maintainer '{
    3.27 +						selected=$0==m?"selected":""
    3.28 +						printf("<option %s value='%s'>%s\n", selected, $0, $0)
    3.29 +					}'
    3.30 +					cat <<EOT
    3.31 +
    3.32 +		</select>
    3.33 +		<button type="submit">Go</button>
    3.34 +	</form>
    3.35 +EOT
    3.36 +
    3.37 +					if [ "$maintainer" != 'maintainer' ]; then
    3.38 +						cat <<EOT
    3.39 +	<table class="maint">
    3.40 +		<thead><tr><th>Package</th><th>Version</th><th>Repology</th></tr></thead>
    3.41 +EOT
    3.42 +						awk -vm=$maintainer '{if ($1 == m) print $2}' $maintdb \
    3.43 +						| while read pkg; do
    3.44 +							unset VERSION; REPOLOGY=$pkg
    3.45 +							. $wok/$pkg/receipt
    3.46 +							if [ "$REPOLOGY" == '-' ]; then
    3.47 +								repo_info=" </td><td> "
    3.48 +							else
    3.49 +								repo_info="<a href='https://repology.org/metapackage/$REPOLOGY' target='_blank'
    3.50 +									rel='noopener noreferrer' title='latest packaged version(s)'>
    3.51 +									<img src='https://repology.org/badge/latest-versions/$REPOLOGY.svg' alt='latest packaged version(s)'>
    3.52 +									</a></td>"
    3.53 +							fi
    3.54 +							cat <<EOT
    3.55 +		<tr>
    3.56 +			<td><img src="$base/s/$pkg"> <a href="$pkg">$pkg</a></td>
    3.57 +			<td>$VERSION</td>
    3.58 +			<td>$repo_info</td>
    3.59 +		</tr>
    3.60 +EOT
    3.61 +					done
    3.62 +
    3.63 +					cat <<EOT
    3.64 +	</table>
    3.65 +EOT
    3.66 +					fi
    3.67 +					cat <<EOT
    3.68 +</section>
    3.69 +EOT
    3.70 +				;;
    3.71  		esac
    3.72  		page_footer
    3.73  		exit 0
    3.74 @@ -1141,6 +1198,15 @@
    3.75  	part summary
    3.76  	part webstat
    3.77  
    3.78 +	cat <<EOT
    3.79 +<p>
    3.80 +	Service logs:
    3.81 +	<a href="?cookorder.log">cookorder</a> ·
    3.82 +	<a href="?commits.log">commits</a> ·
    3.83 +	<a href="?pkgdb.log">pkgdb</a>
    3.84 +</p>
    3.85 +EOT
    3.86 +
    3.87  	if [ -e "$CACHE/cooker-request" -a ! -s $command ]; then
    3.88  		if [ "$activity" -nt "$CACHE/cooker-request" ]; then
    3.89  			echo '<a class="button icon bell r" href="?poke">Wake up</a>'
    3.90 @@ -1150,12 +1216,7 @@
    3.91  	fi
    3.92  
    3.93  	cat <<EOT
    3.94 -<p>
    3.95 -	Service logs:
    3.96 -	<a href="?cookorder.log">cookorder</a> ·
    3.97 -	<a href="?commits.log">commits</a> ·
    3.98 -	<a href="?pkgdb.log">pkgdb</a>
    3.99 -</p>
   3.100 +<a class="button icon maintainers" href="?maintainer">For maintainers</a>
   3.101  </section>
   3.102  EOT
   3.103