From b272e00d6ac969dc18de07574f45eae092bfff11 Mon Sep 17 00:00:00 2001
From: Robert Blake <blake14@llnl.gov>
Date: Mon, 21 Sep 2020 14:11:44 -0700
Subject: [PATCH] util-linux: fix bash completion install errors. (#18696)

* Disable bash completion by default.

* flake8

* Adding explicit dependence on libuuid

* Adding explicit dependence on cryptsetup

This way we don't pick up host crypto packages by mistake.

* Fixing the completion directory.

* Update var/spack/repos/builtin/packages/util-linux/package.py

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>

* flake8

* Removing libuuid linkage according to @michaelkuhn on #18696

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
---
 .../repos/builtin/packages/cryptsetup/package.py  |  4 +++-
 .../repos/builtin/packages/util-linux/package.py  | 15 ++++++++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/var/spack/repos/builtin/packages/cryptsetup/package.py b/var/spack/repos/builtin/packages/cryptsetup/package.py
index c81e024d4d..6b57ad6877 100644
--- a/var/spack/repos/builtin/packages/cryptsetup/package.py
+++ b/var/spack/repos/builtin/packages/cryptsetup/package.py
@@ -35,6 +35,7 @@ class Cryptsetup(AutotoolsPackage):
     depends_on('m4',       type='build')
 
     depends_on('automake@:1.16.1', when='@2.2.1', type='build')
+    depends_on('openssl')
 
     # Upstream includes support for discovering the location of the libintl
     # library but is missing the bit in the Makefile.ac that includes it in
@@ -49,7 +50,8 @@ def url_for_version(self, version):
 
     def configure_args(self):
         args = [
-            'systemd_tmpfilesdir={0}/tmpfiles.d'.format(self.prefix)
+            'systemd_tmpfilesdir={0}/tmpfiles.d'.format(self.prefix),
+            '--with-crypto_backend=openssl',
         ]
         return args
 
diff --git a/var/spack/repos/builtin/packages/util-linux/package.py b/var/spack/repos/builtin/packages/util-linux/package.py
index 1c13e43c42..adb043ecac 100644
--- a/var/spack/repos/builtin/packages/util-linux/package.py
+++ b/var/spack/repos/builtin/packages/util-linux/package.py
@@ -4,6 +4,7 @@
 # SPDX-License-Identifier: (Apache-2.0 OR MIT)
 
 from spack import *
+import os
 
 
 class UtilLinux(AutotoolsPackage):
@@ -28,6 +29,9 @@ class UtilLinux(AutotoolsPackage):
     # Make it possible to disable util-linux's libuuid so that you may
     # reliably depend_on(`libuuid`).
     variant('libuuid', default=True, description='Build libuuid')
+    variant('bash', default=False, description='Install bash completion scripts')
+
+    depends_on('bash', when="+bash", type='run')
 
     def url_for_version(self, version):
         url = "https://www.kernel.org/pub/linux/utils/util-linux/v{0}/util-linux-{1}.tar.gz"
@@ -37,9 +41,18 @@ def configure_args(self):
         config_args = [
             '--disable-use-tty-group',
             '--disable-makeinstall-chown',
-            '--without-systemd'
+            '--without-systemd',
         ]
+        if "+bash" in self.spec:
+            config_args.extend(
+                ['--enable-bash-completion',
+                 '--with-bashcompletiondir=' + os.path.join(
+                     self.spec['bash'].prefix,
+                     "share", "bash-completion", "completions")])
+        else:
+            config_args.append('--disable-bash-completion')
         config_args.extend(self.enable_or_disable('libuuid'))
+
         return config_args
 
     def install(self, spec, prefix):
-- 
GitLab