From 44c0d26a0f5794ec09cf6d2e9c8dd97c3613a421 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer <sebastien.luttringer@smartjog.com> Date: Fri, 4 Nov 2011 11:35:08 +0100 Subject: [PATCH] add resolv.conf copying in prepare chroot tricks --- installsystems/tools.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/installsystems/tools.py b/installsystems/tools.py index ede3ae7..6a6f910 100644 --- a/installsystems/tools.py +++ b/installsystems/tools.py @@ -361,6 +361,12 @@ def prepare_chroot(path, mount=True): check_call(["mount", "--bind", origin, target], close_fds=True) except CalledProcessError as e: warn("Mount failed: %s.\n" % e) + # trick resolv.conf + if os.path.exists("/etc/resolv.conf"): + resolv_path = os.path.join(path, "etc/resolv.conf") + if os.path.exists(resolv_path): + os.rename(resolv_path, "%s.isbackup" % resolv_path) + shutil.copy("/etc/resolv.conf", resolv_path) # try to guest distro distro = guess_distro(path) # in case of debian disable policy @@ -380,6 +386,14 @@ def unprepare_chroot(path, mount=True): ''' Rollback preparation of a chroot environment inside a directory ''' + # untrick resolv.conf + if os.path.exists("/etc/resolv.conf"): + resolv_path = os.path.join(path, "etc/resolv.conf") + if os.path.exists(resolv_path): + os.unlink(resolv_path) + if os.path.exists("%s.isbackup" % resolv_path): + os.rename("%s.isbackup" % resolv_path, resolv_path) + # try to guest distro distro = guess_distro(path) # cleaning debian stuff -- GitLab