os.remove(filepath)
shutil.move(temp_new_filepath, filepath)
-def fix_hosts_line_in_nsswitch(line):
- if line.startswith("hosts:"):
- sources = line.split(" ")
- if 'resolve' not in sources:
- return " ".join(["resolve" if w == "dns" else w for w in sources])
- return line
-
def enable_networkd(workspace):
run(["systemctl",
"--root", os.path.join(workspace, "root"),
check=True)
os.remove(os.path.join(workspace, "root", "etc/resolv.conf"))
- os.symlink("../usr/lib/systemd/resolv.conf", os.path.join(workspace, "root", "etc/resolv.conf"))
-
- patch_file(os.path.join(workspace, "root", "etc/nsswitch.conf"), fix_hosts_line_in_nsswitch)
+ os.symlink("../run/systemd/resolve/stub-resolv.conf", os.path.join(workspace, "root", "etc/resolv.conf"))
with open(os.path.join(workspace, "root", "etc/systemd/network/all-ethernet.network"), "w") as f:
f.write("""\