From 3e2c46af6b33709d13876fe9a3143288f7b9d187 Mon Sep 17 00:00:00 2001
From: Werner Koch <wk@gnupg.org>
Date: Sun, 23 May 1999 17:17:09 +0000
Subject: [PATCH] *** empty log message ***

---
 scripts/mkwebpage | 89 +++++++++++++++++++++++++++++++++--------------
 1 file changed, 63 insertions(+), 26 deletions(-)

diff --git a/scripts/mkwebpage b/scripts/mkwebpage
index bdb1bbf3c..10d170c79 100755
--- a/scripts/mkwebpage
+++ b/scripts/mkwebpage
@@ -6,13 +6,66 @@
 
 set -e
 
-cd $HOME/pub
+#cd $HOME/pub
+
+extract_date () {
+    # This strange construct is to speed up things.  Grouping a "s" and a "q"
+    # does not work. Anyway we should use awk instead.
+    sed '/^.*\$Id$.*$/q' $1 |
+    sed -n 's!^.*\$Id$!\1-\2-\3 \4!p'
+}
+
+# We have to edit most files
+sed_it () {
+    src=$1
+    dst=$2
+
+    for srcdir in `find $src -type d -print` ; do
+	dstdir=`echo "$srcdir" | sed "s/^$src/$dst/g"`
+	mkdir $dstdir || true
+	for sf in `find $srcdir -type f -maxdepth 1 -print`; do
+	    updated=`extract_date $sf`
+	    df="$dstdir/`basename $sf`"
+	    case "$df" in
+		*.html)
+		    sed "/@FOOTER@/ {
+			r $src/footer.html.inc
+			d
+			}
+			/^<body>$/ {
+			r $src/body-tag.html.inc
+			d
+			}
+			/@UPDATED@/c\\
+Updated: $updated \\
+<hr>
+			/@INSERT_BUGLIST_HERE@/ {
+			r $src/BUGS
+			d
+			}
+		     " $sf > $df
+		    ;;
+		*.html.inc | *~ | *.tmp | */BUGS )
+		    :
+		    ;;
+		*)
+		    cat $sf > $df
+		    ;;
+	    esac
+	done
+    done
+}
 
 
-fix_it () {
-    dir=$1
+do_export () {
+    pgm=$1
+    mod=$2
 
-    cat <<EOF >$dir/NEWS
+    rm -rf $pgm.tmp 2>/dev/null || true
+    rm -rf $pgm.new || true
+    rm -rf $pgm.old || true
+    cvs -Q export -r HEAD -d $pgm.tmp $mod
+    cat <<EOF >$pgm.tmp/NEWS
 [ This is a snapshot of the NEWS file from the CVS head revision.
   You will find the NEWS for the latest revision below the line
   "Noteworthy changes in version 0.x.y".
@@ -20,29 +73,13 @@ fix_it () {
 
 
 EOF
-    cvs -Q checkout -p gnupg/NEWS >>$dir/NEWS
-    cvs -Q checkout -p gnupg/BUGS >>$dir/BUGS
-    here=`pwd`
-    cd $dir
-    ln -sf gnupg.html index.html
-    sed -n '1,/@BEGIN_BUGLIST@/ p' buglist.html       >buglist.tmp
-    sed    '1,/^~~~~~~~~~~~/ d'  BUGS                >>buglist.tmp
-    echo "(List generated from CVS: " $(date +%Y-%m-%d) ")"  >>buglist.tmp
-    sed -n '/@END_BUGLIST@/,$ p'   buglist.html      >>buglist.tmp
-    mv	buglist.tmp buglist.html
-    cd $here
-}
-
-
-
-do_export () {
-    pgm=$1
-    mod=$2
-
-    rm -rf $pgm.new || true
+    cvs -Q checkout -p gnupg/NEWS >>$pgm.tmp/NEWS
+    cvs -Q checkout -p gnupg/BUGS | sed  '1,/^~~~~~~~~~~~/ d' > $pgm.tmp/BUGS
+    echo "(List generated from CVS: " $(date +%Y-%m-%d) ")"  >> $pgm.tmp/BUGS
+    sed_it $pgm.tmp $pgm.new
+    fix_it $pgm.tmp $pgm.new
     rm -rf $pgm.old || true
-    cvs -Q export -r HEAD -d $pgm.new $mod
-    fix_it $pgm.new
+
     [ -d $pgm ] && mv $pgm $pgm.old
     if ! mv $pgm.new $pgm ; then
 	echo "rename failed - restoring" >&2