本地build包并自动解决依赖的shell脚本

前端之家收集整理的这篇文章主要介绍了本地build包并自动解决依赖的shell脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

初级,勿喷,呵呵

#!/bin/bash

clear
ls /root/rpmbuild/SPECS/ > /home/spec-auto.list
cd /root/rpmbuild/SPECS/
####build error info
mkdir /home/Ero/
####build log
mkdir /home/log/
####put spec that successed
mkdir /home/spec/

awk '{print NR,$1}' /home/spec-auto.list > /home/test.list
i=2
n=1
m=0
k=0
tmp=`ls /root/rpmbuild/SPECS|wc -l`
num=$(($tmp+2))
echo "There have $tmp specs;Auto-locabuild start!"

while [ $i != $num ]
do
obj=`awk -v j=$n '$1==j{print $2}' /home/test.list`
echo ""
Time=`date +%Y-%m-%d---%R`
echo "[$Time]---------[$tmp:$n]"
echo "$obj"
rpmbuild -ba $obj &>/home/log/$obj.log
if [ $? != 0 ];
then
# echo "Failed!!!!XXXX"
# tail -n 20 /home/log/$obj.log
################add auto yum pakg and rebuild,back results
cat /home/log/$obj.log |while read line
do
echo "$line" &> /line.list
two=`awk '{print $2}' /line.list`
one=`awk '{print $1}' /line.list`
if [ "$two" == "is" ];then
yum install $one -y &> /dev/null
elif [ "$two" == ">=" ];then
yum install $one -y &> /dev/null
else
echo "" &> /dev/null
fi
done
rpmbuild -ba $obj &>/home/log/$obj.log
if [ $? != 0 ];
then
echo "Failed!!!!XXXX"
tail -n 20 /home/log/$obj.log
echo "$obj " &>> /home/Ero/ero.log
m=$(($m+1))
else
echo "Succssed!!"
rm -rf /home/log/$obj.log
mv /root/rpmbuild/SPECS/$obj /home/spec/
fi
#########################################################
# echo "$obj " &>> /home/Ero/ero.log
# m=$(($m+1))
else
echo "Succssed!!"
rm -rf /home/log/$obj.log
mv /root/rpmbuild/SPECS/$obj /home/spec/
fi
i=$(($i+1))
n=$(($n+1))
done

k=$(($tmp-$m))
echo ""
echo ""
echo "================================================ "
echo "[total:$tmp succeeded:$k Failed:$m] "
echo ""
if [ $m != 0 ];
then
awk '{print NR,$1}' /home/Ero/ero.log > /home/Ero/ero.nr.log
echo "See the Errorinfo at /home/log/*.spec.log,and The following is Failed list:"
cat /home/Ero/ero.nr.log
else
echo "Congratulations!! All build succssed!!"
fi
echo "================================================ "
rm -rf /home/spec-auto.list /home/test.list /home/Ero /line/list
echo -n "End!"
echo ""

Type the name of a command and press enter to execute it,or help for assistance.

猜你在找的设计模式相关文章