cookutils rev 1083
lighttpd/index.cgi: Tank's wget can't communicate with repology.org - using Next (or Next64) chroot; improve maintainer's page
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Jul 13 03:28:18 2018 +0300 (2018-07-13) |
parents | de3264a4a756 |
children | 307bb45d96c2 |
files | lighttpd/index.cgi |
line diff
1.1 --- a/lighttpd/index.cgi Thu Jul 12 18:01:24 2018 +0300 1.2 +++ b/lighttpd/index.cgi Fri Jul 13 03:28:18 2018 +0300 1.3 @@ -275,7 +275,7 @@ 1.4 if [ -n "$found" ]; then 1.5 echo "$found" 1.6 else 1.7 - versions=$(wget -q -T 20 -O- https://repology.org/badge/latest-versions/$1.svg \ 1.8 + versions=$(chroot /home/slitaz/next/chroot/ wget -q -T 20 -O- https://repology.org/badge/latest-versions/$1.svg \ 1.9 | sed '/<text /!d; /fill/d; /latest/d; s|.*>\(.*\)<.*|\1|; s|, | |g') # space separated list 1.10 if [ -n "$versions" ]; then 1.11 sed -i "/^$1 /d" $repologydb 1.12 @@ -1144,9 +1144,9 @@ 1.13 </div> 1.14 EOT 1.15 ;; 1.16 - maintainer*) 1.17 - maintainer=$(GET maintainer) 1.18 - cat <<EOT 1.19 + maintainer*) 1.20 + maintainer=$(GET maintainer) 1.21 + cat <<EOT 1.22 <section> 1.23 <h2>For maintainers</h2> 1.24 <p>Check your packages version, ${maintainer:-maintainer}.</p> 1.25 @@ -1154,53 +1154,81 @@ 1.26 <select name="maintainer"> 1.27 <option value=''>--- select maintainer --- 1.28 EOT 1.29 - cut -d$'\t' -f1 $maintdb | sort -u \ 1.30 - | awk -vm=$maintainer '{ 1.31 - selected=$0==m?"selected":"" 1.32 - printf("<option %s value='%s'>%s\n", selected, $0, $0) 1.33 - }' 1.34 - cat <<EOT 1.35 + cut -d$'\t' -f1 $maintdb | sort -u \ 1.36 + | awk -vm=$maintainer '{ 1.37 + selected=$0==m?"selected":"" 1.38 + printf("<option %s value='%s'>%s\n", selected, $0, $0) 1.39 + }' 1.40 + cat <<EOT 1.41 1.42 </select> 1.43 <button type="submit">Go</button> 1.44 </form> 1.45 EOT 1.46 1.47 - if [ "$maintainer" != 'maintainer' ]; then 1.48 - cat <<EOT 1.49 + if [ "$maintainer" != 'maintainer' ]; then 1.50 + tmp_status=$(mktemp) 1.51 + cat <<EOT 1.52 <table class="maint"> 1.53 <thead><tr><th>Package</th><th>Version</th><th>Repology</th></tr></thead> 1.54 EOT 1.55 - awk -vm=$maintainer '{if ($1 == m) print $2}' $maintdb \ 1.56 - | while read pkg; do 1.57 - unset VERSION; REPOLOGY=$pkg 1.58 - . $wok/$pkg/receipt 1.59 - if [ "$REPOLOGY" == '-' ]; then 1.60 - unset repo_info1 repo_info2 1.61 + awk -vm=$maintainer '{if ($1 == m) print $2}' $maintdb \ 1.62 + | while read pkg; do 1.63 + unset VERSION; REPOLOGY=$pkg 1.64 + . $wok/$pkg/receipt 1.65 + ver=$(awk -F$'\t' -vpkg="$pkg" '{if ($1 == pkg) {print $2; exit}}' $PKGS/packages.info) 1.66 + if [ "$REPOLOGY" == '-' ]; then 1.67 + unset repo_info1 repo_info2 1.68 + echo '-' >>$tmp_status 1.69 + else 1.70 + repo_ver=$(repology_get $REPOLOGY) 1.71 + if [ "$repo_ver" == '-' ]; then 1.72 + echo '-' >>$tmp_status 1.73 + icon='more' 1.74 else 1.75 - repo_ver=$(repology_get $REPOLOGY) 1.76 - if echo " $repo_ver " | fgrep -q " $VERSION "; then 1.77 + if echo " $repo_ver " | fgrep -q " ${ver:-$VERSION} "; then 1.78 icon='actual' 1.79 else 1.80 icon='update' 1.81 fi 1.82 - repo_info1="<a class='icon $icon' href='https://repology.org/metapackage/$REPOLOGY' target='_blank'" 1.83 - repo_info2="rel='noopener noreferrer' title='latest packaged version(s)'>${repo_ver// /, }</a>" 1.84 + echo $icon >>$tmp_status 1.85 fi 1.86 - cat <<EOT 1.87 + repo_info1="<a class='icon $icon' href='https://repology.org/metapackage/$REPOLOGY' target='_blank'" 1.88 + repo_info2="rel='noopener noreferrer' title='latest packaged version(s)'>${repo_ver// /, }</a>" 1.89 + fi 1.90 + cat <<EOT 1.91 <tr> 1.92 <td><img src="$base/s/$pkg"> <a href="$pkg">$pkg</a></td> 1.93 - <td>$VERSION</td> 1.94 + <td>${ver:-$VERSION}</td> 1.95 <td>$repo_info1 $repo_info2</td> 1.96 </tr> 1.97 EOT 1.98 done 1.99 1.100 + pkg_total=$( wc -l < $tmp_status) 1.101 + pkg_actual=$( fgrep actual $tmp_status | wc -l) 1.102 + pkg_outdated=$(fgrep update $tmp_status | wc -l) 1.103 + pkg_unknown=$( fgrep '-' $tmp_status | wc -l) 1.104 + 1.105 + pct_actual=$(( $pkg_actual * 100 / $pkg_total )) 1.106 + pct_outdated=$(( $pkg_outdated * 100 / $pkg_total )) 1.107 + pct_unknown=$(( $pkg_unknown * 100 / $pkg_total )) 1.108 + 1.109 + [ "$pkg_actual" -eq 0 ] && pkg_actual='' 1.110 + [ "$pkg_outdated" -eq 0 ] && pkg_outdated='' 1.111 + [ "$pkg_unknown" -eq 0 ] && pkg_unknown='' 1.112 + 1.113 cat <<EOT 1.114 </table> 1.115 + 1.116 + <div class="meter" style="width:100%;text-align:center"><div 1.117 + style="display:inline-block;background-color:#090;width:$pct_actual%">$pkg_actual</div><div 1.118 + style="display:inline-block;background-color:#f90;width:$pct_outdated%">$pkg_outdated</div><div 1.119 + style="display:inline-block;background-color:#ccc;width:$pct_unknown%">$pkg_unknown</div></div> 1.120 EOT 1.121 - fi 1.122 - cat <<EOT 1.123 + rm $tmp_status 1.124 + fi 1.125 + cat <<EOT 1.126 </section> 1.127 EOT 1.128 ;;