cleaning up old production directories now, so upgraded feisty doesn't have crud...
[feisty_meow.git] / scripts / generator / whack_build.sh
1 #!/bin/bash
2
3 #hmmm: nice to set an interrupt handler for ctrl-c, to catch a break and send it to the cleanup of the crudfile.
4
5 # catch whether they want rigorous cleaning or not.
6 clean_src="$1"; shift
7
8 function whack_single_build_area()
9 {
10   local CLEANING_LOCALE="$1"; shift
11   if [ ! -d "$CLEANING_LOCALE" ]; then
12 #    echo "the folder $CLEANING_LOCALE does not exist.  not cleaning."
13     return 0
14   fi
15
16   local choprepo="$(basename "$(dirname "$CLEANING_LOCALE")" )/$(basename "$CLEANING_LOCALE")"
17   echo $(date): "cleaning up [$choprepo]..."
18   if [ -z "$CLEANING_LOCALE" ]; then
19     echo "The CLEANING_LOCALE variable is not set!"
20     exit 3
21   fi
22
23 #old  export NEW_TMP="$(mktemp -d "$CLEANING_LOCALE/TEMPS.XXXXXX")"
24   export NEW_TMP="$(mktemp -d "$TMP/temps-build-whacking.XXXXXX")"
25   export CRUDFILE="$(mktemp "$NEW_TMP/whack_build.XXXXXX")"
26   echo "" &>"$CRUDFILE"
27
28   CLEANING_TOP="$CLEANING_LOCALE/production"
29
30 #  echo $(date): "  cleaning up the build products..."
31
32   # avoid accidentally removing way too much important stuff if our variables have not
33   # been previously established.
34   local GENERATED_DIR="$CLEANING_TOP/generated-feisty_meow"
35 #*** hmmm: above is wrong place now!
36   local TEMPORARIES_DIR="$CLEANING_TOP/temporaries"
37
38   # kerzap.  the few cleanups in production directory remove older locations of generated files.
39   rm -rf \
40     "$FEISTY_MEOW_DIR/generatedJUnitFiles" \
41     "$CLEANING_TOP/binaries" \
42     "$CLEANING_TOP/install" \
43     "$CLEANING_TOP/logs" \
44     "$CLEANING_TOP/objects" \
45     "$TEMPORARIES_DIR" \
46     "$GENERATED_DIR" \
47     "$CLEANING_TOP/__build_"*.h \
48     "$CLEANING_TOP/manifest.txt" \
49     "$PRODUCTION_DIR/clam_bin" \
50     "$PRODUCTION_DIR/binaries" \
51     "$PRODUCTION_DIR/install" \
52     "$PRODUCTION_DIR/logs" \
53     "$PRODUCTION_DIR/waste" 
54
55 #  echo $(date): "  cleaning generated files in source hierarchy..."
56
57   if [ "$clean_src" == "clean" -o "$clean_src" == "CLEAN"  ]; then
58     echo $(date): "    ** aggressive cleaning activated..."
59     perl "$FEISTY_MEOW_SCRIPTS/files/zapdirs.pl" "$FEISTY_MEOW_DIR" >>"$CRUDFILE"
60   fi
61
62   echo $(date): "cleaned [$choprepo]."
63   rm -rf "$NEW_TMP"
64   return 0
65 }
66
67 ##############
68
69 # clean all known hierarchies of build products...
70
71 whack_single_build_area "$FEISTY_MEOW_DIR"
72