summaryrefslogtreecommitdiff
path: root/clone_build_tree.pl
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2008-07-18 16:05:54 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2008-07-18 16:05:54 +0000
commit6fd3ad3f828f394c6f668cc6b43981a22e1f6317 (patch)
tree61c90e72b7bf915d9d80c8e5e1837abbbaaadb0d /clone_build_tree.pl
parent97fa1ff1e6cf30fa55cb9c32081ea3ef9055fbd2 (diff)
downloadMPC-6fd3ad3f828f394c6f668cc6b43981a22e1f6317.tar.gz
ChangeLogTag: Fri Jul 18 16:03:52 UTC 2008 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'clone_build_tree.pl')
-rwxr-xr-xclone_build_tree.pl31
1 files changed, 15 insertions, 16 deletions
diff --git a/clone_build_tree.pl b/clone_build_tree.pl
index b4385b70..8dd66391 100755
--- a/clone_build_tree.pl
+++ b/clone_build_tree.pl
@@ -140,6 +140,11 @@ sub backupAndMoveModified {
## -M returns the number of days since modification. Therefore,
## a smaller time means that it has been modified more recently.
## This is different than what stat() returns.
+
+ ## If the hard linked file is newer than the original file, that means
+ ## the link has been broken by something and needs to be "fixed". We
+ ## will back up the original file and move the modified file into it's
+ ## place.
if ($mltime < $mrtime) {
$status = 0;
@@ -158,10 +163,9 @@ sub backupAndMoveModified {
}
}
}
- elsif ($mltime != $mrtime) {
- $status = 0;
- }
- elsif (-s $linkpath != -s $realpath) {
+ elsif ($mltime != $mrtime || -s $linkpath != -s $realpath) {
+ ## The two files are different in some way, we need to make a backup
+ ## so that we don't cause a loss of data/work.
$status = 0;
}
@@ -250,9 +254,8 @@ sub symlinkFiles {
my $slashcount = ($buildfile =~ tr/\///);
my $real = ($slashcount == 0 ? './' : ('../' x $slashcount)) .
$file;
- if ($verbose) {
- print "symlink $real $fullpath\n";
- }
+
+ print "symlink $real $fullpath\n" if ($verbose);
if (!symlink($real, $fullpath)) {
print STDERR "ERROR: Unable to symlink $fullpath\n";
return 1;
@@ -339,9 +342,7 @@ sub hardlinkFiles {
my $full = "$fullbuild/$line";
unlink($full);
$dirs{dirname($full)} = 1;
- if ($verbose) {
- print "Removing $full\n";
- }
+ print "Removing $full\n" if ($verbose);
}
}
close($lfh);
@@ -405,9 +406,7 @@ sub linkFiles {
print "Finished in $fullbuild\n";
}
- if ($status == 0) {
- print 'Total time: ', time() - $starttime, " seconds.\n";
- }
+ print 'Total time: ', time() - $starttime, " seconds.\n" if ($status == 0);
return $status;
}
@@ -415,9 +414,9 @@ sub linkFiles {
sub usageAndExit {
my $msg = shift;
- if (defined $msg) {
- print STDERR "$msg\n";
- }
+
+ print STDERR "$msg\n" if (defined $msg);
+
my $base = basename($0);
my $spc = ' ' x (length($base) + 8);