diff --git a/installsystems/tools.py b/installsystems/tools.py index ede3ae7dba8e074fee826007fb68cb758546e3ac..6a6f910a92f1ec28283cbde18718b7255e0f1c3b 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