Mattia Rizzolo dixit:

>Probably the best solution here is to also include whatever is in
>/etc/hostname into the generated /etc/hosts, but I'm filing this bug to
>see if anybody thinks otherwise.

Probably not, but the short and long hostname as returned
by the hostname command (which can differ from what’s in
the file). [Update: hostname -f does DNS lookups, so we
take whatever hostname without an argument returns, which
is the node name as known to the kernel, and if it contains
a period, also add the short(ened) form.]

In the long term, however, adding more and more tricks for
packages doing network stuff during build is not the best
way forward, I’d definitely patch them, so they connect to
localhost only. But this one is easy enough, I think, so
let’s do that. (Attached.)

bye,
//mirabilos
-- 
22:20⎜<asarch> The crazy that persists in his craziness becomes a master
22:21⎜<asarch> And the distance between the craziness and geniality is
only measured by the success 18:35⎜<asarch> "Psychotics are consistently
inconsistent. The essence of sanity is to be inconsistently inconsistent
From 844bf96ba181520a63e362febcfe61dd846e7f0a Mon Sep 17 00:00:00 2001
From: mirabilos <t...@debian.org>
Date: Sun, 1 Sep 2019 17:55:05 +0200
Subject: [PATCH] Add current system hostname to localhost in generated hosts
 file.

Closes: #939099
---
 pbuilder-buildpackage | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/pbuilder-buildpackage b/pbuilder-buildpackage
index e597ee42..1c162057 100755
--- a/pbuilder-buildpackage
+++ b/pbuilder-buildpackage
@@ -197,10 +197,16 @@ if [ "$USENETWORK" = "no" ]; then
     # no network is possible doesn't choke.
     rm -f "$BUILDPLACE/etc/resolv.conf" # break hardlinks
     : > "$BUILDPLACE/etc/resolv.conf"
+    # possibly long hostname
+    hostname=$(hostname)
+    # also short hostname
+    case $hostname in
+    (*.*) hostname="$hostname ${hostname%%.*}" ;;
+    esac
     # loopback access only
     rm -f "$BUILDPLACE/etc/hosts" # break hardlinks
-    cat > "$BUILDPLACE/etc/hosts" <<'EOF'
-       127.0.0.1       localhost localhost.localdomain
+    cat > "$BUILDPLACE/etc/hosts" <<EOF
+       127.0.0.1       localhost localhost.localdomain $hostname
 
        ::1     ip6-localhost ip6-loopback localhost6 localhost6.localdomain6
        fe00::0 ip6-localnet
-- 
2.23.0

Reply via email to