Click to See Complete Forum and Search --> : simple source installation


ecks
05-21-2004, 09:07 PM
I'm sure that a lot of you people have this script already written, but for those of you that don't, here's a basic script for installing from source:

#!/bin/bash

download_dir=/home/ecks/Desktop
src_dir=/usr/local/src
input=$1

check_file()
{
file_exist=`ls | grep $input`

if [ -z $file_exist ] ; then
echo "No such file in current directory"
exit
fi
}

check_root()
{
user=`whoami`
if [ $user != "root" ] ; then
echo "You need to log in as root to use this script"
exit
fi
}

make_env()
{
cd $download_dir
check_file
check_root
mv $input $src_dir
cd $src_dir
check_file
tar -x -z -f $input
tar_dir=${input%%.tar.gz}
cd $src_dir/$tar_dir
}

make_file()
{
./configure
make
make install
make clean
}

# this puts all the files in it's appropriate directories
make_env

# this actually compiles the program. Comment it if you don't want to install.
make_files


Note that it checks for files saved in ~/Desktop, so because your dir is different you need to change it.

EDIT: So far, it only works for .tar.gz files.

DSwain
05-21-2004, 09:52 PM
maybe you should have it ask for an input of bz2 or gz formats and allow it go about it that way. Very nice though, I wish i could have done it myself.

ecks
05-21-2004, 10:26 PM
I will do that later on when I have free time. However, today I'm tired of bash. What I'm thinking is, a user wont have to use a switch to distinguish between gzip and bzip files, the script will detect it automatically, and maybe I'll add a switch if a person doesn't want to configure and make the program. Cause, you know, he might need to put some extra arguments when he's configuring it.

DSwain
05-21-2004, 11:41 PM
interesting idea. If it were me though, i'd rather just have the option for me right there. Also, maybe you can make something like an "Add additional arugments here (Enter if none):" or something to that extent. Just idea's, i'm not a programmer, just a user.

bwkaz
05-21-2004, 11:56 PM
Well, I know I wouldn't want to hardcode no options to the configure script of any package I compile... ;)

It might be nice to pass along "$@" to the configure script, in other words. Maybe even add a check so that if $1 is --help, then don't run "make" or "make install".

Ludootje
05-24-2004, 03:22 PM
Nice idea, maybe when the suggestions are implemented (if you do plan to implement them), it could be posted in the 'How I did it' section? I think it'd mostly be useful to people who *don't* visit the Programming section.

ecks
05-24-2004, 07:39 PM
Nice idea, I think I'll do that.