mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-08 22:45:43 +00:00
623 lines
No EOL
108 KiB
Bash
623 lines
No EOL
108 KiB
Bash
#=======================================================
|
||
#
|
||
# the SIMPL - Self Extracting Archive
|
||
#
|
||
#=======================================================
|
||
|
||
SIMPLVER=3.3.4
|
||
|
||
MYPWD=`pwd`
|
||
if [ $MYPWD != '/tmp' ]
|
||
then
|
||
echo "==================================================="
|
||
echo " This script needs to be run from /tmp."
|
||
echo ""
|
||
echo " Please copy it there and rerun from /tmp."
|
||
echo ""
|
||
echo "==================================================="
|
||
exit
|
||
fi
|
||
|
||
echo "==================================================="
|
||
echo ""
|
||
echo " SIMPL Self Extracting Archive"
|
||
echo ""
|
||
echo " This archive will be safely installed entirely in"
|
||
echo " /tmp. With the option to permanently install SIMPL"
|
||
echo " into a directory of your choosing."
|
||
echo ""
|
||
echo " You can examine this installer script with any text"
|
||
echo " editor. Nothing is hidden. The gzip'd tarballs at"
|
||
echo " the end of this file are all individually available"
|
||
echo " from the SIMPL project website at"
|
||
echo " http://www.icanprogram.com/simpl"
|
||
echo ""
|
||
echo " As with all open source software we offer this script"
|
||
echo " without warranty or implied liabilities."
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo -n "I accept these terms [y/n] "
|
||
read ans
|
||
if [ $ans == 'n' ]
|
||
then
|
||
exit
|
||
fi
|
||
|
||
#
|
||
# SKIP denotes the line number where the tarball begins.
|
||
#
|
||
SKIP=`awk '/^__TARBALL_FOLLOWS__/ { print NR + 1; exit 0; }' $0`
|
||
THIS=`pwd`/$0
|
||
|
||
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo " STAGE 1: Setting up work area in /tmp."
|
||
echo ""
|
||
echo " This SIMPL install will be compiled and run from "
|
||
echo " /tmp."
|
||
echo " Several files and subdirectories will be created"
|
||
echo " including:"
|
||
echo " /tmp/simpl.config - working config file"
|
||
echo " /tmp/simplfifo - working SIMPL sandbox"
|
||
echo " /tmp/simpl - SIMPL tree"
|
||
echo " /tmp/simpl/simplBook - sample code tree"
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo "******* Press Enter to continue ********"
|
||
read ans
|
||
echo ""
|
||
|
||
#
|
||
# Create the contents of the temporary config file.
|
||
# This will be appended to more lines to form the cut and paste
|
||
# insert for the users startup profile should they elect to
|
||
# make a permanent installation.
|
||
#
|
||
TMP_CONFIG=/tmp/simpl.config
|
||
|
||
echo "if [ -z \$FIFO_PATH ]" > $TMP_CONFIG
|
||
echo "then" >> $TMP_CONFIG
|
||
echo " if [ ! -d /tmp/simplfifo ]" >> $TMP_CONFIG
|
||
echo " then" >> $TMP_CONFIG
|
||
echo " mkdir /tmp/simplfifo" >> $TMP_CONFIG
|
||
echo " chmod a+rw /tmp/simplfifo" >> $TMP_CONFIG
|
||
echo " fi" >> $TMP_CONFIG
|
||
echo " export FIFO_PATH=/tmp/simplfifo" >> $TMP_CONFIG
|
||
echo "fi" >> $TMP_CONFIG
|
||
echo "export PATH=\$PATH:\$SIMPL_HOME/bin:\$SIMPL_HOME/scripts:." >> $TMP_CONFIG
|
||
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$SIMPL_HOME/lib" >> $TMP_CONFIG
|
||
|
||
#
|
||
# Create the working directories in /tmp.
|
||
#
|
||
if [ ! -d /tmp/simplfifo ]
|
||
then
|
||
mkdir /tmp/simplfifo
|
||
chmod a+rw /tmp/simplfifo
|
||
fi
|
||
export FIFO_PATH=/tmp/simplfifo
|
||
|
||
if [ -h /tmp/simpl ]
|
||
then
|
||
cd /tmp
|
||
rm simpl
|
||
fi
|
||
ln -s simpl-$SIMPLVER simpl
|
||
|
||
export SIMPL_HOME=/tmp/simpl
|
||
|
||
export PATH=$PATH:$SIMPL_HOME/bin:$SIMPL_HOME/scripts:.
|
||
|
||
export TEST_HOME=$SIMPL_HOME
|
||
|
||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/simpl/lib
|
||
|
||
#
|
||
# Display the relevant temporary SIMPL environment variables
|
||
#
|
||
echo " temporary SIMPL environment variables"
|
||
echo ""
|
||
echo "FIFO_PATH=$FIFO_PATH"
|
||
echo "SIMPL_HOME=$SIMPL_HOME"
|
||
echo "TEST_HOME=$TEST_HOME"
|
||
echo "PATH=$PATH"
|
||
echo ""
|
||
echo "Code will be temporarily installed at $SIMPL_HOME"
|
||
echo ""
|
||
echo "******* Press Enter to continue ********"
|
||
read ans
|
||
echo ""
|
||
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo " STAGE 2: Undoing the installation tarballs."
|
||
echo ""
|
||
echo " Several SIMPL tarballs are extracted into /tmp. "
|
||
echo " These include:"
|
||
echo " simpl-$SIMPLVER.tar.gz - main SIMPL source tarball."
|
||
echo " simpltest.tar.gz - SIMPL testing framework."
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo "******* Press Enter to continue ********"
|
||
read ans
|
||
echo ""
|
||
|
||
#
|
||
# Actual undoing of the self extracting archive occurs here
|
||
#
|
||
cd /tmp
|
||
pwd
|
||
tail -n +$SKIP $THIS | tar -xv
|
||
|
||
tar -zxvf /tmp/simplplugbin-$SIMPLVER.tar.gz
|
||
tar -zxvf /tmp/simpltest.tar.gz
|
||
|
||
cd /tmp/simpl/lib
|
||
ln -s libsimpl.so libsimpl.so.1
|
||
ln -s libsimpllog.so libsimpllog.so.1
|
||
ln -s libsimplmisc.so libsimplmisc.so.1
|
||
|
||
echo ""
|
||
echo "******* Press Enter to continue ********"
|
||
read ans
|
||
echo ""
|
||
|
||
cd /tmp
|
||
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo " STAGE 3: Running the tests."
|
||
echo ""
|
||
echo " The testing framework associated with the sample "
|
||
echo " code for the book will be exercised next."
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo "******* Press Enter to continue ********"
|
||
read ans
|
||
echo ""
|
||
|
||
count=3
|
||
while [ $count -gt 0 ]
|
||
do
|
||
echo ""
|
||
echo "==================================================="
|
||
echo " List of Tests "
|
||
echo " (You will be allowed $count more test runs.)"
|
||
echo ""
|
||
|
||
seetest i
|
||
echo ""
|
||
echo -n "Which test do you wish to run? (suggest s0001) [q to exit] "
|
||
read ans
|
||
if [ $ans == 'q' ]
|
||
then
|
||
break
|
||
else
|
||
echo ""
|
||
pretest $ans
|
||
dotest $ans $1
|
||
fi
|
||
let count=count-1
|
||
done
|
||
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo " STAGE 4: Allowing this SIMPL installation"
|
||
echo " to become permanent."
|
||
echo ""
|
||
echo " You will be asked to select a permanent directory "
|
||
echo " home for this SIMPL instance. Once done the"
|
||
echo " contents of the /tmp/simpl tree will be moved to "
|
||
echo " this permanent home."
|
||
echo ""
|
||
echo " To make the new environment variables permanent"
|
||
echo " you will have to cut and paste the contents of a"
|
||
echo " premade config file into your startup profile."
|
||
echo ""
|
||
echo "==================================================="
|
||
echo ""
|
||
echo "******* Press Enter to continue ********"
|
||
read ans
|
||
echo ""
|
||
|
||
echo -n "Would you like to install this instance of SIMPL permanently? [y/n] "
|
||
read ans
|
||
if [ $ans == 'y' ]
|
||
then
|
||
count=3
|
||
while [ $count -gt 0 ]
|
||
do
|
||
echo -n "Where would you like SIMPL installed? [eg. /home] "
|
||
read ans
|
||
|
||
#
|
||
# Intercept a null entry and allow retry
|
||
#
|
||
if [ ${#ans} == 0 ]
|
||
then
|
||
echo "Invalid entry. Please reenter a valid directory."
|
||
else
|
||
#
|
||
# Intercept a basename of simpl which will result in simpl/simpl
|
||
#
|
||
MYSIMPL_DIR=$ans
|
||
MYBASE=`basename $ans`
|
||
if [ $MYBASE == "simpl" ]
|
||
then
|
||
echo "Please reenter a directory which doesn't end in simpl."
|
||
else
|
||
|
||
#
|
||
# Intercept existing simpl directory to prevent accidental overwrite
|
||
#
|
||
if [ -d $MYSIMPL_DIR/simpl ]
|
||
then
|
||
echo "Cannot install here."
|
||
echo "$MYSIMPL_DIR/simpl already exists."
|
||
echo "Please reenter another directory."
|
||
else
|
||
break
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
let count=count-1
|
||
echo "You have $count tries left."
|
||
done
|
||
|
||
#
|
||
# check if all retries were used up. If so exit.
|
||
#
|
||
if [ $count -eq 0 ]
|
||
then
|
||
exit
|
||
fi
|
||
|
||
echo "MYSIMPL_DIR=$MYSIMPL_DIR"
|
||
|
||
#
|
||
# The directory entered must itself exist. Allow the user
|
||
# an opportunity to create it.
|
||
#
|
||
let count=3
|
||
while [ ! -d $MYSIMPL_DIR ]
|
||
do
|
||
echo "Please make sure"
|
||
echo " $MYSIMPL_DIR"
|
||
echo "exists."
|
||
|
||
echo "Hit Enter to continue once you've completed this."
|
||
read ans
|
||
let count=count-1
|
||
echo "You have $count tries left."
|
||
if [ $count -eq 0 ]
|
||
then
|
||
break
|
||
fi
|
||
done
|
||
|
||
#
|
||
# If all conditions are met move the simpl tree to new location.
|
||
#
|
||
if [ -d $MYSIMPL_DIR ]
|
||
then
|
||
mv /tmp/simpl-$SIMPLVER $MYSIMPL_DIR
|
||
cd $MYSIMPL_DIR
|
||
ln -s simpl-$SIMPLVER simpl
|
||
export SIMPL_HOME=$MYSIMPL_DIR/simpl
|
||
SIMPL_CONFIG=$SIMPL_HOME/simpl.config
|
||
|
||
#
|
||
# Create the startup profile insert. User must cut and paste
|
||
# this insert manually into the .profile or .bash_profile file.
|
||
#
|
||
echo "#=====================================================" > $SIMPL_CONFIG
|
||
echo "#" >> $SIMPL_CONFIG
|
||
echo "# Append this to the end of your startup profile" >> $SIMPL_CONFIG
|
||
echo "# in order that SIMPL environment variables are available" >> $SIMPL_CONFIG
|
||
echo "# at each console." >> $SIMPL_CONFIG
|
||
echo "#" >> $SIMPL_CONFIG
|
||
echo "#=====================================================" >> $SIMPL_CONFIG
|
||
echo "" >> $SIMPL_CONFIG
|
||
|
||
echo "export SIMPL_HOME=$SIMPL_HOME" >> $SIMPL_CONFIG
|
||
cat $TMP_CONFIG >> $SIMPL_CONFIG
|
||
|
||
#
|
||
# Announce this to the user.
|
||
#
|
||
|
||
echo ""
|
||
echo "=============================================================="
|
||
echo "Please manually append the contents of"
|
||
echo " $SIMPL_CONFIG"
|
||
echo "to your startup profile (.profile or .bash_profile or .bashrc)."
|
||
echo "=============================================================="
|
||
fi
|
||
fi
|
||
|
||
exit 0
|
||
__TARBALL_FOLLOWS__
|
||
simplplugbin-3.3.4.tar.gz |