summaryrefslogtreecommitdiffstats
path: root/src/windows/build/makeZip.pl
diff options
context:
space:
mode:
authorKevin Koch <kpkoch@mit.edu>2007-03-30 20:08:53 +0000
committerKevin Koch <kpkoch@mit.edu>2007-03-30 20:08:53 +0000
commit53b462aa4829fa9e1b9f191e55c83698bc44501a (patch)
treeda82677f8ac5fbbe6bfdfc16583dcfb3cfe6d826 /src/windows/build/makeZip.pl
parent4a1a867562bbc20ef769e3f556a69767b236433f (diff)
downloadkrb5-53b462aa4829fa9e1b9f191e55c83698bc44501a.tar.gz
krb5-53b462aa4829fa9e1b9f191e55c83698bc44501a.tar.xz
krb5-53b462aa4829fa9e1b9f191e55c83698bc44501a.zip
Remove tabs. Improve some comments. Regroup files in copylist.pl according to destination
Add signing. Factor zipfiles out of bkw.pl and signing out of makeZip.pl. Rename MITKerberosForWindows.exe before zipping it into the SDK zipfile. Target_Version: 1.6.1 Ticket: 5490 Tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19344 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/build/makeZip.pl')
-rw-r--r--src/windows/build/makeZip.pl108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/windows/build/makeZip.pl b/src/windows/build/makeZip.pl
new file mode 100644
index 000000000..ab1100554
--- /dev/null
+++ b/src/windows/build/makeZip.pl
@@ -0,0 +1,108 @@
+#!perl -w
+
+#use strict;
+use Data::Dumper;
+
+require "signfiles.pl";
+
+sub makeZip {
+ local ($zip, $config) = @_;
+
+ local $src = $config->{CommandLine}->{Directories}->{src}->{path};
+ local $toPath = $config->{CommandLine}->{Directories}->{out}->{path};
+ local @switches = $config->{CommandLine}->{Options};
+ local $zipname = $zip->{filename};
+ local $filestem = $config->{Stages}->{PostPackage}->{Config}->{FileStem}->{name};
+ $zipname =~ s/%filestem%/$filestem/g;
+ if (exists $zip->{Requires}) {
+ local $bMakeIt = 1;
+ local $rverb = $switches[0]->{repository}->{value};
+ local $j = 0;
+ while ($zip->{Requires}->{Switch}[$j]) { ## Check Require switches
+ local $switch = $zip->{Requires}->{Switch}[$j];
+ if (exists $switch->{name}) { ## Ignore dummy entry
+ # We handle REPOSITORY and CLEAN switches:
+ if ($switch->{name} =~ /REPOSITORY/i) {
+ $bMakeIt &&= ($switch->{value} =~ /$rverb/i); ## Repository verb must match requirement
+ }
+ elsif ($switch->{name} =~ /CLEAN/i) { ## Clean must be specified
+ $bMakeIt &&= $clean;
+ }
+ else {print "Error -- Unsupported switch $switch->{name} in Requires in ".Dumper($zip);
+ $bMakeIt = 0;
+ }
+ }
+ $j++;
+ }
+ if ( !$bMakeIt ) {
+ if (exists $zip->{Requires}->{ErrorMsg}) {
+ print "Error -- $zip->{Requires}->{ErrorMsg}->{text}\n";
+ }
+ else {
+ print "Error -- requirements not met for building $zipname.\n";
+ }
+ return 0;
+ }
+ }
+
+ local $ziptemp = "$src\\$toPath\\ziptemp";
+ chdir "$src\\$toPath";
+ print "Info -- chdir to ".`cd`."\n" if ($verbose);
+ system("rm -rf $ziptemp") if (-d $ziptemp);
+ die "Fatal -- Couldn't remove $ziptemp" if (-d $ziptemp);
+ mkdir($ziptemp);
+ # Set up the zip's config section:
+ $zip->{Config} = $config->{Stages}->{PostPackage}->{Config};
+ # Add to the copylist's config section. Don't copy Postpackage->Config,
+ # because the CopyList's Config might contain substitution tags.
+ $zip->{CopyList}->{Config}->{FileStem}->{name} = $config->{Stages}->{PostPackage}->{Config}->{FileStem}->{name};
+ $zip->{CopyList}->{Config}->{From}->{root} = "$src\\pismere"; ## Add zip-specific config settings.
+ $zip->{CopyList}->{Config}->{To}->{root} = "$ziptemp\\$zip->{topdir}";
+ copyFiles($zip->{CopyList}, $config);
+ # Drop down into <out>/ziptemp so the path to the added file won't include <out>:
+ chdir $ziptemp;
+ 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;
+ }
+
+ # Sign files:
+ if ($switches[0]->{sign}->{value}) {
+ signFiles($zip->{Config}->{Signing}, $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.";}
+ $zipfile->writeToFileNamed($zipname);
+ print "Info -- created $src\\$toPath\\$zipname.\n" if ($verbose);
+ # move .zip from <src>/<out>/ziptemp to <src>/<out>.
+ !system("mv -f $zipname ..") or die "Error -- Couldn't move $zipname to ..";
+ }
+
+return 1; \ No newline at end of file