summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-06-22 18:02:45 +0200
committerHelmut Grohne <helmut@subdivi.de>2024-06-22 18:02:45 +0200
commit99932b7bd7d312449877d26ac39ca8e88f7b81b0 (patch)
treeb8f2d4b0c0c50b631b1b32bc0e0b543cd250e73b /examples
parent97ef2fbc93483aac68a1db1c3622859cc897f1d2 (diff)
downloadpython-linuxnamespaces-99932b7bd7d312449877d26ac39ca8e88f7b81b0.tar.gz
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.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/unschroot.py9
1 files changed, 9 insertions, 0 deletions
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)