* gpg.c (reopen_std): New function to reopen fd 0, 1, or 2 if we are
[gnupg.git] / scripts / mkwebpage
blobb39feb176ec9e9b1069f31d16dcd2db7d5331e3f
1 #!/bin/sh
2 # Make a snapshot of the CVS head revision for the gnupg webpages
5 set -e
7 cd $HOME/pub
9 extract_date () {
10 # This strange construct is to speed up things. Grouping a "s" and a "q"
11 # does not work. Anyway we should use awk instead.
12 # Have to quote the I from $Id so that CVS does not expand it
13 sed '/^.*\$[I]d:.*\$.*$/q' $1 |
14 sed -n 's!^.*\$[I]d: [^ ]\+ [^ ]\+ \([0-9]*\)/\([0-9]*\)/\([0-9]*\) [^ ]\+ \([^ ]\+\).*$!\1-\2-\3 \4!p'
17 # We have to edit most files
18 sed_it () {
19 src=$1
20 dst=$2
22 for srcdir in `find $src -type d -print` ; do
23 dstdir=`echo "$srcdir" | sed "s/^$src/$dst/g"`
24 mkdir $dstdir || true
25 for sf in `find $srcdir -type f -maxdepth 1 -print`; do
26 updated=`extract_date $sf`
27 df="$dstdir/`basename $sf`"
28 case "$df" in
29 *.html)
30 sed "/@FOOTER@/ {
31 r $src/footer.html.inc
34 /^<body>$/ {
35 r $src/body-tag.html.inc
38 /@UPDATED@/c\\
39 Updated: $updated \\
40 <hr>
41 /@INSERT_BUGLIST_HERE@/ {
42 r $src/BUGS
45 /@HOSTEDBY@/ {
46 r $src/hostedby.html.inc
49 " $sf > $df
51 *.html.inc | *~ | *.tmp | */BUGS )
55 cat $sf > $df
57 esac
58 done
59 done
63 do_export () {
64 pgm=$1
65 mod=$2
67 rm -rf $pgm.tmp 2>/dev/null || true
68 rm -rf $pgm.new || true
69 rm -rf $pgm.old || true
70 cvs -Q export -r HEAD -d $pgm.tmp $mod
71 cat <<EOF >$pgm.tmp/NEWS
72 [ This is a snapshot of the NEWS file from the CVS head revision.
73 You will find the NEWS for the latest revision below the line
74 "Noteworthy changes in version 0.x.y".
75 (wk $(date +%Y-%m-%d)) ]
78 EOF
79 cvs -Q checkout -p gnupg/NEWS >>$pgm.tmp/NEWS
80 cvs -Q checkout -p gnupg/BUGS | sed '1,/^~~~~~~~~~~~/ d' > $pgm.tmp/BUGS
81 echo "(List generated from CVS: " $(date +%Y-%m-%d) ")" >> $pgm.tmp/BUGS
82 sed_it $pgm.tmp $pgm.new
83 rm -rf $pgm.tmp || true
84 ln -sf gnupg.html $pgm.new/index.html
86 rm -rf $pgm.old || true
87 [ -d $pgm ] && mv $pgm $pgm.old
88 if ! mv $pgm.new $pgm ; then
89 echo "rename failed - restoring" >&2
90 mv $pgm.old $pgm
91 exit 1
93 rm -rf $pgm.old || true
97 do_export gnupg-www gnupg-www
99 #cd gnupg-www
100 #tar czf /home/ftp/pub/gcrypt/.old/webpages.tmp *
101 #mv /home/ftp/pub/gcrypt/old/webpages.tmp /home/ftp/pub/gcrypt/old/webpages.tar.gz
104 exit 0