Some software (for ex. the NetBeans IDE) ship the Linux installers in .sh files. Curious about how exactly they 'package' a whole IDE into a 'shell script', I opened the file in an editor. I saw some plain text shell scripting code and then some random gibberish, which I reckon is 'binary' or non-plain text.
I am wondering how they mix plain shell scripts and then probably call the 'non-readable' stuff, which would be the binaries.
Any insight on this?
There are also other/commercial software installer builder (like InstallAnywhere) they basically have their own version of shar/makeself.
Netbeans has their own installer engine, and part of it, which does the unpacking and launching is done in the NBI native launcher component: http://wiki.netbeans.org/NBINativeLaunchers
Creates a shell(script) archive for Linux/Unix/MacOS and native executable for Windows. You can use that tool for your own projects, also.
Add a Binary Payload to your Shell Scripts
GNU sharutils:
http://www.gnu.org/software/sharutils/
is a toolset for creating shell archives, and provides some additional features that may be helpful (such as checksums to ensuring that the payload is not damaged in transit).
Protecting against malicious modifications is not really feasible when the final product has to be interpretable by the shell - anyone who understood the generation technique could modify the checksum as well.
You might want to check out
makeself.sh
From the authors' notes.
Finally, the
makeself
package itself comes as a self-extracting script calledmakeself.run
.Basically, it's a shell script prepended to a compressed archive of some sort, such as a tar archive. You use the
tail
orsed
command on yourself (the$0
variable in Bourne shell) to strip off the shell script at the front and pass the rest to your unarchiver.For example, create the following script as
self-extracting
:The
sed
command above deletes all lines from the first line of the file to the first one that starts with "exit", and then passes the rest on through. If what starts immediately after the "exit" line is a tar file, thetar
command will extract it. If that's successful, the./project/Setup
file (presumably extracted from the tarball) will be executed.Then:
Now, if you get rid of your old
project
directory, you can runself-extracting
and it will extract that tar file and run the setup script.