Repository: spack/spack

Issue:
samtools 1.2 through 1.6 won't build without zlib/bzip2 dependencies
### Steps to reproduce the issue
## bzip2 error:
```console
spack install samtools@1.2
==> pkgconf is already installed in /opt/htcf/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.3.0/pkgconf-1.5.4-6cgd5wsggutanretgkdakedajoxegncy
==> ncurses is already installed in /opt/htcf/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.3.0/ncurses-6.1-c4iq7eli75yuf5rkigpk7is63eurr6rp
==> Installing samtools
==> Searching for binary cache of samtools
==> Warning: No Spack mirrors are currently configured
==> No binary for samtools found: installing from source
==> Using cached archive: /opt/htcf/spack/var/spack/cache/samtools/samtools-1.2.tar.bz2
==> Staging archive: /opt/htcf/spack/var/spack/stage/samtools-1.2-t7kaxunppzlxxoipbca3r63jshkjxq2r/samtools-1.2.tar.bz2
tar (child): lbzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
/bin/tar: Child returned status 2
/bin/tar: Error is not recoverable: exiting now
==> Error: ProcessError: Command exited with status 2:
    '/bin/tar' '-xf' '/opt/htcf/spack/var/spack/stage/samtools-1.2-t7kaxunppzlxxoipbca3r63jshkjxq2r/samtools-1.2.tar.bz2'
```

## zlib error:
```console
$ spack install samtools@1.3
==> pkgconf is already installed in /opt/htcf/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.3.0/pkgconf-1.5.4-6cgd5wsggutanretgkdakedajoxegncy
==> ncurses is already installed in /opt/htcf/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.3.0/ncurses-6.1-c4iq7eli75yuf5rkigpk7is63eurr6rp
==> Installing samtools
==> Searching for binary cache of samtools
==> Warning: No Spack mirrors are currently configured
==> No binary for samtools found: installing from source
==> Using cached archive: /opt/htcf/spack/var/spack/cache/samtools/samtools-1.2.tar.bz2
==> Staging archive: /opt/htcf/spack/var/spack/stage/samtools-1.2-t7kaxunppzlxxoipbca3r63jshkjxq2r/samtools-1.2.tar.bz2
==> Created stage in /opt/htcf/spack/var/spack/stage/samtools-1.2-t7kaxunppzlxxoipbca3r63jshkjxq2r
==> No patches needed for samtools
==> Building samtools [Package]
==> Executing phase: 'install'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j24' 'prefix=/opt/htcf/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.3.0/samtools-1.2-t7kaxunppzlxxoipbca3r63jshkjxq2r'

24 errors found in build log:
     22     gcc -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_CURSES_LIB=1 -I. -Ihtslib-1.2.1 -c -o cut_target.o cut_target.c
     23     gcc -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_CURSES_LIB=1 -I. -Ihtslib-1.2.1 -c -o phase.o phase.c
     24     gcc -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_CURSES_LIB=1 -I. -Ihtslib-1.2.1 -c -o bam2depth.o bam2depth.c
     25     gcc -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_CURSES_LIB=1 -I. -Ihtslib-1.2.1 -c -o padding.o padding.c
     26     gcc -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_CURSES_LIB=1 -I. -Ihtslib-1.2.1 -c -o bedcov.o bedcov.c
     27     gcc -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_CURSES_LIB=1 -I. -Ihtslib-1.2.1 -c -o bamshuf.o bamshuf.c
  >> 28     bedcov.c:26:10: fatal error: zlib.h: No such file or directory
     29      #include <zlib.h>
     30               ^~~~~~~~
     31     compilation terminated.
     32     Makefile:116: recipe for target 'bedcov.o' failed
  >> 33     make: *** [bedcov.o] Error 1
     34     make: *** Waiting for unfinished jobs....
     35     In file included from bam_reheader.c:28:0:
  >> 36     htslib-1.2.1/htslib/bgzf.h:34:10: fatal error: zlib.h: No such file or directory
     37      #include <zlib.h>
     38               ^~~~~~~~
     39     compilation terminated.
     40     In file included from bam.h:48:0,
     41                      from bam_color.c:26:
  >> 42     htslib-1.2.1/htslib/bgzf.h:34:10: fatal error: zlib.h: No such file or directory
     43      #include <zlib.h>
     44               ^~~~~~~~
     45     compilation terminated.
     46     Makefile:116: recipe for target 'bam_color.o' failed
  >> 47     make: *** [bam_color.o] Error 1
     48     Makefile:116: recipe for target 'bam_reheader.o' failed
  >> 49     make: *** [bam_reheader.o] Error 1
  >> 50     bam_rmdup.c:29:10: fatal error: zlib.h: No such file or directory
     51      #include <zlib.h>
     52               ^~~~~~~~
     53     compilation terminated.
  >> 54     bedidx.c:31:10: fatal error: zlib.h: No such file or directory
     55      #include <zlib.h>
     56               ^~~~~~~~
     57     compilation terminated.
     58     Makefile:116: recipe for target 'bam_rmdup.o' failed
     59     In file included from bam_cat.c:41:0:
  >> 60     htslib-1.2.1/htslib/bgzf.h:34:10: fatal error: zlib.h: No such file or directory
     61      #include <zlib.h>
     62               ^~~~~~~~
  >> 63     make: *** [bam_rmdup.o] Error 1
     64     compilation terminated.
     65     Makefile:116: recipe for target 'bedidx.o' failed
  >> 66     make: *** [bedidx.o] Error 1
     67     Makefile:116: recipe for target 'bam_cat.o' failed
  >> 68     make: *** [bam_cat.o] Error 1
     69     kprobaln.c: In function 'kpa_glocal':
     70     kprobaln.c:78:21: warning: variable 'is_diff' set but not used [-Wunused-but-set-variable]
     71       int bw, bw2, i, k, is_diff = 0, is_backward = 1, Pr;
     72                          ^~~~~~~
     73     In file included from bam.h:48:0,
     74                      from cut_target.c:29:
  >> 75     htslib-1.2.1/htslib/bgzf.h:34:10: fatal error: zlib.h: No such file or directory
# Copyright 2013-2018 Lawrence Livermore National Security, LLC and other
     76      #include <zlib.h>
     77               ^~~~~~~~
     78     compilation terminated.
     79     In file included from bam.h:48:0,
     80                      from sam.h:29,
     81                      from padding.c:32:
  >> 82     htslib-1.2.1/htslib/bgzf.h:34:10: fatal error: zlib.h: No such file or directory
     83      #include <zlib.h>
     84               ^~~~~~~~
     85     compilation terminated.
     86     In file included from bam.h:48:0,
     87                      from sam.h:29,
     88                      from bam_rmdupse.c:27:
  >> 89     htslib-1.2.1/htslib/bgzf.h:34:10: fatal error: zlib.h: No such file or directory
     90      #include <zlib.h>
     91               ^~~~~~~~
     92     compilation terminated.
     93     Makefile:116: recipe for target 'cut_target.o' failed
  >> 94     make: *** [cut_target.o] Error 1
     95     Makefile:116: recipe for target 'padding.o' failed
  >> 96     make: *** [padding.o] Error 1
     97     Makefile:116: recipe for target 'bam_rmdupse.o' failed
  >> 98     phase.c:31:10: fatal error: zlib.h: No such file or directory
     99      #include <zlib.h>
     100              ^~~~~~~~
  >> 101    make: *** [bam_rmdupse.o] Error 1
     102    compilation terminated.
     103    In file included from bam.h:48:0,
     104                     from sam.h:29,
     105                     from bam_md.c:31:
  >> 106    htslib-1.2.1/htslib/bgzf.h:34:10: fatal error: zlib.h: No such file or directory
     107     #include <zlib.h>
     108              ^~~~~~~~
     109    compilation terminated.
     110    In file included from bamshuf.c:32:0:
  >> 111    htslib-1.2.1/htslib/bgzf.h:34:10: fatal error: zlib.h: No such file or directory
     112     #include <zlib.h>
     113              ^~~~~~~~
     114    compilation terminated.
     115    Makefile:116: recipe for target 'phase.o' failed
  >> 116    make: *** [phase.o] Error 1
     117    Makefile:116: recipe for target 'bam_md.o' failed
  >> 118    make: *** [bam_md.o] Error 1
     119    Makefile:116: recipe for target 'bamshuf.o' failed
  >> 120    make: *** [bamshuf.o] Error 1
```

### Platform and user environment

```commandline
$ uname -a 
Linux n220 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -d
Description:	Ubuntu 18.04.1 LTS
``` 



Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/samtools/package.py b/var/spack/repos/builtin/packages/samtools/package.py
--- a/var/spack/repos/builtin/packages/samtools/package.py
+++ b/var/spack/repos/builtin/packages/samtools/package.py
@@ -30,8 +30,8 @@ class Samtools(Package):
     depends_on('htslib@1.6',   when='@1.6')
     depends_on('htslib@1.4',   when='@1.4')
     depends_on('htslib@1.3.1', when='@1.3.1')
-    depends_on('zlib', when='@1.7:')
-    depends_on('bzip2', when='@1.7:')
+    depends_on('zlib')
+    depends_on('bzip2')
 
     def install(self, spec, prefix):
         if self.spec.version >= Version('1.3.1'):


Test patch: