The solution is simple to explain: The self-extractable file are joint from an extractor shell script and an tar archive, which contains the actual contents to be extracted and installed into the system. The extractor script is a text file while the archive file is binary. They are joint together using
cat to make the self-extractable archive. Thus, the self-extractable archive file should have the following parts:
Also, we use a builder script:
build.sh to create the self-extractable archive file.
- To start, we need to prepare thhe directory structure like below:
./archive
./archive/bin
./archive/doc
./archive/install.sh
./archive/lib
./build.sh
./extract.sh
The archive directory is the directory contains the install.sh and the actual content files to install. The extract.sh file is extractor script.
- The build.sh script:
#!/bin/bash
cd archive
tar pczvf ../arc.tar.gz ./*
cd ..
cat extract.sh arc.tar.gz > install.bin
rm arc.tar.gz
chmod +x install.bin
- The final self-extractable installer: install.bin
See Also
No comments:
Post a Comment