eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; # $Id$ # # Creates an ACE or TAO kit. Intended to be called from the # ACE or TAO top-level Makefiles. # # The first three lines above let this script run without specifying the # full path to perl, as long as it is in the user's PATH. # Taken from perlrun man page. $usage="usage: $0 [-?] [-k ] [-n] [-t ] " . "[-c ] [-r ] " . "[-l , where is ace, tao, or ace+tao\n" . " -n option prints what would be done, but doesn't do it\n" . " -t , where is major, minor, or beta (default)\n" . " -c lists the CVS-controlled files\n" . " -r lists the files to be released\n" . " -l list the files to put in the lib kit\n"; ######## ######## Configuration parameters. ######## if (-d '/pkg/gnu/bin') { $gnu = '/pkg/gnu/bin/'; } else { #### The default utilities had better be GNU. $gnu = ''; } $exec_prefix = $exec_suffix = ''; $kit = ''; $release_type = 'beta'; $controlled_files = ''; $release_files = ''; $release_filter = '-name CVS -prune -name build -prune -o ! -name \'.\#*\' ' . '! -name \'\#*\' ! -name \'*~\' ' . '! -name \'*.MAK\' -print'; ######## ######## Process command line args. ######## while ($#ARGV >= $[ && $ARGV[0] =~ /^-/) { if ($ARGV[0] eq '-k') { if ($ARGV[1] =~ /^[^-]+/ && ($ARGV[1] eq 'ace' || $ARGV[1] eq 'tao' || $ARGV[1] eq 'ace+tao')) { $kit = $ARGV[1]; shift; } else { print STDERR "$0: must provide argument for -k option\n"; die "$usage$long_usage"; } } elsif ($ARGV[0] eq '-n') { $exec_prefix = 'echo \''; $exec_suffix = '\''; } elsif ($ARGV[0] eq '-t') { if ( $ARGV[1] =~ /^[^-]+/ && ($ARGV[1] eq 'major' || $ARGV[1] eq 'minor' || $ARGV[1] eq 'beta')) { $release_type = $ARGV[1]; shift; } else { print STDERR "$0: must provide argument for -t option\n"; die "$usage$long_usage"; } } elsif ($ARGV[0] eq '-c') { if ( $ARGV[1] =~ /^[^-]+/) { $controlled_files = $ARGV[1]; shift; } else { print STDERR "$0: must provide argument for -c option\n"; die "$usage$long_usage"; } } elsif ($ARGV[0] eq '-r') { if ( $ARGV[1] =~ /^[^-]+/) { $release_files = $ARGV[1]; shift; } else { print STDERR "$0: must provide argument for -r option\n"; die "$usage$long_usage"; } } elsif ($ARGV[0] eq '-l') { if ( $ARGV[1] =~ /^[^-]+/) { $release_lib_files = $ARGV[1]; shift; } else { print STDERR "$0: must provide argument for -l option\n"; die "$usage$long_usage"; } } elsif ($ARGV[0] eq '-?') { print "$usage$long_usage"; exit; } else { print STDERR "$0: unknown option $ARGV[0]\n"; die "$usage$long_usage"; } shift; } die "must specify a -k option\n" unless "$kit"; $update_versions = 0; if ($kit eq 'ace') { $KIT = 'ACE'; $update_versions = (`pwd` eq "/project/adaptive/ACE_wrappers\n"); } elsif ($kit eq 'tao') { $KIT = 'TAO'; $update_versions = (`pwd` eq "/project/adaptive/ACE_wrappers/TAO\n"); } else { #### Creating combined ACE+TAO kit. Don't use $KIT. }; $chmod = '/bin/chmod'; $cpio = "${gnu}cpio"; $cvs = "${exec_prefix}${gnu}cvs"; $date = "${gnu}date"; $find = "${gnu}find"; $gzip = "${gnu}gzip"; $mv = '/bin/mv'; chop ($now = `$date +"%a %b %d %T %Y"`); ######## ######## Setup signal handler. ######## $SIG{'HUP'} = $SIG{'INT'} = $SIG{'QUIT'} = $SIG{'TERM'} = 'cleanup'; ######## ######## Defend against fascist umasks. ######## umask 022; ######## ######## Main execution thread. ######## if ($update_versions && "$kit" ne 'ace+tao') { $major_version = $minor_version = $beta_version = 0; $version = ''; &check_workspace () || &get_versions () || &update_version_files () || &update_changelog () || &tag () || &create_kit (); } else { &create_kit (); } &cleanup; ######## ######## Clean up when done or on signal. ######## sub cleanup { exit; } ######## ######## Check that the workspace is up-to-date, if releasing from ######## the official release directory. ######## sub check_workspace () { if ("$controlled_files") { my @out_of_date = (); open (CVS, "$cvs -nq update $controlled_files |") || die "$0: unable to open $cvs\n"; while () { next if m%/tests/log/%; push (@out_of_date, $_) if "$_"; } close CVS; if (! "$exec_prefix" && @out_of_date) { warn "ERROR: workspace must be updated or cleaned: " . join ("\n ", @out_of_date) . "\n"; return 1; } } 0; } ######## ######## Retrieve version information from VERSION file(s). ######## sub get_versions () { open (VERSION, '< VERSION') || die "$0: unable to open VERSION\n"; while () { if (/$KIT version (\d+)\.(\d+)\.(\d+)/o) { $major_version = $1; $minor_version = $2; $beta_version = $3; last; } elsif (/$KIT version (\d+)\.(\d+)[^\.]/o) { #### Previous release was a minor. $major_version = $1; $minor_version = $2; last; } elsif (/$KIT version (\d+)[^\.]/o) { #### Previous release was a major. $major_version = $1; last; } } close VERSION; if ($release_type eq 'beta') { ++$beta_version; $version = "$major_version.$minor_version.$beta_version"; } elsif ($release_type eq 'minor' ) { $beta_version = 0; ++$minor_version; $version = "$major_version.$minor_version"; } elsif ($release_type eq 'major' ) { $minor_version = $beta_version = 0; ++$major_version; $version = "$major_version"; } print "new $KIT version: $version\n"; 0; } ######## ######## Update VERSION file(s). ######## sub update_version_files () { system ("$exec_prefix" . "perl -pi -e " . "'s/$KIT version .*/$KIT version $version, released $now./' " . "VERSION $exec_suffix"); return 1 if $? >> 8; if (! "$exec_prefix" && $kit =~ /^ace/) { open (ACE_VERSION_H, "> ace/Version.h") || die "$0: unable to open ace/Version.h\n"; print ACE_VERSION_H "// \$Id\$\n" . "// This is an automatically generated file.\n\n" . "\#define ACE_MAJOR_VERSION (${major_version}u)\n" . "\#define ACE_MINOR_VERSION (${minor_version}u)\n" . "\#define ACE_BETA_VERSION (${beta_version}u)\n" . "\#define ACE_VERSION \"${version}\\0\"\n"; close ACE_VERSION_H; } 0; } ######## ######## Add ChangeLog entries, and make sure that they have proper ######## permissions. ######## sub update_changelog () { my $logname = $ENV{'LOGNAME'}; my $signature = $ENV{'SIGNATURE'} || $logname; my $message = "$now $signature <$logname\\\@cs.wustl.edu>\n\n" . " * $KIT version $version released.\n\n"; my $message_insert = "perl -pi -e 'BEGIN {\$message_printed = 0;} if (! \$message_printed) { print \"$message\"; ++\$message_printed; }' ChangeLog"; if ("$exec_prefix") { print "$message_insert\n"; } else { system ($message_insert); } if ($kit =~ /^ace/) { system ("$cvs commit -m'$version' VERSION ChangeLog ace/Version.h " . "&& chmod 0644 VERSION ChangeLog ace/Version.h"); } elsif ($kit =~ /tao/) { system ("$cvs commit -m'$version' VERSION ChangeLog " . "&& chmod 0644 VERSION ChangeLog"); } return 1 if $? >> 8; 0; } ######## ######## Tag the release. ######## sub tag () { my $tag = "$KIT-$version"; #### cvs tag does not allow dots. $tag =~ tr/./_/; system ("$cvs -q tag $tag $controlled_files"); return 1 if $? >> 8; 0; } ######## ######## Create the tar file(s) and move to their proper location. ######## sub create_kit () { if ("$exec_prefix") { print "chdir '..'\n"; } else { chdir '..' || die "$0: unable to chdir ..\n"; } if ($kit eq 'ace') { system ("$exec_prefix" . "$find $release_files $release_filter | $cpio -o -H tar | " . "$gzip -9 > ACE.tar.gz && " . "$find $release_lib_files $release_filter | $cpio -o -H tar | " . "$gzip -9 > ACE-lib.tar.gz && " . "$chmod a+r ACE.tar.gz ACE-lib.tar.gz && " . "$mv ACE.tar.gz ACE-lib.tar.gz ACE_wrappers/ $exec_suffix"); } elsif ($kit eq 'ace+tao') { system ("$exec_prefix" . "$find $release_files $release_filter | $cpio -o -H tar | " . "$gzip -9 > ACE+TAO.tar.gz && " . "$chmod a+r ACE+TAO.tar.gz && " . "$mv ACE+TAO.tar.gz ACE_wrappers/ $exec_suffix"); } 0; }