Subversion Repositories DevTools

Rev

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

Rev 6242 Rev 6535
Line 318... Line 318...
318
        #   Remove the directory for this package
318
        #   Remove the directory for this package
319
        #   Remove the general work dir - if all packages have been cleaned
319
        #   Remove the general work dir - if all packages have been cleaned
320
        #
320
        #
321
        rmtree( $WorkDirBase );
321
        rmtree( $WorkDirBase );
322
        rmtree ($opt_tarFile) if ( defined($opt_tarFile) && -f $opt_tarFile );
322
        rmtree ($opt_tarFile) if ( defined($opt_tarFile) && -f $opt_tarFile );
323
        rmtree ($opt_output) if ( -f $opt_output );
323
        rmtree ($opt_output) if ( $opt_output && -f $opt_output );
324
        exit;
324
        exit;
325
    }
325
    }
326
 
326
 
327
    #
327
    #
328
    #   NoArch sanity test
328
    #   NoArch sanity test
Line 1706... Line 1706...
1706
#                   $dst_dir    - Within the output workspace
1706
#                   $dst_dir    - Within the output workspace
1707
#                   Options
1707
#                   Options
1708
#                       --Merge                 - Don't delete first
1708
#                       --Merge                 - Don't delete first
1709
#                       --Source=Name           - Source via Symbolic Name
1709
#                       --Source=Name           - Source via Symbolic Name
1710
#                       --FromPackage           - Source via package roots
1710
#                       --FromPackage           - Source via package roots
-
 
1711
#                       --FromPackage:Name      - Source via specified package roots
1711
#                       --NoIgnoreDbgFiles      - Do not ignore .dbg and .debug files in dir copy
1712
#                       --NoIgnoreDbgFiles      - Do not ignore .dbg and .debug files in dir copy
1712
#                       --IfPresent             - Not an error if the path cannot be found
1713
#                       --IfPresent             - Not an error if the path cannot be found
1713
#                       --ConfFile              - Mark transferred files as config files
1714
#                       --ConfFile              - Mark transferred files as config files
1714
#                       --Flatten               - Copy all to one directory
1715
#                       --Flatten               - Copy all to one directory
1715
#                       --FilterOut=xxx         - Ignore files. DOS Wildcard
1716
#                       --FilterOut=xxx         - Ignore files. DOS Wildcard
Line 1733... Line 1734...
1733
    my $ignoreDbg = 1;
1734
    my $ignoreDbg = 1;
1734
    my $ignoreNoDir;
1735
    my $ignoreNoDir;
1735
    my $user_src_dir = $src_dir;
1736
    my $user_src_dir = $src_dir;
1736
    my $opt_source;
1737
    my $opt_source;
1737
    my $opt_package;
1738
    my $opt_package;
-
 
1739
    my $opt_package_name;
1738
    my @fileList;
1740
    my @fileList;
1739
    my $isFiltered;
1741
    my $isFiltered;
1740
    return 1 unless ($ActiveSection);
1742
    return 1 unless ($ActiveSection);
1741
 
1743
 
1742
    #
1744
    #
Line 1764... Line 1766...
1764
        } elsif ( m/^--Source=(.+)/ ) {
1766
        } elsif ( m/^--Source=(.+)/ ) {
1765
            Error ("Source directory can only be specified once")
1767
            Error ("Source directory can only be specified once")
1766
                if ( defined $opt_source );
1768
                if ( defined $opt_source );
1767
            $opt_source = $1;
1769
            $opt_source = $1;
1768
 
1770
 
-
 
1771
        } elsif ( m/^--FromPackage:(.+)/ ) {
-
 
1772
            Error ("FromPackage can only be specified once")
-
 
1773
                if ( defined $opt_package );
-
 
1774
            $opt_package = 1;
-
 
1775
            $opt_package_name = $1;
-
 
1776
 
1769
        } elsif ( m/^--FromPackage/ ) {
1777
        } elsif ( m/^--FromPackage/ ) {
1770
            Error ("FromPackage can only be specified once")
1778
            Error ("FromPackage can only be specified once")
1771
                if ( defined $opt_package );
1779
                if ( defined $opt_package );
1772
            $opt_package = 1;
1780
            $opt_package = 1;
1773
 
1781
 
Line 1880... Line 1888...
1880
        Verbose2 ("CopyDir: FromPackage: $src_dir");
1888
        Verbose2 ("CopyDir: FromPackage: $src_dir");
1881
 
1889
 
1882
        my @path;
1890
        my @path;
1883
        foreach my $entry ( getPackageList() )
1891
        foreach my $entry ( getPackageList() )
1884
        {
1892
        {
-
 
1893
            #
-
 
1894
            #   Locate the named package if specified
-
 
1895
            #
-
 
1896
            if (defined $opt_package_name) {
-
 
1897
                next unless ($opt_package_name eq $entry->getName() || uc($opt_package_name) eq $entry->getUnifiedName() );
-
 
1898
            }
-
 
1899
 
1885
            my $base = $entry->getBase(3);
1900
            my $base = $entry->getBase(3);
1886
            next unless ( defined $base );
1901
            next unless ( defined $base );
1887
            if ( -d $base . '/' . $src_dir )
1902
            if ( folderHasFiles( $base . '/' . $src_dir) )
1888
            {
1903
            {
1889
                push @path, $base;
1904
                push @path, $base;
1890
                $from_interface = 1
1905
                $from_interface = 1
1891
                    if ( $entry->{'TYPE'} eq 'interface' );
1906
                    if ( $entry->{'TYPE'} eq 'interface' );
1892
            }
1907
            }
Line 1975... Line 1990...
1975
#                   $stop       - Stop Number
1990
#                   $stop       - Stop Number
1976
#                   Options:
1991
#                   Options:
1977
#                       --NoCopy        - Don't copy the script, just add links
1992
#                       --NoCopy        - Don't copy the script, just add links
1978
#                       --Afc           - Place in AFC init area
1993
#                       --Afc           - Place in AFC init area
1979
#                       --FromPackage   - Source is in a package
1994
#                       --FromPackage   - Source is in a package
-
 
1995
#                       --Hibernate     - Add hibernate symlink
-
 
1996
#                       --Resume        - Add resume symlink
1980
#
1997
#
1981
# Returns         : 
1998
# Returns         : 
1982
#
1999
#
1983
sub AddInitScript
2000
sub AddInitScript
1984
{
2001
{
1985
    my $no_copy;
2002
    my $no_copy;
1986
    my $basedir = "";
2003
    my $basedir = "";
1987
    my @args;
2004
    my @args;
1988
    my $from_package = 0;
2005
    my $from_package = 0;
-
 
2006
    my $hibernate = 0;
-
 
2007
    my $resume = 0;
1989
    return 1 unless ($ActiveSection);
2008
    return 1 unless ($ActiveSection);
1990
 
2009
 
1991
    # This directive is only available on the VIX platforms
2010
    # This directive is only available on the VIX platforms
1992
    #   Kludgey test - at the moment
2011
    #   Kludgey test - at the moment
1993
    #
2012
    #
Line 2008... Line 2027...
2008
            $basedir = "/afc";
2027
            $basedir = "/afc";
2009
 
2028
 
2010
        } elsif ( m/^--FromPackage/ ) {
2029
        } elsif ( m/^--FromPackage/ ) {
2011
            $from_package = 1;
2030
            $from_package = 1;
2012
 
2031
 
-
 
2032
        } elsif ( m/^--Hibernate=(.*)/ ) {
-
 
2033
            $hibernate = $1;
-
 
2034
 
-
 
2035
        } elsif ( m/^--Resume=(.*)/ ) {
-
 
2036
            $resume = $1;
-
 
2037
 
2013
        } elsif ( m/^--/ ) {
2038
        } elsif ( m/^--/ ) {
2014
            Error ("AddInitScript: Unknown option: $_");
2039
            Error ("AddInitScript: Unknown option: $_");
2015
 
2040
 
2016
        } else {
2041
        } else {
2017
            push @args, $_;
2042
            push @args, $_;
Line 2022... Line 2047...
2022
    my( $script, $start, $stop ) = @args;
2047
    my( $script, $start, $stop ) = @args;
2023
    Error ("No script file specified") unless ( $script );
2048
    Error ("No script file specified") unless ( $script );
2024
    Warning("AddInitScript: No start or stop index specified") unless ( $start || $stop );
2049
    Warning("AddInitScript: No start or stop index specified") unless ( $start || $stop );
2025
    Verbose ("AddInitScript: $script, " . ($start || 'No Start') . ", " . ($stop || 'No Stop'));
2050
    Verbose ("AddInitScript: $script, " . ($start || 'No Start') . ", " . ($stop || 'No Stop'));
2026
    $script = ResolveFile($from_package, $script );
2051
    $script = ResolveFile($from_package, $script );
2027
 
-
 
-
 
2052
    Message ("basedir: $basedir");
2028
    my $tdir = $basedir . "/etc/init.d/init.d";
2053
    my $tdir = $basedir . "/etc/init.d/init.d";
-
 
2054
    if ( $opt_platform eq 'SK100' ) {
-
 
2055
        $tdir = $basedir . "/etc/init.d/init.vix.d";
-
 
2056
    }
2029
    my $base = StripDir($script);
2057
    my $base = StripDir($script);
2030
 
2058
 
2031
    CopyFile( $script, $tdir ) unless $no_copy;
2059
    CopyFile( $script, $tdir ) unless $no_copy;
2032
 
2060
 
2033
    my $link;
2061
    my $link;
-
 
2062
    my $linkPath = "/etc/init.d/";
2034
    if ( $start )
2063
    if ( $opt_platform eq 'SK100' ) {
-
 
2064
        $linkPath = $basedir . "/etc/init.d/init.vix.d/";
2035
    {
2065
    }
-
 
2066
    if ( $start ) {
2036
        $link = sprintf ("${basedir}/etc/init.d/S%2.2d%s", $start, $base );
2067
        $link = sprintf ("${linkPath}S%2.2d%s", $start, $base );
2037
        MakeSymLink( "$tdir/$base", $link);
2068
        MakeSymLink( "$tdir/$base", $link);
2038
    }
2069
    }
2039
 
2070
 
2040
    if ( $stop )
2071
    if ( $stop ) {
-
 
2072
        $link = sprintf ("${linkPath}K%2.2d%s", $stop, $base );
-
 
2073
        MakeSymLink( "$tdir/$base", $link);
2041
    {
2074
    }
-
 
2075
 
-
 
2076
    if ( $hibernate ) {
2042
        $link = sprintf ("${basedir}/etc/init.d/K%2.2d%s", $stop, $base );
2077
        $link = sprintf ("${linkPath}H%2.2d%s", $hibernate, $base );
2043
        MakeSymLink( "$tdir/$base", $link);
2078
        MakeSymLink( "$tdir/$base", $link);
2044
    }
2079
    }
-
 
2080
 
-
 
2081
    if ( $resume ) {
-
 
2082
        $link = sprintf ("${linkPath}R%2.2d%s", $resume, $base );
-
 
2083
        MakeSymLink( "$tdir/$base", $link);
-
 
2084
    }
-
 
2085
 
-
 
2086
    # on SK100 init script must be placed in rc.local.d and mus be sources and 
-
 
2087
    # a start stop resume or suspend function must be implemented.
-
 
2088
    # For VIX these functions will call existing initscripts already package in
-
 
2089
    # a vix folder. 
-
 
2090
    if ( $opt_platform eq 'SK100' ) {
-
 
2091
        my $service_file = "$base" . ".service";
-
 
2092
        Message ("creating service file for SK100: $service_file in $basedir");
-
 
2093
        unless (open FILE,'>'.$service_file) {
-
 
2094
            Error ("Failed to create Service file for SK100");
-
 
2095
        }
-
 
2096
        print FILE "#!/bin/sh\\n\\n# $base service file\n\n";
-
 
2097
        print FILE "start() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base start\n}\n";
-
 
2098
        print FILE "stop() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base stop\n}\n";
-
 
2099
        print FILE "restart() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base restart\n}\n";
-
 
2100
        print FILE "suspend() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base suspend\n}\n";
-
 
2101
        print FILE "resume() {\n    [ -e /etc/init.d/init.vix.d/$base ] && /etc/init.d/init.vix.d/$base resume\n}\n";
-
 
2102
        close FILE;
-
 
2103
        CopyFile($service_file, "/etc/init.d/rc.local.d", "$base");
-
 
2104
        SetFilePerms('a+rx', "/etc/init.d/rc.local.d/$base");
-
 
2105
    }
2045
}
2106
}
2046
 
2107
 
2047
#-------------------------------------------------------------------------------
2108
#-------------------------------------------------------------------------------
2048
# Function        : CatFile
2109
# Function        : CatFile
2049
#
2110
#
Line 3031... Line 3092...
3031
    Debug("RelPath: Result: $result");
3092
    Debug("RelPath: Result: $result");
3032
    return $result;
3093
    return $result;
3033
}
3094
}
3034
 
3095
 
3035
#-------------------------------------------------------------------------------
3096
#-------------------------------------------------------------------------------
-
 
3097
# Function        : folderHasFiles  
-
 
3098
#
-
 
3099
# Description     : Detect empty folders
-
 
3100
#
-
 
3101
# Inputs          : dirname - Path to examine 
-
 
3102
#
-
 
3103
# Returns         : TRUE - Is a folder and it has files
-
 
3104
#
-
 
3105
 
-
 
3106
sub folderHasFiles {
-
 
3107
    my $dirname = shift;
-
 
3108
    my $rv = 0;
-
 
3109
 
-
 
3110
    opendir(my $dh, $dirname) or return 0;
-
 
3111
    while (readdir $dh)
-
 
3112
    {
-
 
3113
        next if ($_ eq "." || $_ eq "..");
-
 
3114
        $rv = 1;
-
 
3115
        last;
-
 
3116
    }
-
 
3117
    closedir $dh;
-
 
3118
    return $rv;
-
 
3119
}
-
 
3120
 
-
 
3121
#-------------------------------------------------------------------------------
3036
# Function        : ExpandLinkFiles
3122
# Function        : ExpandLinkFiles
3037
#
3123
#
3038
# Description     : Look for .LINK files in the output image and expand
3124
# Description     : Look for .LINK files in the output image and expand
3039
#                   the links into softlinks
3125
#                   the links into softlinks
3040
#
3126
#