Subversion Repositories DevTools

Rev

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

Rev 6177 Rev 6276
Line 111... Line 111...
111
                   'cache'     => 'GBE_DPKG_CACHE',
111
                   'cache'     => 'GBE_DPKG_CACHE',
112
                   'local'     => 'GBE_DPKG_LOCAL',
112
                   'local'     => 'GBE_DPKG_LOCAL',
113
                   'sandbox'   => 'GBE_DPKG_SBOX',
113
                   'sandbox'   => 'GBE_DPKG_SBOX',
114
                   'deploy'    => 'GBE_DPLY',
114
                   'deploy'    => 'GBE_DPLY',
115
                   'replica'   => 'GBE_DPKG_REPLICA',
115
                   'replica'   => 'GBE_DPKG_REPLICA',
-
 
116
                   'escrow'    => 'GBE_DPKG_ESCROW',
116
                   );
117
                   );
117
 
118
 
118
#------------------------------------------------------------------------------
119
#------------------------------------------------------------------------------
119
#------------------------------------------------------------------------------
120
#------------------------------------------------------------------------------
120
# Subroutines
121
# Subroutines
Line 296... Line 297...
296
    #
297
    #
297
    EnvImport ('GBE_MACHTYPE');
298
    EnvImport ('GBE_MACHTYPE');
298
    EnvImport ('GBE_HOSTNAME');
299
    EnvImport ('GBE_HOSTNAME');
299
    EnvImport ('USER' );
300
    EnvImport ('USER' );
300
    EnvImportOptional ('GBE_ABT', "");
301
    EnvImportOptional ('GBE_ABT', "");
-
 
302
    EnvImportOptional ('GBE_DPKG_ESCROW', "");
301
    $CWD_DIR = catdir($CWD_DIR);
303
    $CWD_DIR = catdir($CWD_DIR);
302
 
304
 
303
    #
305
    #
304
    #   Determine the target archive
306
    #   Determine the target archive
305
    #   The default archive is GBE_DPKG, but this may be changed
307
    #   The default archive is GBE_DPKG, but this may be changed
306
    #
308
    #
307
    $opt_archive = 'main' unless ( $opt_archive );
309
    unless ( $opt_archive )
-
 
310
    {
-
 
311
        $opt_archive = 'main';
-
 
312
        $opt_archive = 'escrow' if ($::GBE_DPKG_ESCROW);
-
 
313
    }
308
    my $archive_tag = $Archive2Var{$opt_archive};
314
    my $archive_tag = $Archive2Var{$opt_archive};
309
    Error("Unknown archive specified: $opt_archive")
315
    Error("Unknown archive specified: $opt_archive")
310
        unless ( $archive_tag );
316
        unless ( $archive_tag );
311
    $DPKG_ROOT = $ENV{$archive_tag} || '';
317
    $DPKG_ROOT = $ENV{$archive_tag} || '';
312
    Verbose ("Archive Variable: $archive_tag" );
318
    Verbose ("Archive Variable: $archive_tag" );
Line 322... Line 328...
322
    #   This will bypass most of the operation of this package
328
    #   This will bypass most of the operation of this package
323
    #
329
    #
324
    $opt_noBuild = 2 if -f 'noBuild.gbe';
330
    $opt_noBuild = 2 if -f 'noBuild.gbe';
325
    if ( $opt_noBuild)
331
    if ( $opt_noBuild)
326
    {
332
    {
327
        Verbose ("No Build Marker file found");
333
        Verbose ("NoBuild Marker file found");
328
        Error("Use of noBuild marker should only be done by a build daemon")
-
 
329
            unless ( $GBE_ABT );
-
 
330
 
334
 
331
        $SRC_ROOT = '';
335
        $SRC_ROOT = '';
332
        $DPKG_NAME = 'pkg';
336
        $DPKG_NAME = 'pkg';
333
        $DESCPKG_FILE = 'descpkg';
337
        $DESCPKG_FILE = 'descpkg';
334
        $PKG_BASE =$CWD_DIR;
338
        $PKG_BASE =$CWD_DIR;
335
 
339
 
336
        Error("NoBuild operation requires package name and version") unless ($opt_pname && $opt_pversion);
-
 
337
        $DPKG_NAME = $opt_pname;
-
 
338
        $DPKG_VERSION = $opt_pversion;
-
 
339
 
-
 
340
        return;
340
        return;
341
    }
341
    }
342
 
342
 
343
    #
343
    #
344
    #   Check for a "pkg" directory
344
    #   Check for a "pkg" directory
Line 405... Line 405...
405
#
405
#
406
# Returns         : Will not return on error
406
# Returns         : Will not return on error
407
#
407
#
408
sub CheckDescPkg
408
sub CheckDescPkg
409
{
409
{
410
    #
-
 
411
    #   Don't need a package description if performing a no-build
-
 
412
    #   The package name and version will be provided on the command line
-
 
413
    #   NoBuilds MUST NOT package up a descpkg file
-
 
414
    #
-
 
415
    return if ($opt_noBuild);
-
 
416
 
410
 
417
    # Get the dpkg_archive version number we are  going to create.
411
    # Get the dpkg_archive version number we are  going to create.
418
    #
412
    #
419
    Error("Descpkg file not found in package directory: $PKG_BASE")
413
    Error("Descpkg file not found in package directory: $PKG_BASE")
420
        unless ( -f "$DESCPKG_FILE" );
414
        unless ( -f "$DESCPKG_FILE" );
Line 512... Line 506...
512
    Information ("---------------------------------------------------------------");
506
    Information ("---------------------------------------------------------------");
513
    Information ("Dpkg archive creation tool...");
507
    Information ("Dpkg archive creation tool...");
514
    Information ("Version: $VERSION");
508
    Information ("Version: $VERSION");
515
    Information ("");
509
    Information ("");
516
    Information ("Information:");
510
    Information ("Information:");
-
 
511
    Information ("Escrow Build") if ($opt_archive eq 'escrow');
517
    Information ("Working dir   = [$CWD_DIR]");
512
    Information ("Working dir   = [$CWD_DIR]");
518
    Information ("Package Root  = [$SRC_ROOT]");
513
    Information ("Package Root  = [$SRC_ROOT]");
519
    Information ("Repository    = [$DPKG_ROOT]");
514
    Information ("Repository    = [$DPKG_ROOT]");
520
    Information ("                *Non Standard archive") unless $opt_archive eq 'main';
515
    Information ("                *Non Standard archive") unless ($opt_archive eq 'main' || $opt_archive eq 'escrow');
521
    Information ("Target dir    = [$DPKG_DIR]");
516
    Information ("Target dir    = [$DPKG_DIR]");
522
    Information1("DPKG_NAME     = [$DPKG_NAME]");
517
    Information1("DPKG_NAME     = [$DPKG_NAME]");
523
    Information1("DPKG_VERSION  = [$DPKG_VERSION]");
518
    Information1("DPKG_VERSION  = [$DPKG_VERSION]");
524
    Information1("DPKG_PRJ      = [$DPKG_PRJ]");
519
    Information1("DPKG_PRJ      = [$DPKG_PRJ]");
525
    Information1("GBE_MACHTYPE  = [$GBE_MACHTYPE]");
520
    Information1("GBE_MACHTYPE  = [$GBE_MACHTYPE]");
Line 544... Line 539...
544
    #   from such an environment is certainly not reproducible - so don't allow
539
    #   from such an environment is certainly not reproducible - so don't allow
545
    #   it to happen
540
    #   it to happen
546
    #
541
    #
547
    #   Allow versions of 99.99.99 as these are known to be test versions
542
    #   Allow versions of 99.99.99 as these are known to be test versions
548
    #
543
    #
549
    unless ( $opt_archive eq 'local' || $opt_archive eq 'sandbox' || $opt_testArchive)
544
    unless ( $opt_archive eq 'local' || $opt_archive eq 'sandbox' || $opt_testArchive || $::GBE_DPKG_ESCROW)
550
    {
545
    {
551
        if ( $ENV{GBE_DPKG_SBOX} )
546
        if ( $ENV{GBE_DPKG_SBOX} )
552
        {
547
        {
553
            unless ( $DPKG_VERSION =~ /^99.99.99/ )
548
            unless ( $DPKG_VERSION =~ /^99.99.99/ )
554
            {
549
            {
Line 779... Line 774...
779
#
774
#
780
#------------------------------------------------------------------------------
775
#------------------------------------------------------------------------------
781
{
776
{
782
    my $item = $File::Find::name;
777
    my $item = $File::Find::name;
783
    my $base = File::Basename::basename($item);
778
    my $base = File::Basename::basename($item);
-
 
779
    my $niceBase = substr ( $item, 1+length ($SRC_ROOT) );
784
 
780
 
785
    #
781
    #
786
    #   Calculate the target directory name
782
    #   Calculate the target directory name
787
    #
783
    #
788
    my $target = $item;
784
    my $target = $item;
Line 832... Line 828...
832
                #   Use: Unix libraries are created as two files:
828
                #   Use: Unix libraries are created as two files:
833
                #        lib.xxxx.so -> libxxxx.so.vv.vv.vv
829
                #        lib.xxxx.so -> libxxxx.so.vv.vv.vv
834
                #
830
                #
835
                if ( -l $item )
831
                if ( -l $item )
836
                {
832
                {
-
 
833
                    if (TestSymlink( $niceBase,$_))
-
 
834
                    {
-
 
835
                        # Don't copy broken Symlinks
-
 
836
                        # Perhaps this should be an error - but is will break escrow builds
-
 
837
                        #
-
 
838
                        LogFileOp("Bad SymLink", $target);
-
 
839
                    }
837
                    if (-f $item)
840
                    elsif (-f $item)
838
                    {
841
                    {
839
                        LogFileOp("Copying Link", $target);
842
                        LogFileOp("Copying Link", $target);
840
                        my $link = readlink $item;
843
                        my $link = readlink $item;
841
                        Verbose( "Link: $item, $link");
844
                        Verbose( "Link: $item, $link");
842
                        symlink ($link, $target );
845
                        symlink ($link, $target );
Line 844... Line 847...
844
                        {
847
                        {
845
                            Error("Failed to copy link [$item] to [$target]: $!");
848
                            Error("Failed to copy link [$item] to [$target]: $!");
846
                        }
849
                        }
847
                        addFile('link', $item , $target);
850
                        addFile('link', $item , $target);
848
                    }
851
                    }
849
                    else
-
 
850
                    {
-
 
851
                        # Don't copy broken Symlinks
-
 
852
                        # Perhaps this should be an error - but is will break escrow builds
-
 
853
                        #
-
 
854
                        LogFileOp("Broken SymLink", $target);
-
 
855
                        push @bad_symlinks, substr ( $item, 1+length ($SRC_ROOT) );
-
 
856
                    }
-
 
857
                }
852
                }
858
                elsif (File::Copy::copy($item, $target))
853
                elsif (File::Copy::copy($item, $target))
859
                {
854
                {
860
                    LogFileOp("Copying File",$target);
855
                    LogFileOp("Copying File",$target);
861
                    #
856
                    #
Line 1152... Line 1147...
1152
#
1147
#
1153
sub pkgFindTarBall
1148
sub pkgFindTarBall
1154
{
1149
{
1155
    my $item = $File::Find::name;
1150
    my $item = $File::Find::name;
1156
    my $base = File::Basename::basename($item);
1151
    my $base = File::Basename::basename($item);
-
 
1152
    my $niceBase = substr ( $item, 1+length ($SRC_ROOT) );
1157
    my $type;
1153
    my $type;
1158
 
1154
 
1159
    #
1155
    #
1160
    #   Ignore the top level directory
1156
    #   Ignore the top level directory
1161
    #
1157
    #
Line 1167... Line 1163...
1167
    #       file
1163
    #       file
1168
    #       link, badlink
1164
    #       link, badlink
1169
    #       dir
1165
    #       dir
1170
    if ( -l $item)
1166
    if ( -l $item)
1171
    {
1167
    {
1172
        if (-f $item) {
1168
        if (TestSymlink( $niceBase,$_)) {
1173
            $type = 'link';
-
 
1174
        }
-
 
1175
        else
1169
            #
1176
        {
-
 
1177
            # Broken symlink
1170
            # Broken/Bad symlink
1178
            #   Remove it from the 'pkg'
1171
            #   Remove it from the 'pkg'
1179
            #   Could try other ways of excluding it from the tar, but this is the simplest  
1172
            #   Could try other ways of excluding it from the tar, but this is the simplest  
1180
            LogFileOp("Broken SymLink", $item);
1173
            LogFileOp("Bad SymLink", $item);
1181
            push @bad_symlinks, substr ( $item, 1+length ($SRC_ROOT) );
-
 
1182
            $type = 'badlink';
1174
            $type = 'badlink';
1183
            unlink $item;
1175
            unlink $item;
1184
            return;
1176
            return;
-
 
1177
 
-
 
1178
        } else {
-
 
1179
            $type = 'link';
1185
        }
1180
        }
1186
    } elsif ( -f $item) {
1181
    } elsif ( -f $item) {
1187
        $type = 'file';
1182
        $type = 'file';
1188
    } elsif ( -d $item) {
1183
    } elsif ( -d $item) {
1189
        $type = 'dir';
1184
        $type = 'dir';
Line 1267... Line 1262...
1267
        {
1262
        {
1268
            #
1263
            #
1269
            #   Locate files in the package root directory that
1264
            #   Locate files in the package root directory that
1270
            #   are not expected to be there.
1265
            #   are not expected to be there.
1271
            #
1266
            #
1272
            unless ((  $_ eq 'descpkg' ) || ( $_ eq 'incpkg' ))
1267
            unless ((  $_ eq 'descpkg' ) || ( $_ eq 'incpkg' ) || $_ =~ m~built\.*~)
1273
            {
1268
            {
1274
                push @test_root_file, $_;
1269
                push @test_root_file, $_;
1275
            }
1270
            }
1276
        }
1271
        }
-
 
1272
        TestSymlink($target, $_);
-
 
1273
    }
-
 
1274
}
-
 
1275
 
-
 
1276
#-------------------------------------------------------------------------------
-
 
1277
# Function        : TestSymlink 
-
 
1278
#
-
 
1279
# Description     : Test a symlink for validity
-
 
1280
#                   Current drectory will be $dir
-
 
1281
#
-
 
1282
# Inputs          : $dir
-
 
1283
#                   $fname
-
 
1284
#
-
 
1285
# Returns         : True if a bad symlink
-
 
1286
#                   Add error messages to @bad_symlinks 
-
 
1287
#
-
 
1288
sub TestSymlink 
-
 
1289
{
-
 
1290
    my ($dir, $fname) = @_;
-
 
1291
    my $msg;
-
 
1292
    my $rv = 0;
-
 
1293
    my $file = join ('/', $dir, $fname) ;
-
 
1294
#Debug0("Testing: $file");
-
 
1295
 
-
 
1296
    if (-l $fname) {
-
 
1297
        my $link = readlink $fname;
-
 
1298
 
1277
        if (-l $_ && ! -f $_)
1299
        if ($link =~ m~^/~) {
-
 
1300
            $msg = '[Absolute link not allowed]:' . $file . ' -> ' . $link;
-
 
1301
 
-
 
1302
        #   Need to test if the symlink escapes the package
-
 
1303
        #        } elsif ($link =~ m~/~) {
-
 
1304
        #            push @bad_symlinks, '[Symlink out of directory]:' . $file . ' -> ' . $link;
-
 
1305
        } elsif (! -f $fname) {
-
 
1306
            $msg =  '[Broken Link]:' . $file . ' -> ' . $link;
-
 
1307
        } else {
-
 
1308
            my @cleanParts = split ('/', CleanPath($link));
-
 
1309
            my @dirParts = split('/', $dir);
-
 
1310
            my $upCount = 0;
-
 
1311
            foreach ( @cleanParts ) {
-
 
1312
                if ($_ eq '..') {
-
 
1313
                    $upCount++;
-
 
1314
                } else {
-
 
1315
                    last;
-
 
1316
                }
1278
        {
1317
            }
-
 
1318
 
-
 
1319
            if ($upCount > scalar @dirParts) {
1279
            push @bad_symlinks, substr ( $File::Find::name, 1+length ($SRC_ROOT) );
1320
                $msg =  '[Escapes Package]:' . $file . ' -> ' . $link;
-
 
1321
            }
1280
        }
1322
        }
1281
    }
1323
    }
-
 
1324
    if ($msg) {
-
 
1325
        push @bad_symlinks, $msg;
-
 
1326
        $rv = 1;
-
 
1327
    }
-
 
1328
 
-
 
1329
    return $rv;
-
 
1330
 
1282
}
1331
}
1283
 
1332
 
-
 
1333
 
1284
#-------------------------------------------------------------------------------
1334
#-------------------------------------------------------------------------------
1285
# Function        : createBuiltFile 
1335
# Function        : createBuiltFile 
1286
#
1336
#
1287
# Description     : Create the packages built.xxxx file
1337
# Description     : Create the packages built.xxxx file
1288
#                   Used to track which build machines have contributed to the build 
1338
#                   Used to track which build machines have contributed to the build 
Line 1418... Line 1468...
1418
    -quiet             - Suppress progress messages, then warning messages
1468
    -quiet             - Suppress progress messages, then warning messages
1419
    -verbose           - Display additional progress messages
1469
    -verbose           - Display additional progress messages
1420
    -override          - Deprecated option
1470
    -override          - Deprecated option
1421
    -delete            - Delete any previous version of the package
1471
    -delete            - Delete any previous version of the package
1422
    -[no]merge         - merge with existing version of the package
1472
    -[no]merge         - merge with existing version of the package
1423
    -archive=name      - Specify archive (cache, local, main, store, sandbox, deploy)
1473
    -archive=name      - Specify archive (cache, local, main, store, sandbox, deploy, escrow)
1424
    -pname=name        - Ensure package is named correctly
1474
    -pname=name        - Ensure package is named correctly
1425
    -pversion=version  - Ensure package version is correct
1475
    -pversion=version  - Ensure package version is correct
1426
    -generic           - Create a built.generic file
1476
    -generic           - Create a built.generic file
1427
    -noBuild           - Create dummy build files
1477
    -noBuild           - Create dummy build files
1428
    -[no]tarmode       - Transfer package as tarball
1478
    -[no]tarmode       - Transfer package as tarball
Line 1506... Line 1556...
1506
 
1556
 
1507
The location of the target archive will be taken from C<GBE_DPKG_SBOX>.
1557
The location of the target archive will be taken from C<GBE_DPKG_SBOX>.
1508
 
1558
 
1509
=item deploy
1559
=item deploy
1510
 
1560
 
1511
The location of the target archive will be taken from C<GBE_DPLY>. This is the
1561
The location of the target archive will be taken from C<GBE_DPLY>.
-
 
1562
 
-
 
1563
Note: This archive is no longer fully supported.
-
 
1564
 
-
 
1565
=item escrow
-
 
1566
 
-
 
1567
The location of the target archive will be taken from C<GBE_DPKG_ESCROW>.
-
 
1568
 
1512
default target archive is a deployment package is detected.
1569
This is the default target archive if an escrow build is detected.
1513
 
1570
 
1514
=back
1571
=back
1515
 
1572
 
1516
=item B<-pname=name>
1573
=item B<-pname=name>
1517
 
1574