From 83e5f0da338f3d736a8230db6196de08225cf4a8 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 27 Sep 2011 11:15:31 +0200 Subject: [PATCH 1/1] Remove some unnecessary code that creates the build chroot. --- pakfire/builder.py | 64 ++++---------------------------------------- pakfire/constants.py | 5 +++- 2 files changed, 9 insertions(+), 60 deletions(-) diff --git a/pakfire/builder.py b/pakfire/builder.py index 0633cf8c..2953e737 100644 --- a/pakfire/builder.py +++ b/pakfire/builder.py @@ -146,8 +146,8 @@ class BuildEnviron(object): # Populate /dev. self.populate_dev() - # Create all devnodes and other dirs we need. - self.prepare() + # Setup domain name resolution in chroot. + self.setup_dns() # Extract all needed packages. self.extract() @@ -319,60 +319,6 @@ class BuildEnviron(object): return ret - def prepare(self): - prepared_tag = ".prepared" - - if os.path.exists(self.chrootPath(prepared_tag)): - return - - # Create directory. - if not os.path.exists(self.path): - os.makedirs(self.path) - - # Create important directories. - dirs = [ - "build", - self.buildroot, - "dev", - "dev/pts", - "dev/shm", - "etc", - "proc", - "result", - "sys", - "tmp", - "usr/src", - ] - - # Create cache dir if ccache is enabled. - if self.settings.get("enable_ccache"): - dirs.append("var/cache/ccache") - - if not os.path.exists(CCACHE_CACHE_DIR): - os.makedirs(CCACHE_CACHE_DIR) - - for dir in dirs: - dir = self.chrootPath(dir) - if not os.path.exists(dir): - os.makedirs(dir) - - # Create neccessary files like /etc/fstab and /etc/mtab. - files = ( - "etc/fstab", - "etc/mtab", - prepared_tag, - ) - - for file in files: - file = self.chrootPath(file) - dir = os.path.dirname(file) - if not os.path.exists(dir): - os.makedirs(dir) - f = open(file, "w") - f.close() - - self._prepare_dns() - def populate_dev(self): nodes = [ "/dev/null", @@ -404,7 +350,7 @@ class BuildEnviron(object): os.symlink("/proc/self/fd/2", self.chrootPath("dev", "stderr")) os.symlink("/proc/self/fd", self.chrootPath("dev", "fd")) - def _prepare_dns(self): + def setup_dns(self): """ Add DNS resolution facility to chroot environment by copying /etc/resolv.conf and /etc/hosts. @@ -609,8 +555,8 @@ class BuildEnviron(object): self.install(SHELL_PACKAGES) # XXX need to set CFLAGS here - command = "/usr/sbin/chroot %s /usr/bin/chroot-shell %s" % \ - (self.chrootPath(), " ".join(args)) + command = "/usr/sbin/chroot %s %s %s" % \ + (self.chrootPath(), SHELL_SCRIPT, " ".join(args)) # Add personality if we require one if self.pakfire.distro.personality: diff --git a/pakfire/constants.py b/pakfire/constants.py index 64fdab26..523ec952 100644 --- a/pakfire/constants.py +++ b/pakfire/constants.py @@ -69,7 +69,10 @@ BUILD_PACKAGES = [ "@Build", "pakfire-build>=%s" % PAKFIRE_LEAST_COMPATIBLE_VERSION, ] -SHELL_PACKAGES = ["elinks", "less", "vim",] + +# A script that is called, when a user is dropped to a chroot shell. +SHELL_SCRIPT = "/usr/lib/buildsystem-tools/chroot-shell" +SHELL_PACKAGES = ["elinks", "less", "vim", SHELL_SCRIPT,] BUILD_ROOT = "/var/lib/pakfire/build" SOURCE_DOWNLOAD_URL = "http://source.ipfire.org/source-3.x/" -- 2.39.2