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
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -363,11 +363,16 @@ def prepare_chroot(path, mount=True):
                except CalledProcessError as e:
                    warn("Mount failed: %s.\n" % e)
    # trick resolv.conf
    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