From 3e80a826da19781f86d7e254efed2bbb3fa2a4a7 Mon Sep 17 00:00:00 2001
From: Mohamed Chibani <mohamed.chibani@savoirfairelinux.com>
Date: Wed, 27 Oct 2021 10:57:35 -0400
Subject: [PATCH] build.py - add an option to disable libwrap

Add the build option '--no-libwrap' to disable libwrap.
If set, it will also set '--disable-shared' in daemon
configure options.

Change-Id: Ie252d574dd6fbe99019981c1cbfc0d1348544c74
---
 build.py           |  5 +++++
 scripts/install.sh | 19 ++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/build.py b/build.py
index f0adde1d..7e86548b 100755
--- a/build.py
+++ b/build.py
@@ -381,6 +381,8 @@ def run_install(args):
         install_args.append('-u')
     if args.debug:
         install_args.append('-d')
+    if args.no_libwrap:
+        install_args.append('-W')
 
     if args.distribution == OSX_DISTRIBUTION_NAME:
         # The `universal_newlines` parameter has been renamed to `text` in
@@ -647,6 +649,9 @@ def parse_args():
                     help='Build the Qt client with the Qt path supplied')
     ap.add_argument('--qtver', default=QT5_VERSION,
                     help='Sets the Qt version to build with')
+    ap.add_argument('--no-libwrap', dest='no_libwrap',
+                    default=False, action='store_true',
+                    help='Disable libwrap. Also set --disable-shared option to daemon configure')
 
     dist = choose_distribution()
 
diff --git a/scripts/install.sh b/scripts/install.sh
index b053090e..c32da118 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -1,6 +1,7 @@
 #!/usr/bin/env bash
 
 # Build and install to a local prefix under this repository.
+export OSTYPE
 
 # Flags:
 
@@ -9,6 +10,7 @@
   # -c: client to build
   # -p: number of processors to use
   # -u: disable use of privileges (sudo) during install
+  # -W: disable libwrap and shared library
 
 set -ex
 
@@ -23,7 +25,9 @@ qt5ver=''
 qt5path=''
 proc='1'
 priv_install=true
-while getopts gsc:dq:Q:P:p:u OPT; do
+enable_libwrap=true
+
+while getopts gsc:dq:Q:P:p:uW OPT; do
   case "$OPT" in
     g)
       global='true'
@@ -52,6 +56,9 @@ while getopts gsc:dq:Q:P:p:u OPT; do
     u)
       priv_install='false'
     ;;
+    W)
+      enable_libwrap='false'
+    ;;
     \?)
       exit 1
     ;;
@@ -91,7 +98,13 @@ mkdir -p contrib/native
     ../bootstrap ${prefix:+"--prefix=$prefix"}
     make -j"${proc}"
 )
-
+# Disable shared if requested
+if [[ "$OSTYPE" != "darwin"* ]]; then
+    # Keep the shared libaries on MAC OSX.
+    if [ "${enable_libwrap}" == "false" ]; then
+        CONFIGURE_FLAGS+=( --disable-shared)
+    fi
+fi
 # Build the daemon itself.
 test -f configure || ./autogen.sh
 
@@ -138,7 +151,7 @@ lrc_cmake_flags=(-DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}"
                  -DCMAKE_BUILD_TYPE=Debug
                  -DQT5_VER="${qt5ver}"
                  -DQT5_PATH="${qt5path}"
-                 -DENABLE_LIBWRAP=true
+                 -DENABLE_LIBWRAP="${enable_libwrap}"
                  $static)
 if [ "${global}" = "true" ]; then
     lrc_cmake_flags+=(${prefix:+"-DCMAKE_INSTALL_PREFIX=$prefix"})
-- 
GitLab