Ejemplo n.º 1
0
    def install(self, repo_urls={}):
        """Install packages into the install root.

        This function installs the packages listed in the supplied kickstart
        into the install root. By default, the packages are installed from the
        repository URLs specified in the kickstart.

        repo_urls -- a dict which maps a repository name to a repository URL;
                     if supplied, this causes any repository URLs specified in
                     the kickstart to be overridden.

        """

        # initialize pkg list to install
        if self.ks:
            self.__sanity_check()

            self._required_pkgs = kickstart.get_packages(self.ks, self._get_required_packages())
            self._excluded_pkgs = kickstart.get_excluded(self.ks, self._get_excluded_packages())
            self._required_groups = kickstart.get_groups(self.ks)
        else:
            self._required_pkgs = None
            self._excluded_pkgs = None
            self._required_groups = None

        pkg_manager = self.get_pkg_manager()
        pkg_manager.setup()

        for repo in kickstart.get_repos(self.ks, repo_urls):
            (
                name,
                baseurl,
                mirrorlist,
                inc,
                exc,
                proxy,
                proxy_username,
                proxy_password,
                debuginfo,
                source,
                gpgkey,
                disable,
                ssl_verify,
                cost,
                priority,
            ) = repo

            yr = pkg_manager.addRepository(
                name, baseurl, mirrorlist, proxy, proxy_username, proxy_password, inc, exc, ssl_verify, cost, priority
            )

        if kickstart.exclude_docs(self.ks):
            rpm.addMacro("_excludedocs", "1")
        rpm.addMacro("_dbpath", "/var/lib/rpm")
        rpm.addMacro("__file_context_path", "%{nil}")
        if kickstart.inst_langs(self.ks) != None:
            rpm.addMacro("_install_langs", kickstart.inst_langs(self.ks))

        try:
            try:
                self.__preinstall_packages(pkg_manager)
                self.__select_packages(pkg_manager)
                self.__select_groups(pkg_manager)
                self.__deselect_packages(pkg_manager)
                self.__localinst_packages(pkg_manager)

                BOOT_SAFEGUARD = 256L * 1024 * 1024  # 256M
                checksize = self._root_fs_avail
                if checksize:
                    checksize -= BOOT_SAFEGUARD
                if self.target_arch:
                    pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_IGNOREARCH)
                pkg_manager.runInstall(checksize)
            except CreatorError, e:
                raise
        finally:
            self._pkgs_content = pkg_manager.getAllContent()
            self._pkgs_license = pkg_manager.getPkgsLicense()
            self.__attachment_packages(pkg_manager)

            pkg_manager.close()

        # hook post install
        self.postinstall()

        # do some clean up to avoid lvm info leakage.  this sucks.
        for subdir in ("cache", "backup", "archive"):
            lvmdir = self._instroot + "/etc/lvm/" + subdir
            try:
                for f in os.listdir(lvmdir):
                    os.unlink(lvmdir + "/" + f)
            except:
                pass
Ejemplo n.º 2
0
    def install(self, repo_urls=None):
        """Install packages into the install root.

        This function installs the packages listed in the supplied kickstart
        into the install root. By default, the packages are installed from the
        repository URLs specified in the kickstart.

        repo_urls -- a dict which maps a repository name to a repository URL;
                     if supplied, this causes any repository URLs specified in
                     the kickstart to be overridden.

        """

        # initialize pkg list to install
        if self.ks:
            self.__sanity_check()

            self._required_pkgs = \
                kickstart.get_packages(self.ks, self._get_required_packages())
            self._excluded_pkgs = \
                kickstart.get_excluded(self.ks, self._get_excluded_packages())
            self._required_groups = kickstart.get_groups(self.ks)
        else:
            self._required_pkgs = None
            self._excluded_pkgs = None
            self._required_groups = None

        pkg_manager = self.get_pkg_manager()
        pkg_manager.setup()

        if hasattr(self, 'install_pkgs') and self.install_pkgs:
            if 'debuginfo' in self.install_pkgs:
                pkg_manager.install_debuginfo = True

        for repo in kickstart.get_repos(self.ks, repo_urls):
            (name, baseurl, mirrorlist, inc, exc, proxy, proxy_username,
             proxy_password, debuginfo, source, gpgkey, disable, ssl_verify,
             nocache, cost, priority) = repo

            yr = pkg_manager.addRepository(name, baseurl, mirrorlist, proxy,
                                           proxy_username, proxy_password, inc,
                                           exc, ssl_verify, nocache, cost,
                                           priority)

        if kickstart.exclude_docs(self.ks):
            rpm.addMacro("_excludedocs", "1")
        rpm.addMacro("_dbpath", "/var/lib/rpm")
        rpm.addMacro("__file_context_path", "%{nil}")
        if kickstart.inst_langs(self.ks) != None:
            rpm.addMacro("_install_langs", kickstart.inst_langs(self.ks))

        try:
            self.__preinstall_packages(pkg_manager)
            self.__select_packages(pkg_manager)
            self.__select_groups(pkg_manager)
            self.__deselect_packages(pkg_manager)
            self.__localinst_packages(pkg_manager)

            BOOT_SAFEGUARD = 256L * 1024 * 1024  # 256M
            checksize = self._root_fs_avail
            if checksize:
                checksize -= BOOT_SAFEGUARD
            if self.target_arch:
                pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_IGNOREARCH)
            pkg_manager.runInstall(checksize)
        except CreatorError, e:
            raise
Ejemplo n.º 3
0
    def install(self, repo_urls=None):
        """Install packages into the install root.

        This function installs the packages listed in the supplied kickstart
        into the install root. By default, the packages are installed from the
        repository URLs specified in the kickstart.

        repo_urls -- a dict which maps a repository name to a repository URL;
                     if supplied, this causes any repository URLs specified in
                     the kickstart to be overridden.

        """

        # initialize pkg list to install
        if self.ks:
            self.__sanity_check()

            self._required_pkgs = \
                kickstart.get_packages(self.ks, self._get_required_packages())
            self._excluded_pkgs = \
                kickstart.get_excluded(self.ks, self._get_excluded_packages())
            self._required_groups = kickstart.get_groups(self.ks)
        else:
            self._required_pkgs = None
            self._excluded_pkgs = None
            self._required_groups = None

        pkg_manager = self.get_pkg_manager()
        pkg_manager.setup()

        if hasattr(self, 'install_pkgs') and self.install_pkgs:
            if 'debuginfo' in self.install_pkgs:
                pkg_manager.install_debuginfo = True

        for repo in kickstart.get_repos(self.ks, repo_urls):
            (name, baseurl, mirrorlist, inc, exc,
             proxy, proxy_username, proxy_password, debuginfo,
             source, gpgkey, disable, ssl_verify, nocache,
             cost, priority) = repo

            yr = pkg_manager.addRepository(name, baseurl, mirrorlist, proxy,
                        proxy_username, proxy_password, inc, exc, ssl_verify,
                        nocache, cost, priority)

        if kickstart.exclude_docs(self.ks):
            rpm.addMacro("_excludedocs", "1")
        rpm.addMacro("_dbpath", "/var/lib/rpm")
        rpm.addMacro("__file_context_path", "%{nil}")
        if kickstart.inst_langs(self.ks) != None:
            rpm.addMacro("_install_langs", kickstart.inst_langs(self.ks))

        try:
            self.__preinstall_packages(pkg_manager)
            self.__select_packages(pkg_manager)
            self.__select_groups(pkg_manager)
            self.__deselect_packages(pkg_manager)
            self.__localinst_packages(pkg_manager)

            BOOT_SAFEGUARD = 256L * 1024 * 1024 # 256M
            checksize = self._root_fs_avail
            if checksize:
                checksize -= BOOT_SAFEGUARD
            if self.target_arch:
                pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_IGNOREARCH)
            pkg_manager.runInstall(checksize)
        except CreatorError, e:
            raise
Ejemplo n.º 4
0
    def install(self, repo_urls = {}):
        """Install packages into the install root.

        This function installs the packages listed in the supplied kickstart
        into the install root. By default, the packages are installed from the
        repository URLs specified in the kickstart.

        repo_urls -- a dict which maps a repository name to a repository URL;
                     if supplied, this causes any repository URLs specified in
                     the kickstart to be overridden.

        """

        # initialize pkg list to install
        if self.ks:
            self.__sanity_check()

            self._required_pkgs = \
                kickstart.get_packages(self.ks, self._get_required_packages())
            self._excluded_pkgs = \
                kickstart.get_excluded(self.ks, self._get_excluded_packages())
            self._required_groups = kickstart.get_groups(self.ks)
        else:
            self._required_pkgs = None
            self._excluded_pkgs = None
            self._required_groups = None

        yum_conf = self._mktemp(prefix = "yum.conf-")

        pkg_manager = self.get_pkg_manager()
        pkg_manager.setup(yum_conf, self._instroot)

        for repo in kickstart.get_repos(self.ks, repo_urls):
            (name, baseurl, mirrorlist, inc, exc,
             proxy, proxy_username, proxy_password, debuginfo,
             source, gpgkey, disable, ssl_verify, cost, priority) = repo

            yr = pkg_manager.addRepository(name, baseurl, mirrorlist, proxy,
                        proxy_username, proxy_password, inc, exc, ssl_verify,
                        cost, priority)

        if kickstart.exclude_docs(self.ks):
            rpm.addMacro("_excludedocs", "1")
        rpm.addMacro("_dbpath", "/var/lib/rpm")
        rpm.addMacro("__file_context_path", "%{nil}")
        if kickstart.inst_langs(self.ks) != None:
            rpm.addMacro("_install_langs", kickstart.inst_langs(self.ks))

        try:
            try:
                self.__select_packages(pkg_manager)
                self.__select_groups(pkg_manager)
                self.__deselect_packages(pkg_manager)
                self.__localinst_packages(pkg_manager)

                BOOT_SAFEGUARD = 256L * 1024 * 1024 # 256M
                checksize = self._root_fs_avail
                if checksize:
                    checksize -= BOOT_SAFEGUARD
                if self.target_arch:
                    pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_IGNOREARCH)
                pkg_manager.runInstall(checksize)
            except CreatorError, e:
                raise
        finally:
            self._pkgs_content = pkg_manager.getAllContent()
            self._pkgs_license = pkg_manager.getPkgsLicense()

            pkg_manager.closeRpmDB()
            pkg_manager.close()
            os.unlink(yum_conf)

        # do some clean up to avoid lvm info leakage.  this sucks.
        for subdir in ("cache", "backup", "archive"):
            lvmdir = self._instroot + "/etc/lvm/" + subdir
            try:
                for f in os.listdir(lvmdir):
                    os.unlink(lvmdir + "/" + f)
            except:
                pass
Ejemplo n.º 5
0
    def install(self, repo_urls=None):
        """Install packages into the install root.

        This function installs the packages listed in the supplied kickstart
        into the install root. By default, the packages are installed from the
        repository URLs specified in the kickstart.

        repo_urls -- a dict which maps a repository name to a repository;
                     if supplied, this causes any repository URLs specified in
                     the kickstart to be overridden.

        """
        def checkScriptletError(dirname, suffix):
            if os.path.exists(dirname):
                list = os.listdir(dirname)
                for line in list:
                    filepath = os.path.join(dirname, line)
                    if os.path.isfile(filepath) and 0 < line.find(suffix):
                        return True
                    else:
                        continue
             
            return False
            
        def get_ssl_verify(ssl_verify=None):
            if ssl_verify is not None:
                return not ssl_verify.lower().strip() == 'no'
            else:
                return not self.ssl_verify.lower().strip() == 'no'

        # initialize pkg list to install
        if self.ks:
            self.__sanity_check()

            self._required_pkgs = \
                kickstart.get_packages(self.ks, self._get_required_packages())
            self._excluded_pkgs = \
                kickstart.get_excluded(self.ks, self._get_excluded_packages())
            self._required_groups = kickstart.get_groups(self.ks)
        else:
            self._required_pkgs = None
            self._excluded_pkgs = None
            self._required_groups = None

        if not repo_urls:
            repo_urls = self.extrarepos

        pkg_manager = self.get_pkg_manager()
        pkg_manager.setup()

        if hasattr(self, 'install_pkgs') and self.install_pkgs:
            if 'debuginfo' in self.install_pkgs:
                pkg_manager.install_debuginfo = True

        for repo in kickstart.get_repos(self.ks, repo_urls, self.ignore_ksrepo):
            (name, baseurl, mirrorlist, inc, exc,
             proxy, proxy_username, proxy_password, debuginfo,
             source, gpgkey, disable, ssl_verify, nocache,
             cost, priority) = repo

            ssl_verify = get_ssl_verify(ssl_verify)
            yr = pkg_manager.addRepository(name, baseurl, mirrorlist, proxy,
                        proxy_username, proxy_password, inc, exc, ssl_verify,
                        nocache, cost, priority)

        if kickstart.exclude_docs(self.ks):
            rpm.addMacro("_excludedocs", "1")
        rpm.addMacro("_dbpath", "/var/lib/rpm")
        rpm.addMacro("__file_context_path", "%{nil}")
        if kickstart.inst_langs(self.ks) != None:
            rpm.addMacro("_install_langs", kickstart.inst_langs(self.ks))

        try:
            self.__preinstall_packages(pkg_manager)
            self.__select_packages(pkg_manager)
            self.__select_groups(pkg_manager)
            self.__deselect_packages(pkg_manager)
            self.__localinst_packages(pkg_manager)
            self.__check_packages(pkg_manager)

            BOOT_SAFEGUARD = 256L * 1024 * 1024 # 256M
            checksize = self._root_fs_avail
            if checksize:
                checksize -= BOOT_SAFEGUARD
            if self.target_arch:
                pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_IGNOREARCH)

            # If we have multiple partitions, don't check diskspace when rpm run transaction
            # because rpm check '/' partition only.
            if self.multiple_partitions:
                pkg_manager._add_prob_flags(rpm.RPMPROB_FILTER_DISKSPACE)
            pkg_manager.runInstall(checksize)
        except CreatorError, e:
            raise