| 1 |
hertzog |
344 |
#!/bin/bash
|
| 2 |
|
|
|
| 3 |
hertzog |
2284 |
# Copyright 2002-2009 Raphaƫl Hertzog
|
| 4 |
zack |
1820 |
# Copyright 2007-2008 Stefano Zacchiroli
|
| 5 |
hertzog |
351 |
# This file is distributed under the terms of the General Public License
|
| 6 |
|
|
# version 2 or (at your option) any later version.
|
| 7 |
|
|
|
| 8 |
obergix |
2926 |
# This script will process a list of source packages in input, and
|
| 9 |
|
|
# invoke the XSL stylesheets to generate the static HTML and RDF
|
| 10 |
|
|
# documents available on the Web interface of the PTS
|
| 11 |
|
|
|
| 12 |
hertzog |
344 |
verbose=
|
| 13 |
obergix |
2926 |
debug=
|
| 14 |
hertzog |
344 |
|
| 15 |
hertzog |
579 |
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
|
| 16 |
|
|
|
| 17 |
hertzog |
344 |
if [ -d "incoming" ]; then
|
| 18 |
|
|
root="$PWD"
|
| 19 |
|
|
elif [ -d "../incoming" ]; then
|
| 20 |
|
|
root="$PWD/.."
|
| 21 |
|
|
else
|
| 22 |
geissert |
2738 |
root="/srv/packages.qa.debian.org/www"
|
| 23 |
hertzog |
344 |
fi
|
| 24 |
|
|
|
| 25 |
obergix |
2809 |
xsldir=$root/xsl
|
| 26 |
obergix |
2926 |
#rdf_stylesheet=$xsldir/admssw.xsl
|
| 27 |
|
|
rdf_stylesheet=$xsldir/admssw-turtle.xsl
|
| 28 |
obergix |
2809 |
|
| 29 |
obergix |
2926 |
|
| 30 |
hertzog |
357 |
if [ "$1" = "-v" -o "$2" = "-v" ]; then
|
| 31 |
hertzog |
344 |
verbose=1
|
| 32 |
|
|
fi
|
| 33 |
obergix |
2926 |
if [ "$1" = "-d" -o "$2" = "-d" ]; then
|
| 34 |
|
|
verbose=1
|
| 35 |
|
|
debug=1
|
| 36 |
|
|
fi
|
| 37 |
hertzog |
357 |
if [ "$1" = "-f" -o "$2" = "-f" ]; then
|
| 38 |
|
|
force="yes"
|
| 39 |
|
|
fi
|
| 40 |
hertzog |
344 |
|
| 41 |
obergix |
2926 |
if [ -n "$debug" ]; then
|
| 42 |
|
|
echo "cd $root/base"
|
| 43 |
|
|
fi
|
| 44 |
hertzog |
344 |
cd $root/base
|
| 45 |
obergix |
2927 |
date=`LC_ALL=C date -u "+%FT%T%:z"`
|
| 46 |
pabs |
2834 |
svnrev=$(svnversion $root)
|
| 47 |
hertzog |
344 |
|
| 48 |
obergix |
2811 |
# Read source package names on stdin
|
| 49 |
hertzog |
344 |
while read package
|
| 50 |
|
|
do
|
| 51 |
|
|
hash=${package:0:1}
|
| 52 |
|
|
if [ "${package:0:3}" = "lib" ]; then
|
| 53 |
|
|
hash=${package:0:4}
|
| 54 |
|
|
fi
|
| 55 |
|
|
dir=$hash/$package
|
| 56 |
hertzog |
357 |
htmlfile=$root/web/$dir.html
|
| 57 |
zack |
1746 |
rssfile=$root/web/$dir/news.rss20.xml
|
| 58 |
obergix |
2811 |
rdffile=$root/web/$dir.rdf
|
| 59 |
obergix |
2926 |
turtlefile=$root/web/$dir.ttl
|
| 60 |
obergix |
2820 |
needhtmlupdate="no"
|
| 61 |
|
|
needrdfupdate="no"
|
| 62 |
zack |
1746 |
param=""
|
| 63 |
pabs |
2834 |
param="$param --stringparam svnrev $svnrev"
|
| 64 |
zack |
1746 |
param="$param --stringparam dir $dir"
|
| 65 |
|
|
param="$param --stringparam package $package"
|
| 66 |
|
|
param="$param --stringparam hash $hash"
|
| 67 |
hertzog |
357 |
# If the file doesn't exist, then require a generation !
|
| 68 |
|
|
if [ ! -f $htmlfile ]; then
|
| 69 |
obergix |
2820 |
needhtmlupdate="yes"
|
| 70 |
hertzog |
357 |
fi
|
| 71 |
obergix |
2926 |
if [ ! -f $turtlefile ]; then
|
| 72 |
obergix |
2820 |
needrdfupdate="yes"
|
| 73 |
obergix |
2819 |
fi
|
| 74 |
hertzog |
357 |
# Force regeneration
|
| 75 |
|
|
if [ "$force" = "yes" ]; then
|
| 76 |
obergix |
2820 |
needhtmlupdate="yes"
|
| 77 |
|
|
needrdfupdate="yes"
|
| 78 |
hertzog |
357 |
fi
|
| 79 |
hertzog |
400 |
# Check if force-rebuild exists
|
| 80 |
|
|
if [ -e $dir/force-rebuild ]; then
|
| 81 |
obergix |
2820 |
needhtmlupdate="yes"
|
| 82 |
|
|
needrdfupdate="yes"
|
| 83 |
hertzog |
400 |
fi
|
| 84 |
hertzog |
402 |
# If the XSL file is newer than the HTML file, then force update
|
| 85 |
obergix |
2838 |
for i in "$xsldir/pts.xsl" "$xsldir/pts-issues.xsl" "$xsldir/common-params-vars.xsl"
|
| 86 |
obergix |
2819 |
do
|
| 87 |
|
|
if [ "$i" -nt "$htmlfile" ]; then
|
| 88 |
obergix |
2820 |
needhtmlupdate="yes"
|
| 89 |
obergix |
2819 |
fi
|
| 90 |
|
|
done
|
| 91 |
|
|
# If the XSL file is newer than the RDF file, then force update
|
| 92 |
obergix |
2926 |
for i in "$rdf_stylesheet" "$xsldir/common-params-vars.xsl"
|
| 93 |
obergix |
2838 |
do
|
| 94 |
obergix |
2926 |
if [ "$i" -nt "$turtlefile" ]; then
|
| 95 |
obergix |
2838 |
needrdfupdate="yes"
|
| 96 |
|
|
fi
|
| 97 |
|
|
done
|
| 98 |
hertzog |
357 |
# Create parameters and check if an update is needed
|
| 99 |
zack |
1933 |
# XXX order _does_ matter, the latter has precedence over the former
|
| 100 |
zack |
1953 |
for i in news excuse other \
|
| 101 |
hertzog |
2478 |
mentors \
|
| 102 |
pabs |
2729 |
oldstable-proposed-updates stable-proposed-updates testing-proposed-updates \
|
| 103 |
hertzog |
2520 |
stable-updates stable-backports \
|
| 104 |
pabs |
2729 |
oldstable oldstable-backports oldstable-backports-sloppy \
|
| 105 |
zack |
2053 |
security-oldstable security-stable security-testing \
|
| 106 |
pabs |
2981 |
stable experimental testing unstable
|
| 107 |
hertzog |
344 |
do
|
| 108 |
hertzog |
351 |
if [ -f "$dir/$i.xml" ]; then
|
| 109 |
hertzog |
400 |
# Input is the main xml file used by xsltproc to generate the HTML
|
| 110 |
|
|
# page. By default it is unstable.xml but it has many
|
| 111 |
|
|
# fallbacks (testing.xml, stable.xml, experimental.xml, ...)
|
| 112 |
zack |
1933 |
if [ "$i" != "mentors" ] ; then
|
| 113 |
|
|
# mentors.d.n needs special handling, because we don't want a PTS
|
| 114 |
|
|
# page to exist for packages only available on mentors.d.n
|
| 115 |
|
|
input=$dir/$i.xml
|
| 116 |
|
|
fi
|
| 117 |
hertzog |
344 |
param="$param --stringparam has$i yes"
|
| 118 |
|
|
fi
|
| 119 |
obergix |
2820 |
if [ "$needhtmlupdate" = "no" -a "$dir/$i.xml" -nt "$htmlfile" ]; then
|
| 120 |
|
|
needhtmlupdate="yes"
|
| 121 |
hertzog |
357 |
fi
|
| 122 |
obergix |
2926 |
if [ "$needrdfupdate" = "no" -a "$dir/$i.xml" -nt "$turtlefile" ]; then
|
| 123 |
obergix |
2820 |
needrdfupdate="yes"
|
| 124 |
|
|
fi
|
| 125 |
hertzog |
344 |
done
|
| 126 |
hertzog |
1303 |
# If no distribution-related input files has been found,
|
| 127 |
|
|
# then the package has been removed
|
| 128 |
|
|
if [ "$input" = "$dir/other.xml" ]; then
|
| 129 |
obergix |
2809 |
input="$xsldir/default.xml"
|
| 130 |
hertzog |
1303 |
param="$param --stringparam removed yes"
|
| 131 |
obergix |
2820 |
if [ "$needhtmlupdate" = "no" -a "$xsldir/default.xml" -nt "$htmlfile" ]; then
|
| 132 |
|
|
needhtmlupdate="yes"
|
| 133 |
hertzog |
1303 |
fi
|
| 134 |
obergix |
2926 |
if [ "$needrdfupdate" = "no" -a "$xsldir/default.xml" -nt "$turtlefile" ]; then
|
| 135 |
obergix |
2820 |
needrdfupdate="yes"
|
| 136 |
|
|
fi
|
| 137 |
hertzog |
1303 |
else
|
| 138 |
|
|
param="$param --stringparam removed no"
|
| 139 |
|
|
fi
|
| 140 |
hertzog |
344 |
if [ ! -d ../web/$dir/static ]; then
|
| 141 |
hertzog |
351 |
mkdir -p ../web/$dir/{static,news} || true
|
| 142 |
hertzog |
344 |
fi
|
| 143 |
obergix |
2820 |
errors="no"
|
| 144 |
|
|
if [ "$needhtmlupdate" = "yes" ]; then
|
| 145 |
jeroen |
1288 |
if [ -n "$verbose" ]; then
|
| 146 |
|
|
echo "Doing $package ..."
|
| 147 |
|
|
fi
|
| 148 |
zack |
1746 |
xsltproc -o $htmlfile \
|
| 149 |
|
|
--stringparam date "$date" $param \
|
| 150 |
obergix |
2809 |
$xsldir/pts.xsl $input
|
| 151 |
zack |
1821 |
test "$?" -ne 0 && errors="yes"
|
| 152 |
zack |
1746 |
if [ -f "$dir/news.xml" ]; then
|
| 153 |
|
|
xsltproc -o $rssfile \
|
| 154 |
|
|
--stringparam date "$date" $param \
|
| 155 |
obergix |
2809 |
$xsldir/news2rss.xsl $dir/news.xml
|
| 156 |
zack |
1821 |
test "$?" -ne 0 && errors="yes"
|
| 157 |
zack |
1746 |
fi
|
| 158 |
obergix |
2820 |
else
|
| 159 |
|
|
if [ -n "$verbose" ]; then
|
| 160 |
|
|
echo "Not doing html for $package : update not needed (use -f to force) ..."
|
| 161 |
|
|
fi
|
| 162 |
|
|
fi
|
| 163 |
|
|
if [ "$needrdfupdate" = "yes" ]; then
|
| 164 |
obergix |
2926 |
if [ -n "$debug" ]; then
|
| 165 |
|
|
echo "xsltproc -o $turtlefile --stringparam date '$date' $param $rdf_stylesheet $input"
|
| 166 |
|
|
fi
|
| 167 |
|
|
xsltproc -o $turtlefile \
|
| 168 |
obergix |
2811 |
--stringparam date "$date" $param \
|
| 169 |
obergix |
2926 |
$rdf_stylesheet $input
|
| 170 |
|
|
if [ $? -ne 0 ]; then
|
| 171 |
|
|
errors="yes"
|
| 172 |
|
|
else
|
| 173 |
|
|
# generate the RDF/XML file from the Turtle one
|
| 174 |
|
|
rapper -q -i turtle -o rdfxml-abbrev $turtlefile > $rdffile
|
| 175 |
|
|
test "$?" -ne 0 && errors="yes"
|
| 176 |
|
|
fi
|
| 177 |
obergix |
2807 |
else
|
| 178 |
|
|
if [ -n "$verbose" ]; then
|
| 179 |
obergix |
2820 |
echo "Not doing rdf $package : update not needed (use -f to force) ..."
|
| 180 |
obergix |
2807 |
fi
|
| 181 |
hertzog |
357 |
fi
|
| 182 |
obergix |
2820 |
test "$errors" = "yes" && \
|
| 183 |
|
|
echo "PTS: non-0 exit code while generating output for package $package"
|
| 184 |
|
|
rm -f $dir/force-rebuild || true
|
| 185 |
hertzog |
344 |
done
|
| 186 |
|
|
|
| 187 |
obergix |
2926 |
# Then update the software repository descriptor
|
| 188 |
|
|
cd $root
|
| 189 |
|
|
$root/bin/generate-admssw-repository.sh
|