[Piuparts-commits] [piuparts] 02/02: p: create /etc/resolv.conf with only nameserver entries

Holger Levsen holger at moszumanska.debian.org
Thu Nov 20 13:42:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 52d7eba4184cf7e933a3649e3135ddd5d0940390
Author: Andreas Beckmann <anbe at debian.org>
Date:   Thu Nov 20 14:29:27 2014 +0100

    p: create /etc/resolv.conf with only nameserver entries
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 debian/changelog |  2 ++
 piuparts.py      | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 241d4fd..0ede1c0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,8 @@ piuparts (0.61) UNRELEASED; urgency=medium
   * piuparts.py:
     - Add to ignored_files:
       + /etc/modules-load.d/modules.conf  (dangling symlink to ../modules)
+    - Create /etc/resolv.conf in the chroot using only the nameserver entries
+      found on the host.
   * Add "AddDefaultCharset utf-8" to the apache2 configuration snipplet
     example, so that logfiles are displayed as UTF-8.
   * pre_install_foreign_architecture: New script to enable foreign
diff --git a/piuparts.py b/piuparts.py
index 07025b6..b9d1359 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -942,6 +942,17 @@ class Chroot:
         os.chmod(full_name, 0755)
         logging.debug("Created policy-rc.d and chmodded it.")
 
+    def create_resolv_conf(self):
+        """Create a resolv.conf containing the nameservers from the host system."""
+        full_name = self.relative("etc/resolv.conf")
+        nameservers = ""
+        with open("/etc/resolv.conf", "r") as f:
+            for line in f:
+                if line.startswith("nameserver"):
+                    nameservers += line
+        create_file(full_name, nameservers)
+        logging.debug("Created resolv.conf.")
+
     def setup_minimal_chroot(self):
         """Set up a minimal Debian system in a chroot."""
         logging.debug("Setting up minimal chroot for %s at %s." %
@@ -981,6 +992,7 @@ class Chroot:
         self.create_apt_conf()
         self.create_dpkg_conf()
         self.create_policy_rc_d()
+        self.create_resolv_conf()
         for bindmount in settings.bindmounts:
             run(["mkdir", "-p", self.relative(bindmount)])
             run(["mount", "-obind", bindmount, self.relative(bindmount)])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list