This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: wwwdocs/bin/preprocess remove_cruft (was: Patch: use .htaccessfor redirects)


On Sun, 28 Jan 2001, Gerald Pfeifer wrote:
>> This seems to be a problem with the `preprocess' script.  Somebody
>> else will have to fix that.
> That's me, yes. I'll try to address this by the end of the month (or a tad
> later)...

I hadn't specified which month, had I? :-(

This turned out to be much more annoying than I had thought -- find is
probably one of the least portable programs in existence, so I hacked
around it in a far less efficient but at least working way.

With this patch, upon every run of the preprocess script we now also look
for and remove directories in DESTTREE that don't exist in SOURCETREE
(with the exception of a few special directories).

We'll have to address the performance issue later.

Repeatedly tested on gcc.gnu.org and installed.

Gerald

Index: preprocess
===================================================================
RCS file: /cvs/gcc/wwwdocs/bin/preprocess,v
retrieving revision 1.18
retrieving revision 1.21
diff -u -3 -p -r1.18 -r1.21
--- preprocess	2001/07/20 07:26:43	1.18
+++ preprocess	2001/07/27 07:13:06	1.21
@@ -17,8 +17,6 @@ DESTTREE=${DESTTREE-/www/gcc/htdocs}

 STYLE=$SOURCETREE/style.mhtml

-DONT_REMOVE='-name onlinedocs -prune -o -name benchresults -prune -o -name testresults -prune -o -name fom_serv -prune'
-
 ####
 # Various safety check first.

@@ -49,17 +47,25 @@ trap "cleanup; exit 1" 1 2 15
 remove_cruft() {
     cd $DESTTREE

-    for f in `find . \( $DONT_REMOVE \) -type f` ; do
-        if [ ! -f $SOURCETREE/$f ]; then
-            echo "Removing obsolete file $f"
-            #rm $f
-        fi
+    for f in `find . -type f` ; do
+        d=`dirname $f`
+        case $d in
+            ./onlinedocs*|./benchresults*|./testresults*|./fom_serv*)
+                echo "  Warning: Keeping $f";
+                ;;
+            *)
+                if [ ! -f $SOURCETREE/$f ]; then
+                    echo "Removing obsolete file $f"
+                    rm -f $f
+                fi
+                ;;
+        esac
     done

-    for f in `find . \( $DONT_REMOVE \) -type d` ; do
-        if [ ! -d $SOURCETREE/$f ]; then
-            echo "Removing obsolete directory $f"
-            #rmdir $f
+    for d in `find . -type d` ; do
+        if [ -z "`ls $d`" ]; then
+            echo "Removing obsolete empty directory $d"
+            rmdir $d
         fi
     done
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]