| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
# Copyright 2002 Raphaƫl Hertzog
|
| 4 |
# This file is distributed under the terms of the General Public License
|
| 5 |
# version 2 or (at your option) any later version.
|
| 6 |
|
| 7 |
verbose=
|
| 8 |
|
| 9 |
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
|
| 10 |
|
| 11 |
if [ -d "incoming" ]; then
|
| 12 |
root="$PWD"
|
| 13 |
elif [ -d "../incoming" ]; then
|
| 14 |
root="$PWD/.."
|
| 15 |
else
|
| 16 |
root="/org/packages.qa.debian.org/www"
|
| 17 |
fi
|
| 18 |
|
| 19 |
if [ "$1" = "-v" -o "$2" = "-v" ]; then
|
| 20 |
verbose=1
|
| 21 |
fi
|
| 22 |
if [ "$1" = "-f" -o "$2" = "-f" ]; then
|
| 23 |
force="yes"
|
| 24 |
fi
|
| 25 |
|
| 26 |
cd $root/base
|
| 27 |
date=`LC_ALL=C date -u`
|
| 28 |
|
| 29 |
while read package
|
| 30 |
do
|
| 31 |
hash=${package:0:1}
|
| 32 |
if [ "${package:0:3}" = "lib" ]; then
|
| 33 |
hash=${package:0:4}
|
| 34 |
fi
|
| 35 |
dir=$hash/$package
|
| 36 |
htmlfile=$root/web/$dir.html
|
| 37 |
needupdate="no"
|
| 38 |
param="--stringparam dir $dir --stringparam package $package"
|
| 39 |
# If the file doesn't exist, then require a generation !
|
| 40 |
if [ ! -f $htmlfile ]; then
|
| 41 |
needupdate="yes"
|
| 42 |
fi
|
| 43 |
# Force regeneration
|
| 44 |
if [ "$force" = "yes" ]; then
|
| 45 |
needupdate="yes"
|
| 46 |
fi
|
| 47 |
# Check if force-rebuild exists
|
| 48 |
if [ -e $dir/force-rebuild ]; then
|
| 49 |
needupdate="yes"
|
| 50 |
fi
|
| 51 |
# If the XSL file is newer than the HTML file, then force update
|
| 52 |
if [ "../xsl/pts.xsl" -nt "$htmlfile" ]; then
|
| 53 |
needupdate="yes"
|
| 54 |
fi
|
| 55 |
# Create parameters and check if an update is needed
|
| 56 |
for i in news excuse other volatile s-p-u t-p-u oldstable oldstable-security stable-security testing-security experimental stable testing unstable
|
| 57 |
do
|
| 58 |
if [ -f "$dir/$i.xml" ]; then
|
| 59 |
# Input is the main xml file used by xsltproc to generate the HTML
|
| 60 |
# page. By default it is unstable.xml but it has many
|
| 61 |
# fallbacks (testing.xml, stable.xml, experimental.xml, ...)
|
| 62 |
input=$dir/$i.xml
|
| 63 |
param="$param --stringparam has$i yes"
|
| 64 |
fi
|
| 65 |
if [ "$needupdate" = "no" -a "$dir/$i.xml" -nt "$htmlfile" ]; then
|
| 66 |
needupdate="yes"
|
| 67 |
fi
|
| 68 |
done
|
| 69 |
# If no distribution-related input files has been found,
|
| 70 |
# then the package has been removed
|
| 71 |
if [ "$input" = "$dir/other.xml" ]; then
|
| 72 |
input="../xsl/default.xml"
|
| 73 |
param="$param --stringparam removed yes"
|
| 74 |
if [ "$needupdate" = "no" -a "../xsl/default.xml" -nt "$htmlfile" ]; then
|
| 75 |
needupdate="yes"
|
| 76 |
fi
|
| 77 |
else
|
| 78 |
param="$param --stringparam removed no"
|
| 79 |
fi
|
| 80 |
if [ ! -d ../web/$dir/static ]; then
|
| 81 |
mkdir -p ../web/$dir/{static,news} || true
|
| 82 |
fi
|
| 83 |
if [ "$needupdate" = "yes" ]; then
|
| 84 |
if [ -n "$verbose" ]; then
|
| 85 |
echo "Doing $package ..."
|
| 86 |
fi
|
| 87 |
xsltproc -o $htmlfile --stringparam date "$date" \
|
| 88 |
$param ../xsl/pts.xsl $input
|
| 89 |
rm -f $dir/force-rebuild || true
|
| 90 |
fi
|
| 91 |
done
|
| 92 |
|