This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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?
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Jothi Shankar Kumar wrote:What exactly is the difference between these two formats?
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)