This is useful for consistent updating RIL, applications and configuration file.
Idea is to add compressed binary at the end of executable shell script file.
On the build machine create payload directory and copy files into it.
Create script installer in that directory which should do installation of components on target platform.
Move one level up from payload directory and create decompress script with following content:
echo “Self Extracting Installer”
# Creates temporary directory.
export TMPDIR=`mktemp -d selfextract.XXXXXX`
# Searches for marker of beginning of binary data.
ARCHIVE=`sed -n ‘/^__ARCHIVE_BELOW__/=’ $0`
# Adds 1 to get next line after the marker.
# Extracts binary data into temporary directory.
tail -n+$ARCHIVE $0 | tar xv -C $TMPDIR
# Stores current directory, goes to the temporary
# directory and starts the install script.
# Returns back and removes temporary directory.
rm -rf $TMPDIR
# Prevents executing binary data.
# No extra lines should be added after the marker.
Create build script having following content:
# Compresses payload data.
tar cf ../payload.tar ./*
if [ -e “payload.tar” ]; then
# Data aren’t compressed due to lack of gunzip on target platform.
# Concatenates the decompressing script with binary data.
cat decompress payload.tar > selfextract.bsx
echo “payload.tar does not exist”
echo “selextract.bsx created”
Execute build script. Make sure that selfextract.bsx file is created.
Copy selfextract.bsx file to target device, change file mode by
# chmod 755 selfextract.bsx
and execute it by
Make sure that files were updated successfully.
Read in more details
Bash Self-Extracting Script
How to make a self-extracting shell script from a TAR archive
Use grep to report back only line numbers
Sed Command in Linux/Unix with examples
Alternative to awk
The main differences from the solution proposed in referenced articles are:
- sed utility is used instead of awk because the latter is not included in Android distribution by default;
- compressing by gzip is not used because gunzip utility is not included as well.