Repository: spack/spack

Issue:
Installation issue: jdk
### Steps to reproduce the issue

```console
$ spack install jdk@11
==> Fetching http://download.oracle.com/otn-pub/java/jdk/11+13/19aef61b38124481863b1413dce1855f/jdk-11_linux-x64_bin.tar.gz
##################################################################################################################################################################################################### 100.0%
==> Warning: The contents of the archive look like HTML. Either the URL you are trying to use does not exist or you have an internet gateway issue. You can remove the bad archive using 'spack clean <package>', then try again using the correct URL.
==> Staging archive: /opt/spack/var/spack/stage/jdk-11-oyuzfniqeymon2l5tgnsbwj5iscatb3v/jdk-11_linux-x64_bin.tar.gz

gzip: stdin: not in gzip format
/opt/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-8.2.0/tar-1.31-ahrqlcrmdvdtia5b5j253tdwyezbbfqc/bin/tar: Child returned status 1
/opt/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-8.2.0/tar-1.31-ahrqlcrmdvdtia5b5j253tdwyezbbfqc/bin/tar: Error is not recoverable: exiting now
==> Error: ProcessError: Command exited with status 2:
    '/opt/spack/opt/spack/linux-ubuntu18.04-x86_64/gcc-8.2.0/tar-1.31-ahrqlcrmdvdtia5b5j253tdwyezbbfqc/bin/tar' '-xf' '/opt/spack/var/spack/stage/jdk-11-oyuzfniqeymon2l5tgnsbwj5iscatb3v/jdk-11_linux-x64_bin.tar.gz'
```

### Platform and user environment

Please report your OS here:
```commandline
$ uname -a 
Linux nessie 4.18.0-16-generic #17~18.04.1-Ubuntu SMP Tue Feb 12 13:35:51 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -d
Description:	Ubuntu 18.04.2 LTS
``` 

### Additional information

The issue seems to be related to the process for accepting the Oracle Java licence - trying to do so using the same mechanism with either curl or wget fails as well.



Discussion:
I don't think the problem is related to licensing.  The jdk package
has curl options for this.

I think the problem is how spack interprets the version number in the
spec `jdk@11`.  If you fully specify the version, then this works:

```
spack install jdk@11.0.2_9
```

It also seems to work if you do this, although I don't know why.

```
spack install java@11
```

Anyway, I agree that spack could be more user-friendly in interpreting
`jdk@11` as `jdk@11.0.2_9` (the latest version of 11).  I've seen this
mentioned before in other contexts.

I don't really consider this a bug.  Or, maybe it's a concretization
bug (or feature request), but not a build error for jdk.

Interesting - I didn't think to try that. I would argue that it is still a bug (don't think I can change the label?) but yes, definitely not a build error.
I agree, not really a bug.  Spack makes very few assumptions about how version numbers work.  Therefore `11` is a different version number from `11.0.2_9`.  My question is, why didn't Spack bomb out when it didn't find version `11` listed in the package?


Resolving patch:
diff --git a/var/spack/repos/builtin/packages/jdk/package.py b/var/spack/repos/builtin/packages/jdk/package.py
--- a/var/spack/repos/builtin/packages/jdk/package.py
+++ b/var/spack/repos/builtin/packages/jdk/package.py
@@ -26,8 +26,8 @@ class Jdk(Package):
     # http://stackoverflow.com/questions/10268583/how-to-automate-download-and-installation-of-java-jdk-on-linux
     curl_options = [
         '-j',  # junk cookies
-        '-H',  # specify required License Agreement cookie
-        'Cookie: oraclelicense=accept-securebackup-cookie'
+        '-b',  # specify required License Agreement cookie
+        'oraclelicense=accept-securebackup-cookie'
     ]
 
     # To add the latest version, go to the homepage listed above,


Test patch: