Esempio n. 1
0
    def __init__(self, name, role, pkgs_to_install, os_version=None):
        """Our arguments are:

        * 'name' - the name of this builder
        * 'role' - the role to which it belongs
        * 'pkgs_to_install' - a sequence specifying which packages are to be
          installed.

        Each item in the sequence 'pkgs_to_install' can be:

        * the name of an OS package to install - for instance, 'libxml2-dev'

          (this is backwards compatible with how this class worked in the past)

        * a Choice allowing a particular package to be selected according to
          the operating system.

          See "muddle doc Choice" for details on the Choice class.

          Note that a choice resulting in None (i.e., where the default value
          is None, and the default is selected) will not do anything.

          If 'os_version' is given, then it will be used as the version name,
          otherwise the result of calling utils.get_os_version_name() will be
          used.

        We also allow a single string, or a single Choice, treated as if they
        were wrapped in a list.
        """
        super(AptGetBuilder, self).__init__(name, role)

        actual_packages = []

        if os_version is None:
            os_verson = get_os_version_name()

        if isinstance(pkgs_to_install, basestring):
            # Just a single package
            actual_packages.append(pkgs_to_install)
        elif isinstance(pkgs_to_install, Choice):
            # Just a single Choice
            # Make a choice according to the OS info
            choice = pkgs_to_install.choose_to_match_os(os_version)
            if choice is not None:
                actual_packages.append(choice)
        else:
            for pkg in pkgs_to_install:
                if isinstance(pkg, basestring):
                    actual_packages.append(pkg)
                elif isinstance(pkg, Choice):
                    # Make a choice according to the OS info
                    choice = pkg.choose_to_match_os(os_version)
                    if choice is not None:
                        actual_packages.append(choice)
                else:
                    raise GiveUp('%r is not a string or a Choice' % pkg)

        self.pkgs_to_install = actual_packages
Esempio n. 2
0
    def __init__(self, name, role,  pkgs_to_install, os_version=None):
        """Our arguments are:

        * 'name' - the name of this builder
        * 'role' - the role to which it belongs
        * 'pkgs_to_install' - a sequence specifying which packages are to be
          installed.

        Each item in the sequence 'pkgs_to_install' can be:

        * the name of an OS package to install - for instance, 'libxml2-dev'

          (this is backwards compatible with how this class worked in the past)

        * a Choice allowing a particular package to be selected according to
          the operating system.

          See "muddle doc Choice" for details on the Choice class.

          Note that a choice resulting in None (i.e., where the default value
          is None, and the default is selected) will not do anything.

          If 'os_version' is given, then it will be used as the version name,
          otherwise the result of calling utils.get_os_version_name() will be
          used.

        We also allow a single string, or a single Choice, treated as if they
        were wrapped in a list.
        """
        super(AptGetBuilder, self).__init__(name, role)

        actual_packages = []

        if os_version is None:
            os_verson = get_os_version_name()

        if isinstance(pkgs_to_install, basestring):
            # Just a single package
            actual_packages.append(pkgs_to_install)
        elif isinstance(pkgs_to_install, Choice):
            # Just a single Choice
            # Make a choice according to the OS info
            choice = pkgs_to_install.choose_to_match_os(os_version)
            if choice is not None:
                actual_packages.append(choice)
        else:
            for pkg in pkgs_to_install:
                if isinstance(pkg, basestring):
                    actual_packages.append(pkg)
                elif isinstance(pkg, Choice):
                    # Make a choice according to the OS info
                    choice = pkg.choose_to_match_os(os_version)
                    if choice is not None:
                        actual_packages.append(choice)
                else:
                    raise GiveUp('%r is not a string or a Choice'%pkg)

        self.pkgs_to_install = actual_packages
Esempio n. 3
0
    def __init__(self, name, role, pkgs_to_install, os_version = None):
        """
        pkgs_to_install is a list of dicts:
        { name: 'pkg_name', min-version: , max-version: ,exact-version:, 
          repo: }
        """
        super(AptAltBuilder, self).__init__(name, role)
        
        actual_packages = [ ]
        if (os_version is None):
            os_version = get_os_version_name()

        for pkg in pkgs_to_install:
            if isinstance(pkg, Choice):
                # A single choice.
                choice = pkg.choose_to_match_os(os_version)
                if (choice is not None):
                    actual_packages.append(choice)
            else:
                actual_packages.append(pkg)
        self.pkgs_to_install = actual_packages
Esempio n. 4
0
    def __init__(self, name, role, pkgs_to_install, os_version=None):
        """
        pkgs_to_install is a list of dicts:
        { name: 'pkg_name', min-version: , max-version: ,exact-version:, 
          repo: }
        """
        super(AptAltBuilder, self).__init__(name, role)

        actual_packages = []
        if (os_version is None):
            os_version = get_os_version_name()

        for pkg in pkgs_to_install:
            if isinstance(pkg, Choice):
                # A single choice.
                choice = pkg.choose_to_match_os(os_version)
                if (choice is not None):
                    actual_packages.append(choice)
            else:
                actual_packages.append(pkg)
        self.pkgs_to_install = actual_packages