| 1 | #!/bin/bash |
|---|
| 2 | IMAKE_VERSION=1.0.2-3 |
|---|
| 3 | IMAKE_MAJOR_VERSION=$(echo $IMAKE_VERSION | cut -d "-" -f 1) |
|---|
| 4 | mkdir -p logs rpms srpms |
|---|
| 5 | rpm_arch=`rpmbuild -E %{_arch} 2>/dev/null` |
|---|
| 6 | if [ -f rpms/imake-$IMAKE_VERSION.${rpm_arch}.rpm ] |
|---|
| 7 | then |
|---|
| 8 | echo "Not building imake as rpms/imake-$IMAKE_VERSION.${rpm_arch}.rpm already exists" |
|---|
| 9 | exit |
|---|
| 10 | fi |
|---|
| 11 | if [ -f /etc/fedora-release ] |
|---|
| 12 | then |
|---|
| 13 | sudo yum -y install rpmdevtools || exit |
|---|
| 14 | SETUPTREE=rpmdev-setuptree |
|---|
| 15 | elif [ -f /etc/redhat-release ] |
|---|
| 16 | then |
|---|
| 17 | sudo yum -y install fedora-rpmdevtools || exit |
|---|
| 18 | SETUPTREE=fedora-buildrpmtree |
|---|
| 19 | REDHAT_VERSION=`cat /etc/redhat-release | cut -d " " -f 3 | cut -d "." -f 1` |
|---|
| 20 | fi |
|---|
| 21 | $SETUPTREE || exit |
|---|
| 22 | if [ "x$(yum info xorg-x11-util-macros | grep Version)" == "x" ] |
|---|
| 23 | then |
|---|
| 24 | ./build-xorg-x11-util-macros-rpm |
|---|
| 25 | ./install-xorg-x11-util-macros-rpm |
|---|
| 26 | fi |
|---|
| 27 | ( |
|---|
| 28 | cd srpms |
|---|
| 29 | wget -c http://mirror.centos.org/centos/5/os/SRPMS/imake-$IMAKE_VERSION.src.rpm |
|---|
| 30 | rpm -ivh --nomd5 imake-$IMAKE_MAJOR_VERSION*.src.rpm |
|---|
| 31 | ) |
|---|
| 32 | sed -ie "/xorg-x11-util-macros/d" ~/rpmbuild/SPECS/imake.spec |
|---|
| 33 | sed -ie "s/xorg-x11-proto-devel/xorg-x11-devel/" ~/rpmbuild/SPECS/imake.spec |
|---|
| 34 | export XPROTO_CFLAGS=-I/usr/include |
|---|
| 35 | export XPROTO_LIBS=" " |
|---|
| 36 | export X_CFLAGS=-I/usr/X11R6/include |
|---|
| 37 | export X_LIBS="-L/usr/X11R6/lib -lX11" |
|---|
| 38 | # add to changelog |
|---|
| 39 | src_rpm=`rpmbuild -bs --nodeps $HOME/rpmbuild/SPECS/imake.spec | sed 's/^Wrote: //'` |
|---|
| 40 | # We manually install this, but if we leave this line in, yum0builddep fails |
|---|
| 41 | sudo cp -pv /etc/yum.conf{,.builddep.orig} |
|---|
| 42 | sudo python -c "import ConfigParser ; cp = ConfigParser.RawConfigParser() ; cp.read('/etc/yum.conf') ; cp.set('main', 'assumeyes', '1') ; cp.write(open('/etc/yum.conf', 'w'))" |
|---|
| 43 | sudo yum-builddep $src_rpm || finished=1 |
|---|
| 44 | sudo cp -pv /etc/yum.conf{.builddep.orig,} |
|---|
| 45 | rm $src_rpm |
|---|
| 46 | [[ "$finished" == 1 ]] && exit |
|---|
| 47 | QA_RPATHS=0x0001 rpmbuild -ba ~/rpmbuild/SPECS/imake.spec >logs/build-imake.log 2>&1 |
|---|
| 48 | result=$? |
|---|
| 49 | tail logs/build-imake.log |
|---|
| 50 | cp -pv ~/rpmbuild/RPMS/${rpm_arch}/imake-*$IMAKE_MAJOR_VERSION*.rpm rpms/ |
|---|
| 51 | cp -pv ~/rpmbuild/SRPMS/imake-$IMAKE_MAJOR_VERSION*.rpm rpms/ |
|---|