Subversion Repositories DevTools

Rev

Rev 5550 | Rev 5582 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5550 Rev 5578
Line 72... Line 72...
72
my $PKG_BASE;
72
my $PKG_BASE;
73
my $bad_merge_count = 0;
73
my $bad_merge_count = 0;
74
my @bad_symlinks;
74
my @bad_symlinks;
75
my @fileList;
75
my @fileList;
76
my $descPkgCount = 0;
76
my $descPkgCount = 0;
-
 
77
my @tmpFiles;
77
 
78
 
78
#
79
#
79
#   Option variables
80
#   Option variables
80
#
81
#
81
my $opt_help = 0;
82
my $opt_help = 0;
Line 94... Line 95...
94
my $opt_outfile;
95
my $opt_outfile;
95
my $opt_info;
96
my $opt_info;
96
my $opt_tarmode;
97
my $opt_tarmode;
97
my $opt_testArchive;
98
my $opt_testArchive;
98
my $opt_noBuild;
99
my $opt_noBuild;
-
 
100
my $opt_keepTemp;
99
 
101
 
100
 
102
 
101
#
103
#
102
#   Structure to translate -archive=xxx option to archive variable
104
#   Structure to translate -archive=xxx option to archive variable
103
#   These are the various dpkg_archives known to JATS
105
#   These are the various dpkg_archives known to JATS
Line 125... Line 127...
125
#------------------------------------------------------------------------------
127
#------------------------------------------------------------------------------
126
{
128
{
127
    my ($opr, $file) = @_;
129
    my ($opr, $file) = @_;
128
    $file =~ s/\Q$DPKG_ROOT\E/DPKG/;
130
    $file =~ s/\Q$DPKG_ROOT\E/DPKG/;
129
    $file =~ s/\Q$SRC_ROOT\E/PKG/;
131
    $file =~ s/\Q$SRC_ROOT\E/PKG/;
-
 
132
    $file =~ s/\Q$CWD_DIR\E/CWD/;
130
 
133
 
131
    Information (sprintf( "%-15s [%s]", $opr, $file));
134
    Information (sprintf( "%-15s [%s]", $opr, $file));
132
}
135
}
133
 
136
 
134
#-------------------------------------------------------------------------------
137
#-------------------------------------------------------------------------------
Line 217... Line 220...
217
    #       Use lots of attributes and only elements for arrays
220
    #       Use lots of attributes and only elements for arrays
218
    #       Save as one attribute per line - for readability
221
    #       Save as one attribute per line - for readability
219
    #
222
    #
220
    $opt_outfile = $opt_generic ? "built.files.generic.xml" : "built.files.$GBE_HOSTNAME.xml";
223
    $opt_outfile = $opt_generic ? "built.files.generic.xml" : "built.files.$GBE_HOSTNAME.xml";
221
    $opt_outfile = catfile( $targetDir, $opt_outfile); 
224
    $opt_outfile = catfile( $targetDir, $opt_outfile); 
-
 
225
    push @tmpFiles, $opt_outfile;
222
 
226
 
223
    LogFileOp ('Meta File', $opt_outfile);
227
    LogFileOp ('Meta File', $opt_outfile);
224
    my $xs = XML::Simple->new( NoAttr =>0, AttrIndent => 1 );
228
    my $xs = XML::Simple->new( NoAttr =>0, AttrIndent => 1 );
225
 
229
 
226
    open (my $XML, '>', $opt_outfile) || Error ("Cannot create output file: $opt_outfile", $!);
230
    open (my $XML, '>', $opt_outfile) || Error ("Cannot create output file: $opt_outfile", $!);
Line 258... Line 262...
258
                'md5!'          => \$opt_md5,               # [no]flag
262
                'md5!'          => \$opt_md5,               # [no]flag
259
                'info!'         => \$opt_info,              # [no]flag
263
                'info!'         => \$opt_info,              # [no]flag
260
                'tarmode!'      => \$opt_tarmode,           # [no]flag
264
                'tarmode!'      => \$opt_tarmode,           # [no]flag
261
                'testArchive'   => \$opt_testArchive,       # [no]flag
265
                'testArchive'   => \$opt_testArchive,       # [no]flag
262
                'nobuild'       => \$opt_noBuild,           # flag
266
                'nobuild'       => \$opt_noBuild,           # flag
-
 
267
                'keepTemp'      => \$opt_keepTemp,          # flag
263
                );
268
                );
264
 
269
 
265
 
270
 
266
    #
271
    #
267
    #   Process help and manual options
272
    #   Process help and manual options
Line 288... Line 293...
288
    #
293
    #
289
    EnvImport ('GBE_MACHTYPE');
294
    EnvImport ('GBE_MACHTYPE');
290
    EnvImport ('GBE_HOSTNAME');
295
    EnvImport ('GBE_HOSTNAME');
291
    EnvImport ('USER' );
296
    EnvImport ('USER' );
292
    EnvImportOptional ('GBE_ABT', "");
297
    EnvImportOptional ('GBE_ABT', "");
-
 
298
    $CWD_DIR = catdir($CWD_DIR);
293
 
299
 
294
    #
300
    #
295
    #   Determine the target archive
301
    #   Determine the target archive
296
    #   The default archive is GBE_DPKG, but this may be changed
302
    #   The default archive is GBE_DPKG, but this may be changed
297
    #
303
    #
Line 531... Line 537...
531
    #   from such an environment is certainly not reproducible - so don't allow
537
    #   from such an environment is certainly not reproducible - so don't allow
532
    #   it to happen
538
    #   it to happen
533
    #
539
    #
534
    #   Allow versions of 99.99.99 as these are known to be test versions
540
    #   Allow versions of 99.99.99 as these are known to be test versions
535
    #
541
    #
536
    unless ( $opt_archive eq 'local' || $opt_archive eq 'sandbox' )
542
    unless ( $opt_archive eq 'local' || $opt_archive eq 'sandbox' || $opt_testArchive)
537
    {
543
    {
538
        if ( $ENV{GBE_DPKG_SBOX} )
544
        if ( $ENV{GBE_DPKG_SBOX} )
539
        {
545
        {
540
            unless ( $DPKG_VERSION =~ /^99.99.99/ )
546
            unless ( $DPKG_VERSION =~ /^99.99.99/ )
541
            {
547
            {
Line 944... Line 950...
944
    Information("");
950
    Information("");
945
    InitFileUtils();
951
    InitFileUtils();
946
 
952
 
947
 
953
 
948
    #
954
    #
949
    #   Locate the tar utility
-
 
950
    #   Use gtar if its available otherwise use tar
-
 
951
    #   
-
 
952
    my $tarProg = LocateProgInPath('gtar', '--All');
-
 
953
    $tarProg = LocateProgInPath('tar', '--All') unless $tarProg;
-
 
954
    Error ("Tar utility not found in path") unless $tarProg;
-
 
955
 
-
 
956
    #
-
 
957
    #   If a 'noBuild' then create a dummy package directory simply
955
    #   If a 'noBuild' then create a dummy package directory simply
958
    #   to contain the metadata. 
956
    #   to contain the metadata. 
959
    #   Delete any existing dir of the same name to ensure its clean.
957
    #   Delete any existing dir of the same name to ensure its clean.
960
    #
958
    #
961
    if ( $SRC_ROOT eq '' )
959
    if ( $SRC_ROOT eq '' )
Line 1000... Line 998...
1000
    #   Create the target path in the target archive
998
    #   Create the target path in the target archive
1001
    #
999
    #
1002
    LogFileOp ('Creating', $DPKG_DIR);
1000
    LogFileOp ('Creating', $DPKG_DIR);
1003
    mkpath($DPKG_DIR, 0, 0775);
1001
    mkpath($DPKG_DIR, 0, 0775);
1004
 
1002
 
1005
 
-
 
1006
    #
1003
    #
-
 
1004
    #   Create a tar.gz file an transfer to the final location
-
 
1005
    #
-
 
1006
    #   Have failed to find a nice windows utility to create a tar.gz
1007
    #   Create the TAR file
1007
    #       bsdtar - crashed under server 2003
1008
    #   Use gzip compression (tar.gz) as it provides a good compromise bewteen speed and size
1008
    #       cygwin - design decision. JATS will not include cygwin
1009
    #
1009
    #
1010
    my $tarTarget = join('_', $DPKG_NAME, $DPKG_VERSION, $GBE_HOSTNAME) . '.tar.gz';
1010
    my $tarTarget = join('_', $DPKG_NAME, $DPKG_VERSION, $GBE_HOSTNAME) . '.tar.gz';
1011
    my $tarPath = catfile($DPKG_DIR, $tarTarget);
1011
    my $tarPath = catfile($DPKG_DIR, $tarTarget);
-
 
1012
    $FileUtils::isUnix ? createUnixTar($tarPath) : createWindowsTar($tarPath); 
-
 
1013
}
-
 
1014
 
-
 
1015
#-------------------------------------------------------------------------------
-
 
1016
# Function        : createUnixTar  
-
 
1017
#
-
 
1018
# Description     : Create a tar.gz file under unix
-
 
1019
#
-
 
1020
# Inputs          : $tarPath    - Place tarfile here 
-
 
1021
#                   $SRC_ROOT   - Directory to tar
-
 
1022
#
-
 
1023
# Returns         : Will not return on error
-
 
1024
#
-
 
1025
sub createUnixTar
-
 
1026
{
-
 
1027
    my ($tarPath) = @_;
-
 
1028
 
-
 
1029
    #
-
 
1030
    #   Locate the tar utility
-
 
1031
    #   Use gtar if its available otherwise use tar
-
 
1032
    #   
-
 
1033
    my $tarProg = LocateProgInPath('gtar', '--All');
-
 
1034
    $tarProg = LocateProgInPath('tar', '--All') unless $tarProg;
-
 
1035
    Error ("Tar utility not found in path") unless $tarProg;
-
 
1036
 
-
 
1037
    #
-
 
1038
    #   Tar and gzip file directly into the final location
1012
    LogFileOp ('TarZip', $tarPath);
1039
    LogFileOp ('TarZip', $tarPath);
1013
    my @tarArgs;
1040
    my @tarArgs;
1014
    push @tarArgs, '-v' if IsVerbose(1);
1041
    push @tarArgs, '-v' if IsVerbose(1);
1015
    my $rv = System ('--NoShell', '--NoExit',$tarProg, @tarArgs, '-czf', $tarPath, '-C', $SRC_ROOT, '.' );
1042
    my $rv = System ('--NoShell', '--NoExit',$tarProg, @tarArgs, '-czf', $tarPath, '-C', $SRC_ROOT, '.' );
1016
    if ($rv)
1043
    if ($rv)
1017
    {
1044
    {
1018
        unlink $tarPath;
1045
        push @tmpFiles, $tarPath;
1019
        unlink $opt_outfile; 
-
 
1020
        Error ('Cannot create tarball', "Path:$tarPath");
1046
        Error ('Cannot create tarball', "Path:$tarPath");
1021
    }
1047
    }
-
 
1048
}
1022
 
1049
 
-
 
1050
#-------------------------------------------------------------------------------
-
 
1051
# Function        : createWindowsTar  
-
 
1052
#
-
 
1053
# Description     : Create a tar.gz file under Windows
-
 
1054
#                   Use 7zip (part of JATS)
-
 
1055
#                   7zip cannot do this in one step
-
 
1056
#                       Create tar file
-
 
1057
#                       Create zip file
-
 
1058
#
-
 
1059
# Inputs          : $tarPath    - Place tarfile here 
-
 
1060
#                   $SRC_ROOT   - Directory to tar
-
 
1061
#
-
 
1062
# Returns         : Will not return on error
-
 
1063
#
-
 
1064
sub createWindowsTar
-
 
1065
{
-
 
1066
    my ($tarPath) = @_;
-
 
1067
    my @verboseArgs;
-
 
1068
    my $verboseCopyArg = '9';
-
 
1069
    #
-
 
1070
    #   Ensure that the target file does not exist
-
 
1071
    #   7z cannot ovewrite it
-
 
1072
    #
-
 
1073
    LogFileOp ('Delete', $tarPath);
-
 
1074
    RmDirTree($tarPath) && Error ("Target file cannot be deleted", "Target: $tarPath");
-
 
1075
 
-
 
1076
    #
-
 
1077
    #   Setup NON-verbose arguments for 7zip
-
 
1078
    # 
-
 
1079
    unless (IsVerbose(1)) {
-
 
1080
        @verboseArgs = qw(-bb0 -bso0 -bsp0);
-
 
1081
        $verboseCopyArg = '0';
-
 
1082
    }
-
 
1083
 
-
 
1084
    #
-
 
1085
    #   Create a tar file of the required output
-
 
1086
    #   Create the tar file into a temp file that will be deleted on exit
-
 
1087
    #   
-
 
1088
    my $tmpTarFile = catfile($CWD_DIR, join('_', $DPKG_NAME, $DPKG_VERSION) . '.tar' );
-
 
1089
    Verbose("TempTar: $tmpTarFile");
-
 
1090
    RmDirTree($tmpTarFile) && Error ("Target file cannot be deleted", "Target: $tmpTarFile");
-
 
1091
    push @tmpFiles, $tmpTarFile;
-
 
1092
    LogFileOp ('TempTar', $tmpTarFile);
-
 
1093
 
-
 
1094
    chdir ($SRC_ROOT) || Error ("Cannot change directory: $?", "Dir: $SRC_ROOT");
-
 
1095
    my $rv = System ('--NoShell', '--NoExit','7z.exe', 'a', '-r','-y', @verboseArgs, '-ttar', $tmpTarFile, '.' );
-
 
1096
    if ($rv)
-
 
1097
    {
-
 
1098
        Error ('Cannot create tar file');
-
 
1099
    }
-
 
1100
    chdir ($CWD_DIR) || Error ("Cannot change directory: $?", "Dir: $CWD_DIR");
-
 
1101
 
-
 
1102
    #
-
 
1103
    #   gzip the tar file to a temp (local) location
-
 
1104
    # 
-
 
1105
    my $tmpTarGzFile = catfile($CWD_DIR, join('_', $DPKG_NAME, $DPKG_VERSION) . '.tar.gz' );
-
 
1106
    Verbose("TempTarGz: $tmpTarGzFile");
-
 
1107
    RmDirTree($tmpTarGzFile) && Error ("Target file cannot be deleted", "Target: $tmpTarFile");
-
 
1108
    push @tmpFiles, $tmpTarGzFile;
-
 
1109
    LogFileOp ('TempTarGz', $tmpTarGzFile);
-
 
1110
 
-
 
1111
    $rv = System ('--NoShell', '--NoExit','7z.exe', 'a', '-y', @verboseArgs, '-tgzip', $tmpTarGzFile, $tmpTarFile );
-
 
1112
    if ($rv)
-
 
1113
    {
-
 
1114
        Error ('Cannot gzip tar file');
-
 
1115
    }
-
 
1116
 
-
 
1117
    #
-
 
1118
    #   Copy the file to the target
-
 
1119
    #   Note: Jats internal copy
-
 
1120
    #         Args are strange as it was designed to work with makefile stuff
-
 
1121
    #
-
 
1122
    LogFileOp ('CopyTarZip', $tarPath);
-
 
1123
    $rv = System ('--NoShell', '--NoExit','JatsFileUtil.exe', 'c' . $verboseCopyArg, 'copyFile', $tarPath, $tmpTarGzFile, '+w' );
1023
    return 1;
1124
    if ($rv)
-
 
1125
    {
-
 
1126
        push @tmpFiles, $tarPath;
-
 
1127
        Error ('Cannot transfer tarball', "Path:$tarPath");
-
 
1128
    }
1024
}
1129
}
1025
 
1130
 
-
 
1131
 
1026
#-------------------------------------------------------------------------------
1132
#-------------------------------------------------------------------------------
1027
# Function        : pkgFindTarBall 
1133
# Function        : pkgFindTarBall 
1028
#
1134
#
1029
# Description     : Used by CreateDpkgArchiveTarBall
1135
# Description     : Used by CreateDpkgArchiveTarBall
1030
#                   File::Find processing function
1136
#                   File::Find processing function
Line 1200... Line 1306...
1200
    FileAppend ( $touchfile, $built_info );
1306
    FileAppend ( $touchfile, $built_info );
1201
 
1307
 
1202
    return $touchfile;
1308
    return $touchfile;
1203
}
1309
}
1204
 
1310
 
-
 
1311
#-------------------------------------------------------------------------------
-
 
1312
# Function        : END Block 
-
 
1313
#
-
 
1314
# Description     : Post execution cleanup
-
 
1315
#
-
 
1316
# Inputs          : 
-
 
1317
#
-
 
1318
# Returns         : 
-
 
1319
#
-
 
1320
END
-
 
1321
{
-
 
1322
    #
-
 
1323
    #   Save the programs exit code
-
 
1324
    #   This END block may use the 'system' call and this will clobber the value in $?
-
 
1325
    #   which is the systems exit code
-
 
1326
    #
-
 
1327
    Verbose2("Cleanup processing");
-
 
1328
    local $?;
-
 
1329
 
-
 
1330
    #
-
 
1331
    #   Delete temp files
-
 
1332
    #
-
 
1333
    foreach my $tmpFile ( @tmpFiles)
-
 
1334
    {
-
 
1335
        if ($opt_keepTemp)
-
 
1336
        {
-
 
1337
            Information("Retain Temp file: " . $tmpFile);
-
 
1338
        }
-
 
1339
        else
-
 
1340
        {
-
 
1341
            Verbose ("Delete file: " . $tmpFile);
-
 
1342
            RmDirTree ($tmpFile) && Warning("$tmpFile not deleted");
-
 
1343
        }
-
 
1344
    }
-
 
1345
 
-
 
1346
}
-
 
1347
 
1205
 
1348
 
1206
# ---------------------------------------------------------
1349
# ---------------------------------------------------------
1207
# ---------------------------------------------------------
1350
# ---------------------------------------------------------
1208
# Main
1351
# Main
1209
# ---------------------------------------------------------
1352
# ---------------------------------------------------------
Line 1278... Line 1421...
1278
 
1421
 
1279
  Debug and Testing:
1422
  Debug and Testing:
1280
    -[no]test          - Test package. Do not transfer.
1423
    -[no]test          - Test package. Do not transfer.
1281
    -[no]info          - Display packaging info. Do not transfer.
1424
    -[no]info          - Display packaging info. Do not transfer.
1282
    -[no]testArchive   - Perform operations within a test archive
1425
    -[no]testArchive   - Perform operations within a test archive
-
 
1426
    -keepTemp          - Do not delete temp files
1283
 
1427
 
1284
=head1 OPTIONS
1428
=head1 OPTIONS
1285
 
1429
 
1286
=over 8
1430
=over 8
1287
 
1431
 
Line 1426... Line 1570...
1426
the currently configured dpkg_archive. The test area is a subdirectory 
1570
the currently configured dpkg_archive. The test area is a subdirectory 
1427
called C<.dpkg_archive/test_dpkg>
1571
called C<.dpkg_archive/test_dpkg>
1428
 
1572
 
1429
This option is intended for testing use only.
1573
This option is intended for testing use only.
1430
 
1574
 
-
 
1575
=item B<-keepTemp>
-
 
1576
 
-
 
1577
This option will prevent temp files, created by this utilty, from being deleted when the utilty
-
 
1578
exists.
-
 
1579
 
-
 
1580
This option is intended for testing use only.
-
 
1581
 
1431
=back
1582
=back
1432
 
1583
 
1433
=head1 DESCRIPTION
1584
=head1 DESCRIPTION
1434
 
1585
 
1435
This utility program is used to transfer a package that has been built into
1586
This utility program is used to transfer a package that has been built into