11

I'm trying to install JavaSE on a OpenWrt (Pandorabox) device. When I run

tar -xvf ejdk-8u65-linux-arm-sflt.tar.gz

I get tar: invalid tar magic. How can I solve this problem?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Toc
  • 253
  • 1
  • 2
  • 8

2 Answers2

21

The version of tar on OpenWRT is a smaller one than the one on full-blown systems, designed to fit small devices (it's BusyBox.) To keep small, it lacks features such as the automatic detection of compressed archives.

Try declaring the compression format manually with the -z option:

tar -xvzf ejdk-8u65-linux-arm-sflt.tar.gz

Support for gzip in the tar utility is an optional feature that may or may not be enabled on OpenWRT. If you don't have it, call zcat (or gzip -dc) explicitly:

zcat ejdk-8u65-linux-arm-sflt.tar.gz | tar -xvf -
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • 1
    Both commands stopped when extracting: `ejdk1.8.0_65/linux_arm_sflt/jre/lib/rt.jar` with another `tar: invalid tar magic` – Toc Dec 14 '15 at 20:03
  • 1
    @Toc Are you sure the file is undamaged and compete? Were there any other errors? Do you have a URL for the file so we can check? – Gilles 'SO- stop being evil' Dec 14 '15 at 20:16
  • http://www.oracle.com/technetwork/java/embedded/embedded-se/downloads/index.html Unfortunately I had to register to download the file (whose name is in the opening question). Thank you. – Toc Dec 14 '15 at 20:56
  • Using a zip utility in Windows I recognized that `rt.jar` is the last file in the tar archive. Maybe the `invalid tar magic message` is only an irrelevant warning? – Toc Dec 14 '15 at 21:03
  • @Toc Damn. Sorry, I'm not going to create an account for this. Does `rt.jar` have the right size after extraction? This message indicates that something about the format of the tar file isn't supported, but this may well be harmless trailing garbage. – Gilles 'SO- stop being evil' Dec 14 '15 at 21:18
  • I've verified the files extracted under Linux and the ones extracted under Windows. No difference. I hope and I think all is well done. Thank you. – Toc Dec 14 '15 at 21:28
6

I had the same problem when extracting an archive, finally I upgraded tar and it solved the problem.

opkg update
opkg upgrade tar
MTVS
  • 163
  • 2
  • 5