Subversion Repositories DevTools

Rev

Rev 7319 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7319 Rev 7322
Line 336... Line 336...
336
        $SRC_ROOT = '';
336
        $SRC_ROOT = '';
337
        $DPKG_NAME = 'pkg';
337
        $DPKG_NAME = 'pkg';
338
        $DESCPKG_FILE = 'descpkg';
338
        $DESCPKG_FILE = 'descpkg';
339
        $PKG_BASE =$CWD_DIR;
339
        $PKG_BASE =$CWD_DIR;
340
 
340
 
-
 
341
        #
-
 
342
        #   Use provided name and version
-
 
343
        #   Comparatbility only with ANT build system. Not needed by JATS
-
 
344
        #
-
 
345
        if ($opt_pname && $opt_pversion) {
-
 
346
            $DPKG_NAME = $opt_pname;
-
 
347
            $DPKG_VERSION = $opt_pversion;
-
 
348
        }
-
 
349
 
341
        return;
350
        return;
342
    }
351
    }
343
 
352
 
344
    #
353
    #
345
    #   Check for a "pkg" directory
354
    #   Check for a "pkg" directory
Line 406... Line 415...
406
#
415
#
407
# Returns         : Will not return on error
416
# Returns         : Will not return on error
408
#
417
#
409
sub CheckDescPkg
418
sub CheckDescPkg
410
{
419
{
-
 
420
    #
-
 
421
    #   May not need a package description if performing a no-build
-
 
422
    #       The package name and version will may be provided on the command line
-
 
423
    #   Compatability for ANT builds
-
 
424
    #       
-
 
425
    #
-
 
426
    if ($opt_noBuild) {
-
 
427
        if ($opt_pname && $opt_pversion) {
-
 
428
            return;
-
 
429
        }
-
 
430
        Error("NoBuild operation requires package name and version")
-
 
431
    }
411
 
432
 
412
    # Get the dpkg_archive version number we are  going to create.
433
    # Get the dpkg_archive version number we are  going to create.
413
    #
434
    #
414
    Error("Descpkg file not found in package directory: $PKG_BASE")
435
    Error("Descpkg file not found in package directory: $PKG_BASE")
415
        unless ( -f "$DESCPKG_FILE" );
436
        unless ( -f "$DESCPKG_FILE" );
Line 834... Line 855...
834
                #   Use: Unix libraries are created as two files:
855
                #   Use: Unix libraries are created as two files:
835
                #        lib.xxxx.so -> libxxxx.so.vv.vv.vv
856
                #        lib.xxxx.so -> libxxxx.so.vv.vv.vv
836
                #
857
                #
837
                if ( -l $item )
858
                if ( -l $item )
838
                {
859
                {
-
 
860
                    my $niceBase = substr ( $item, 1+length ($SRC_ROOT) );
-
 
861
                    if (TestSymlink( $niceBase,$_))
-
 
862
                    {
-
 
863
                        # Don't copy broken Symlinks
-
 
864
                        # Perhaps this should be an error - but is will break escrow builds
-
 
865
                        #
-
 
866
                        LogFileOp("Bad SymLink", $target);
-
 
867
                    }
839
                    if (-f $item)
868
                    elsif (-f $item)
840
                    {
869
                    {
841
                        LogFileOp("Copying Link", $target);
870
                        LogFileOp("Copying Link", $target);
842
                        my $link = readlink $item;
871
                        my $link = readlink $item;
843
                        Verbose( "Link: $item, $link");
872
                        Verbose( "Link: $item, $link");
844
                        symlink ($link, $target );
873
                        symlink ($link, $target );
Line 846... Line 875...
846
                        {
875
                        {
847
                            Error("Failed to copy link [$item] to [$target]: $!");
876
                            Error("Failed to copy link [$item] to [$target]: $!");
848
                        }
877
                        }
849
                        addFile('link', $item , $target);
878
                        addFile('link', $item , $target);
850
                    }
879
                    }
851
                    else
-
 
852
                    {
-
 
853
                        # Don't copy broken Symlinks
-
 
854
                        # Perhaps this should be an error - but is will break escrow builds
-
 
855
                        #
-
 
856
                        LogFileOp("Broken SymLink", $target);
-
 
857
                        push @bad_symlinks, substr ( $item, 1+length ($SRC_ROOT) );
-
 
858
                    }
-
 
859
                }
880
                }
860
                elsif (File::Copy::copy($item, $target))
881
                elsif (File::Copy::copy($item, $target))
861
                {
882
                {
862
                    LogFileOp("Copying File",$target);
883
                    LogFileOp("Copying File",$target);
863
                    #
884
                    #
Line 1159... Line 1180...
1159
    my $type;
1180
    my $type;
1160
 
1181
 
1161
    #
1182
    #
1162
    #   Ignore the top level directory
1183
    #   Ignore the top level directory
1163
    #
1184
    #
1164
    return
-
 
1165
        if ( $item eq $SRC_ROOT );
1185
    return if ( $item eq $SRC_ROOT );
1166
 
1186
 
1167
    #
1187
    #
1168
    #   Determine type of this item
1188
    #   Determine type of this item
1169
    #       file
1189
    #       file
1170
    #       link, badlink
1190
    #       link, badlink
1171
    #       dir
1191
    #       dir
1172
    if ( -l $item)
1192
    if ( -l $item)
1173
    {
1193
    {
1174
        if (-f $item) {
1194
        my $niceBase = substr ( $item, 1+length ($SRC_ROOT) );
1175
            $type = 'link';
1195
        if (TestSymlink( $niceBase,$_)) {
1176
        }
-
 
1177
        else
1196
            #
1178
        {
-
 
1179
            # Broken symlink
1197
            # Broken/Bad symlink
1180
            #   Remove it from the 'pkg'
1198
            #   Remove it from the 'pkg'
1181
            #   Could try other ways of excluding it from the tar, but this is the simplest  
1199
            #   Could try other ways of excluding it from the tar, but this is the simplest  
1182
            LogFileOp("Broken SymLink", $item);
1200
            LogFileOp("Bad SymLink", $item);
1183
            push @bad_symlinks, substr ( $item, 1+length ($SRC_ROOT) );
-
 
1184
            $type = 'badlink';
1201
            $type = 'badlink';
1185
            unlink $item;
1202
            unlink $item;
1186
            return;
1203
            return;
-
 
1204
 
-
 
1205
        } else {
-
 
1206
            $type = 'link';
1187
        }
1207
        }
1188
    } elsif ( -f $item) {
1208
    } elsif ( -f $item) {
1189
        $type = 'file';
1209
        $type = 'file';
1190
    } elsif ( -d $item) {
1210
    } elsif ( -d $item) {
1191
        $type = 'dir';
1211
        $type = 'dir';
Line 1269... Line 1289...
1269
        {
1289
        {
1270
            #
1290
            #
1271
            #   Locate files in the package root directory that
1291
            #   Locate files in the package root directory that
1272
            #   are not expected to be there.
1292
            #   are not expected to be there.
1273
            #
1293
            #
1274
            unless ((  $_ eq 'descpkg' ) || ( $_ eq 'incpkg' ))
1294
            unless ((  $_ eq 'descpkg' ) || ( $_ eq 'incpkg' ) || $_ =~ m~built\.*~)
1275
            {
1295
            {
1276
                push @test_root_file, $_;
1296
                push @test_root_file, $_;
1277
            }
1297
            }
1278
        }
1298
        }
-
 
1299
        TestSymlink($target, $_);
-
 
1300
    }
-
 
1301
}
-
 
1302
 
-
 
1303
#-------------------------------------------------------------------------------
-
 
1304
# Function        : TestSymlink 
-
 
1305
#
-
 
1306
# Description     : Test a symlink for validity
-
 
1307
#                   Current drectory will be $dir
-
 
1308
#
-
 
1309
# Inputs          : $dir
-
 
1310
#                   $fname
-
 
1311
#
-
 
1312
# Returns         : True if a bad symlink
-
 
1313
#                   Add error messages to @bad_symlinks 
-
 
1314
#
-
 
1315
sub TestSymlink 
-
 
1316
{
-
 
1317
    my ($dir, $fname) = @_;
-
 
1318
    my $msg;
-
 
1319
    my $rv = 0;
-
 
1320
    my $file = join ('/', $dir, $fname) ;
-
 
1321
#Debug0("Testing: $file");
-
 
1322
 
-
 
1323
    if (-l $fname) {
-
 
1324
        my $link = readlink $fname;
-
 
1325
 
1279
        if (-l $_ && ! -f $_)
1326
        if ($link =~ m~^/~) {
-
 
1327
            $msg = '[Absolute link not allowed]:' . $file . ' -> ' . $link;
-
 
1328
 
-
 
1329
        #   Need to test if the symlink escapes the package
-
 
1330
        #        } elsif ($link =~ m~/~) {
-
 
1331
        #            push @bad_symlinks, '[Symlink out of directory]:' . $file . ' -> ' . $link;
-
 
1332
        } elsif (! -f $fname) {
-
 
1333
            $msg =  '[Broken Link]:' . $file . ' -> ' . $link;
-
 
1334
        } else {
-
 
1335
            my @cleanParts = split ('/', CleanPath($link));
-
 
1336
            my @dirParts = split('/', $dir);
-
 
1337
            my $upCount = 0;
-
 
1338
            foreach ( @cleanParts ) {
-
 
1339
                if ($_ eq '..') {
-
 
1340
                    $upCount++;
-
 
1341
                } else {
-
 
1342
                    last;
-
 
1343
                }
1280
        {
1344
            }
-
 
1345
 
-
 
1346
            if ($upCount > scalar @dirParts) {
1281
            push @bad_symlinks, substr ( $File::Find::name, 1+length ($SRC_ROOT) );
1347
                $msg =  '[Escapes Package]:' . $file . ' -> ' . $link;
-
 
1348
            }
1282
        }
1349
        }
1283
    }
1350
    }
-
 
1351
    if ($msg) {
-
 
1352
        push @bad_symlinks, $msg;
-
 
1353
        $rv = 1;
-
 
1354
    }
-
 
1355
 
-
 
1356
    return $rv;
-
 
1357
 
1284
}
1358
}
1285
 
1359
 
-
 
1360
 
1286
#-------------------------------------------------------------------------------
1361
#-------------------------------------------------------------------------------
1287
# Function        : createBuiltFile 
1362
# Function        : createBuiltFile 
1288
#
1363
#
1289
# Description     : Create the packages built.xxxx file
1364
# Description     : Create the packages built.xxxx file
1290
#                   Used to track which build machines have contributed to the build 
1365
#                   Used to track which build machines have contributed to the build