| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
# Copyright 2002-2009 Raphaƫl Hertzog
|
| 4 |
# Copyright 2007-2008 Stefano Zacchiroli
|
| 5 |
# This file is distributed under the terms of the General Public License
|
| 6 |
# version 2 or (at your option) any later version.
|
| 7 |
|
| 8 |
# 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 |
verbose=
|
| 13 |
debug=
|
| 14 |
|
| 15 |
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
|
| 16 |
|
| 17 |
if [ -d "incoming" ]; then
|
| 18 |
root="$PWD"
|
| 19 |
elif [ -d "../incoming" ]; then
|
| 20 |
root="$PWD/.."
|
| 21 |
else
|
| 22 |
root="/srv/packages.qa.debian.org/www"
|
| 23 |
fi
|
| 24 |
|
| 25 |
xsldir=$root/xsl
|
| 26 |
#rdf_stylesheet=$xsldir/admssw.xsl
|
| 27 |
rdf_stylesheet=$xsldir/admssw-turtle.xsl
|
| 28 |
|
| 29 |
|
| 30 |
if [ "$1" = "-v" -o "$2" = "-v" ]; then
|
| 31 |
verbose=1
|
| 32 |
fi
|
| 33 |
if [ "$1" = "-d" -o "$2" = "-d" ]; then
|
| 34 |
verbose=1
|
| 35 |
debug=1
|
| 36 |
fi
|
| 37 |
if [ "$1" = "-f" -o "$2" = "-f" ]; then
|
| 38 |
force="yes"
|
| 39 |
fi
|
| 40 |
|
| 41 |
if [ -n "$debug" ]; then
|
| 42 |
echo "cd $root/base"
|
| 43 |
fi
|
| 44 |
cd $root/base
|
| 45 |
date=`LC_ALL=C date -u "+%FT%T%:z"`
|
| 46 |
svnrev=$(svnversion $root)
|
| 47 |
|
| 48 |
# Read source package names on stdin
|
| 49 |
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 |
htmlfile=$root/web/$dir.html
|
| 57 |
rssfile=$root/web/$dir/news.rss20.xml
|
| 58 |
rdffile=$root/web/$dir.rdf
|
| 59 |
turtlefile=$root/web/$dir.ttl
|
| 60 |
needhtmlupdate="no"
|
| 61 |
needrdfupdate="no"
|
| 62 |
param=""
|
| 63 |
param="$param --stringparam svnrev $svnrev"
|
| 64 |
param="$param --stringparam dir $dir"
|
| 65 |
param="$param --stringparam package $package"
|
| 66 |
param="$param --stringparam hash $hash"
|
| 67 |
# If the file doesn't exist, then require a generation !
|
| 68 |
if [ ! -f $htmlfile ]; then
|
| 69 |
needhtmlupdate="yes"
|
| 70 |
fi
|
| 71 |
if [ ! -f $turtlefile ]; then
|
| 72 |
needrdfupdate="yes"
|
| 73 |
fi
|
| 74 |
# Force regeneration
|
| 75 |
if [ "$force" = "yes" ]; then
|
| 76 |
needhtmlupdate="yes"
|
| 77 |
needrdfupdate="yes"
|
| 78 |
fi
|
| 79 |
# Check if force-rebuild exists
|
| 80 |
if [ -e $dir/force-rebuild ]; then
|
| 81 |
needhtmlupdate="yes"
|
| 82 |
needrdfupdate="yes"
|
| 83 |
fi
|
| 84 |
# If the XSL file is newer than the HTML file, then force update
|
| 85 |
for i in "$xsldir/pts.xsl" "$xsldir/pts-issues.xsl" "$xsldir/common-params-vars.xsl"
|
| 86 |
do
|
| 87 |
if [ "$i" -nt "$htmlfile" ]; then
|
| 88 |
needhtmlupdate="yes"
|
| 89 |
fi
|
| 90 |
done
|
| 91 |
# If the XSL file is newer than the RDF file, then force update
|
| 92 |
for i in "$rdf_stylesheet" "$xsldir/common-params-vars.xsl"
|
| 93 |
do
|
| 94 |
if [ "$i" -nt "$turtlefile" ]; then
|
| 95 |
needrdfupdate="yes"
|
| 96 |
fi
|
| 97 |
done
|
| 98 |
# Create parameters and check if an update is needed
|
| 99 |
# XXX order _does_ matter, the latter has precedence over the former
|
| 100 |
for i in news excuse other \
|
| 101 |
mentors \
|
| 102 |
oldstable-proposed-updates stable-proposed-updates testing-proposed-updates \
|
| 103 |
stable-updates stable-backports \
|
| 104 |
oldstable oldstable-backports oldstable-backports-sloppy \
|
| 105 |
security-oldstable security-stable security-testing \
|
| 106 |
stable experimental testing unstable
|
| 107 |
do
|
| 108 |
if [ -f "$dir/$i.xml" ]; then
|
| 109 |
# 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 |
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 |
param="$param --stringparam has$i yes"
|
| 118 |
fi
|
| 119 |
if [ "$needhtmlupdate" = "no" -a "$dir/$i.xml" -nt "$htmlfile" ]; then
|
| 120 |
needhtmlupdate="yes"
|
| 121 |
fi
|
| 122 |
if [ "$needrdfupdate" = "no" -a "$dir/$i.xml" -nt "$turtlefile" ]; then
|
| 123 |
needrdfupdate="yes"
|
| 124 |
fi
|
| 125 |
done
|
| 126 |
# If no distribution-related input files has been found,
|
| 127 |
# then the package has been removed
|
| 128 |
if [ "$input" = "$dir/other.xml" ]; then
|
| 129 |
input="$xsldir/default.xml"
|
| 130 |
param="$param --stringparam removed yes"
|
| 131 |
if [ "$needhtmlupdate" = "no" -a "$xsldir/default.xml" -nt "$htmlfile" ]; then
|
| 132 |
needhtmlupdate="yes"
|
| 133 |
fi
|
| 134 |
if [ "$needrdfupdate" = "no" -a "$xsldir/default.xml" -nt "$turtlefile" ]; then
|
| 135 |
needrdfupdate="yes"
|
| 136 |
fi
|
| 137 |
else
|
| 138 |
param="$param --stringparam removed no"
|
| 139 |
fi
|
| 140 |
if [ ! -d ../web/$dir/static ]; then
|
| 141 |
mkdir -p ../web/$dir/{static,news} || true
|
| 142 |
fi
|
| 143 |
errors="no"
|
| 144 |
if [ "$needhtmlupdate" = "yes" ]; then
|
| 145 |
if [ -n "$verbose" ]; then
|
| 146 |
echo "Doing $package ..."
|
| 147 |
fi
|
| 148 |
xsltproc -o $htmlfile \
|
| 149 |
--stringparam date "$date" $param \
|
| 150 |
$xsldir/pts.xsl $input
|
| 151 |
test "$?" -ne 0 && errors="yes"
|
| 152 |
if [ -f "$dir/news.xml" ]; then
|
| 153 |
xsltproc -o $rssfile \
|
| 154 |
--stringparam date "$date" $param \
|
| 155 |
$xsldir/news2rss.xsl $dir/news.xml
|
| 156 |
test "$?" -ne 0 && errors="yes"
|
| 157 |
fi
|
| 158 |
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 |
if [ -n "$debug" ]; then
|
| 165 |
echo "xsltproc -o $turtlefile --stringparam date '$date' $param $rdf_stylesheet $input"
|
| 166 |
fi
|
| 167 |
xsltproc -o $turtlefile \
|
| 168 |
--stringparam date "$date" $param \
|
| 169 |
$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 |
else
|
| 178 |
if [ -n "$verbose" ]; then
|
| 179 |
echo "Not doing rdf $package : update not needed (use -f to force) ..."
|
| 180 |
fi
|
| 181 |
fi
|
| 182 |
test "$errors" = "yes" && \
|
| 183 |
echo "PTS: non-0 exit code while generating output for package $package"
|
| 184 |
rm -f $dir/force-rebuild || true
|
| 185 |
done
|
| 186 |
|
| 187 |
# Then update the software repository descriptor
|
| 188 |
cd $root
|
| 189 |
$root/bin/generate-admssw-repository.sh
|