| 1 |
#!/bin/bash |
|---|
| 2 |
|
|---|
| 3 |
if [ $ |
|---|
| 4 |
echo -e "usage: `basename $0` <in dir>\n <in dir> - Directory containing tar.gz files for\n all perl modules, distributions you want to install" |
|---|
| 5 |
exit 1 |
|---|
| 6 |
else |
|---|
| 7 |
IND=$1 |
|---|
| 8 |
LOGD=`pwd`/perl_module_installation_logs |
|---|
| 9 |
fi |
|---|
| 10 |
|
|---|
| 11 |
echo "Input directory: $IND" |
|---|
| 12 |
echo "Log directory: $LOGD" |
|---|
| 13 |
|
|---|
| 14 |
TD=/tmp/.pm_perlmod_installer |
|---|
| 15 |
rm -rf $TD $LOGD |
|---|
| 16 |
mkdir -p $TD $LOGD |
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
RESP_FILE=/tmp/.pm_perlmod_installer_resp_file |
|---|
| 24 |
cat <<EOFILE > $RESP_FILE |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
EOFILE |
|---|
| 36 |
|
|---|
| 37 |
echo "gunzipping n untarring from $IND to $TD." |
|---|
| 38 |
for targz in $IND/*.tar.gz |
|---|
| 39 |
do |
|---|
| 40 |
gunzip $targz |
|---|
| 41 |
tar -C $TD -xf ${targz/.gz/} |
|---|
| 42 |
done |
|---|
| 43 |
|
|---|
| 44 |
echo "gzipping..." |
|---|
| 45 |
gzip $IND/*.tar |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
cd $TD |
|---|
| 52 |
num_succ_modules=0 |
|---|
| 53 |
num_retries=0 |
|---|
| 54 |
echo "Number of modules to install = `ls -1 $TD | wc -l`" |
|---|
| 55 |
while true |
|---|
| 56 |
do |
|---|
| 57 |
num_modules=`ls -1 $TD | wc -l` |
|---|
| 58 |
if [ $num_modules -eq 0 ]; then |
|---|
| 59 |
echo "Unbeleivable.. all modules installed successfully. Congratulations." |
|---|
| 60 |
break; |
|---|
| 61 |
fi |
|---|
| 62 |
|
|---|
| 63 |
if [ $num_retries -gt $num_modules ]; then |
|---|
| 64 |
echo "Tried $num_retries times, but looks like the $IND contains modules which depend on some modules which are neither installed nor inside $IND." |
|---|
| 65 |
rm -rf $TD |
|---|
| 66 |
exit 1; |
|---|
| 67 |
fi |
|---|
| 68 |
|
|---|
| 69 |
echo "-----------------Try number: $num_retries-----------------" |
|---|
| 70 |
cd $TD |
|---|
| 71 |
for f in * |
|---|
| 72 |
do |
|---|
| 73 |
LOGF=$LOGD/$f.log |
|---|
| 74 |
echo "Installing $f" |
|---|
| 75 |
echo "------------------------------------------------------------" >> $LOGF |
|---|
| 76 |
echo "-----------------Retry number: $num_retries-----------------" >> $LOGF |
|---|
| 77 |
echo "------------------------------------------------------------" >> $LOGF |
|---|
| 78 |
cd $TD/$f |
|---|
| 79 |
|
|---|
| 80 |
if [ -f Makefile.PL ]; then |
|---|
| 81 |
step_one="perl Makefile.PL" |
|---|
| 82 |
step_two="make" |
|---|
| 83 |
step_three="make install" |
|---|
| 84 |
else |
|---|
| 85 |
step_one="perl Build.PL" |
|---|
| 86 |
step_two="perl ./Build" |
|---|
| 87 |
step_three="perl ./Build install" |
|---|
| 88 |
fi |
|---|
| 89 |
echo "---------------------------$step_one---------------------------" >> $LOGF |
|---|
| 90 |
$step_one < $RESP_FILE >> $LOGF 2>&1 |
|---|
| 91 |
if [ $? -ne 0 ]; then |
|---|
| 92 |
echo "\"$step_one\" phase for $f failed." |
|---|
| 93 |
else |
|---|
| 94 |
echo "---------------------------$step_two---------------------------" >> $LOGF |
|---|
| 95 |
$step_two < $RESP_FILE >> $LOGF 2>&1 |
|---|
| 96 |
if [ $? -ne 0 ]; then |
|---|
| 97 |
echo "\"$step_two\" phase for $f failed." |
|---|
| 98 |
else |
|---|
| 99 |
echo "---------------------------$step_three---------------------------" >> $LOGF |
|---|
| 100 |
$step_three < $RESP_FILE >> $LOGF 2>&1 |
|---|
| 101 |
if [ $? -ne 0 ]; then |
|---|
| 102 |
echo "\"$step_three\" phase for $f failed." |
|---|
| 103 |
else |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
echo "$f installed SUCCESSFULLY." |
|---|
| 107 |
rm -rf $TD/$f |
|---|
| 108 |
num_succ_modules=`expr $num_succ_modules + 1` |
|---|
| 109 |
fi |
|---|
| 110 |
fi |
|---|
| 111 |
fi |
|---|
| 112 |
|
|---|
| 113 |
done |
|---|
| 114 |
num_retries=`expr $num_retries + 1` |
|---|
| 115 |
|
|---|
| 116 |
done |
|---|
| 117 |
|
|---|
| 118 |
rm -rf $TD |
|---|
| 119 |
echo "All done. Logs available in: $LOGD" |
|---|
| 120 |
|
|---|
| 121 |
exit 0; |
|---|