Skip to content
Snippets Groups Projects
Commit 44c0d26a authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

add resolv.conf copying in prepare chroot tricks

parent dd2c2ce4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment