diff options
author | Jaka Kranjc | 2006-10-14 14:21:42 +0200 |
---|---|---|
committer | Jaka Kranjc | 2006-10-14 14:31:03 +0200 |
commit | a74473694e15387cfb5b55e5134de4ef428f5eea (patch) | |
tree | f7d17b538612867ee28619c3e203911364407084 | |
parent | f4115d8c10f31c2511300d458e2ff5288021791f (diff) |
pm-post-cast: generalised the usrlocal function to be capable of searching fordevel-wip
any bad path and added search for files in /usr/man and /usr/info
pm-seer: accompanying change, so the bugreports will mention all the bad paths
Please review, especially perl is new to me.
-rwxr-xr-x | usr/sbin/pm-post-cast | 53 | ||||
-rwxr-xr-x | usr/sbin/pm-seer | 50 |
2 files changed, 60 insertions, 43 deletions
diff --git a/usr/sbin/pm-post-cast b/usr/sbin/pm-post-cast index 6e32c39..81e1fd3 100755 --- a/usr/sbin/pm-post-cast +++ b/usr/sbin/pm-post-cast @@ -185,28 +185,37 @@ snap_failure(){ done } -check_usrlocal(){ - echo "checking for /usr/local files" - #files that were there before - grep "/usr/local" $PMDIR/md5sum_image |awk '{print $2}' > /tmp/usrlocal.ok - #files that are there now - find /usr/local \( -type p -o -type s \) -prune -o -type d -o -print >/tmp/usrlocal.found - #if theres nothing in /usr/local at all, return - if [[ ! -s /tmp/usrlocal.found ]]; then return ; fi - - #otherwise clear off whats already there from our list - pm-exclude /tmp/usrlocal.found /tmp/usrlocal.ok > $SNAPSHOT/usrlocal.lst - #if theres still something there save it all for later consumption - if [[ -s $SNAPSHOT/usrlocal.lst ]]; then - mkdir -p $SNAPSHOT/usrlocal 2>/dev/null - for each in $(cat $SNAPSHOT/usrlocal.lst );do - echo "$each should not be in /usr/local" - mkdir -p usrlocal/$(dirname $each) 2>/dev/null - cp $each $SNAPSHOT/usrlocal/ - done - fi - rm /tmp/usrlocal.* +check_bad_paths(){ + rm -f $SNAPSHOT/badpaths.lst + while [[ ! -z $1 ]]; do + bad_path=$1 + pruned_path=${bad_path//\//} + + echo "checking for $bad_path files" + #files that were there before + grep $bad_path $PMDIR/md5sum_image |awk '{print $2}' > /tmp/$pruned_path.ok + #files that are there now + find $bad_path \( -type p -o -type s \) -prune -o -type d -o -print >/tmp/$pruned_path.found + #if theres nothing in $bad_path at all, return + if [[ ! -s /tmp/$pruned_path.found ]]; then return ; fi + + #otherwise clear off whats already there from our list + pm-exclude /tmp/$pruned_path.found /tmp/$pruned_path.ok > $SNAPSHOT/$pruned_path.lst + #if theres still something there save it all for later consumption + if [[ -s $SNAPSHOT/$pruned_path.lst ]]; then + mkdir -p $SNAPSHOT/$pruned_path 2>/dev/null + for each in $(cat $SNAPSHOT/$pruned_path.lst );do + echo "$each should not be in $bad_path" + mkdir -p $pruned_path/$(dirname $each) 2>/dev/null + cp $each $SNAPSHOT/$pruned_path/ + done + fi + rm /tmp/$pruned_path.* + echo $pruned_path >> $SNAPSHOT/badpaths.lst + shift + done } + ###########################end-subroutines##################### ###########################begin real code##################### @@ -263,7 +272,7 @@ source /etc/sorcery/config #oh boy...but dont worry, I only want the variables snap_success "$SNAPSHOT" snap_failure "$SNAPSHOT" -check_usrlocal $SNAPSHOT +check_bad_paths /usr/local /usr/man /usr/info echo "pm-post-cast:stop" > $PMDIR/state exit 0 diff --git a/usr/sbin/pm-seer b/usr/sbin/pm-seer index 5c87327..94ff956 100755 --- a/usr/sbin/pm-seer +++ b/usr/sbin/pm-seer @@ -58,7 +58,7 @@ reporting options: --compile <#lines|full> : reports #line or all of compile log --badfiles : report files that were deleted, left, or changed - --usrlocal : files that somehow ended up in /usr/local + --badpaths : files that somehow ended up in /usr/{local,man,info} END_OF_HELP } @@ -114,7 +114,7 @@ sub seer_build_config(){ $CONFIG{"new_list"} ="$CONFIG{snapshot_dir}/new.lst"; $CONFIG{"diff_list"} ="$CONFIG{snapshot_dir}/different.lst"; $CONFIG{"diff_log"} ="$CONFIG{snapshot_dir}/diff.log"; - $CONFIG{"usrlocal_list"} ="$CONFIG{snapshot_dir}/usrlocal.lst"; + $CONFIG{"badpaths_list"} ="$CONFIG{snapshot_dir}/badpaths.lst"; $CONFIG{"pm_automd5"} ="$CONFIG{snapshot_dir}/pm-automd5.lst"; } @@ -173,7 +173,7 @@ sub seer_parse{ %CONFIG=(%CONFIG, coord,1, hls,1, analysis,1, activity,1, lists,1, installed,1, depends,1, "system",1, "local",1, grimoires,1, compile,1, badfiles,1, - usrlocal,1,md5,1,title,1); + badpaths,1,md5,1,title,1); }elsif($ARGV[$i]=~/^--snapshot/){ if($ARGV[$i+1] ne /--|-/){$CONFIG{snapshot_name}=$ARGV[++$i];}} elsif($ARGV[$i]=~/^--output/){ @@ -191,7 +191,8 @@ sub seer_parse{ elsif($ARGV[$i]=~/^--installed/){%CONFIG=(%CONFIG,"installed",1);} elsif($ARGV[$i]=~/^--badfiles/){%CONFIG=(%CONFIG,"badfiles",1);} elsif($ARGV[$i]=~/^--md5/){%CONFIG=(%CONFIG,"md5",1);} - elsif($ARGV[$i]=~/^--usrlocal/){%CONFIG=(%CONFIG,"usrlocal",1);} + elsif($ARGV[$i]=~/^--usrlocal/){%CONFIG=(%CONFIG,"badpaths",1);} + elsif($ARGV[$i]=~/^--badpaths/){%CONFIG=(%CONFIG,"badpaths",1);} elsif($ARGV[$i]=~/^--depends/){%CONFIG=(%CONFIG,"depends",1);} elsif($ARGV[$i]=~/^--bzip2/){%CONFIG=(%CONFIG,"bzip2",1);} elsif($ARGV[$i]=~/^--help/){%CONFIG=(%CONFIG,"help",1);} @@ -245,7 +246,7 @@ sub seer_trim_options{ }elsif($CONFIG{"system"}){ $CONFIG{"system"}=0; }elsif($CONFIG{md5}){ $CONFIG{md5}=0; }elsif($CONFIG{badfiles}){ $CONFIG{badfiles}=0; - }elsif($CONFIG{usrlocal}){ $CONFIG{usrlocal}=0; + }elsif($CONFIG{badpaths}){ $CONFIG{badpaths}=0; }elsif($CONFIG{installed}){ $CONFIG{installed}=0; }elsif($CONFIG{coord}){ $CONFIG{coord}=0; }elsif($CONFIG{lists}){ $CONFIG{lists}=0; @@ -298,7 +299,7 @@ sub seer_read{ if($CONFIG{installed} or $CONFIG{analysis}){seer_read_installed();} if($CONFIG{badfiles}){ seer_read_badfiles(); } if($CONFIG{md5}){ seer_read_md5(); } - if($CONFIG{usrlocal}){ seer_read_usrlocal(); } + if($CONFIG{badpaths}){ seer_read_badpaths(); } return; } @@ -323,8 +324,8 @@ print "COMPILE COUNT IS $count\n"; $LINES{badfiles} = $count; $count = 0; seer_write_md5() if($CONFIG{md5}); $LINES{md5} = $count; $count = 0; - seer_write_usrlocal() if($CONFIG{usrlocal}); - $LINES{usrlocal} = $count; $count = 0; + seer_write_badpaths() if($CONFIG{badpaths}); + $LINES{badpaths} = $count; $count = 0; seer_write_system() if($CONFIG{system}); $LINES{system} = $count; $count = 0; seer_write_activity() if($CONFIG{activity}); @@ -403,12 +404,19 @@ sub seer_read_badfiles{ } } -sub seer_read_usrlocal{ - if( -s $CONFIG{usrlocal_list}){ - open FILE, "$CONFIG{usrlocal_list}"; - @usrlocal_files=<FILE>; - $ERROR{usrlocal}=@usrlocal_files; - close FILE +sub seer_read_badpaths{ + if( -s $CONFIG{badpaths_list}){ + open FILE, "$CONFIG{badpaths_list}"; + @badpaths_files=<FILE>; + close FILE; + for $file(@badpaths_files) { + $file="$file".".lst"; + open FILE, "$file"; + @badpaths_file=<FILE>; + close FILE; + push(@badpaths_all, @badpaths_file); + } + $ERROR{badpaths}=@badpaths_all; } } @@ -456,8 +464,8 @@ sub seer_write_title{ print FILE "$ERROR{$key} file(s) removed from $spell"; goto end; } elsif($key eq "diff_files"){ print FILE "$ERROR{$key} file(s) changed from $spell"; goto end; - } elsif($key eq "usrlocal"){ - print FILE "$ERROR{$_} file(s) in /usr/local from $spell"; goto end; + } elsif($key eq "badpaths"){ + print FILE "$ERROR{$_} file(s) in wrong places from $spell"; goto end; } } end: @@ -476,7 +484,7 @@ sub seer_write_hls{ cprint (FILE, " At least $ERROR{$_} file(s) left behind after the dispel.\n") if($_ eq "new_files"); cprint (FILE, " At least $ERROR{$_} file(s) removed after a dispel when it shouldnt have.\n") if($_ eq "old_files"); cprint (FILE, " At least $ERROR{$_} file(s) left changed after the dispel.\n") if($_ eq "diff_files"); - cprint (FILE, " At least $ERROR{$_} file(s) placed in /usr/local after a cast.\n") if($_ eq "usrlocal"); + cprint (FILE, " At least $ERROR{$_} file(s) placed in wrong paths after a cast.\n") if($_ eq "badpaths"); } sort keys %ERROR }else{ cprint (FILE, "I found no problems.\n"); @@ -650,10 +658,10 @@ sub seer_write_md5{ } } -sub seer_write_usrlocal{ - if($CONFIG{usrlocal} and $ERROR{usrlocal}){ - cprint (FILE,"/USR/LOCAL FILES:\n"); - cprint (FILE ,"@usrlocal_files"); +sub seer_write_badpaths{ + if($CONFIG{badpaths} and $ERROR{badpaths}){ + cprint (FILE,"MISPLACED FILES:\n"); + cprint (FILE ,"@badpaths_all"); cprint (FILE,"\n\n"); } } |