• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Extracting a bin file and a tar file

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

What is the difference between extracting a bin file and a tar.gz file? For example when I downloaded java, I got them as binaries and I user a sh ./java.xxx.bin to unpack the contents. When I downloaded Maven, it was of the tar.gz form and used a tar utility to unpack the contents. What exactly is the difference between these two formats?
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jothi Shankar Kumar wrote:What exactly is the difference between these two formats?


(my highlighting)

Precise differences are unlikely to be forthcoming, as there is no precise definition for a "bin" format file (at least in the way that Sun are using it here - there are other "bin" files that have more precise definitions).

Non precise ...

The tar format (tape archive) just provides a way of storing one or more files and directories into a single archive file (or device). That is all it allows - it does not specify licensing terms or anything else that you might typically find in a distribution.

For something like Maven, this is fine. The license is contained as a file within the archive, and you can read it at your leisure anytime after installing it.

For the Java distribution provided by Sun, this is not the case. They want you to explicitly look at the license agreement and accept it before you can install it. In theory, some software being distributed might also need to have a special user or group installed on your computer, and/or install daemons.

To meet these needs, it makes sense to have a file that can work on any Linux system, regardless of what has already been installed. In the Microsoft world, this might be considered an executable file (*.exe or *.msi) that contains the distribution within itself.

So that really is all the bin file is - an archive (possibly a tar archive) that is contained within an executable that knows how to process it and potentially do other work as well.

As an example, consider the following file:

(You can run this without any problems on your computer - it doesn't actually do anything other than list the contents of a tar file that is contained within lines 5 - 7. If you want to try it, just copy all 8 lines into a file and name it something like "example.sh". Then run "sh ./example.sh" - you should see output showing you the contents of my file).

In this example, all my work is done in line 4:
  • cat << EOF simply concatenates all the lines between line 5 (the line following the cat command) and 7 (the line before the EOF on line 8) and sends the output to ...
  • base64 -d which converts the plain-text data in those 3 lines back into the binary tar format, and then sends that to ...
  • tar -tzvf - the tar command that tells us what is in the gzipped archive in verbose mode for the file it has just been passed (indicated by the -)


  • If that was all I was doing, I could have just provided you with the tar file directly. However I wanted you to press "Enter" first, and that is what lines 1 & 2 get you to do.

    Hopefully you can see from this simple example how this can be used to create a distribution that can easily be sent to a customer that can do more than just provide the raw distribution. In theory the archive contained in lines 5 - 7 could contain something that my script could have executed after extracting it.

    (If you really want to see what is in that archive, change the "tzvf" in line 4 to an "xzvf" (where the 'x' is for extract) and re-run it. This will create the "txt" file in the same directory where you run the script)
     
    Joe San
    Ranch Hand
    Posts: 10198
    3
    Mac PPC Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    That was a very good explanattion. Thank you!
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic