From bda1c2f72144e81b8aab7db5282cfe323dddf775 Mon Sep 17 00:00:00 2001 From: Kevin Koch Date: Mon, 2 Apr 2007 16:13:58 +0000 Subject: [PATCH] Uncomment w2k files in corebinaries.xml Factor processing of xml into pruneFiles.pl. Factor processing of xml into zipXML.pl. Move SRC zip XML to section of config file. Call zipXML in /REPOSITORY CHECKOUT section of script. Keep track of cleaning of OUTDIR so SRC zip isn't removed during packaging. Remove UNIXFIND from config file. If UNIXFIND isn't present in the config file, set the in-memory UNIXFIND to c:\tools\cygwin\bin. UNIXFIND is now an implementation detail stored in the in-memory config XML, like the versions read from kerberos.ver. Prune more temporary files before making SDK zip. Remove redundant custom files from sdkfiles.xml. Copy *.* from staging/inc instead of *.h -- one .c file is also required. Target_Version: 1.6.1 Ticket: 5490 Tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19375 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/build/BKWconfig.xml | 66 ++++---- src/windows/build/bkw.pl | 218 +++++++++++++------------- src/windows/build/corebinaryfiles.xml | 11 +- src/windows/build/makeZip.pl | 41 ++--- src/windows/build/pruneFiles.pl | 34 ++++ src/windows/build/sdkfiles.xml | 8 +- src/windows/build/zipXML.pl | 21 +++ 7 files changed, 217 insertions(+), 182 deletions(-) create mode 100644 src/windows/build/pruneFiles.pl create mode 100644 src/windows/build/zipXML.pl diff --git a/src/windows/build/BKWconfig.xml b/src/windows/build/BKWconfig.xml index 37c1a5c43..a7a34ee2a 100644 --- a/src/windows/build/BKWconfig.xml +++ b/src/windows/build/BKWconfig.xml @@ -12,7 +12,6 @@ of the repositories will cause pismere/athena to be created under . --> - @@ -33,8 +32,38 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -110,33 +139,12 @@ + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/windows/build/bkw.pl b/src/windows/build/bkw.pl index a5d014233..6c9fad1f5 100644 --- a/src/windows/build/bkw.pl +++ b/src/windows/build/bkw.pl @@ -12,8 +12,9 @@ use Data::Dumper; use Archive::Zip; use Logger; require "copyfiles.pl"; +require "prunefiles.pl"; require "signfiles.pl"; -require "makeZip.pl"; +require "zipXML.pl"; my $BAIL; $0 = fileparse($0); @@ -122,9 +123,9 @@ sub main { # List of programs which must be in PATH: my @required_list = ('sed', 'awk', 'which', 'cat', 'rm', 'cvs', 'svn', 'doxygen', 'hhc', 'candle', 'light', 'makensis', 'nmake', 'plink'); - my $requirements_met = 1; - my $first_missing = 0; - my $error_list = ""; + my $requirements_met = 1; + my $first_missing = 0; + my $error_list = ""; foreach my $required (@required_list) { if (!get_info($required)) { $requirements_met = 0; @@ -150,8 +151,8 @@ sub main { ##++ Assemble configuration from config file and command line: - my $configfile; - $configfile = $OPT->{config}; + my $configfile = $OPT->{config}; + my $bOutputCleaned = 0; print "Info -- Reading configuration from $configfile.\n"; @@ -212,6 +213,78 @@ sub main { #print "cvs tag: $tags[0]->{cvs}->{value}\n"; #print "CVSROOT: $fetch[0]->{CVSROOT}->{name}\n"; + # We read in the version information to be able to update the site-local files in the install build areas: + local $version_path = $config->{Stages}->{Package}->{Config}->{Paths}->{Versions}->{path}; + open(DAT, "$src/$version_path") or die "Could not open $version_path."; + @raw = ; + close DAT; + foreach $line (@raw) { + chomp $line; + if ($line =~ /#define/) { # Process #define lines: + $line =~ s/#define//; # Remove #define token + $line =~ s/^\s+//; # and leading & trailing whitespace + $line =~ s/\s+$//; + local @qr = split("\"", $line); # Try splitting with quotes + if (exists $qr[1]) { + $qr[0] =~ s/^\s+//; # Clean up whitespace + $qr[0] =~ s/\s+$//; + $config->{Versions}->{$qr[0]} = $qr[1]; # Save string + } + else { # No quotes, so + local @ar = split(" ", $line); # split with space + $ar[0] =~ s/^\s+//; # Clean up whitespace + $ar[0] =~ s/\s+$//; + $config->{Versions}->{$ar[0]} = $ar[1]; # and save numeric value + } + } + } + + # Check that the versions we will need for site-local have been defined: + my @required_versions = ('VER_PROD_MAJOR', 'VER_PROD_MINOR', 'VER_PROD_REV', + 'VER_PROD_MAJOR_STR', 'VER_PROD_MINOR_STR', 'VER_PROD_REV_STR', + 'VER_PRODUCTNAME_STR'); + $requirements_met = 1; + $first_missing = 0; + $error_list = ""; + foreach my $required (@required_versions) { + if (! exists $config->{Versions}->{$required}) { + $requirements_met = 0; + if (!$first_missing) { + $first_missing = 1; + $error_list = "Fatal -- The following version(s) are not defined in $src/$version_path.\n"; + } + $error_list .= "$required\n"; + } + } + if (!$requirements_met) { + print $error_list; + exit(0); + } + # Apply any of these tags to filestem: + my $filestem = $config->{Stages}->{PostPackage}->{Config}->{FileStem}->{name}; + $filestem =~ s/%VERSION_MAJOR%/$config->{Versions}->{'VER_PROD_MAJOR_STR'}/; + $filestem =~ s/%VERSION_MINOR%/$config->{Versions}->{'VER_PROD_MINOR_STR'}/; + $filestem =~ s/%VERSION_PATCH%/$config->{Versions}->{'VER_PROD_REV_STR'}/; + $config->{Stages}->{PostPackage}->{Config}->{FileStem}->{name} = $filestem; + + # Test the unix find command: + if (! exists $config->{CommandLine}->{Directories}->{unixfind}->{path}) { + $config->{CommandLine}->{Directories}->{unixfind}->{path} = "C:\\tools\\cygwin\\bin"; + } + local $unixfind = $config->{CommandLine}->{Directories}->{unixfind}->{path}; + + local $savedPATH = $ENV{PATH}; + $ENV{PATH} = $unixfind.";".$savedPATH; +print "PATH now $ENV{PATH}\n"; + print "Info -- chdir to ".`cd`."\n" if ($verbose); + if (-e "a.tmp") {!system("rm a.tmp") or die "Fatal -- Couldn't clean temporary file a.tmp.";} + !system("find . -name a.tmp > b.tmp 2>&1") or die "Fatal -- find test failed."; + local $filesize = -s "b.tmp"; + $ENV{PATH} = $savedPATH; + if ($filesize > 0) { + die "Fatal -- $unixfind does not appear to be a path to a UNIX find command."; + } + ##-- Assemble configuration from config file and command line. my $sw = $switches[0]->{repository}->{value}; @@ -228,6 +301,11 @@ sub main { } $switches[0]->{repository}->{value} = $rverb; ## Save canonicalized repository verb. + if ( ($rverb =~ /checkout/) && $clean) { + print "Warning -- Because sources afe being checked out, make clean will not be run.\n"; + $clean = $switches[0]->{clean}->{value} = 0; + } + my $wd = $src."\\pismere"; if (! ($rverb =~ /skip/)) { @@ -316,6 +394,15 @@ sub main { if ($verbose) {print "Info -- svn command: $svncmd\n";} !system($svncmd) or die "Fatal -- command \"$svncmd\" failed; return code $?\n"; + if ($rverb =~ /checkout/) { + if (! $bOutputCleaned) { ## In case somebody cleaned $out before us. + if (-d $out) {!system("rm -rf $out/*") or die "Fatal -- Couldn't clean $out."} ## Clean output directory. + else {mkdir($out);} + $bOutputCleaned = 1; + } + zipXML($config->{Stages}->{FetchSources}, $config); ## Make zips. + } + if ($verbose) {print "Info -- *** End fetching sources.\n";} } ##-- End repository action. @@ -345,31 +432,7 @@ sub main { } # Prune any unwanted directories before the build: - if (exists $config->{Stages}->{Make}->{Prunes}) { - # Use Unix find instead of Windows find. Save PATH so we can restore it when we're done: - my $savedPATH = $ENV{PATH}; - $ENV{PATH} = $config->{CommandLine}->{Directories}->{unixfind}->{path}.";".$savedPATH; - my $prunes = $config->{Stages}->{Make}->{Prunes}; - my $j=0; - print "Info -- Processing prunes in ".`cd`."\n" if ($verbose); -print Dumper($prunes); - while ($prunes->{Prune}->[$j]) { - if (exists $prunes->{Prune}->[$j]->{name}) { ## Don't process dummy entry! - my $prune = $prunes->{Prune}->[$j]->{name}; - my $flags = $prunes->{Prune}->[$j]->{flags}; - $flags = "" if (!$flags); - my $cmd = "find . -".$flags."name $prune"; - print "Info -- Looking for filenames containing $prune\n"; - my $list = `$cmd`; - foreach $target (split("\n", $list)) { - print "Info -- Pruning $target\n" if ($verbose); - ! system("rm -rf $target") or die "Unable to prune $target"; - } - } - $j++; - } - $ENV{PATH} = $savedPATH; - } + pruneFiles($config->{Stages}->{Make}, $config); if ($verbose) {print "Info -- *** End preparing for build.\n";} @@ -385,7 +448,7 @@ print Dumper($prunes); chdir("$wd\\athena") or die "Fatal -- couldn't chdir to source directory $wd\\athena\n"; print "Info -- chdir to ".`cd`."\n" if ($verbose); - my $dbgswitch = ($switches[0]->{debug}->{value}) ? " " : "NODEBUG=1"; + local $dbgswitch = ($switches[0]->{debug}->{value}) ? " " : "NODEBUG=1"; !system("perl ../scripts/build.pl --softdirs --nolog $buildtarget $dbgswitch") or die "Fatal -- build $buildtarget failed."; chdir("$wd") or die "Fatal -- couldn't chdir to $wd."; @@ -401,76 +464,21 @@ print Dumper($prunes); ##-- Make action. ##++ Package action: - if ($switches[0]->{nopackage}->{value}) { ## If /clean, this switch will have been cleared. - print "Info -- *** Skipping packaging."; - if (-d $out) { + if ($switches[0]->{nopackage}->{value}) { ## If /clean, nopackage will be set. + print "Info -- *** Skipping packaging.\n"; + if ((-d $out) && ! $bOutputCleaned) { print "Warning -- *** Output directory $out will not be cleaned.\n"; } } else { if ($verbose) {print "Info -- *** Begin prepackage.\n";} - if (-d $out) { - !system("rm -rf $out/*") or die "Fatal -- Couldn't clean $out."; - } - else { - mkdir($out) or die "Fatal -- Couldn't create $out."; - } - - # We read in the version information to be able to update the site-local files in the install build areas: - local $version_path = $config->{Stages}->{Package}->{Config}->{Paths}->{Versions}->{path}; - open(DAT, "$src/$version_path") or die "Could not open $version_path."; - @raw = ; - close DAT; - foreach $line (@raw) { - chomp $line; - if ($line =~ /#define/) { # Process #define lines: - $line =~ s/#define//; # Remove #define token - $line =~ s/^\s+//; # and leading & trailing whitespace - $line =~ s/\s+$//; - local @qr = split("\"", $line); # Try splitting with quotes - if (exists $qr[1]) { - $qr[0] =~ s/^\s+//; # Clean up whitespace - $qr[0] =~ s/\s+$//; - $config->{Versions}->{$qr[0]} = $qr[1]; # Save string - } - else { # No quotes, so - local @ar = split(" ", $line); # split with space - $ar[0] =~ s/^\s+//; # Clean up whitespace - $ar[0] =~ s/\s+$//; - $config->{Versions}->{$ar[0]} = $ar[1]; # and save numeric value - } - } + if (! $bOutputCleaned) { ## In case somebody cleaned $out before us. + if (-d $out) {!system("rm -rf $out/*") or die "Fatal -- Couldn't clean $out."} ## Clean output directory. + else {mkdir($out);} + $bOutputCleaned = 1; } - # Check that the versions we will need for site-local have been defined: - my @required_versions = ('VER_PROD_MAJOR', 'VER_PROD_MINOR', 'VER_PROD_REV', - 'VER_PROD_MAJOR_STR', 'VER_PROD_MINOR_STR', 'VER_PROD_REV_STR', - 'VER_PRODUCTNAME_STR'); - my $requirements_met = 1; - my $first_missing = 0; - my $error_list = ""; - foreach my $required (@required_versions) { - if (! exists $config->{Versions}->{$required}) { - $requirements_met = 0; - if (!$first_missing) { - $first_missing = 1; - $error_list = "Fatal -- The following version(s) are not defined in $src/$version_path.\n"; - } - $error_list .= "$required\n"; - } - } - if (!$requirements_met) { - print $error_list; - exit(0); - } - # Apply any of these tags to filestem: - my $filestem = $config->{Stages}->{PostPackage}->{Config}->{FileStem}->{name}; - $filestem =~ s/%VERSION_MAJOR%/$config->{Versions}->{'VER_PROD_MAJOR_STR'}/; - $filestem =~ s/%VERSION_MINOR%/$config->{Versions}->{'VER_PROD_MINOR_STR'}/; - $filestem =~ s/%VERSION_PATCH%/$config->{Versions}->{'VER_PROD_REV_STR'}/; - $config->{Stages}->{PostPackage}->{Config}->{FileStem}->{name} = $filestem; - # The build results are copied to a staging area, where the packager expects to find them. # We put the staging area in the fixed area .../pismere/staging. my $prepackage = $config->{Stages}->{PrePackage}; @@ -525,11 +533,13 @@ print Dumper($prunes); # Run the script on site-local.wxi: !system("sed -f $tmpfile site-local-tagged.wxi > site-local.wxi") or die "Fatal -- Couldn't modify site-local.wxi."; + !system("rm site-local-tagged.wxi") or die "Fatal -- Couldn't remove site-local-tagged.wsi."; # Now update site-local.nsi: chdir "..\\nsis"; print "Info -- chdir to ".`cd`."\n" if ($verbose); !system("sed -f ..\\wix\\$tmpfile site-local-tagged.nsi > b.tmp") or die "Fatal -- Couldn't modify site-local.wxi."; + !system("rm site-local-tagged.nsi") or die "Fatal -- Couldn't remove site-local-tagged.nsi."; # Add DEBUG or RELEASE: if ($switches[0]->{debug}->{value}) { ## debug build !system("echo !define DEBUG >> b.tmp") or die "Fatal -- Couldn't modify b.tmp."; @@ -546,6 +556,8 @@ print Dumper($prunes); # Run the script on nsi-includes-tagged.nsi: !system("sed -f ..\\wix\\$tmpfile nsi-includes-tagged.nsi > nsi-includes.nsi") or die "Fatal -- Couldn't modify nsi-includes.nsi."; + !system("rm nsi-includes-tagged.nsi") or die "Fatal -- Couldn't remove nsi-includes-tagged.nsi."; + !system("rm ..\\wix\\$tmpfile") or die "Fatal -- Couldn't remove $tmpfile."; if ($verbose) {print "Info -- *** End prepackage.\n";} @@ -563,22 +575,8 @@ print Dumper($prunes); !system("makensis kfw.nsi") or die "Error -- executable installer build failed."; # Begin packaging extra items: - chdir($src); # Now in . - print "Info -- chdir to ".`cd`."\n" if ($verbose); - if (-d $out) {!system("rm -rf $out/*") or die "Fatal -- Couldn't clean $out."} ## Clean output directory. - else {mkdir($out);} - my $zipsXML = $config->{Stages}->{PostPackage}->{Zips}; - - local $i = 0; - while ($zipsXML->{Zip}[$i]) { - local $zip = $zipsXML->{Zip}[$i]; - makeZip($zip, $config) if (exists $zip->{name}); ## Ignore dummy entry. - chdir("$out"); - print "Info -- chdir to ".`cd`."\n" if ($verbose); - system("rm -rf ziptemp") if (-d "ziptemp"); ## Clean up any temp directory. - $i++; - } ## End zip in xml. - + zipXML($config->{Stages}->{PostPackage}, $config); ## Make zips. + $config->{Stages}->{PostPackage}->{CopyList}->{Config} = $config->{Stages}->{PostPackage}->{Config}; ## Use the post package config. $config->{Stages}->{PostPackage}->{CopyList}->{Config}->{From}->{root} = "$src\\pismere"; $config->{Stages}->{PostPackage}->{CopyList}->{Config}->{To}->{root} = "$out"; diff --git a/src/windows/build/corebinaryfiles.xml b/src/windows/build/corebinaryfiles.xml index 41c569e6c..c3b35f5c1 100644 --- a/src/windows/build/corebinaryfiles.xml +++ b/src/windows/build/corebinaryfiles.xml @@ -77,11 +77,8 @@ - - + + + + \ No newline at end of file diff --git a/src/windows/build/makeZip.pl b/src/windows/build/makeZip.pl index 4162386df..12215ddcd 100644 --- a/src/windows/build/makeZip.pl +++ b/src/windows/build/makeZip.pl @@ -1,9 +1,10 @@ #!perl -w #use strict; -use Data::Dumper; -require "signfiles.pl"; +require "prunefiles.pl"; + +use Data::Dumper; sub makeZip { local ($zip, $config) = @_; @@ -64,40 +65,20 @@ sub makeZip { print "Info -- chdir to ".`cd`."\n" if ($verbose); # Prune any unwanted files or directories from the directory we're about to zip: - if (exists $zip->{Prunes}) { - # Use Unix find instead of Windows find. Save PATH so we can restore it when we're done: - local $savedPATH = $ENV{PATH}; - $ENV{PATH} = $config->{CommandLine}->{Directories}->{unixfind}->{path}.";".$savedPATH; - local $prunes = $zip->{Prunes}; - local $j = 0; - print "Info -- Processing prunes in ".`cd`."\n" if ($verbose); - while ($prunes->{Prune}->[$j]) { - if (exists $prunes->{Prune}->[$j]->{name}) { ## Don't process dummy entry! - local $prune = $prunes->{Prune}->[$j]->{name}; - local $flags = $prunes->{Prune}->[$j]->{flags}; - $flags = "" if (!$flags); - local $cmd = "find . -".$flags."name $prune"; - print "Info -- Looking for filenames containing $prune\n"; - local $list = `$cmd`; - foreach $target (split("\n", $list)) { - print "Info -- Pruning $target\n" if ($verbose); - !system("rm -rf $target") or die "Error -- Couldn't remove $target.";; - } - } - $j++; - } - $ENV{PATH} = $savedPATH; - } + pruneFiles($zip, $config); local $zipfile = Archive::Zip->new(); local $topdir = $zip->{topdir}; $topdir =~ s/%filestem%/$filestem/g; $zipfile->addTree('.', $topdir); - if (-e $zipname) {!system("rm -f $zipname") or die "Error -- Couldn't remove $zipname.";} + if (-e $zipname) {!system("rm -f $zipname") or die "Error -- Couldn't remove $zipname.";} $zipfile->writeToFileNamed($zipname); - print "Info -- created $out\\$zipname.\n" if ($verbose); - # move .zip from /ziptemp to . - !system("mv -f $zipname ..") or die "Error -- Couldn't move $zipname to .."; + chdir("$out"); + print "Info -- chdir to ".`cd`."\n" if ($verbose); + # move .zip from /ziptemp to . + !system("mv -f ziptemp/$zipname .") or die "Error -- Couldn't move $zipname to .."; + system("rm -rf ziptemp") if (-d "ziptemp"); ## Clean up any temp directory. + print "Info -- created $out\\$zipname.\n" if ($verbose); } return 1; \ No newline at end of file diff --git a/src/windows/build/pruneFiles.pl b/src/windows/build/pruneFiles.pl new file mode 100644 index 000000000..2406c770e --- /dev/null +++ b/src/windows/build/pruneFiles.pl @@ -0,0 +1,34 @@ +#!perl -w + +#use strict; +require "makeZip.pl"; + +sub pruneFiles { + local ($xml, $config) = @_; + local $prunes = $xml->{Prunes}; + if (! $prunes) {return 0;} + + # Use Unix find instead of Windows find. Save PATH so we can restore it when we're done: + local $savedPATH = $ENV{PATH}; + $ENV{PATH} = $config->{CommandLine}->{Directories}->{unixfind}->{path}.";".$savedPATH; + local $j=0; + print "Info -- Processing prunes in ".`cd`."\n" if ($verbose); + while ($prunes->{Prune}->[$j]) { + if (exists $prunes->{Prune}->[$j]->{name}) { ## Don't process dummy entry! + local $prune = $prunes->{Prune}->[$j]->{name}; + local $flags = $prunes->{Prune}->[$j]->{flags}; + $flags = "" if (!$flags); + local $cmd = "find . -".$flags."name $prune"; + print "Info -- Looking for filenames containing $prune\n"; + local $list = `$cmd`; + foreach $target (split("\n", $list)) { + print "Info -- Pruning $target\n" if ($verbose); + ! system("rm -rf $target") or die "Unable to prune $target"; + } + } + $j++; + } + $ENV{PATH} = $savedPATH; + } + +return 1; diff --git a/src/windows/build/sdkfiles.xml b/src/windows/build/sdkfiles.xml index d62b962b2..5ef7f48fb 100644 --- a/src/windows/build/sdkfiles.xml +++ b/src/windows/build/sdkfiles.xml @@ -8,7 +8,8 @@ - + + @@ -16,11 +17,6 @@ - - - - - \ No newline at end of file diff --git a/src/windows/build/zipXML.pl b/src/windows/build/zipXML.pl new file mode 100644 index 000000000..0c50e96ae --- /dev/null +++ b/src/windows/build/zipXML.pl @@ -0,0 +1,21 @@ +#!perl -w + +#use strict; +require "makeZip.pl"; + +use Data::Dumper; + +sub zipXML { + local ($xml, $config) = @_; + my $zipsXML = $xml->{Zips}; + if (! $zipsXML) {return 0;} + + local $i = 0; + while ($zipsXML->{Zip}[$i]) { + local $zip = $zipsXML->{Zip}[$i]; + makeZip($zip, $config) if (exists $zip->{name}); ## Ignore dummy entry. + $i++; + } ## End zip in xml. + } + +return 1; -- 2.26.2