Subversion Repositories DevTools

Rev

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

Rev 5485 Rev 5486
Line 925... Line 925...
925
# Returns         : 
925
# Returns         : 
926
#
926
#
927
sub CreateDpkgArchiveTarBall
927
sub CreateDpkgArchiveTarBall
928
{
928
{
929
    Information("");
929
    Information("");
-
 
930
    InitFileUtils();
-
 
931
 
-
 
932
 
-
 
933
    #
-
 
934
    #   Locate the tar utility
-
 
935
    #   Use gtar if its available otherwise use tar
-
 
936
    #   
-
 
937
    my $tarProg = LocateProgInPath('gtar', '--All');
-
 
938
    $tarProg = LocateProgInPath('tar', '--All') unless $tarProg;
-
 
939
    Error ("Tar utility not found in path") unless $tarProg;
930
 
940
 
931
    #
941
    #
932
    #   Process the source directory, unless this is a noBuild
942
    #   If a 'noBuild' then create a dummy package directory simply
-
 
943
    #   to contain the metadata
933
    #
944
    #
934
    if ( $SRC_ROOT ne '' )
945
    if ( $SRC_ROOT eq '' )
935
    {
946
    {
936
        # Process the files
947
        $SRC_ROOT = AbsPath('pkg/noBuild');
937
        #
-
 
938
        if ( -d $SRC_ROOT )
948
        mkpath($SRC_ROOT, 0, 0775);
939
        {
949
    }
940
            File::Find::find( \&pkgFindTarBall, $SRC_ROOT );
-
 
941
 
950
 
-
 
951
    #
-
 
952
    #   Mark the archive with the build machine to indicate which parts of
942
            if (@bad_symlinks)
953
    #   a multi-machine build have been performed
943
            {
954
    #
-
 
955
    my $touchfile = $opt_generic ? "$SRC_ROOT/built.generic" : "$SRC_ROOT/built.$GBE_HOSTNAME";
-
 
956
 
-
 
957
    #
944
                my $msg = "Bad Symlinks: " . scalar @bad_symlinks;
958
    #   Create a string to be appended to the 'built' file
945
                $opt_test ? ReportError($msg, @bad_symlinks) : Warning($msg, @bad_symlinks);
959
    #   Comma seperated list of (possibly) useful info
946
            }
960
    #       Date-Time ( Local and GMT)
-
 
961
    #       machine type, machine name and the user
947
            ErrorDoExit();
962
    #       GBE_ABT value
948
        }
963
    #
949
        else
964
    #   Having build issues where the file is not seen for a very long time
950
        {
965
    #
-
 
966
    my $built_info = localtime() ."," . gmtime() . " GMT,$GBE_MACHTYPE,$GBE_HOSTNAME,$USER,$GBE_ABT";
-
 
967
    LogFileOp("Mark File",$touchfile);
-
 
968
    FileAppend ( $touchfile, $built_info );
-
 
969
 
951
            Error("Failed to find dir [$SRC_ROOT]",
970
    #   Process the source directory
952
                  "Check JATS config.");
971
    #   A NoBuild will contain one metafile
-
 
972
    #
-
 
973
    if ( -d $SRC_ROOT )
953
        }
974
    {
-
 
975
        File::Find::find( \&pkgFindTarBall, $SRC_ROOT );
954
 
976
 
955
        #
-
 
956
        #   Create the MD5 info file
-
 
957
        #   
-
 
958
        writeFileInfo();
-
 
959
 
-
 
960
        #
-
 
961
        #   Create the target patch in the target archive
-
 
962
        #   
-
 
963
        Message "Creating: $DPKG_DIR";
-
 
964
        mkpath($DPKG_DIR, 0, 0775);
-
 
965
 
-
 
966
 
-
 
967
        #
-
 
968
        #   Create the TAR file
-
 
969
        #   Use gzip compression (tar.gz) as it provides a good compromise bewteen speed and size
-
 
970
        #       - Not Windows yet
-
 
971
        my $tarTarget = join('_', $DPKG_NAME, $DPKG_VERSION, $GBE_HOSTNAME) . '.tar.gz';
-
 
972
        my $tarPath = catfile($DPKG_DIR, $tarTarget);
-
 
973
        Message "Creating: $tarTarget";
-
 
974
        my @tarArgs;
977
        if (@bad_symlinks)
975
        push @tarArgs, '-v' if IsVerbose(1);
-
 
976
        my $rv = System ('--NoShell', '--NoExit','tar', @tarArgs, '-czf', $tarPath, '-C', $SRC_ROOT, '.' );
-
 
977
        if ($rv)
-
 
978
        {
978
        {
979
            unlink $tarPath;
-
 
980
            unlink $opt_outfile; 
979
            my $msg = "Bad Symlinks: " . scalar @bad_symlinks;
981
            Error ('Cannot create tarball', "Path:$tarPath");
980
            $opt_test ? ReportError($msg, @bad_symlinks) : Warning($msg, @bad_symlinks);
982
        }
981
        }
-
 
982
        ErrorDoExit();
-
 
983
    }
-
 
984
    else
-
 
985
    {
-
 
986
        Error("Failed to find dir [$SRC_ROOT]",
-
 
987
              "Check JATS config.");
-
 
988
    }
-
 
989
 
-
 
990
    #
-
 
991
    #   Create the MD5 info file
-
 
992
    #   
-
 
993
    writeFileInfo();
-
 
994
 
-
 
995
    #
-
 
996
    #   Create the target patch in the target archive
-
 
997
    #   
-
 
998
    Message "Creating: $DPKG_DIR";
-
 
999
    mkpath($DPKG_DIR, 0, 0775);
-
 
1000
 
-
 
1001
 
-
 
1002
    #
-
 
1003
    #   Create the TAR file
-
 
1004
    #   Use gzip compression (tar.gz) as it provides a good compromise bewteen speed and size
-
 
1005
    #       - Not Windows yet
-
 
1006
    my $tarTarget = join('_', $DPKG_NAME, $DPKG_VERSION, $GBE_HOSTNAME) . '.tar.gz';
-
 
1007
    my $tarPath = catfile($DPKG_DIR, $tarTarget);
-
 
1008
    Message "Creating: $tarTarget";
-
 
1009
    my @tarArgs;
-
 
1010
    push @tarArgs, '-v' if IsVerbose(1);
-
 
1011
    my $rv = System ('--NoShell', '--NoExit',$tarProg, @tarArgs, '-czf', $tarPath, '-C', $SRC_ROOT, '.' );
-
 
1012
    if ($rv)
-
 
1013
    {
-
 
1014
        unlink $tarPath;
-
 
1015
        unlink $opt_outfile; 
-
 
1016
        Error ('Cannot create tarball', "Path:$tarPath");
983
    }
1017
    }
984
 
1018
 
985
    return 1;
1019
    return 1;
986
 
1020
 
987
}
1021
}
Line 1003... Line 1037...
1003
    my $item = $File::Find::name;
1037
    my $item = $File::Find::name;
1004
    my $base = File::Basename::basename($item);
1038
    my $base = File::Basename::basename($item);
1005
    my $type;
1039
    my $type;
1006
 
1040
 
1007
    #
1041
    #
-
 
1042
    #   Ignore the top level directory
-
 
1043
    #
-
 
1044
    return
-
 
1045
        if ( $item eq $SRC_ROOT );
-
 
1046
 
-
 
1047
    #
1008
    #   Determine type of this item
1048
    #   Determine type of this item
1009
    #       file
1049
    #       file
1010
    #       link, badlink
1050
    #       link, badlink
1011
    #       dir
1051
    #       dir
1012
    if ( -l $item)
1052
    if ( -l $item)
Line 1014... Line 1054...
1014
        if (-f $item) {
1054
        if (-f $item) {
1015
            $type = 'link';
1055
            $type = 'link';
1016
        }
1056
        }
1017
        else
1057
        else
1018
        {
1058
        {
-
 
1059
            # Broken symlink
-
 
1060
            #   Remove it from the 'pkg'
-
 
1061
            #   Could try other ways of excluding it from the tar, but this is the simplest  
1019
            LogFileOp("Broken SymLink", $item);
1062
            LogFileOp("Broken SymLink", $item);
1020
            push @bad_symlinks, substr ( $item, 1+length ($SRC_ROOT) );
1063
            push @bad_symlinks, substr ( $item, 1+length ($SRC_ROOT) );
1021
            $type = 'badlink';
1064
            $type = 'badlink';
-
 
1065
            unlink $item;
-
 
1066
            return;
1022
        }
1067
        }
1023
    } elsif ( -f $item) {
1068
    } elsif ( -f $item) {
1024
        $type = 'file';
1069
        $type = 'file';
1025
    } elsif ( -d $item) {
1070
    } elsif ( -d $item) {
1026
        $type = 'dir';
1071
        $type = 'dir';
-
 
1072
    } else {
-
 
1073
        Error("Unknown file type. Cannot be packaged");
1027
    }
1074
    }
1028
 
1075
 
1029
    #
1076
    #
1030
    #   Calculate the target directory name
1077
    #   Calculate the target directory name
1031
    #
1078
    #