first check-in of feisty meow codebase. many things broken still due to recent
[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   export NEW_TMP="$(mktemp -d "$CLEANING_LOCALE/TEMPS.XXXXXX")"
24   export CRUDFILE="$(mktemp "$NEW_TMP/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 way too much important stuff if our variables have not
32   # been previously established.
33   local WASTE_DIR="$CLEANING_LOCALE/waste"
34   local TEMPORARIES_DIR="$CLEANING_LOCALE/temporaries"
35
36   # kerzap.
37   rm -rf \
38     "$CLEANING_TOP/binaries" \
39     "$CLEANING_TOP/install" \
40     "$CLEANING_TOP/logs" \
41     "$CLEANING_TOP/objects" \
42     "$TEMPORARIES_DIR" \
43     "$WASTE_DIR" \
44     "$CLEANING_TOP/__build_"*.h \
45     "$CLEANING_TOP/manifest.txt" 
46
47 #  echo $(date): "  Cleaning generated files in source hierarchy..."
48
49   if [ "$clean_src" == "clean" -o "$clean_src" == "CLEAN"  ]; then
50     echo $(date): "    ** Aggressive cleaning activated..."
51     perl "$SHELLDIR/files/zapdirs.pl" "$CLEANING_TOP" >>"$CRUDFILE"
52   fi
53
54   echo $(date): "Cleaned [$choprepo]."
55
56   rm -rf "$NEW_TMP"
57
58   return 0
59 }
60
61 ##############
62
63 # clean all known hierarchies of build products...
64
65 whack_single_build_area "$REPOSITORY_DIR"
66
67
68