Repository: spack/spack

Issue:
Installation issue: lmod  -- build error with patch for libbsd on rhel7
Sorry I'm very new to spack, and I'm running into some patch issues trying to install lmod to a rhel7 machine.


### Steps to reproduce the issue

```console
$ vagrant init generic/rhel7
$ vagrant ssh
$ cd opt;
$ git clone https://github.com/spack/spack
$ cd spack
$ export SPACK_ROOT=$PWD
$ export PATH=$SPACK_ROOT/bin:$PATH
$ . $SPACK_ROOT/share/spack/setup-env.sh
$ spack install lmod
... errors out

[root@controller spack]# spack spec lmod
Input spec
--------------------------------
lmod

Concretized
--------------------------------
lmod@7.8%gcc@4.8.5 arch=linux-rhel7-x86_64 
    ^lua@5.3.4%gcc@4.8.5 arch=linux-rhel7-x86_64 
        ^ncurses@6.1%gcc@4.8.5~symlinks~termlib arch=linux-rhel7-x86_64 
            ^pkgconf@1.5.4%gcc@4.8.5 arch=linux-rhel7-x86_64 
        ^readline@7.0%gcc@4.8.5 arch=linux-rhel7-x86_64 
        ^unzip@6.0%gcc@4.8.5 arch=linux-rhel7-x86_64 
    ^lua-luafilesystem@1_6_3%gcc@4.8.5 arch=linux-rhel7-x86_64 
        ^git@2.20.1%gcc@4.8.5~tcltk arch=linux-rhel7-x86_64 
            ^autoconf@2.69%gcc@4.8.5 arch=linux-rhel7-x86_64 
                ^m4@1.4.18%gcc@4.8.5 patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,c0a408fbffb7255fcc75e26bd8edab116fc81d216bfd18b473668b7739a4158e,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 +sigsegv arch=linux-rhel7-x86_64 
                    ^libsigsegv@2.11%gcc@4.8.5 arch=linux-rhel7-x86_64 
                ^perl@5.26.2%gcc@4.8.5+cpanm patches=0eac10ed90aeb0459ad8851f88081d439a4e41978e586ec743069e8b059370ac +shared+threads arch=linux-rhel7-x86_64 
                    ^gdbm@1.18.1%gcc@4.8.5 arch=linux-rhel7-x86_64 
            ^automake@1.16.1%gcc@4.8.5 arch=linux-rhel7-x86_64 
            ^curl@7.60.0%gcc@4.8.5~darwinssl~libssh~libssh2~nghttp2 arch=linux-rhel7-x86_64 
                ^openssl@1.1.1%gcc@4.8.5+systemcerts arch=linux-rhel7-x86_64 
                    ^zlib@1.2.11%gcc@4.8.5+optimize+pic+shared arch=linux-rhel7-x86_64 
            ^expat@2.2.5%gcc@4.8.5+libbsd arch=linux-rhel7-x86_64 
                ^libbsd@0.9.1%gcc@4.8.5 patches=aaae81b3edc29362a94770cc235f1eb6d6f84bb6168c4084a7376a09a2ae93c2 arch=linux-rhel7-x86_64 
            ^gettext@0.19.8.1%gcc@4.8.5+bzip2+curses+git~libunistring+libxml2 patches=9acdb4e73f67c241b5ef32505c9ddf7cf6884ca8ea661692f21dca28483b04b8 +tar+xz arch=linux-rhel7-x86_64 
                ^bzip2@1.0.6%gcc@4.8.5+shared arch=linux-rhel7-x86_64 
                    ^diffutils@3.6%gcc@4.8.5 arch=linux-rhel7-x86_64 
                ^libxml2@2.9.8%gcc@4.8.5~python arch=linux-rhel7-x86_64 
                    ^xz@5.2.4%gcc@4.8.5 arch=linux-rhel7-x86_64 
                ^tar@1.30%gcc@4.8.5 arch=linux-rhel7-x86_64 
            ^libiconv@1.15%gcc@4.8.5 arch=linux-rhel7-x86_64 
            ^libtool@2.4.6%gcc@4.8.5 arch=linux-rhel7-x86_64 
            ^pcre@8.42%gcc@4.8.5+jit+utf arch=linux-rhel7-x86_64 
    ^lua-luaposix@33.4.0%gcc@4.8.5 arch=linux-rhel7-x86_64 
    ^tcl@8.6.8%gcc@4.8.5 arch=linux-rhel7-x86_64 

[root@controller spack]# spack install libbsd
==> Installing libbsd
==> Searching for binary cache of libbsd
==> Warning: No Spack mirrors are currently configured
==> No binary for libbsd found: installing from source
==> Using cached archive: /opt/spack/var/spack/cache/libbsd/libbsd-0.9.1.tar.xz
==> Staging archive: /opt/spack/var/spack/stage/libbsd-0.9.1-r3trfta3vmqcxxbzsacgagk7hiaiau3s/libbsd-0.9.1.tar.xz
==> Created stage in /opt/spack/var/spack/stage/libbsd-0.9.1-r3trfta3vmqcxxbzsacgagk7hiaiau3s
1 out of 1 hunk FAILED -- saving rejects to file include/bsd/sys/cdefs.h.rej
==> Patch cdefs.h.patch failed.
==> Error: ProcessError: Command exited with status 1:
    '/bin/patch' '-s' '-p' '1' '-i' '/opt/spack/var/spack/repos/builtin/packages/libbsd/cdefs.h.patch' '-d' '.'

```

### Platform and user environment

Please report your OS here:
```commandline
$ uname -a 
Linux controller 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/system-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)

``` 
and, if relevant, post or attach:

- `packages.yaml`
- `compilers.yaml`

to the issue 

Not entirely clear where these are located?

### Additional information

Sometimes the issue benefits from additional details. In these cases there are
a few things we can suggest doing. First of all, you can post the full output of:
```console
$ spack spec --install-status lmod
[root@controller etc]# spack spec --install-status lmod
Input spec
--------------------------------
 -   lmod

Concretized
--------------------------------
 -   lmod@7.8%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]      ^lua@5.3.4%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]          ^ncurses@6.1%gcc@4.8.5~symlinks~termlib arch=linux-rhel7-x86_64 
[+]              ^pkgconf@1.5.4%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]          ^readline@7.0%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]          ^unzip@6.0%gcc@4.8.5 arch=linux-rhel7-x86_64 
 -       ^lua-luafilesystem@1_6_3%gcc@4.8.5 arch=linux-rhel7-x86_64 
 -           ^git@2.20.1%gcc@4.8.5~tcltk arch=linux-rhel7-x86_64 
[+]              ^autoconf@2.69%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]                  ^m4@1.4.18%gcc@4.8.5 patches=3877ab548f88597ab2327a2230ee048d2d07ace1062efe81fc92e91b7f39cd00,c0a408fbffb7255fcc75e26bd8edab116fc81d216bfd18b473668b7739a4158e,fc9b61654a3ba1a8d6cd78ce087e7c96366c290bc8d2c299f09828d793b853c8 +sigsegv arch=linux-rhel7-x86_64 
[+]                      ^libsigsegv@2.11%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]                  ^perl@5.26.2%gcc@4.8.5+cpanm patches=0eac10ed90aeb0459ad8851f88081d439a4e41978e586ec743069e8b059370ac +shared+threads arch=linux-rhel7-x86_64 
[+]                      ^gdbm@1.18.1%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]              ^automake@1.16.1%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]              ^curl@7.60.0%gcc@4.8.5~darwinssl~libssh~libssh2~nghttp2 arch=linux-rhel7-x86_64 
[+]                  ^openssl@1.1.1%gcc@4.8.5+systemcerts arch=linux-rhel7-x86_64 
[+]                      ^zlib@1.2.11%gcc@4.8.5+optimize+pic+shared arch=linux-rhel7-x86_64 
 -               ^expat@2.2.5%gcc@4.8.5+libbsd arch=linux-rhel7-x86_64 
 -                   ^libbsd@0.9.1%gcc@4.8.5 patches=aaae81b3edc29362a94770cc235f1eb6d6f84bb6168c4084a7376a09a2ae93c2 arch=linux-rhel7-x86_64 
 -               ^gettext@0.19.8.1%gcc@4.8.5+bzip2+curses+git~libunistring+libxml2 patches=9acdb4e73f67c241b5ef32505c9ddf7cf6884ca8ea661692f21dca28483b04b8 +tar+xz arch=linux-rhel7-x86_64 
 -                   ^bzip2@1.0.6%gcc@4.8.5+shared arch=linux-rhel7-x86_64 
 -                       ^diffutils@3.6%gcc@4.8.5 arch=linux-rhel7-x86_64 
 -                   ^libxml2@2.9.8%gcc@4.8.5~python arch=linux-rhel7-x86_64 
 -                       ^xz@5.2.4%gcc@4.8.5 arch=linux-rhel7-x86_64 
 -                   ^tar@1.30%gcc@4.8.5 arch=linux-rhel7-x86_64 
 -               ^libiconv@1.15%gcc@4.8.5 arch=linux-rhel7-x86_64 
 -               ^libtool@2.4.6%gcc@4.8.5 arch=linux-rhel7-x86_64 
 -               ^pcre@8.42%gcc@4.8.5+jit+utf arch=linux-rhel7-x86_64 
 -       ^lua-luaposix@33.4.0%gcc@4.8.5 arch=linux-rhel7-x86_64 
[+]      ^tcl@8.6.8%gcc@4.8.5 arch=linux-rhel7-x86_64 
...
```
to show people whether Spack installed a faulty software or if it was not able to
build it at all. 

If your build didn't make it past the configure stage, Spack as also commands to parse 
logs and report error and warning messages:
```console
$ spack log-parse --show=errors,warnings <file-to-parse>
```
You might want to run this command on the `config.log` or any other similar file
found in the stage directory: 
```console
[root@controller spack]# spack location -s lmod
/opt/spack/var/spack/stage/lmod-7.8-tf4lqsqo4ffijreb4ssbf3tpjqb3kkxb
```
In case in `config.log` there are other settings that you think might be the cause 
of the build failure, you can consider attaching the file to this issue.
```console
[root@controller spack]# ll /opt/spack/var/spack/stage/lmod-7.8-tf4lqsqo4ffijreb4ssbf3tpjqb3kkxb/
total 0
```
Rebuilding the package with the following options:
```console
[root@controller etc]# spack -d install -j 1 lmod
==> Reading config file /opt/spack/etc/spack/defaults/modules.yaml
==> Reading config file /opt/spack/etc/spack/defaults/linux/modules.yaml
==> Reading config file /opt/spack/etc/spack/defaults/config.yaml
==> Reading config file /opt/spack/etc/spack/defaults/repos.yaml
==> Reading config file /opt/spack/etc/spack/defaults/packages.yaml
==> READ LOCK: /root/.spack/cache/providers/.builtin-index.yaml.lock[0:0] [Acquiring]
==> READ LOCK: /root/.spack/cache/providers/.builtin-index.yaml.lock[0:0] [Acquired]
==> READ LOCK: /root/.spack/cache/providers/.builtin-index.yaml.lock[0:0] [Released]
==> Reading config file /root/.spack/linux/compilers.yaml
==> DATABASE LOCK TIMEOUT: 120s
==> PACKAGE LOCK TIMEOUT: No timeout
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5529395756612494658:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5529395756612494658:1] [Acquired]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/lock[0:0] [Acquired]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/lock[0:0] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5529395756612494658:1] [Released]
==> link /opt/spack/var/spack/stage/lmod-7.8-tf4lqsqo4ffijreb4ssbf3tpjqb3kkxb -> /tmp/root/spack-stage/spack-stage-0e6ZGk
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5529395756612494658:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5529395756612494658:1] [Acquired]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5529395756612494658:1] [Released]
==> Installing lmod dependencies
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3306097597550001336:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3306097597550001336:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3306097597550001336:1] [Released]
==> link /opt/spack/var/spack/stage/pkgconf-1.5.4-lpbty7z5pl4xcz5espjf3q3lwhmcbkxq -> /tmp/root/spack-stage/spack-stage-4gdOOu
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3306097597550001336:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3306097597550001336:1] [Acquired]
==> pkgconf is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/pkgconf-1.5.4-lpbty7z5pl4xcz5espjf3q3lwhmcbkxq
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3306097597550001336:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6437916248499161147:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6437916248499161147:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6437916248499161147:1] [Released]
==> link /opt/spack/var/spack/stage/ncurses-6.1-wkyck363aqihprfuuiipgdmzt6vjk6nk -> /tmp/root/spack-stage/spack-stage-5hJtw5
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6437916248499161147:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6437916248499161147:1] [Acquired]
==> ncurses is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/ncurses-6.1-wkyck363aqihprfuuiipgdmzt6vjk6nk
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6437916248499161147:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5238252783809966745:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5238252783809966745:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5238252783809966745:1] [Released]
==> link /opt/spack/var/spack/stage/readline-7.0-sfsamtunmnste5uxxmlvskfkjz7uhbcj -> /tmp/root/spack-stage/spack-stage-TuUXGs
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5238252783809966745:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5238252783809966745:1] [Acquired]
==> readline is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/readline-7.0-sfsamtunmnste5uxxmlvskfkjz7uhbcj
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5238252783809966745:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1703220015039601267:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1703220015039601267:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1703220015039601267:1] [Released]
==> link /opt/spack/var/spack/stage/unzip-6.0-f5dbwkgfrk2oov7xbetny3qhhbkegfmj -> /tmp/root/spack-stage/spack-stage-apg2QU
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1703220015039601267:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1703220015039601267:1] [Acquired]
==> unzip is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/unzip-6.0-f5dbwkgfrk2oov7xbetny3qhhbkegfmj
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1703220015039601267:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[8265281426144169521:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[8265281426144169521:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[8265281426144169521:1] [Released]
==> link /opt/spack/var/spack/stage/lua-5.3.4-4vufwvg35iogfmr5wmhwq5yo2maha7ja -> /tmp/root/spack-stage/spack-stage-io_sRT
==> link /opt/spack/var/spack/stage/resource-luarocks-4vufwvg35iogfmr5wmhwq5yo2maha7ja -> /tmp/root/spack-stage/spack-stage-1fne9l
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[8265281426144169521:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[8265281426144169521:1] [Acquired]
==> lua is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/lua-5.3.4-4vufwvg35iogfmr5wmhwq5yo2maha7ja
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[8265281426144169521:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[7798185437166155213:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[7798185437166155213:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[7798185437166155213:1] [Released]
==> link /opt/spack/var/spack/stage/libsigsegv-2.11-3byxblkv2nvzumj3wk5cbzyud5hpjdlv -> /tmp/root/spack-stage/spack-stage-KrZk1O
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[7798185437166155213:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[7798185437166155213:1] [Acquired]
==> libsigsegv is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/libsigsegv-2.11-3byxblkv2nvzumj3wk5cbzyud5hpjdlv
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[7798185437166155213:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1579839987092468803:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1579839987092468803:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1579839987092468803:1] [Released]
==> link /opt/spack/var/spack/stage/m4-1.4.18-fpmxamrbgvuinzjofvamktlmzzqq347t -> /tmp/root/spack-stage/spack-stage-k9RvoT
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1579839987092468803:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1579839987092468803:1] [Acquired]
==> m4 is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/m4-1.4.18-fpmxamrbgvuinzjofvamktlmzzqq347t
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[1579839987092468803:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6093679930026684944:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6093679930026684944:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6093679930026684944:1] [Released]
==> link /opt/spack/var/spack/stage/gdbm-1.18.1-verdgofikxsccbgxxozvdsrnewnc6jgh -> /tmp/root/spack-stage/spack-stage-KLGWeY
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6093679930026684944:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6093679930026684944:1] [Acquired]
==> gdbm is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/gdbm-1.18.1-verdgofikxsccbgxxozvdsrnewnc6jgh
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6093679930026684944:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6349191301999206016:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6349191301999206016:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6349191301999206016:1] [Released]
==> link /opt/spack/var/spack/stage/perl-5.26.2-wa43pmynkm6qb5j7yi7mxo45jmrmi5iz -> /tmp/root/spack-stage/spack-stage-E0ac5e
==> link /opt/spack/var/spack/stage/resource-cpanm-wa43pmynkm6qb5j7yi7mxo45jmrmi5iz -> /tmp/root/spack-stage/spack-stage-y1uMNC
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6349191301999206016:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6349191301999206016:1] [Acquired]
==> perl is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/perl-5.26.2-wa43pmynkm6qb5j7yi7mxo45jmrmi5iz
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6349191301999206016:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[51853771843487525:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[51853771843487525:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[51853771843487525:1] [Released]
==> link /opt/spack/var/spack/stage/autoconf-2.69-afyhc5rf7whevgknfmn5bwtv6dxde2wi -> /tmp/root/spack-stage/spack-stage-OhmGVk
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[51853771843487525:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[51853771843487525:1] [Acquired]
==> autoconf is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/autoconf-2.69-afyhc5rf7whevgknfmn5bwtv6dxde2wi
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[51853771843487525:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[374898105021230744:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[374898105021230744:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[374898105021230744:1] [Released]
==> link /opt/spack/var/spack/stage/automake-1.16.1-bjt47lrrqpotdgeauyinhmgkzi4skkkk -> /tmp/root/spack-stage/spack-stage-NavqCO
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[374898105021230744:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[374898105021230744:1] [Acquired]
==> automake is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/automake-1.16.1-bjt47lrrqpotdgeauyinhmgkzi4skkkk
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[374898105021230744:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6122994731022097757:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6122994731022097757:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6122994731022097757:1] [Released]
==> link /opt/spack/var/spack/stage/zlib-1.2.11-vhzh5cfaki5lx5sjuth5iuojq5azdkbd -> /tmp/root/spack-stage/spack-stage-7eeeXm
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6122994731022097757:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6122994731022097757:1] [Acquired]
==> zlib is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/zlib-1.2.11-vhzh5cfaki5lx5sjuth5iuojq5azdkbd
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[6122994731022097757:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5908120669360253833:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5908120669360253833:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5908120669360253833:1] [Released]
==> link /opt/spack/var/spack/stage/openssl-1.1.1-up53rzdwxdlrf4gtat6zrew4vc5hhjgd -> /tmp/root/spack-stage/spack-stage-dzOeWu
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5908120669360253833:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5908120669360253833:1] [Acquired]
==> openssl is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/openssl-1.1.1-up53rzdwxdlrf4gtat6zrew4vc5hhjgd
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5908120669360253833:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3607452505321571133:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3607452505321571133:1] [Acquired]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3607452505321571133:1] [Released]
==> link /opt/spack/var/spack/stage/curl-7.60.0-mqqh3ymhsidhuj7cyy4nexpq3zi7jwbp -> /tmp/root/spack-stage/spack-stage-TX0Tfm
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3607452505321571133:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3607452505321571133:1] [Acquired]
==> curl is already installed in /opt/spack/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/curl-7.60.0-mqqh3ymhsidhuj7cyy4nexpq3zi7jwbp
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[3607452505321571133:1] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5148609870426378261:1] [Acquiring]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5148609870426378261:1] [Acquired]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/lock[0:0] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/lock[0:0] [Acquired]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/lock[0:0] [Released]
==> WRITE LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5148609870426378261:1] [Released]
==> link /opt/spack/var/spack/stage/libbsd-0.9.1-r3trfta3vmqcxxbzsacgagk7hiaiau3s -> /tmp/root/spack-stage/spack-stage-8GTdOX
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5148609870426378261:1] [Acquiring]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5148609870426378261:1] [Acquired]
==> READ LOCK: /opt/spack/opt/spack/.spack-db/prefix_lock[5148609870426378261:1] [Released]
==> Installing libbsd
==> Searching for binary cache of libbsd
==> Reading config file /root/.spack/linux/mirrors.yaml
==> Warning: No Spack mirrors are currently configured
==> No binary for libbsd found: installing from source
==> Using cached archive: /opt/spack/var/spack/cache/libbsd/libbsd-0.9.1.tar.xz
==> Staging archive: /opt/spack/var/spack/stage/libbsd-0.9.1-r3trfta3vmqcxxbzsacgagk7hiaiau3s/libbsd-0.9.1.tar.xz
==> '/bin/tar' '-xf' '/opt/spack/var/spack/stage/libbsd-0.9.1-r3trfta3vmqcxxbzsacgagk7hiaiau3s/libbsd-0.9.1.tar.xz'
==> Created stage in /opt/spack/var/spack/stage/libbsd-0.9.1-r3trfta3vmqcxxbzsacgagk7hiaiau3s
==> '/bin/patch' '-s' '-p' '1' '-i' '/opt/spack/var/spack/repos/builtin/packages/libbsd/cdefs.h.patch' '-d' '.'
1 out of 1 hunk FAILED -- saving rejects to file include/bsd/sys/cdefs.h.rej
==> Patch cdefs.h.patch failed.
==> Error: ProcessError: Command exited with status 1:
    '/bin/patch' '-s' '-p' '1' '-i' '/opt/spack/var/spack/repos/builtin/packages/libbsd/cdefs.h.patch' '-d' '.'
Traceback (most recent call last):
  File "/opt/spack/lib/spack/spack/build_environment.py", line 731, in child_process
    return_value = function()
  File "/opt/spack/lib/spack/spack/package.py", line 1437, in build_process
    self.do_patch()
  File "/opt/spack/lib/spack/spack/package.py", line 1015, in do_patch
    patch.apply(self.stage)
  File "/opt/spack/lib/spack/spack/patch.py", line 85, in apply
    "-d", self.working_dir)
  File "/opt/spack/lib/spack/spack/util/executable.py", line 189, in __call__
    proc.returncode, long_msg)
ProcessError: Command exited with status 1:
    '/bin/patch' '-s' '-p' '1' '-i' '/opt/spack/var/spack/repos/builtin/packages/libbsd/cdefs.h.patch' '-d' '.'
...
```



Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/libbsd/package.py b/var/spack/repos/builtin/packages/libbsd/package.py
--- a/var/spack/repos/builtin/packages/libbsd/package.py
+++ b/var/spack/repos/builtin/packages/libbsd/package.py
@@ -17,6 +17,8 @@ class Libbsd(AutotoolsPackage):
     url      = "https://libbsd.freedesktop.org/releases/libbsd-0.9.1.tar.xz"
 
     version('0.9.1', sha256='56d835742327d69faccd16955a60b6dcf30684a8da518c4eca0ac713b9e0a7a4')
-    version('0.8.6', '4ab7bec639af17d0aacb50222b479110')
+    version('0.9.0', sha256='8a469afd1bab340992cf99e1e6b7ae4f4c54882d663d8a2c5ea52250617afb01')
+    version('0.8.7', sha256='f548f10e5af5a08b1e22889ce84315b1ebe41505b015c9596bad03fd13a12b31')
+    version('0.8.6', sha256='467fbf9df1f49af11f7f686691057c8c0a7613ae5a870577bef9155de39f9687')
 
-    patch('cdefs.h.patch', when='%gcc@:4')
+    patch('cdefs.h.patch', when='@0.8.6 %gcc@:4')


Test patch: