From 484f2c118521d1976a989414b314a29e540137f9 Mon Sep 17 00:00:00 2001 From: Kevin Koch Date: Thu, 12 Apr 2007 14:29:07 +0000 Subject: [PATCH] KfW build automation: Consolidate all command line switch info in one section of the config.xml, flatten structure. Don't prune .../site/... . Use getopts negate option where possible. New method of dealing with repository options, driven from config xml. Adjust code to find switches in new place. Hardwire default config to bkwconfig.xml. Makes "bkw.pl" the out-of-the-box command line. Hardwire unixfind path to C:\tools\cygwin\bin. Add filver to required programs list. Update documentation. Target_Version: 1.6.1 Ticket: 5521 Tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19430 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/build/BKWconfig.xml | 79 ++-- src/windows/build/bkw-automation.html | 652 ++++++++++++++------------ src/windows/build/bkw.pl | 228 ++++----- src/windows/build/copyfiles.pl | 6 +- src/windows/build/makeZip.pl | 14 +- src/windows/build/pruneFiles.pl | 2 +- src/windows/build/signFiles.pl | 2 +- 7 files changed, 537 insertions(+), 446 deletions(-) diff --git a/src/windows/build/BKWconfig.xml b/src/windows/build/BKWconfig.xml index 35ba05650..31294ea66 100644 --- a/src/windows/build/BKWconfig.xml +++ b/src/windows/build/BKWconfig.xml @@ -1,38 +1,55 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + - - - - - @@ -52,7 +69,7 @@ - + diff --git a/src/windows/build/bkw-automation.html b/src/windows/build/bkw-automation.html index eb41053c5..d463df3a6 100644 --- a/src/windows/build/bkw-automation.html +++ b/src/windows/build/bkw-automation.html @@ -1,295 +1,361 @@ - - - - lore-bkw-automation - Confluence - - - - - - - -
-
The - Kerberos For Windows build is being automated. This description consists of -
- -

Build steps

-

Building the complete KfW product consists of these steps:

-
    -
  • - Setting up the environment -
  • - Fetching sources from repositories -
  • - Building the sources with nmake -
  • - Setting up the packaging environment -
  • - Building the two installers -- a msi installer and an exe installer -
  • - Building other distribution components -
      -
    • - KfW source distribution -
    • - KfW core binaries -
    • - KfW SDK -
    • - Microsoft redistributable components -
    • - Individual files: release notes, Leash user guide, MSI Deployment Guide. -
    • -
    -
  • -
-

Script structure

-

The build is a perl script controlled by command line switches and an XML - configuration file. The config file is required. Settings in the config file - can be overridden by optional command line switches.

-

The main steps in the script are

-
    -
  • - Setting up the environment -
  • - Fetching the sources from repositories -
  • - Building the sources -
  • - Setting up the packaging environment -
  • - Building the msi with the package nmake -
  • - Building the rest of the components -
  • -
-

The usage message shows the available switches:

-

C:\Projects\KfW>perl bkw.pl /?
- Usage: bkw.pl (-f --config) config-file [options] NMAKE-options

-

Options are case insensitive.

-

Options:
- /help /? usage information (what you now see)
- /srcdir dir   Source directory to use. Should contain
-               - pismere/athena. If cvstag or svntag is null,
-               - the directory should be prepopulated.
- /cvstag tag   \ For whichever of these tags is specified,
- /svntag url   / a checkout will be done into srcdir
- /debug        Do debug make instead of - release make
- /outdir dir   Directory to be created where build results will go
- /nomake       Skip make step
- /nopackage    Skip packaging step
- /clean        Build clean target
- /verbose      Debug mode - verbose output
- /vverbose     very verbose output
- /config path  Path to config file
- /logfile path Where to write output. If omitted, ...
- /srcdir dir   Source directory to use. Should contain -
-              
pismere/athena. - If cvstag or svntag is null, -
-               - the directory should be prepopulated. -
-
/outdir dir   Directory to be created where build results will - go -
- /repository checkout | co \ What repository action to take. -
-            
update   - | up | Options are to checkout, update or
-             skip          - / take no action [skip]. -
- /cvstag tag   \ For whichever of these tags is specified, -
-
/svntag url   / the repository action will be done into srcdir -
- /debug        Do debug make instead of - release make -
- /nomake       Skip make step -
- /nopackage    Skip packaging step -
- /clean        Build clean target -
- /verbose      Debug mode - verbose output -
- /config path  Path to config file -
- /logfile path Where to write output. If omitted, ...
-
Other:
- NMAKE-options any options you want to pass to NMAKE, which can be:
- (note: /nologo is always used)
- [ nmake options follow ]

-

Additional controls, not available from the command line:

-

<CVSROOT name=":kserver:cvs.mit.edu:/cvs/pismere" />
- <SVNURL name="" />
- <CopyList><Config><DebugArea value="dbg" />
-                   - <ReleaseArea value="rel" />
-                   <AlwaysTag - value="%bldtype%" />
-                   - <DebugTag value="%debug%" />
-                   - <ReleaseTag value="%release%" />
-                   - <Files><Include path="copyfiles.xml" />

-

The pre-package steps gathers up build results and puts them in - a target area.  "target" is hardwired in the - build script.

-

The post-package step zips up various files and then copies the - zips and other files tosrcdir/public.  - "public" is hardwired in the build script.

-

Config file

-

- CopyLists

-

- CopyLists are used in many places.  There is an optional - Configuration section and a required Files section. 

-

The configuration section defines the roots of the from and to paths and can - optionally define path substitutions.  -

-

Internally, the to and from paths are required.  They are forced by the - script rather than being set in the config file.  Comments in the copyfile - xml indicate this.

-

The overall build configuration specifies a debug or release build.  The - debug and release results are put in different places.  File entries can - indicate a variable part of a path with a tag such as %bldtype%.  The - script will substitute %bldtype% with either dbg or rel, depending on the build - type.  The substitution tags are specified with these declarations:

-

- - - - - - - - - - - - - - - - - - - - - - - - - -
DebugAreaPath value used in debug build.  Must match what the build - script uses.  Typically "dbg."
ReleaseAreaPath value used in release build.  Must match the build - script.  Typically "rel."
AlwaysTagString in file entries which will always be changed to either - DebugArea or ReleaseArea. File is always copied.  Typically "%bldtype%."
DebugTagString in file entries which will only be changed to DebugArea during a debug - build.  File is only copied in a debug build.  Typically "%debug%."
ReleaseTagString in file entries which will only be changed to ReleaseArea during a - release build.  File is only copied in a release build.  Typically - "%release%."
FileStem%filestem% will always be changed to FileStem.  Example:  - "kfw-3-2-0."  This is used in when building or copying the final build - results.
-

-

Example

-

Each segment of the file's path that comes from a different place is in a - different color.

-

- Release build.  Config file: -

-

- - - - - - - - - - - - - - - - - - - -
<BKW_Config>
<CommandLine>
<Directories>
<src path ="C:\projects\Autobuild" - /> -
-

-

Copylist comments:

-

- <!-- File from paths are relative to - \pismere\athena --> -
- <!-- File to paths are relative to \pismere\staging - --> -

-

When the script processes this copylist, it will force the from and to paths as - indicated.

-

This line -

-

<File name="comerr32.dll" from="..\target\bin\i386\%bldtype%\" - to="\bin\i386" />

-

will result in C:\projects\Autobuild\pismere\athena\..\target\bin\i386\rel\comerr32.dll

-

being copied to C:\projects\Autobuild\pismere\staging\bin\i386\comerr32.dll.

- -

- Other possible attributes in a copylist entry:

-
    -
  • - notrequired -
  • - newname="filename" -
  • -
-

By default, copylist entries are required and the script will die if they aren't - present. To ignore missing files, add notrequired.

-

To rename the file, set the newname attribute.

-

Lengthy copy lists can be kept in separate files and included with the Include - directive.  Example:

-

<Include path="sdkfiles.xml" />

-

Remaining work / bug list

-

This is a work in progress. What's left:

-

Bugs:

-
    -
  • - Eliminate need for redundant /debug debug. -
  • - Handle checkout into non-existant directory. -
  • -
-

Troubleshooting -

-

svn can't create tunnel:
-
Make sure environment variable SVN_SSH points to a valid - plink.exe.  Path separators must be backslashes and must be doubled.

- -
- + + lore-bkw-automation - Confluence + + + + + + + +
+
The + Kerberos for Windows (KfW) build is automated.  A script will fetch the + sources from a repository and then build, sign and package all the KfW + distribution components. +
+
This + description consists of +
+ +

Setting Up the Build Environment

+

KfW is built on a Windows PC, in the default Windows shell (cmd.exe). These + components must be installed:

+
    +
  • + Visual Studio 2003
    + Versions of Visual Studio before or after 2003 are not supported. +
  • + A recent release of the + + + Microsoft Platform SDK +   +
  • + + + ActiveState Perl 5.8 or more recent
    + Build 631 is known to work. +
  • + + + Doxygen +
  • + sed, awk, cat, rm and find
    + These can be obtained from the + + Cygwin + distribution. +
    +
    + find must be in C:\tools\cygwin\bin, so install Cygwin in C:\tools\cygwin. +
    +
    + The cygwin awk is a link and the MS shell doesn't deal well with that.  C + opy c:\tools\cygwin\bin\gawk to c:\tools\cygwin\bin\awk. +
  • + + Wix +
  • + + + NSIS
+

Environment variables

+

+ All the components above must be in PATH. Installing ActivePerl puts perl in + the PATH. Doxygen, Cygwin, hhc, wix and nsis need to be added.

+

perl must be installed so that .pl files are automatically executed with perl. + The ActivePerl installation will do this for you.

+

In the INCLUDE path, the Microsoft Platform SDK must come before the Microsoft + Visual C++ include files. Using a Platform SDK Build Environment window will + set this up the right way. 

+

If you make your path modifications permanent via Control Panel / System / + Advanced / Environment Variables:  If you use a Platform SDK Build + Environment window, it appears that you need to put your PATH components in the + System PATH, not the User PATH.

+

Visual Studio installs hhc in C:\Program Files\HTML Help Workshop.

+

nmake must be in PATH. If you use a Platform SDK build environment window, it is + already done for you.

+

Running the Script

+

+ The build is a perl script controlled by command line switches and an XML + configuration file. The config file is required. Settings in the config file + can be overridden by optional command line switches. 

+

There are options for controlling most steps of the build process.  The + steps are

+
    +
  • + Verifying the environment +
  • + Fetching the sources from repositories +
  • + Building the sources +
  • + Setting up the packaging environment +
  • + Building the installers +
  • + Building the rest of the components +
  • +
+

The usage message shows the switches that control these steps:

+

C:\Projects\KfW>perl bkw.pl /?
+ Usage: bkw.pl [options] NMAKE-options

+

  Options are case insensitive. +

+

  Options:  +
+
  /help /?          + usage information (what you now see). +
+   /config /f path   Path to config file. Default is + bkwconfig.xml. +
+   /src /r dir       Source directory to use. + Should contain +
+     +                 + pismere/athena. If cvstag or svntag is null, +
+       +               + the directory should be prepopulated. +
+   /out /o dir       Directory to be created + where build results will go +
+
  /repository checkout | co \ What repository action to take. +
+               + update   | up  ) Options are to checkout, update or +
+               + skip          / take no + action [skip]. +
+   /username /u name username used to access svn if checking out. +
+   /cvstag /c tag    use -r <tag> + in cvs +command
  /svnbranch /b tag use +/branches/<tag> instead of /trunk.
  /svntag /s tag    use +/tags/<tag> instead of /trunk.
  /debug +/d         Do debug make instead of +release make.
  +/[no]make         +Control the make +step.
  +/clean            Build +clean target.
  +/[no]package      Control the packaging step.
  +/[no]sign         Control +signinf +of executable files.
  /verbose +/v       Debug mode - verbose output.
  /logfile /l path  Where to write output. +Default is bkw.pl.log.
  + /nolog            Don't + save output.
+

+

  Other: +
+     NMAKE-options any options you want to pass to NMAKE, which + can be: +
+                   + (note: /nologo is always used)
+                   NODEBUG=1

+

NMAKE-options any options you want to pass to NMAKE, which can be:
+ (note: /nologo is always used)
+ [ nmake options follow ]

+


+ Notes on the script steps:

+

Verifying the environment:  +
+ The script tests for each program that it needs and warns if the program isn't + found.

+

Fetching sources from repositories:  +
+ If building from a source distribution kit, this section does not apply.

+

CVSROOT and SVNURL must be specified in the configuration file.

+

A source zip file can only be produced if checking out fresh sources from a + repository. 

+

If checking out, the entire pismere directory will be deleted.  A warning + message requires that you confirm this action.

+

Building the sources:
+ /DEBUG controls whether a debug or release build is done.  /CLEAN will + build the CLEAN target.

+

Setting up the packaging environment :
+
The pre-package steps gathers up build results and puts them in a + staging area.  +

+

If /SIGN is specified, .exes, .dlls + and .cpls are signed.  The signing command + template is in the configuration file.

+

Building the installers:
+ The staging area is copied into a fresh area for + each of the installers.  The installer results are copied back to the + staging area.

+

Building the rest of the components:
+ Zip files are built in temporary areas and copied to outdir.  + The installers and assorted files are copied from staging + to outdir.  If /SIGN is specified, the + installers will be signed.

+

 

+

Script Internal Details

+

Copy Lists

+

CopyLists are used in many places.  For example, files to be put into + a .zip are copied to a fresh directory which is then zipped up.  There is + an optional Configuration section and a required Files section. 

+

The configuration section defines the roots of the from and to paths and can + optionally define path substitutions.  +

+

The to and from paths are forced by the script rather than being set in the + config file.  Comments in the copyfile xml indicate this.

+

Lengthy copy lists can be kept in separate files and included with the Include + directive.  Example:

+

<Include path="sdkfiles.xml" />

+

Substitution tags

+

Filenames in copylists can contain variable 'tags' that are replaced before the + file is copied.  Some configuration files contain substitution tags which + customize the configuration.  The supported tags are

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
%VERSION_MAJOR%KfW Version from pismere/athena/include/kerberos.ver.
%VERSION_MINOR%KfW Version from pismere/athena/include/kerberos.ver.
%VERSION_PATCH%KfW Version from pismere/athena/include/kerberos.ver.
%filestem%Defined as kfw-%VERSION_MAJOR%-%VERSION_MINOR%-%VERSION_PATCH%.
%debug%'dbg.'  Only substituted during a debug build. 
%release%'rel.'  Only substituted during a release build.  +
%bldtype%Always substituted, to 'dbg' or 'rel,' depending on the type of build.
%-DEBUG%'-DEBUG' during a debug build; otherwise empty.
%BUILDDIR%SRCDIR\pismere.  Used in site-local installer configuration files.
%TARGETDIR%SRCDIR\pismere\staging.  Used in site-local installer configuration files.
%CONFIGDIR-WIX%SRCDIR\pismere\staging\sample.  Used in site-local installer configuration + files.
%CONFIGDIR-NSI%SRCDIR\pismere\staging.  Used in site-local installer configuration files.
+

+

The overall build configuration specifies a debug or release build.  Debug + and release results are put in different places.  Files whose location + depend on the build type can use %bldtype% in their names.  The script + will substitute %bldtype% with either dbg or rel, depending on the build + type. 

+
+
+

Example

+
+

Here is a copylist entry.  Each segment of the file's path that comes + from a different place is in a different color.

+

Release build.  Config file: +

+

+ + + + + + + + + + + + + + + + + + + +
<BKW_Config>
<CommandLine>
<Directories>
<src path ="C:\bkw" /> +
+

+

Copylist comments:

+

<!-- File from paths are relative to + \pismere\athena -->
<!-- File to paths are relative to \ + pismere\staging + -->
+

+

When the script processes this copylist, it will force the from and to paths as + indicated.

+

This line +

+

<File name="comerr32.dll" from="..\target\bin\i386\%bldtype%\" + to="\bin\i386" />

+

will result in C:\bkw\pismere\athena\..\target\bin\i386\rel\comerr32.dll

+

being copied to C:\bkw\pismere\staging\bin\i386\comerr32.dll.

+

Other possible attributes in a copylist entry:

+
    +
  • + notrequired +
  • + newname="filename" +
  • +
+

By default, copylist entries are required and the script will die if they aren't + present. To ignore missing files, add notrequired.

+

To rename the file, set the newname attribute.

+

Remaining Work / Bug List

+

Implement RETAIL, OFFICIAL, PRERELEASE, PRIVATE, SPECIAL.

+

Figure out what MIT_ONLY, BUILD_KFW, DEBUG_SYMBOL should be.

+

TARGET, APPVER.

+

NODEBUG=1.  Set if release build.

+

Troubleshooting +

+

Can't clean directory; can't delete file or directory
+ Make sure a file in the named directory isn't open in another application.

+
+ diff --git a/src/windows/build/bkw.pl b/src/windows/build/bkw.pl index 2f7c6be13..ea7c192ac 100644 --- a/src/windows/build/bkw.pl +++ b/src/windows/build/bkw.pl @@ -34,13 +34,13 @@ sub get_info { sub usage { print < in cvs command - /svnbranch /b tag append /branches/ to svn path. - /svntag /s tag append /tags/ to svn path. + /svnbranch /b tag use /branches/ instead of /trunk. + /svntag /s tag use /tags/ instead of /trunk. /debug /d Do debug make instead of release make. - /nomake Skip make step. + /[no]make Control the make step. /clean Build clean target. - /nopackage Skip packaging step. - /sign Sign files - /nosign Don't sign files + /[no]package Control the packaging step. + /[no]sign Control signing of executable files. /verbose /v Debug mode - verbose output. - /logfile /l path Where to write output. Default is bkw.pl.log - /nolog Don't save output + /logfile /l path Where to write output. Default is bkw.pl.log. + /nolog Don't save output. Other: NMAKE-options any options you want to pass to NMAKE, which can be: (note: /nologo is always used) @@ -82,6 +81,9 @@ EOH } sub main { + local $cmdline = "bkw.pl"; + foreach $arg (@ARGV) {$cmdline .= " $arg";} + Getopt::Long::Configure('no_bundling', 'no_auto_abbrev', 'no_getopt_compat', 'require_order', 'ignore_case', 'pass_through', @@ -92,21 +94,21 @@ sub main { 'cvstag|c:s', 'svntag|s:s', 'svnbranch|b:s', - 'srcdir|r:s', - 'outdir|o:s', + 'src|r:s', + 'out|o:s', 'debug|d', - 'config|f:s', + 'nodebug', + 'config|f=s', 'logfile|l:s', 'nolog', 'repository:s', 'username|u:s', 'verbose|v', 'vverbose', - 'nomake', + 'make!', 'clean', - 'nopackage', - 'sign', - 'nosign', + 'package!', + 'sign!', ); if ( $OPT->{help} ) { @@ -114,17 +116,22 @@ sub main { exit(0); } + delete $OPT->{foo}; + ##++ Validate required conditions: - if ($OPT->{config}) {} - else { - print "Fatal -- Configuration file must be specified.\n"; + local $argvsize = @ARGV; + if ($argvsize > 0) { + print "Error -- invalid argument: $ARGV[0]\n"; usage(); - exit(0); + die; } + + if (! exists $OPT->{config}) {$OPT->{config} = "bkwconfig.xml";} # 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 @required_list = ('sed', 'awk', 'which', 'cat', 'rm', 'cvs', 'svn', 'doxygen', + 'hhc', 'candle', 'light', 'makensis', 'nmake', 'plink', 'filever'); my $requirements_met = 1; my $first_missing = 0; my $error_list = ""; @@ -161,66 +168,78 @@ sub main { # Get configuration file: my $xml = new XML::Simple(); $config = $xml->XMLin($configfile); - # Set up convenience variables: - my (@switches, @paths, @tags, @fetch); - @switches = $config->{CommandLine}->{Options}; - @paths = $config->{CommandLine}->{Directories}; - @tags = $config->{CommandLine}->{Tags}; - @fetch = $config->{Stages}->{FetchSources}->{Config}; - - # Update the configuration with overrides from the command line: - $tags[0]->{cvs}->{value} = $OPT->{cvstag} if exists $OPT->{cvstag}; - $tags[0]->{svntag}->{value} = $OPT->{svntag} if exists $OPT->{svntag}; - $tags[0]->{svnbranch}->{value} = $OPT->{svnbranch} if exists $OPT->{svnbranch}; - $paths[0]->{src}->{path} = $OPT->{srcdir} if exists $OPT->{srcdir}; - $paths[0]->{out}->{path} = $OPT->{outdir} if exists $OPT->{outdir}; - $switches[0]->{debug}->{value} = $OPT->{debug} if exists $OPT->{debug}; - $switches[0]->{clean}->{value} = 1 if exists $OPT->{clean}; - $switches[0]->{repository}->{value} = $OPT->{repository} if exists $OPT->{repository}; - $fetch[0]->{USERNAME}->{name} = $OPT->{username} if exists $OPT->{username}; - $switches[0]->{nomake}->{value} = 1 if exists $OPT->{nomake}; - $switches[0]->{nopackage}->{value} = 1 if exists $OPT->{nopackage}; - $switches[0]->{verbose}->{value} = $OPT->{verbose} if exists $OPT->{verbose}; - $switches[0]->{vverbose}->{value} = $OPT->{verbose} if exists $OPT->{vverbose}; - if (exists $OPT->{logfile}) { - $switches[0]->{logfile}->{path} = $OPT->{logfile}; - $switches[0]->{logfile}->{value} = 1; - } - if (exists $OPT->{nolog}) { - $switches[0]->{logfile}->{value} = 0; - } - if (exists $OPT->{sign}) { - $switches[0]->{sign}->{timestampserver} = $OPT->{sign}; - $switches[0]->{sign}->{value} = 1; - } - if (exists $OPT->{nosign}) { - $switches[0]->{sign}->{value} = 0; + local $odr = $config->{Config}; ## Options, directories, repository, environment. + +#while ($v = each %$OPT) {print "$v: $OPT->{$v}\n";} + + # Scan the configuration for switch definitions: + while (($sw, $val) = each %$odr) { + next if (! exists $val->{def}); ## ?? Should always exist. + # If the switch is in the command line, override the stored value: + if (exists $OPT->{$sw}) { + if (exists $val->{value}) { + $val->{value} = $OPT->{$sw}; + $val->{def} = 1; + } + else { + $val->{def} = $OPT->{$sw}; ## If no, value will be zero. + } + } + # If the switch can be negated, test that, too: + if ( ! ($val->{def} =~ /A/)) { + local $nosw = "no".$sw; + if (exists $OPT->{$nosw}) { + $val->{def} = 0; + } + } + + # For any switch definition with fixed values ("options"), validate: + if (exists $val->{options}) { + local $bValid = 0; + # options can be like value1|syn1 value2|syn2|syn3 + foreach $option (split(/ /, $val->{options})) { + local $bFirst = 1; + local $sFirst; + foreach $opt (split(/\|/, $option)) { + # opt will be like value2, syn2, syn3 + if ($bFirst) { + $sFirst = $opt; ## Remember the full name of the option. + $bFirst = 0; + } + if ($val->{value} =~ /$opt/i) { + $val->{value} = $sFirst; ## Save the full name. + $bValid = 1; + } + } + } + if (! $bValid) { + print "Fatal -- invalid $sw value $val->{value}. Possible values are $val->{options}.\n"; + usage(); + die; + } + } } - our $verbose = $config->{CommandLine}->{Options}->{verbose}->{value}; - our $vverbose = $config->{CommandLine}->{Options}->{vverbose}->{value}; - our $clean = $switches[0]->{clean}->{value}; - local $src = $paths[0]->{src}->{path}; - local $out = $paths[0]->{out}->{path}; - if ($clean && !$switches[0]->{nopackage}->{value}) { + # Set up convenience variables: + our $verbose = $odr->{verbose}->{def}; + our $vverbose = $odr->{vverbose}->{def}; + our $clean = $clean->{clean}->{def}; + local $src = $odr->{src}->{value}; + local $out = $odr->{out}->{value}; + + if ($clean && $odr->{package}->{def}) { print "Info -- /clean forces /nopackage.\n"; - $switches[0]->{nopackage}->{value} = 1; + $odr->{package}->{def} = 0; } if ($vverbose) {print "Debug -- Config: ".Dumper($config);} - # Examples of use: - #print "Logfile path: $switches[0]->{log}->{path}\n"; - #print "src path: $paths[0]->{src}->{path}\n"; - #print "cvs tag: $tags[0]->{cvs}->{value}\n"; - #print "CVSROOT: $fetch[0]->{CVSROOT}->{name}\n"; - # Test the unix find command: - if (! exists $config->{CommandLine}->{Directories}->{unixfind}->{path}) { - $config->{CommandLine}->{Directories}->{unixfind}->{path} = "C:\\tools\\cygwin\\bin"; + if (! exists $odr->{unixfind}->{value}) { + $odr->{unixfind}->{value} = "C:\\tools\\cygwin\\bin"; } - local $unixfind = $config->{CommandLine}->{Directories}->{unixfind}->{path}; + local $unixfind = $odr->{unixfind}->{value}; local $savedPATH = $ENV{PATH}; $ENV{PATH} = $unixfind.";".$savedPATH; @@ -234,38 +253,25 @@ sub main { } # Don't allow /svntag and /svnbranch simultaneously: - if ( (length $tags[0]->{svntag}->{value} > 0) && - (length $tags[0]->{svnbranch}->{value} > 0) ) { + if ( (length $odr->{svntag}->{value} > 0) && + (length $odr->{svnbranch}->{value} > 0) ) { die "Fatal -- Can't specify both /SVNTAG and /SVNBRANCH."; } ##-- Assemble configuration from config file and command line. - my $sw = $switches[0]->{repository}->{value}; - my $rverb; - if ($sw =~ /skip/i) {$rverb = "skip";} - elsif ($sw =~ /update/i) {$rverb = "update";} - elsif ($sw =~ /up/i) {$rverb = "update";} - elsif ($sw =~ /checkout/i) {$rverb = "checkout";} - elsif ($sw =~ /co/i) {$rverb = "checkout";} - else { - print "Fatal -- invalid /repository value.\n"; - usage(); - die; - } - $switches[0]->{repository}->{value} = $rverb; ## Save canonicalized repository verb. - + local $rverb = $odr->{repository}->{value}; 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; + $clean = $odr->{clean}->{def} = 0; } my $wd = $src."\\pismere"; if (! ($rverb =~ /skip/)) { local $len = 0; - if (exists $fetch[0]->{USERNAME}->{name}) { - $len = length $fetch[0]->{USERNAME}->{name}; + if (exists $odr->{USERNAME}->{value}) { + $len = length $odr->{USERNAME}->{value}; } if ($len < 1) { die "Fatal -- you won't get far accessing the repository without specifying a username."; @@ -285,13 +291,15 @@ sub main { # Begin logging: my $l; - if ($switches[0]->{logfile}->{value}) { - print "Info -- logging to $switches[0]->{logfile}->{path}.\n"; - $l = new Logger $switches[0]->{logfile}->{path}; + if ($odr->{logfile}->{def}) { + print "Info -- logging to $odr->{logfile}->{value}.\n"; + $l = new Logger $odr->{logfile}->{value}; $l->start; $l->no_die_handler; ## Needed so XML::Simple won't throw exceptions. } + print "Executing $cmdline\n"; + ##++ Begin repository action: if ($rverb =~ /skip/) {print "Info -- *** Skipping repository access.\n" if ($verbose);} else { @@ -305,12 +313,12 @@ sub main { } # Set up cvs environment variables: - $ENV{CVSROOT} = $fetch[0]->{CVSROOT}->{name}; + $ENV{CVSROOT} = $odr->{CVSROOT}->{value}; local $krb5dir = "$wd\\athena\\auth\\krb5"; local $cvscmdroot = "cvs $rverb"; - if (length $tags[0]->{cvs}->{value} > 0) { - $cvscmdroot .= " -r $tags[0]->{cvs}->{value}"; + if (length $odr->{cvstag}->{value} > 0) { + $cvscmdroot .= " -r $odr->{cvstag}->{value}"; } if ($rverb =~ /checkout/) { @@ -351,12 +359,12 @@ sub main { my $svncmd = "svn $rverb "; if ($rverb =~ /checkout/) { # Append the rest of the checkout command: chdir(".."); - $svncmd .= "svn+ssh://".$fetch[0]->{USERNAME}->{name}."@".$fetch[0]->{SVNURL}->{name}."/krb5/"; - if (length $tags[0]->{svntag}->{value} > 0) { - $svncmd .= "tags/$tags[0]->{svntag}->{value}"; + $svncmd .= "svn+ssh://".$odr->{USERNAME}->{value}."@".$odr->{SVNURL}->{value}."/krb5/"; + if (length $odr->{svntag}->{value} > 0) { + $svncmd .= "tags/$odr->{svntag}->{value}"; } - elsif (length $tags[0]->{svnbranch}->{value} > 0) { - $svncmd .= "branches/$tags[0]->{svnbranch}->{value}"; + elsif (length $odr->{svnbranch}->{value} > 0) { + $svncmd .= "branches/$odr->{svnbranch}->{value}"; } else { $svncmd .= "trunk"; @@ -442,7 +450,7 @@ sub main { ##-- End repository action, part 2. ##++ Make action: - if ( (!$switches[0]->{nomake}->{value}) ) { + if ( ($odr->{make}->{def}) ) { if ($verbose) {print "Info -- *** Begin preparing for build.\n";} chdir("$wd") or die "Fatal -- couldn't chdir to $wd\n"; @@ -482,8 +490,8 @@ sub main { chdir("$wd\\athena") or die "Fatal -- couldn't chdir to source directory $wd\\athena\n"; print "Info -- chdir to ".`cd`."\n" if ($verbose); - local $dbgswitch = ($switches[0]->{debug}->{value}) ? " " : "NODEBUG=1"; - !system("perl ../scripts/build.pl --softdirs --nolog $buildtarget $dbgswitch") or die "Fatal -- build $buildtarget failed."; + local $dbgswitch = ($odr->{debug}->{def}) ? " " : "NODEBUG=1"; + !system("perl ../scripts/build.pl --softdirs --nolog $buildtarget $dbgswitch BUILD_OFFICIAL=1") or die "Fatal -- build $buildtarget failed."; chdir("$wd") or die "Fatal -- couldn't chdir to $wd."; if ($clean) { @@ -498,7 +506,7 @@ sub main { ##-- Make action. ##++ Package action: - if ($switches[0]->{nopackage}->{value}) { ## If /clean, nopackage will be set. + if (! $odr->{package}->{def}) { ## 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"; @@ -534,7 +542,7 @@ sub main { # Sign files: chdir($staging) or die "Fatal -- couldn't chdir to $staging\n"; print "Info -- chdir to ".`cd`."\n" if ($verbose); - if ($switches[0]->{sign}->{value}) { + if ($odr->{sign}->{def}) { signFiles($config->{Stages}->{PostPackage}->{Config}->{Signing}, $config); } @@ -576,7 +584,7 @@ sub main { !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 + if ($odr->{debug}->{def}) { ## debug build !system("echo !define DEBUG >> b.tmp") or die "Fatal -- Couldn't modify b.tmp."; } else { ## release build @@ -632,7 +640,7 @@ sub main { copyFiles($config->{Stages}->{PostPackage}->{CopyList}, $config); ## Copy any files print "Info -- chdir to ".`cd`."\n" if ($verbose); - if ($switches[0]->{sign}->{value}) { + if ($odr->{sign}->{def}) { signFiles($config->{Stages}->{PostPackage}->{Config}->{Signing}, $config); } @@ -645,7 +653,7 @@ sub main { system("rm -rf $out/ziptemp"); ## Clean up junk. # End logging: - if ($switches[0]->{logfile}->{value}) {$l->stop;} + if ($odr->{logfile}->{def}) {$l->stop;} return 0; } ## End subroutine main. diff --git a/src/windows/build/copyfiles.pl b/src/windows/build/copyfiles.pl index 9160db07b..79b6e156b 100644 --- a/src/windows/build/copyfiles.pl +++ b/src/windows/build/copyfiles.pl @@ -6,7 +6,7 @@ use Data::Dumper; sub copyFiles { local ($xml, $config) = @_; - local @switches = $config->{CommandLine}->{Options}; + local @odr = $config->{Config}; local @files = $xml->{Files}; # Check for includes: if (exists $xml->{Files}->{Include}->{path}) { @@ -38,7 +38,7 @@ sub copyFiles { my $bPathTags = (exists $xml->{Config}->{DebugArea}) && (exists $xml->{Config}->{ReleaseArea}); my $bFileStem = (exists $xml->{Config}->{FileStem}); - if ($switches[0]->{debug}->{value}) { ## Debug build tags: + if ($odr->{debug}->{def}) { ## Debug build tags: $PathFragment = $xml->{Config}->{DebugArea}->{value}; $BuildDependentTag = $xml->{Config}->{DebugTag}->{value}; $IgnoreTag = $xml->{Config}->{ReleaseTag}->{value}; @@ -84,7 +84,7 @@ sub copyFiles { $to =~ s/%filestem%/$FileStemFragment/g; } # %-DEBUG% substitution: - local $DebugFragment = ($switches[0]->{debug}->{value}) ? "-DEBUG" : ""; + local $DebugFragment = ($odr->{debug}->{def}) ? "-DEBUG" : ""; $from =~ s/%\-DEBUG%/$DebugFragment/g; $to =~ s/%\-DEBUG%/$DebugFragment/g; $to =~ s/\*.*//; ## Truncate to path before any wildcard diff --git a/src/windows/build/makeZip.pl b/src/windows/build/makeZip.pl index 12215ddcd..1a1b533c3 100644 --- a/src/windows/build/makeZip.pl +++ b/src/windows/build/makeZip.pl @@ -9,15 +9,15 @@ use Data::Dumper; sub makeZip { local ($zip, $config) = @_; - local $src = $config->{CommandLine}->{Directories}->{src}->{path}; - local $out = $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; + local $odr = $config->{Config}; ## Options, directories, repository, environment. + local $src = $odr->{src}->{value}; + local $out = $odr->{out}->{value}; + 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 $rverb = $odr->{repository}->{value}; local $j = 0; while ($zip->{Requires}->{Switch}[$j]) { ## Check Require switches local $switch = $zip->{Requires}->{Switch}[$j]; diff --git a/src/windows/build/pruneFiles.pl b/src/windows/build/pruneFiles.pl index 2406c770e..a62da536e 100644 --- a/src/windows/build/pruneFiles.pl +++ b/src/windows/build/pruneFiles.pl @@ -10,7 +10,7 @@ sub pruneFiles { # 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; + $ENV{PATH} = $config->{Config}->{Directories}->{unixfind}->{path}.";".$savedPATH; local $j=0; print "Info -- Processing prunes in ".`cd`."\n" if ($verbose); while ($prunes->{Prune}->[$j]) { diff --git a/src/windows/build/signFiles.pl b/src/windows/build/signFiles.pl index d2ffb2c0e..65ccb0a11 100644 --- a/src/windows/build/signFiles.pl +++ b/src/windows/build/signFiles.pl @@ -9,7 +9,7 @@ sub signFiles { local $template = $signing->{CommandTemplate}->{value}; # 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; + $ENV{PATH} = $config->{Config}->{unixfind}->{value}.";".$savedPATH; foreach $expr (split(" ", $exprs)) { ## exprs is something like "*.exe *.dll" local $cmd = "find . -iname \"$expr\""; local $list = `$cmd`; ## $list is files matching *.exe, for example. -- 2.26.2