Commit 3101c6a0 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

prepare and unprepare chroot create resolf.conf only if /etc exists

parent 72b88654
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -375,12 +375,10 @@ def prepare_chroot(path, mount=True):
                    warn("Mount failed: %s.\n" % e)
    # trick resolv.conf
    try:
        if os.path.exists("/etc/resolv.conf"):
        if os.path.exists("/etc/resolv.conf") and os.path.exists(os.path.join(path, "etc")):
            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)
@@ -404,7 +402,7 @@ 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"):
    if os.path.exists("/etc/resolv.conf") and os.path.exists(os.path.join(path, "etc"))::
        resolv_path = os.path.join(path, "etc/resolv.conf")
        if os.path.exists(resolv_path):
            os.unlink(resolv_path)