diff options
author | michel_j <michel_j@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-07-02 19:57:42 +0000 |
---|---|---|
committer | michel_j <michel_j@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-07-02 19:57:42 +0000 |
commit | aa067a0ec61bfdc84729eafd81b82dd0ba2f1a67 (patch) | |
tree | 0ac0820f33ddc6dab63ed4e798ae32f29733db80 /bin/create_ace_build.pl | |
parent | bd49f66465ff6476edc769839504cf9a7fa4ec2f (diff) | |
download | ATCD-aa067a0ec61bfdc84729eafd81b82dd0ba2f1a67.tar.gz |
Wed Jul 02 14:57:00 2003 Justin Michel <michel_j@ociweb.com>
Diffstat (limited to 'bin/create_ace_build.pl')
-rwxr-xr-x | bin/create_ace_build.pl | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/bin/create_ace_build.pl b/bin/create_ace_build.pl index d017bc97dc9..c2f49c2e592 100755 --- a/bin/create_ace_build.pl +++ b/bin/create_ace_build.pl @@ -78,64 +78,67 @@ my(@build_re) = (); print "Creating or updating builds in $starting_dir\n"; -sub is_changed { - my($real, $fake) = @_; - unless (-e $real) { +#### If the $linked file is newer than the real file then +#### backup the real file, and replace it with the linked +#### version. + +sub backup_and_copy_changed { + my($real, $linked) = @_; + my($status_real) = stat($real); + if (! $status_real) { die "ERROR: is_changed() real $real not exist.\n"; } - my($status1) = stat($real); - my($status2) = stat($fake); - my($tm1) = $status1->mtime; + my($status_linked) = stat($linked); - if ($status1->mtime != $status2->mtime) { + if ($status_linked->mtime > $status_real->mtime) { + rename($real, $real . '.bak'); + rename($linked, $real); return 1; } - if ($status1->size != $status2->size) { + + if ($status_real->mtime != $status_linked->mtime) { + unlink($linked); + return 1; + } + if ($status_real->size != $status_linked->size) { + unlink($linked); return 1; } return 0; } sub cab_link { - my($real,$fake,$build_regex) = @_; - my($uif) = ($^O eq 'MSWin32' ? 'link' : 'symlink'); + my($real,$linked,$build_regex) = @_; my($status) = 0; if ($^O eq 'MSWin32') { - my($fixed) = $fake; + my($fixed) = $linked; $fixed =~ s/$build_regex//; push(@nlinks, $fixed); - if (-d "$starting_dir/$fake") { - die "ERROR: cab_link() $fake is a directory.\n"; - } - - #### chdir does NOT work with relative path names. (ActivePerl 5.6 WinXP) - my($curdir) = "$starting_dir/" . dirname($fake); + my($curdir) = "$starting_dir/" . dirname($linked); $status = chdir($curdir); if (! $status) { die "ERROR: cab_link() chdir " . $curdir . " failed.\n"; } - my($base_fake) = basename($fake); + my($base_linked) = basename($linked); - if (-e $base_fake) { - if (is_changed($real, $base_fake)) { - unlink($base_fake); - } else { + if (-e $base_linked) { + if (! backup_and_copy_changed($real, $base_linked)) { return; } } - print "$uif $real $fake\n" if $verbose; - $status = link ($real, $base_fake); + print "link $real $linked\n" if $verbose; + $status = link ($real, $base_linked); chdir($starting_dir); } else { - print "$uif $real $fake\n" if $verbose; - $status = symlink ($real, $fake); + print "$symlink $real $linked\n" if $verbose; + $status = symlink ($real, $linked); } if (!$status) { - die "$0: $real -> $fake failed\n"; + die "$0: $real -> $linked failed\n"; } } @@ -272,6 +275,7 @@ sub wanted { ! /^.*\.icp\z/s && ! /^.*\.ncb\z/s && ! /^.*\.opt\z/s && + ! /^.*\.bak\z/s && ! /^\.cvsignore\z/s && ! /^Makefile.*\z/s ); @@ -291,7 +295,6 @@ print "Found $#files files and directories.\n"; #### foreach $file (@files) { $file =~ s%^./%%g; #### excise leading ./ directory component - #### -d does NOT work with relative path names. (ActivePerl 5.6 WinXP) my($fullname) = "$starting_dir/$file"; for ($idx = 0; $idx <= $#builds; $idx++) { my($build) = $builds[$idx]; @@ -301,7 +304,7 @@ foreach $file (@files) { mkdir ("$starting_dir/$build/$file", $directory_mode); } } else { - unless ((-e "$build/$file") && ($^O ne 'MSWin32')) { + unless (($^O ne 'MSWin32') && (-e "$build/$file")) { $up = '../..'; while ($file =~ m%/%g) { $up .= '/..'; @@ -312,6 +315,8 @@ foreach $file (@files) { } } +print "Finished creating and updating links.\n"; + foreach $build (@builds) { #### #### Find all the symlinks in the build directory, and remove ones @@ -378,15 +383,24 @@ foreach $build (@builds) { #### print "\nCompleted creation of $build/.\n"; - if (! -e "$build/ace/config.h") { +foreach $build (@builds) { + unless (-d "$starting_dir/$build") { + print "Creating $starting_dir/$build\n"; + mkdir ("$starting_dir/$build", $directory_mode); + } + + + if (! -e "$starting_dir/$build/ace/config.h") { print "Be sure to setup $build/ace/config.h"; } if ($^O ne 'MSWin32' && - ! -e "$build/include/makeinclude/platform_macros.GNU") { + ! -e "$starting_dir/$build/include/makeinclude/platform_macros.GNU") { print " and\n$build/include/makeinclude/platform_macros.GNU"; } print ".\n"; } +} + #### EOF |