Monday, March 8, 2010

How to create self-Extracting script

It involves 3 steps,
  1. Create Payload
  2. Create Installer script
  3. Packaging
Create Payload:
This is a tar ball  in which all the installable binaries, libraries, script files, configuration files, etc will be placed in the same file hierarchy of the target board considering the base directory of the tar ball is the installation directory on the target board.

periask@ubuntu:~$ mkdir -vp packaging/Payload
mkdir: created directory `packaging
mkdir: created directory `packaging/Payload'
periask@ubuntu:~$ cd packaging/Payload
periask@ubuntu:~/packaging/Payload$ cp --preserve=mode -rl <installables> .
periask@ubuntu:~/packaging/Payload$ tar zcf ../Payload.tar.gz .
periask@ubuntu:~/packaging/Payload$ cd ..

Create Installer Script:
Copy the below content and create "installer" file in "packaging" directory.


# Get the starting point of the tar ball
SKIP=`awk '/^__ARCHIVE__/ { print NR + 1; exit 0; }' $0`

# Do pre-installation steps here.

# Extracting the tar ball Which is appended to this file
tail -n "+$SKIP" $0 >/dev/null 2>&1
if [ $? -eq 0 ]; then
    tail -n +$SKIP $0 | gunzip -c | tar -C / -xvf -
    tail +$SKIP $0 | gunzip -c | tar -C / -xvf - 

# Do post-installation steps here.

exit 0


Note: There should not be any space  after "__ARCHIVE__" and should be a new line after "__ARCHIVE__".

Concatenate the file "installer" and "Payload.tar.gz" and create the package file.

periask@ubuntu:~/packaging$ cat installer Payload.tar.gz >
periask@ubuntu:~/packaging$ chmod +x

Installer for your package "" is ready.

Source: Linux Journal

No comments :

Post a Comment