Creating Self-Extracting Sources Files
The idea is pretty simple : Embed all your tgz’s below a place holder and count the lines to get each tgz and pipe tail and tar to extract them to required folder.
Steps
Step I Make a tgz file with all the source you have Assuming we call the folder to be source, so the compressed file must be source.tgz and the source might contain any extractable files, even simple shell scripts. Lets assume that our source folder has a build.sh script which takes care of installing each and every source.
Step 2 Make an extractor script as below “
!/bin/bash
Author : Hemanth
echo "" echo “Self Extracting Files” echo "" echo "" echo “Extracting file into pwd/source”
Count for source list
COUNT=awk '/^__SOURCE__/ { print NR + 1; exit 0; }' $0
The current file
FILE=pwd/$0
take the tarfile and pipe it into tar
tail -n+$COUNT $FILE | tar -xz
echo “Finished” cd sources
build.sh to build and install the sources as per your need
./build.sh
Remove the source folder
cd .. ; rm -rf sources exit 0
SOURCE
Step 3 Final move Make the file ready, that is embed the tgz below the extractor.sh **cat source.tgz extractor.sh> install.sh **
That’s it run the install.sh to do whatever its intended to do
About Hemanth HM
Hemanth HM is a Sr. Machine Learning Manager at PayPal, Google Developer Expert, TC39 delegate, FOSS advocate, and community leader with a passion for programming, AI, and open-source contributions.