diff --git a/build.sh b/build.sh index 9b637bf..70fcad8 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,9 @@ #!/bin/sh +mkdir -p ~/RPM/SOURCES +mkdir -p ~/RPM/SPECS +mkdir -p ~/RPM/BUILD +mkdir -p ~/RPM/RPMS +mkdir -p ~/RPM/SRPMS rm -rf ~/RPM/BUILD/* rm -rf ~/RPM/RPMS/* rm -rf ~/RPM/SOURCES/* @@ -6,11 +11,15 @@ rm -rf ~/RPM/SPECS/* rm -rf ~/RPM/SRPMS/* for i in $(ls *.spec) do - v=$(cat $i | grep Version | cut -c 9- | sed 's/ *//g') - n=$(basename -s .spec $i) - d=$n-$v - tar -cvf $d.tar $d - mv -f $d.tar ~/RPM/SOURCES/ - cp -f $i ~/RPM/SPECS/ - rpm -ba ~/RPM/SPECS/$i + v=$(cat $i | grep Version | cut -c 9- | sed 's/ *//g') + n=$(basename -s .spec $i) + d=$n-$v + if [ -d $n ]; then + cp -fr $n $d + tar -cvf $d.tar $d + mv -f $d.tar ~/RPM/SOURCES/ + rm -rf $d + fi + cp -f $i ~/RPM/SPECS/ + rpm -ba ~/RPM/SPECS/$i done