| 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 |
hertzog |
344 |
verbose=
|
| 9 |
|
|
|
| 10 |
hertzog |
579 |
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
|
| 11 |
|
|
|
| 12 |
hertzog |
344 |
if [ -d "incoming" ]; then
|
| 13 |
|
|
root="$PWD"
|
| 14 |
|
|
elif [ -d "../incoming" ]; then
|
| 15 |
|
|
root="$PWD/.."
|
| 16 |
|
|
else
|
| 17 |
geissert |
2738 |
root="/srv/packages.qa.debian.org/www"
|
| 18 |
hertzog |
344 |
fi
|
| 19 |
|
|
|
| 20 |
hertzog |
357 |
if [ "$1" = "-v" -o "$2" = "-v" ]; then
|
| 21 |
hertzog |
344 |
verbose=1
|
| 22 |
|
|
fi
|
| 23 |
hertzog |
357 |
if [ "$1" = "-f" -o "$2" = "-f" ]; then
|
| 24 |
|
|
force="yes"
|
| 25 |
|
|
fi
|
| 26 |
hertzog |
344 |
|
| 27 |
|
|
cd $root/base
|
| 28 |
|
|
date=`LC_ALL=C date -u`
|
| 29 |
|
|
|
| 30 |
|
|
while read package
|
| 31 |
|
|
do
|
| 32 |
|
|
hash=${package:0:1}
|
| 33 |
|
|
if [ "${package:0:3}" = "lib" ]; then
|
| 34 |
|
|
hash=${package:0:4}
|
| 35 |
|
|
fi
|
| 36 |
|
|
dir=$hash/$package
|
| 37 |
hertzog |
357 |
htmlfile=$root/web/$dir.html
|
| 38 |
zack |
1746 |
rssfile=$root/web/$dir/news.rss20.xml
|
| 39 |
hertzog |
357 |
needupdate="no"
|
| 40 |
zack |
1746 |
param=""
|
| 41 |
|
|
param="$param --stringparam dir $dir"
|
| 42 |
|
|
param="$param --stringparam package $package"
|
| 43 |
|
|
param="$param --stringparam hash $hash"
|
| 44 |
hertzog |
357 |
# If the file doesn't exist, then require a generation !
|
| 45 |
|
|
if [ ! -f $htmlfile ]; then
|
| 46 |
|
|
needupdate="yes"
|
| 47 |
|
|
fi
|
| 48 |
|
|
# Force regeneration
|
| 49 |
|
|
if [ "$force" = "yes" ]; then
|
| 50 |
|
|
needupdate="yes"
|
| 51 |
|
|
fi
|
| 52 |
hertzog |
400 |
# Check if force-rebuild exists
|
| 53 |
|
|
if [ -e $dir/force-rebuild ]; then
|
| 54 |
|
|
needupdate="yes"
|
| 55 |
|
|
fi
|
| 56 |
hertzog |
402 |
# If the XSL file is newer than the HTML file, then force update
|
| 57 |
hertzog |
2284 |
if [ "../xsl/pts.xsl" -nt "$htmlfile" ] || \
|
| 58 |
|
|
[ "../xsl/pts-issues.xsl" -nt "$htmlfile" ]; then
|
| 59 |
hertzog |
402 |
needupdate="yes"
|
| 60 |
|
|
fi
|
| 61 |
hertzog |
357 |
# Create parameters and check if an update is needed
|
| 62 |
zack |
1933 |
# XXX order _does_ matter, the latter has precedence over the former
|
| 63 |
zack |
1953 |
for i in news excuse other \
|
| 64 |
hertzog |
2478 |
mentors \
|
| 65 |
pabs |
2729 |
oldstable-proposed-updates stable-proposed-updates testing-proposed-updates \
|
| 66 |
hertzog |
2520 |
stable-updates stable-backports \
|
| 67 |
pabs |
2729 |
oldstable oldstable-backports oldstable-backports-sloppy \
|
| 68 |
zack |
2053 |
security-oldstable security-stable security-testing \
|
| 69 |
zack |
1953 |
experimental stable testing unstable
|
| 70 |
hertzog |
344 |
do
|
| 71 |
hertzog |
351 |
if [ -f "$dir/$i.xml" ]; then
|
| 72 |
hertzog |
400 |
# Input is the main xml file used by xsltproc to generate the HTML
|
| 73 |
|
|
# page. By default it is unstable.xml but it has many
|
| 74 |
|
|
# fallbacks (testing.xml, stable.xml, experimental.xml, ...)
|
| 75 |
zack |
1933 |
if [ "$i" != "mentors" ] ; then
|
| 76 |
|
|
# mentors.d.n needs special handling, because we don't want a PTS
|
| 77 |
|
|
# page to exist for packages only available on mentors.d.n
|
| 78 |
|
|
input=$dir/$i.xml
|
| 79 |
|
|
fi
|
| 80 |
hertzog |
344 |
param="$param --stringparam has$i yes"
|
| 81 |
|
|
fi
|
| 82 |
hertzog |
357 |
if [ "$needupdate" = "no" -a "$dir/$i.xml" -nt "$htmlfile" ]; then
|
| 83 |
|
|
needupdate="yes"
|
| 84 |
|
|
fi
|
| 85 |
hertzog |
344 |
done
|
| 86 |
hertzog |
1303 |
# If no distribution-related input files has been found,
|
| 87 |
|
|
# then the package has been removed
|
| 88 |
|
|
if [ "$input" = "$dir/other.xml" ]; then
|
| 89 |
|
|
input="../xsl/default.xml"
|
| 90 |
|
|
param="$param --stringparam removed yes"
|
| 91 |
|
|
if [ "$needupdate" = "no" -a "../xsl/default.xml" -nt "$htmlfile" ]; then
|
| 92 |
|
|
needupdate="yes"
|
| 93 |
|
|
fi
|
| 94 |
|
|
else
|
| 95 |
|
|
param="$param --stringparam removed no"
|
| 96 |
|
|
fi
|
| 97 |
hertzog |
344 |
if [ ! -d ../web/$dir/static ]; then
|
| 98 |
hertzog |
351 |
mkdir -p ../web/$dir/{static,news} || true
|
| 99 |
hertzog |
344 |
fi
|
| 100 |
hertzog |
357 |
if [ "$needupdate" = "yes" ]; then
|
| 101 |
jeroen |
1288 |
if [ -n "$verbose" ]; then
|
| 102 |
|
|
echo "Doing $package ..."
|
| 103 |
|
|
fi
|
| 104 |
zack |
1821 |
errors="no"
|
| 105 |
zack |
1746 |
xsltproc -o $htmlfile \
|
| 106 |
|
|
--stringparam date "$date" $param \
|
| 107 |
|
|
../xsl/pts.xsl $input
|
| 108 |
zack |
1821 |
test "$?" -ne 0 && errors="yes"
|
| 109 |
zack |
1746 |
if [ -f "$dir/news.xml" ]; then
|
| 110 |
|
|
xsltproc -o $rssfile \
|
| 111 |
|
|
--stringparam date "$date" $param \
|
| 112 |
|
|
../xsl/news2rss.xsl $dir/news.xml
|
| 113 |
zack |
1821 |
test "$?" -ne 0 && errors="yes"
|
| 114 |
zack |
1746 |
fi
|
| 115 |
zack |
1821 |
test "$errors" = "yes" && \
|
| 116 |
|
|
echo "PTS: non-0 exit code while generating output for package $package"
|
| 117 |
hertzog |
400 |
rm -f $dir/force-rebuild || true
|
| 118 |
hertzog |
357 |
fi
|
| 119 |
hertzog |
344 |
done
|
| 120 |
|
|
|