From 99932b7bd7d312449877d26ac39ca8e88f7b81b0 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 22 Jun 2024 18:02:45 +0200 Subject: unschroot: create an /etc/hosts unless it exists Software has a reasonable assumption that localhost as well as the current hostname resolves to an IP address. Without an /etc/hosts file, this is not the case and makes some builds such as src:ovn fail. --- examples/unschroot.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/unschroot.py b/examples/unschroot.py index 5f6ad72..cbabcc4 100755 --- a/examples/unschroot.py +++ b/examples/unschroot.py @@ -167,6 +167,15 @@ def do_begin_session(args: argparse.Namespace) -> None: for tmem in tarf: if not tmem.name.startswith(("dev/", "./dev/")): tarf.extract(tmem, numeric_owner=True) + etc_hosts = pathlib.Path("./etc/hosts") + if not etc_hosts.exists(): + etc_hosts.write_text( + """127.0.0.1 localhost +127.0.1.1 %s +::1 localhost ip6-localhost ip6-loopback +""" + % socket.gethostname(), + ) sys.exit(0) childsock.close() mainsock.recv(1) -- cgit v1.2.3