LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   installler shell script (https://www.linuxquestions.org/questions/programming-9/installler-shell-script-367433/)

nirav.jani 09-27-2005 05:44 AM

installler shell script
 
Hi all,
I am installing various packages for a tv tuner card, which contains various tar.gz files.
These files are required to be untarred and then ./configure, make and make install as usual.
I want a script which should install these packages, before intsalling packages it should also check the list of installed packages. Regarding to scripts I don't have much exposure, can any body point me to some good example of the same kind.

I am also willing to have one tar.gz with shell script which contains the complete group of tar.gz required to install my packages. Is it possible to do this, if yes how to do it ?

I have goen through the tldp.org tutorial on bash shell script, still not getting how to solve this problem in short time !!
Thanx in advance
nj :confused:

flower.Hercules 09-27-2005 09:23 PM

I can give you a couple hints to get you on your way:

cut the last line of the output of the tar xvzf process out and strip it down to everything before the /, change directory to that stored value and run ./configure && make && make install.

Code:

#!/bin/bash

declare -r DIRECTORY=$(tar xvzf $1 | grep -m 1 Makefile | cut -d'/' -f1)
cd ${DIRECTORY}
./configure && make && make install

Perhaps something like that will do the trick.

DIRECTORY will hold the output of what is in the paranthesis, which is taking (or piping) the output of the tar command to the grep, only allowing one line to match (in case you get multiple Makefiles), and then cutting that one line up by the slash (/) and stripping off anything after and including the first match (or in this case, the first slash). Then it changes the directory up and configures, makes, and make installs. Good luck!


Edit: A side note, you probably know, but I will describe it for clarity. $1 means the OPTION included after the script name, so, in this case, you will have to run a file at a time. If you named the script install_script, then you would have to type:

# install_script <filename>.tar.gz

HTH


All times are GMT -5. The time now is 09:34 AM.