I am trying to package an Oracle JDK distribution into an RPM. To do this I must untar the tar.gz file. According to User Guide, I could try doing it like this:
project.tasks.create("rpm", Rpm) {
project.afterEvaluate {
...
into(destPath) {
from project.tarTree(inputJdkFile)
}
}
}
But when I do that, I get the error message
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jdk32:rpm'.
> Unable to expand TAR '/vtone/3rd-party/JDKS/jdk-8u101-linux-i586.tar.gz'
The tar might be corrupted or it is compressed in an unexpected way.
By default the tar tree tries to guess the compression based on the file extension.
If you need to specify the compression explicitly please refer to the DSL reference.
Consulting the DSL reference I try
project.tasks.create("rpm", Rpm) {
project.afterEvaluate {
...
into(destPath) {
from project.tarTree(project.resources.gzip(inputJdkFile))
}
}
}
but I get the same error.
Yet the linux tar command has no trouble with this file. And I can hardly believe I need to specify the project.resources.gzip
for such a common filetype and such a common file.
The stack trace offers some clues but I don’t know what they mean:
Caused by: org.gradle.api.GradleException: Could not copy tar entry /vtone/3rd-party/JDKS/jdk-8u101-linux-i586.tar.gz!jdk1.8.0_101/THIRDPARTYLICENSEREADME.txt to '/home/sc1478/jdkinstaller/jdk32/build/tmp/expandedArchives/jdk-8u101-linux-i586.tar.gz_e4j07uh9x00wimibzfsxdt3fj/jdk1.8.0_101/THIRDPARTYLICENSEREADME.txt'.
at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:79)
at org.gradle.api.internal.file.archive.TarFileTree$DetailsImpl.getFile(TarFileTree.java:139)
at org.gradle.api.internal.file.copy.DefaultFileCopyDetails.getFile(DefaultFileCopyDetails.java:64)
at com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction.extractFile(AbstractPackagingCopyAction.groovy:200)
at com.netflix.gradle.plugins.rpm.RpmCopyAction.visitFile(RpmCopyAction.groovy:104)
at com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction.this$dist$invoke$1(AbstractPackagingCopyAction.groovy)
at com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction$StreamAction.methodMissing(AbstractPackagingCopyAction.groovy)
at com.netflix.gradle.plugins.packaging.AbstractPackagingCopyAction$StreamAction.processFile(AbstractPackagingCopyAction.groovy:60)
at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1$1.processFile(NormalizingCopyActionDecorator.java:66)
at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1$1.processFile(DuplicateHandlingCopyActionDecorator.java:60)
at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.processFile(CopyFileVisitorImpl.java:60)
at org.gradle.api.internal.file.copy.CopyFileVisitorImpl.visitFile(CopyFileVisitorImpl.java:44)
at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTreeImpl$1.visitFile(AbstractFileTree.java:150)
at org.gradle.api.internal.file.archive.TarFileTree.visitImpl(TarFileTree.java:99)
at org.gradle.api.internal.file.archive.TarFileTree.visit(TarFileTree.java:78)
... 97 more
Caused by: java.io.FileNotFoundException: /home/sc1478/jdkinstaller/jdk32/build/tmp/expandedArchives/jdk-8u101-linux-i586.tar.gz_e4j07uh9x00wimibzfsxdt3fj/jdk1.8.0_101/THIRDPARTYLICENSEREADME.txt (Permission denied)
at org.gradle.api.internal.file.AbstractFileTreeElement.copyFile(AbstractFileTreeElement.java:91)
at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:74)
... 111 more
Permission errors? Must I explicitly unzip the file first to a temporary directory, then add it to my rpm? But it looks from the stack trace that that is exactly what it is doing and failing.