10968823000a8a55095723987d6939fea6efe76d
[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 CRUDFILE="$(mktemp "$TMP/zz_whack_build.XXXXXX")"
25   echo "" &>"$CRUDFILE"
26
27 #  CLEANING_TOP="$CLEANING_LOCALE/production"
28
29 #  echo $(date): "  cleaning up the build products..."
30
31   # avoid accidentally removing important stuff if our variables have not been previously
32   # established.
33   if [ -z "$GENERATED_DIR" -o -z "$TEMPORARIES_DIR" ]; then
34     echo The build whacking script cannot run because either the GENERATED_DIR
35     echo variable or the TEMPORARIES_DIR variable have not been set.  This makes
36     echo it unsafe to remove anything in the build products.
37     exit 1
38   fi
39
40   # kerzap.  the cleanups in production directory remove older locations of generated files.
41   rm -rf \
42     "$FEISTY_MEOW_DIR/generatedJUnitFiles" \
43     "$TEMPORARIES_DIR" \
44     "$GENERATED_DIR" \
45     "$CLEANING_TOP/__build_"*.h \
46     "$CLEANING_TOP/manifest.txt" \
47     "$PRODUCTION_DIR/clam_bin" \
48     "$PRODUCTION_DIR/binaries" \
49     "$PRODUCTION_DIR/install" \
50     "$PRODUCTION_DIR/logs" \
51     "$PRODUCTION_DIR/waste" 
52
53 #  echo $(date): "  cleaning generated files in source hierarchy..."
54
55   if [ "$clean_src" == "clean" -o "$clean_src" == "CLEAN"  ]; then
56     echo $(date): "    ** aggressive cleaning activated..."
57     perl "$FEISTY_MEOW_SCRIPTS/files/zapdirs.pl" "$FEISTY_MEOW_DIR" >>"$CRUDFILE"
58   fi
59
60   echo $(date): "cleaned [$choprepo]."
61   rm -rf "$CRUDFILE"
62   return 0
63 }
64
65 ##############
66
67 # clean all known hierarchies of build products...
68
69 whack_single_build_area "$FEISTY_MEOW_DIR"
70