From 9ef1ba623b878eda022950a285a308cb61b76ba7 Mon Sep 17 00:00:00 2001
From: Ritesh Raj Sarraf <ritesh.sarraf@collabora.com>
Date: Thu, 17 Mar 2022 19:05:53 +0530
Subject: [PATCH] Move hostname ip entry to the end of /etc/hosts

spymemcached package is FTBFS because a test expects a reverse lookup of
127.0.0.1 to return localhost, but current /etc/hosts configuration
returns the hostname instead.

Let's move this `hostname/ip` entry to the end of /etc/hosts so the
reverse lookup of 127.0.0.1 returns localhost, which makes sense to be
the default case usually.

Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
Signed-off-by: Ritesh Raj Sarraf <ritesh.sarraf@collabora.com>
---
 ...-hostname-ip-entry-to-the-end-of-etc.patch | 36 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 debian/patches/collabora/init_buildsystem-Move-hostname-ip-entry-to-the-end-of-etc.patch

diff --git a/debian/patches/collabora/init_buildsystem-Move-hostname-ip-entry-to-the-end-of-etc.patch b/debian/patches/collabora/init_buildsystem-Move-hostname-ip-entry-to-the-end-of-etc.patch
new file mode 100644
index 0000000000..9afb991776
--- /dev/null
+++ b/debian/patches/collabora/init_buildsystem-Move-hostname-ip-entry-to-the-end-of-etc.patch
@@ -0,0 +1,36 @@
+From: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
+Date: Mon, 21 Jun 2021 12:04:54 -0300
+Subject: init_buildsystem: Move hostname ip entry to the end of /etc/hosts
+
+spymemcached package is FTBFS because a test expects a reverse lookup of
+127.0.0.1 to return localhost, but current /etc/hosts configuration
+returns the hostname instead.
+
+Let's move this `hostname/ip` entry to the end of /etc/hosts so the
+reverse lookup of 127.0.0.1 returns localhost, which makes sense to be
+the default case usually.
+
+Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>
+
+Bug-Debian: https://bugs.debian.org/990278
+---
+ init_buildsystem | 6 +-----
+ 1 file changed, 1 insertion(+), 5 deletions(-)
+
+diff --git a/init_buildsystem b/init_buildsystem
+index d362bc7..e172de6 100755
+--- a/init_buildsystem
++++ b/init_buildsystem
+@@ -1169,11 +1169,7 @@ fi
+ test -e $BUILD_ROOT/.build/init_buildsystem.data || HOST=`hostname`
+ test -e $BUILD_ROOT/etc/hosts || echo "127.0.0.1 localhost" > $BUILD_ROOT/etc/hosts
+ if ! grep -F "127.0.0.1 $HOST" $BUILD_ROOT/etc/hosts > /dev/null ; then
+-    # this makes a reverse lookup on 127.0.0.1 return the host name,
+-    # which is bad, but 127.0.0.2 does not work on all unix systems
+-    echo "127.0.0.1 $HOST" > $BUILD_ROOT/etc/hosts.new
+-    test -f $BUILD_ROOT/etc/hosts && cat $BUILD_ROOT/etc/hosts >> $BUILD_ROOT/etc/hosts.new
+-    mv $BUILD_ROOT/etc/hosts.new $BUILD_ROOT/etc/hosts
++    echo "127.0.0.1 $HOST" >> $BUILD_ROOT/etc/hosts
+ fi
+ 
+ rm -f $BUILD_ROOT/.rpmmacros $BUILD_ROOT/root/.rpmmacros
diff --git a/debian/patches/series b/debian/patches/series
index 8ff52c6bd7..85ff76c031 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -40,3 +40,4 @@ collabora/Add-a-new-none-or-some-element-allowbuilddep-to-project-m.patch
 collabora/Use-the-allowbuilddep-in-meta-config-to-whitelist-project.patch
 collabora/Invalidate-the-rails-cache-for-project-meta-xml-in-show_p.patch
 collabora/Suppress-a-500-error-in-the-web-UI-for-project-meta-confi.patch
+collabora/init_buildsystem-Move-hostname-ip-entry-to-the-end-of-etc.patch
-- 
GitLab