From: Chris Koeritz Date: Mon, 16 Jan 2012 16:42:06 +0000 (-0500) Subject: more powerful scrubbing package for getting rid of files with same names: cleanerator X-Git-Tag: 2.140.90~1660 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=5d1d3508f85469d3a035a943d7b0ddfad3a72487;p=feisty_meow.git more powerful scrubbing package for getting rid of files with same names: cleanerator will scan across a hierarchy and consider N other hierarchies authoritative versions of similar code. if the cleaning directories have any files with the same names as the authoritative directories, then the files are removed. be really careful with this! it's a powerful nuke on all your files, especially if you have a directory in both the cleaning and authoritative lists! --- diff --git a/scripts/files/cleanerator.sh b/scripts/files/cleanerator.sh new file mode 100644 index 00000000..45b26795 --- /dev/null +++ b/scripts/files/cleanerator.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +cleaning_dirs=($*) + +more_authoritative=( ~/quartz/example_source_code/inova_legacy ~/feisty_meow ~/scavenging_inova/inovasoft ) +###not yet ~/scavenging_inova/lightlink + +if [ -z "$TMP" ]; then TMP=/tmp; fi + +# we generate the full directory list for the authoritative places into here. +zesty_authoritative_dirs=$(mktemp $TMP/cleanerator_authority.XXXXXX) +# we also make a list of all the directories under our cleaning locations here. +perky_scrubbing_dirs=$(mktemp $TMP/cleanerator_scrubbinz.XXXXXX) + +# dump out the directories found in the authoritative areas. +for i in "${more_authoritative[@]}"; do + real_dir="$(\cd "$i" && \pwd)" + find "$real_dir" -type d | grep -v "\.svn" | grep -v "\.git" >>"$zesty_authoritative_dirs" +done + +# now go to all of our places to clean, find all directories under them, +# and add them to our big list of places to scrub. +for i in "${cleaning_dirs[@]}"; do + real_dir="$(\cd "$i" && \pwd)" + find "$real_dir" -depth -type d | grep -v "\.svn" | grep -v "\.git" >>"$perky_scrubbing_dirs" +done + +# load all the names from our files and do a massive N x M size loop. +while read i; do +# echo "cleaning: $i" + pushd "$i" &>/dev/null +#pwd + while read j; do +# echo "against authority: $j" + # try to clean it out of source control first. + bash ~/feisty_meow/scripts/rev_control/svn_rm_dupes.sh "$j" "$i" + # if that doesn't work, just whack it. + bash ~/feisty_meow/scripts/files/whack_dupes.sh "$j" "$i" + done <"$zesty_authoritative_dirs" + popd &>/dev/null +done <"$perky_scrubbing_dirs" + +# clean up afterwards. +rm -f "$zesty_authoritative_dirs" +rm -f "$perky_scrubbing_dirs" + diff --git a/scripts/rev_control/svn_rm_dupes.sh b/scripts/rev_control/svn_rm_dupes.sh index 404ad073..70448dde 100644 --- a/scripts/rev_control/svn_rm_dupes.sh +++ b/scripts/rev_control/svn_rm_dupes.sh @@ -7,6 +7,8 @@ exemplar_dir="$1"; shift whack_dir="$1"; shift +#hmmm: much code here is shared with whack_dupes. get into a library. + # make sure they gave us a good directory to start with. if [ -z "$exemplar_dir" ]; then echo "whack_dupes" @@ -44,6 +46,12 @@ if [ ! -z "$whack_dir" ]; then pushd "$whack_dir" &>/dev/null fi +# now that we're in the directory to clean, make sure we're good there. +if [ ! -d ".svn" ]; then +# echo "Could not find a subversion directory; operation would be pointless." + exit 0 +fi + current_dir="$(pwd)" #echo "currdir=$current_dir gooddir=$the_good_place" @@ -54,11 +62,6 @@ if [ "$current_dir" == "$the_good_place" ]; then exit 4 fi -if [ ! -d ".svn" ]; then - echo "Could not find a subversion directory; operation would be pointless." - exit 1 -fi - # do the real work now... for i in *; do if [ -f "$exemplar_dir/$i" ]; then