def install_packages(self, buildenv=False): with self.buildenv: # First update the apt cache try: self.get_rpcaptcache().update() except: self.log.printo("update cache failed") raise AptCacheUpdateError() # Then dump the debootstrap packages if self.buildenv.fresh_debootstrap: if self.buildenv.need_dumpdebootstrap: dump_debootstrappkgs(self.xml, self.get_rpcaptcache()) dump_initvmpkgs(self.xml) self.buildenv.need_dumpdebootstrap = False source = self.xml try: initxml = ElbeXML("/var/cache/elbe/source.xml", skip_validate=self.skip_validate, skip_urlcheck=True) self.xml.get_initvmnode_from(initxml) except ValidationError as e: self.log.printo( "/var/cache/elbe/source.xml validation failed") self.log.printo(str(e)) self.log.printo("will not copy initvm node") except IOError: self.log.printo("/var/cache/elbe/source.xml not available") self.log.printo("can not copy initvm node") except NoInitvmNode: self.log.printo("/var/cache/elbe/source.xml is available") self.log.printo("But it does not contain an initvm node") else: sourcepath = os.path.join(self.builddir, "source.xml") source = ElbeXML(sourcepath, buildtype=self.override_buildtype, skip_validate=self.skip_validate, skip_urlcheck=self.skip_urlcheck) self.xml.get_debootstrappkgs_from(source) try: self.xml.get_initvmnode_from(source) except NoInitvmNode: self.log.printo("source.xml is available") self.log.printo("But it does not contain an initvm node") # Seed /etc, we need /etc/hosts for hostname -f to work correctly if not buildenv: self.buildenv.seed_etc() # remove all non-essential packages to ensure that on a incremental # build packages can be removed debootstrap_pkgs = [] for p in self.xml.node("debootstrappkgs"): debootstrap_pkgs.append(p.et.text) pkgs = self.buildenv.xml.get_target_packages() if buildenv: pkgs = pkgs + self.buildenv.xml.get_buildenv_packages() # Now install requested packages for p in pkgs: try: self.get_rpcaptcache().mark_install(p, None) except KeyError: self.log.printo("No Package " + p) except SystemError: self.log.printo("Unable to correct problems " + p) # temporary disabled because of # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776057 # the functions cleans up to much # self.get_rpcaptcache().cleanup(debootstrap_pkgs + pkgs) try: self.get_rpcaptcache().commit() except SystemError: self.log.printo("commiting changes failed") raise AptCacheCommitError()
def install_packages(self, target, buildenv=False): # pylint: disable=too-many-statements # pylint: disable=too-many-branches with target: # First update the apt cache try: self.get_rpcaptcache(env=target).update() except Exception as e: raise AptCacheUpdateError(e) # Then dump the debootstrap packages if target.fresh_debootstrap: if target.need_dumpdebootstrap: dump_debootstrappkgs(self.xml, self.get_rpcaptcache(env=target)) dump_initvmpkgs(self.xml) target.need_dumpdebootstrap = False source = self.xml source_path = "/var/cache/elbe/source.xml" try: initxml = ElbeXML(source_path, skip_validate=self.skip_validate, url_validation=ValidationMode.NO_CHECK) self.xml.get_initvmnode_from(initxml) except ValidationError: logging.exception( "%s validation failed. " "Will not copy initvm node", source_path) except IOError: logging.exception( "%s not available. " "Can not copy initvm node", source_path) except NoInitvmNode: logging.exception( "%s is available. But it does not " "contain an initvm node", source_path) else: sourcepath = os.path.join(self.builddir, "source.xml") source = ElbeXML(sourcepath, buildtype=self.override_buildtype, skip_validate=self.skip_validate, url_validation=self.url_validation) self.xml.get_debootstrappkgs_from(source) try: self.xml.get_initvmnode_from(source) except NoInitvmNode: logging.exception("source.xml is available. " "But it does not contain an initvm node") # Seed /etc, we need /etc/hosts for hostname -f to work correctly if not buildenv: target.seed_etc() # remove all non-essential packages to ensure that on a incremental # build packages can be removed debootstrap_pkgs = [] for p in self.xml.node("debootstrappkgs"): debootstrap_pkgs.append(p.et.text) pkgs = target.xml.get_target_packages() + debootstrap_pkgs if buildenv: pkgs = pkgs + target.xml.get_buildenv_packages() # Now install requested packages for p in pkgs: try: self.get_rpcaptcache(env=target).mark_install(p, None) except KeyError: logging.exception("No Package %s", p) except SystemError: logging.exception( "Unable to correct problems " "in package %s", p) # temporary disabled because of # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776057 # the functions cleans up to much # self.get_rpcaptcache().cleanup(debootstrap_pkgs + pkgs) try: self.get_rpcaptcache(env=target).commit() except SystemError as e: logging.exception("Commiting changes failed") raise AptCacheCommitError(str(e))
def install_packages(self, target, buildenv=False): # pylint: disable=too-many-statements # pylint: disable=too-many-branches with target: # First update the apt cache try: self.get_rpcaptcache(env=target).update() except Exception as e: raise AptCacheUpdateError(e) # Then dump the debootstrap packages if target.fresh_debootstrap: if target.need_dumpdebootstrap: dump_debootstrappkgs(self.xml, self.get_rpcaptcache(env=target)) dump_initvmpkgs(self.xml) target.need_dumpdebootstrap = False source = self.xml try: initxml = ElbeXML( "/var/cache/elbe/source.xml", skip_validate=self.skip_validate, url_validation=ValidationMode.NO_CHECK) self.xml.get_initvmnode_from(initxml) except ValidationError as e: self.log.printo( "/var/cache/elbe/source.xml validation failed") self.log.printo(str(e)) self.log.printo("will not copy initvm node") except IOError: self.log.printo("/var/cache/elbe/source.xml not available") self.log.printo("can not copy initvm node") except NoInitvmNode: self.log.printo("/var/cache/elbe/source.xml is available") self.log.printo("But it does not contain an initvm node") else: sourcepath = os.path.join(self.builddir, "source.xml") source = ElbeXML(sourcepath, buildtype=self.override_buildtype, skip_validate=self.skip_validate, url_validation=self.url_validation) self.xml.get_debootstrappkgs_from(source) try: self.xml.get_initvmnode_from(source) except NoInitvmNode: self.log.printo("source.xml is available") self.log.printo("But it does not contain an initvm node") # Seed /etc, we need /etc/hosts for hostname -f to work correctly if not buildenv: target.seed_etc() # remove all non-essential packages to ensure that on a incremental # build packages can be removed debootstrap_pkgs = [] for p in self.xml.node("debootstrappkgs"): debootstrap_pkgs.append(p.et.text) pkgs = target.xml.get_target_packages() + debootstrap_pkgs if buildenv: pkgs = pkgs + target.xml.get_buildenv_packages() # Now install requested packages for p in pkgs: try: self.get_rpcaptcache(env=target).mark_install(p, None) except KeyError: self.log.printo("No Package " + p) except SystemError as e: self.log.printo("Error: Unable to correct problems in " "package %s (%s)" % (p, str(e))) # temporary disabled because of # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776057 # the functions cleans up to much # self.get_rpcaptcache().cleanup(debootstrap_pkgs + pkgs) try: self.get_rpcaptcache(env=target).commit() except SystemError as e: self.log.printo("commiting changes failed: %s" % str(e)) raise AptCacheCommitError(str(e))