I have written three small scripts to
1.Uncompress zip or tar files from a directory
2.execute ./configure , make , make install
3.simultaneously do step 2 on all the directories of BDB, i.e db-4.x.y at one shot:
2.execute ./configure , make , make install
3.simultaneously do step 2 on all the directories of BDB, i.e db-4.x.y at one shot:
Script
1 : Perl script to extract all zip or tar files, Run script 2 from
Script 1. Syntax and logic is correct , but script is not correctly
invoked from script 1.
Script 2 : written separately to take the unzipped directory as an argument, finish configuring, compiling and installing.
Script 3 : This is just a wrapper over Script 3 to take all db-4.x.y directories at one shot.
Script 1 : List_binaries_Berekely_DB_allversions.pl
Usage : Perl List_binaries_Berekely_DB_allversions.pl
#!/usr/bin/perl -w
#############################################################################################
##Compiling and installing Berekely DB 3.x and above with perl script##
#
#step 1. Unzip / Untar the zip files.
#step 2. cut the zipfile or tar file to get name "x" out of x.y.zip or x.y.tar.gz
#step 3. go to x.y directory out of x.y.zip or x.y.tar.gz
#step 4. go to /%/x.y/dist
#step 5. execute ./configure
#step 6. execute make -f Makefile
#step 7. execut make install
#
#
#Note: I have used perl because shell is incomptable on four unix platforms
#
#
#############################################################################################
# Global declarations #
my $BDB_WORK = "/opt1/Oracle/Sriram_Working_on_Erroneous_Installers/Sriram_Berkeley_DB_Work/compare_dir" ;
#my $CD_COMMAND = 'cd $BDB_WORK';
my $UNZIP_COMMAND = 'unzip';
my $UNZIP_UNTAR = 'tar -xzvf';
my $status;
my $zipfile;
my $ls_output = "";
#change to $BDB_WORK dir#
#system "$CD_COMMAND";
my @Filelist = `ls`;
foreach (@Filelist)
{
chomp;
$zipfile = $_;
## Construct BerkeleyDB.x.y on the fly ##
my @split_version = split (/[-\.]/,$zipfile) ;
my $ver_subversion = "$split_version[1]" . ".$split_version[2]" ;
if ( $zipfile =~ /.zip$/ )
{
$status = system "$UNZIP_COMMAND $zipfile" ;
if ( $status = 0 )
{
##extract x.y from x.y.zip file ##
$zipfile =~ s/(\w+)\.zip/$1/;
my $unzipped_dir = $zipfile;
system "ksh execute_make.sh $unzipped_dir" ;
#Now get the ls -l output of installed location (/usr/local/BerkeleyDB.x.y/bin) of all Berkeley DB versions" ##
$ls_output = `ls -l /usr/local/BerkeleyDB.$ver_subversion/bin/ | awk ' $0 !~ /^total/ {print $5" "$9}' > /tmp/BDB-$ver_subversion.txt ` ;
## print $ls_output ##
print "ls_output of /usr/local/BerkeleyDB.$ver_subversion/bin/ is $ls_output \n" ;
}
}
elsif ( $zipfile =~ /.tar.gz$/ )
{
$status = system "$UNZIP_UNTAR $zipfile";
if ( $status = 0 )
{
##extract x.y from x.y.tar.gz file##
$zipfile =~ s/(\w+)\.tar.gz/$1/;
my $unzipped_dir = $zipfile;
##Execute make ##
system "ksh execute_make.sh $unzipped_dir" ;
#Now get the ls -l output of installed location (/usr/local/BerkeleyDB.x.y/bin) of all Berkeley DB versions" ##
$ls_output = `ls -l /usr/local/BerkeleyDB.$ver_subversion/bin/ | awk ' $0 !~ /^total/ {print $5" "$9}' > /tmp/BDB-$ver_subversion.txt ` ;
## print $ls_output ##
print "ls_output of /usr/local/BerkeleyDB.$ver_subversion/bin/ is $ls_output \n" ;
}
}
}
## diff <(ls -l /usr/local/BerkeleyDB.4.1/bin/ | awk ' $0 !~ /^total/ {print $5" "$9}') <(ls -l /usr/local/BerkeleyDB.4.0/bin | awk ' $0 !~ /^total/ {print $5" "$9}')
#ls -l /usr/local/BerkeleyDB.4.0/bin | awk ' $0 !~ /^total/ {print $5" "$9}' > /tmp/DBD-4.0.txt
#sdiff -s /tmp/BDB-4.1.txt /tmp/DBD-4.0.txt
|
Script 2 : written separately to take the unzipped directory as an argument, finish configuring, compiling and installing.
Usage : ksh execute_make.sh db-4.4.20
#!/usr/bin/ksh
Alert=911
export BDB_WORK="/opt1/Oracle/Sriram_Working_on_Erroneous_Installers/Sriram_Berkeley_DB_Work/compare_dir"
cd
${1}/build_unix/
../dist/configure -prefix=/usr/local/BerkeleyDB.${1}
make
make install
[ $? -eq 0 ] && echo "--- Compilation and Installation of BDB ${1} done --" || echo " -- something wrong check !!! --" && exit $Alert
|
Usage : ksh loop_all_zips.sh
#!/usr/bin/ksh
for dir in db-4.4.20 db-4.5.20 db-4.6.21 db-4.7.25 ; do echo "-- processing $dir --" ; ksh execute_make.sh $dir ; done
|
No comments:
Post a Comment