| 1 | #!/bin/bash |
|---|
| 2 | if [ x"$PYTHON_VERSION" == "x2.5" ] |
|---|
| 3 | then |
|---|
| 4 | PYTHON_SRPM_URL=http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/10/Everything/source/SRPMS/python-2.5.2-1.fc10.src.rpm |
|---|
| 5 | elif [ x"$PYTHON_VERSION" == "x2.6" ] |
|---|
| 6 | then |
|---|
| 7 | PYTHON_SRPM_URL=http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/11/Everything/source/SRPMS/python-2.6-7.fc11.src.rpm |
|---|
| 8 | else |
|---|
| 9 | echo "Can't find a source RPM for Python $PYTHON_VERSION" |
|---|
| 10 | exit 1 |
|---|
| 11 | fi |
|---|
| 12 | mkdir -p logs rpms srpms |
|---|
| 13 | rpm_arch=`rpmbuild -E %{_arch} 2>/dev/null` |
|---|
| 14 | if [ $(ls rpms/python$PYTHON_SUFFIX-$PYTHON_VERSION*.rpm | wc -l) -gt 0 ] |
|---|
| 15 | then |
|---|
| 16 | echo "Not building python as the following packages are already built:" |
|---|
| 17 | ls rpms/python$PYTHON_SUFFIX-$PYTHON_VERSION*.rpm |
|---|
| 18 | exit |
|---|
| 19 | fi |
|---|
| 20 | if [ -f /etc/fedora-release ] |
|---|
| 21 | then |
|---|
| 22 | sudo yum -y install rpmdevtools || exit |
|---|
| 23 | SETUPTREE=rpmdev-setuptree |
|---|
| 24 | elif [ -f /etc/redhat-release ] |
|---|
| 25 | then |
|---|
| 26 | REDHAT_VERSION=`cat /etc/redhat-release | cut -d " " -f 3 | cut -d "." -f 1` |
|---|
| 27 | if [[ $REDHAT_VERSION -lt 5 ]] |
|---|
| 28 | then |
|---|
| 29 | sudo yum -y install fedora-rpmdevtools || exit |
|---|
| 30 | elif [[ $REDHAT_VERSION == 5 ]] |
|---|
| 31 | then |
|---|
| 32 | cd rpms |
|---|
| 33 | wget -c ftp://mirror.switch.ch/pool/1/mirror/epel/5/${rpm_arch}/fakeroot-libs-1.12.2-21.el5.2.${rpm_arch}.rpm |
|---|
| 34 | wget -c ftp://mirror.switch.ch/pool/1/mirror/epel/5/${rpm_arch}/fakeroot-1.12.2-21.el5.2.${rpm_arch}.rpm |
|---|
| 35 | wget -c ftp://mirror.switch.ch/pool/1/mirror/epel/5/${rpm_arch}/rpmdevtools-6.8-1.el5.noarch.rpm |
|---|
| 36 | if [ "x`rpm -qa redhat-rpm-config`" == "x" ] |
|---|
| 37 | then |
|---|
| 38 | sudo yum install -y redhat-rpm-config |
|---|
| 39 | fi |
|---|
| 40 | if [ "x`rpm -qa gcc-c++`" == "x" ] |
|---|
| 41 | then |
|---|
| 42 | sudo yum install -y gcc-c++ |
|---|
| 43 | fi |
|---|
| 44 | if [ "x`rpm -qa rpmdevtools`" == "x" ] |
|---|
| 45 | then |
|---|
| 46 | sudo rpm -Uvh fakeroot-{,libs-}1.12.2-21.el5.2.${rpm_arch}.rpm rpmdevtools-6.8-1.el5.noarch.rpm || exit 1 |
|---|
| 47 | fi |
|---|
| 48 | cd .. |
|---|
| 49 | else |
|---|
| 50 | echo I don\'t know how to install rpmdevtools on RedHat $REDHAT_VERSION |
|---|
| 51 | exit 1 |
|---|
| 52 | fi |
|---|
| 53 | SETUPTREE=fedora-buildrpmtree |
|---|
| 54 | fi |
|---|
| 55 | $SETUPTREE || exit |
|---|
| 56 | # Check official distro version |
|---|
| 57 | EXPAT_VERSION=`yum info expat | grep Version | head -n 1 | sed -e "s/[ \t]\+/ /g" | cut -d ":" -f 2 | cut -d " " -f 2 | sort | tail -n 1` |
|---|
| 58 | if [ `echo $EXPAT_VERSION | cut -d "." -f 1` == "1" ] && [ `echo $EXPAT_VERSION | cut -d "." -f 2` == "95" ] && [ `echo $EXPAT_VERSION | cut -d "." -f 3` -lt 8 ] |
|---|
| 59 | then |
|---|
| 60 | ( |
|---|
| 61 | echo Building expat... |
|---|
| 62 | ./build-expat-rpm |
|---|
| 63 | ./install-expat-rpm |
|---|
| 64 | ) |
|---|
| 65 | fi |
|---|
| 66 | LIBXML_VERSION=`yum info libxml2 | grep Version | head -n 1 | sed -e "s/[ \t]\+/ /g" | cut -d ":" -f 2 | cut -d " " -f 2 | sort | tail -n 1` |
|---|
| 67 | if [ "`echo $LIBXML_VERSION | cut -d "." -f 1`" == "2" ] && [ `echo $LIBXML_VERSION | cut -d "." -f 2` == "6" ] && [ `echo $LIBXML_VERSION | cut -d "." -f 3` -lt 20 ] |
|---|
| 68 | then |
|---|
| 69 | ( |
|---|
| 70 | echo Building LibXML... |
|---|
| 71 | ./build-libxml-rpm |
|---|
| 72 | ./install-libxml-rpm |
|---|
| 73 | ) |
|---|
| 74 | fi |
|---|
| 75 | LIBFFI_VERSION=`yum info libffi | grep Version | head -n 1 | sed -e "s/[ \t]\+/ /g" | cut -d ":" -f 2 | cut -d " " -f 2 | sort | tail -n 1` |
|---|
| 76 | if [ "x$LIBFFI_VERSION" == "x" ] |
|---|
| 77 | then |
|---|
| 78 | ( |
|---|
| 79 | echo Building LibFFI... |
|---|
| 80 | ./build-libffi-rpm |
|---|
| 81 | ./install-libffi-rpm |
|---|
| 82 | ) |
|---|
| 83 | elif [ "x`rpm -q libffi-devel`" == "x" ] |
|---|
| 84 | then |
|---|
| 85 | sudo yum install libffi-devel |
|---|
| 86 | fi |
|---|
| 87 | AUTOCONF_VERSION=`yum info autoconf | grep Version | head -n 1 | sed -e "s/[ \t]\+/ /g" | cut -d ":" -f 2 | cut -d " " -f 2 | sort | tail -n 1` |
|---|
| 88 | if [ "`echo $AUTOCONF_VERSION | cut -d "." -f 1`" == "2" ] && [ `echo $AUTOCONF_VERSION | cut -d "." -f 2` -lt "61" ] |
|---|
| 89 | then |
|---|
| 90 | ( |
|---|
| 91 | echo Building Autoconf 2.61... |
|---|
| 92 | ./build-autoconf-rpm |
|---|
| 93 | ./install-autoconf-rpm |
|---|
| 94 | ) |
|---|
| 95 | fi |
|---|
| 96 | SQLITE_VERSION=`yum info sqlite | grep Version | head -n 1 | sed -e "s/[ \t]\+/ /g" | cut -d ":" -f 2 | cut -d " " -f 2 | sort | tail -n 1` |
|---|
| 97 | if [ "`echo $SQLITE_VERSION | cut -d "." -f 1`" == "3" ] && [ `echo $SQLITE_VERSION | cut -d "." -f 2` -lt "4" ] |
|---|
| 98 | then |
|---|
| 99 | ( |
|---|
| 100 | echo Building SQLite... |
|---|
| 101 | ./build-sqlite-rpm |
|---|
| 102 | ./install-sqlite-rpm |
|---|
| 103 | ) |
|---|
| 104 | fi |
|---|
| 105 | ( |
|---|
| 106 | cd srpms |
|---|
| 107 | wget -c $PYTHON_SRPM_URL |
|---|
| 108 | rpm -ivh --nomd5 python-$PYTHON_VERSION*.src.rpm |
|---|
| 109 | ) |
|---|
| 110 | DB_VERSION=`yum info db4-devel | grep Version | head -n 1 | sed -e "s/[ \t]\+/ /g" | cut -d ":" -f 2 | cut -d " " -f 2 | sed -e "s/\([0-9]\+\.[0-9]\+\)\..*/\1/"` |
|---|
| 111 | [ -f ~/rpmbuild/SOURCES/python-$PYTHON_VERSION-config.patch ] && sed -ie "s/DBLIBVER=4.[4-9]/DBLIBVER=$DB_VERSION/" ~/rpmbuild/SOURCES/python-$PYTHON_VERSION-config.patch |
|---|
| 112 | sed -ie "s/db4-devel >= 4.[4-9]/db4-devel >= $DB_VERSION/" $HOME/rpmbuild/SPECS/python.spec |
|---|
| 113 | # Name of libX11-devel on old systems is xorg-x11-devel |
|---|
| 114 | if [ 'x$REDHAT_VERSION' != 'x' ] |
|---|
| 115 | then |
|---|
| 116 | if [[ $REDHAT_VERSION -lt 5 ]] |
|---|
| 117 | then |
|---|
| 118 | [ -f ~/rpmbuild/SOURCES/python-$PYTHON_VERSION-config.patch ] && sed -ie 's/\+.*-lX11/\+ -L\/usr\/X11R6\/lib -lX11/' ~/rpmbuild/SOURCES/python-$PYTHON_VERSION-config.patch |
|---|
| 119 | sed -ie 's/libX11-devel/xorg-x11-devel/' $HOME/rpmbuild/SPECS/python.spec |
|---|
| 120 | fi |
|---|
| 121 | fi |
|---|
| 122 | # We've made sure libffi-devel is installed, and yum-builddep doesn't detect it |
|---|
| 123 | sed -ie "/libffi-devel/ s/^/#/" $HOME/rpmbuild/SPECS/python.spec |
|---|
| 124 | # add to changelog |
|---|
| 125 | src_rpm=`rpmbuild -bs --nodeps $HOME/rpmbuild/SPECS/python.spec | sed 's/^Wrote: //'` |
|---|
| 126 | sudo cp -pv /etc/yum.conf{,.builddep.orig} |
|---|
| 127 | 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'))" |
|---|
| 128 | sudo yum-builddep $src_rpm || finished=1 |
|---|
| 129 | sudo cp -pv /etc/yum.conf{.builddep.orig,} |
|---|
| 130 | rm $src_rpm |
|---|
| 131 | [[ "$finished" == 1 ]] && exit 1 |
|---|
| 132 | # for fedora 6 |
|---|
| 133 | # QA_RPATHS to prevent /usr/lib64... sqlite error |
|---|
| 134 | # --define __python_ver to include the python version in the bin filenames etc |
|---|
| 135 | QA_RPATHS=0x0001 rpmbuild --define "__python_ver $PYTHON_SUFFIX" -ba ~/rpmbuild/SPECS/python.spec >logs/build-python$PYTHON_SUFFIX.log 2>&1 |
|---|
| 136 | result=$? |
|---|
| 137 | tail logs/build-python$PYTHON_SUFFIX.log |
|---|
| 138 | cp -pv ~/rpmbuild/RPMS/$rpm_arch/python$PYTHON_SUFFIX{,-debuginfo,-devel,-libs,-test,-tools}-$PYTHON_VERSION*.rpm rpms/ |
|---|
| 139 | cp -pv ~/rpmbuild/RPMS/$rpm_arch/tkinter$PYTHON_SUFFIX-$PYTHON_VERSION*.rpm rpms/ |
|---|
| 140 | cp -pv ~/rpmbuild/SRPMS/python$PYTHON_SUFFIX-$PYTHON_VERSION*.rpm rpms/ |
|---|
| 141 | |
|---|