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

fix error when chrooting inside a root without /etc

chroot failed when root is missing dirs before resolv.conf fil
parent 53226773
No related branches found
No related tags found
No related merge requests found
......@@ -363,11 +363,16 @@ def prepare_chroot(path, mount=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:
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)
if not os.path.exists(os.path.dirname(resolv_path)):
os.makedirs(os.path.dirname(resolv_path))
shutil.copy("/etc/resolv.conf", resolv_path)
except Exception as e:
warn("resolv.conf tricks fail: %s" % e)
# try to guest distro
distro = guess_distro(path)
# in case of debian disable policy
......
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