#!/bin/sh

# This scripts creates a binary for installation on the OLPC

# It helps in installing Bibledit on the OLPC.
# It gathers all libraries and binaries that Bibledit uses.
# It will create a gzipped tarball that contains all these.
# If this tarball is unpacked in the root folder of the OLPC, 
# then Bibledit will work there.



# Get the version number of Bibledit and give information to the user.
VERSION=`grep PACKAGE_VERSION ../config.h | sed 's/#define PACKAGE_VERSION //' | sed 's/"//g'`
echo Creating binary installer of Bibledit $VERSION for the OLPC machine.



# Create and move into the temporal directory where all files are going to be staged.
TEMPORALDIR=temporal_directory
rm -rf $TEMPORALDIR
mkdir $TEMPORALDIR
cd  $TEMPORALDIR


# The name of the tarball.
TARBALL=bibledit-$VERSION-xo-bin.tar


# Add files to the tarball:
# - Bibledit's auxiliary files
tar --create -v -P -f $TARBALL /usr/share/bibledit/* > /dev/null
# - Bibledit's binaries.
tar --append -v -P -f $TARBALL /usr/bin/bibledit* > /dev/null


# Compress the tarball and move it a directory level up.
gzip $TARBALL
mv $TARBALL.gz ..


# Remove the temporal directory.
cd ..
rm -rf $TEMPORALDIR


# Final information.
echo The gzipped tarball $TARBALL.gz was created.
