##// END OF EJS Templates
buildrpm: bump bundled Python version to 2.7.16 when building for centos{5,6}...
Antonio Muci -
r42378:ae68418c stable
parent child Browse files
Show More
@@ -1,76 +1,76 b''
1 PYTHONVER=2.7.14
1 PYTHONVER=2.7.16
2 PYTHONNAME=python-
2 PYTHONNAME=python-
3 PREFIX=$(HOME)/bin/prefix-$(PYTHONNAME)$(PYTHONVER)
3 PREFIX=$(HOME)/bin/prefix-$(PYTHONNAME)$(PYTHONVER)
4 SYMLINKDIR=$(HOME)/bin
4 SYMLINKDIR=$(HOME)/bin
5
5
6 help:
6 help:
7 @echo
7 @echo
8 @echo 'Make a custom installation of a Python version'
8 @echo 'Make a custom installation of a Python version'
9 @echo
9 @echo
10 @echo 'Common make parameters:'
10 @echo 'Common make parameters:'
11 @echo ' PYTHONVER=... [$(PYTHONVER)]'
11 @echo ' PYTHONVER=... [$(PYTHONVER)]'
12 @echo ' PREFIX=... [$(PREFIX)]'
12 @echo ' PREFIX=... [$(PREFIX)]'
13 @echo ' SYMLINKDIR=... [$(SYMLINKDIR) creating $(PYTHONNAME)$(PYTHONVER)]'
13 @echo ' SYMLINKDIR=... [$(SYMLINKDIR) creating $(PYTHONNAME)$(PYTHONVER)]'
14 @echo
14 @echo
15 @echo 'Common make targets:'
15 @echo 'Common make targets:'
16 @echo ' python - install Python $$PYTHONVER in $$PREFIX'
16 @echo ' python - install Python $$PYTHONVER in $$PREFIX'
17 @echo ' symlink - create a $$SYMLINKDIR/$(PYTHONNAME)$$PYTHONVER symlink'
17 @echo ' symlink - create a $$SYMLINKDIR/$(PYTHONNAME)$$PYTHONVER symlink'
18 @echo
18 @echo
19 @echo 'Example: create a temporary Python installation:'
19 @echo 'Example: create a temporary Python installation:'
20 @echo ' $$ make -f Makefile.python python PYTHONVER=${PYTHONVER} PREFIX=/tmp/p27'
20 @echo ' $$ make -f Makefile.python python PYTHONVER=${PYTHONVER} PREFIX=/tmp/p27'
21 @echo ' $$ /tmp/p27/bin/python -V'
21 @echo ' $$ /tmp/p27/bin/python -V'
22 @echo ' Python 2.7'
22 @echo ' Python 2.7'
23 @echo
23 @echo
24 @echo 'Some external libraries are required for building Python: zlib bzip2 openssl.'
24 @echo 'Some external libraries are required for building Python: zlib bzip2 openssl.'
25 @echo 'Make sure their development packages are installed systemwide.'
25 @echo 'Make sure their development packages are installed systemwide.'
26 # fedora: yum install zlib-devel bzip2-devel openssl-devel
26 # fedora: yum install zlib-devel bzip2-devel openssl-devel
27 # debian: apt-get install zlib1g-dev libbz2-dev libssl-dev
27 # debian: apt-get install zlib1g-dev libbz2-dev libssl-dev
28 @echo
28 @echo
29 @echo 'To build a nice collection of interesting Python versions:'
29 @echo 'To build a nice collection of interesting Python versions:'
30 @echo ' $$ for v in 2.{6{,.1,.2,.9},7{,.8,.10}}; do'
30 @echo ' $$ for v in 2.{6{,.1,.2,.9},7{,.8,.10}}; do'
31 @echo ' make -f Makefile.python symlink PYTHONVER=$$v || break; done'
31 @echo ' make -f Makefile.python symlink PYTHONVER=$$v || break; done'
32 @echo 'To run a Mercurial test on all these Python versions:'
32 @echo 'To run a Mercurial test on all these Python versions:'
33 @echo ' $$ for py in `cd ~/bin && ls $(PYTHONNAME)2.*`; do'
33 @echo ' $$ for py in `cd ~/bin && ls $(PYTHONNAME)2.*`; do'
34 @echo ' echo $$py; $$py run-tests.py test-http.t; echo; done'
34 @echo ' echo $$py; $$py run-tests.py test-http.t; echo; done'
35 @echo
35 @echo
36
36
37 export LANGUAGE=C
37 export LANGUAGE=C
38 export LC_ALL=C
38 export LC_ALL=C
39
39
40 python: $(PREFIX)/bin/python docutils
40 python: $(PREFIX)/bin/python docutils
41 printf 'import sys, zlib, bz2, docutils, ssl' | $(PREFIX)/bin/python
41 printf 'import sys, zlib, bz2, docutils, ssl' | $(PREFIX)/bin/python
42
42
43 PYTHON_SRCDIR=Python-$(PYTHONVER)
43 PYTHON_SRCDIR=Python-$(PYTHONVER)
44 PYTHON_SRCFILE=$(PYTHON_SRCDIR).tgz
44 PYTHON_SRCFILE=$(PYTHON_SRCDIR).tgz
45
45
46 $(PREFIX)/bin/python:
46 $(PREFIX)/bin/python:
47 [ -f $(PYTHON_SRCFILE) ] || wget http://www.python.org/ftp/python/$(PYTHONVER)/$(PYTHON_SRCFILE) || curl -OL http://www.python.org/ftp/python/$(PYTHONVER)/$(PYTHON_SRCFILE) || [ -f $(PYTHON_SRCFILE) ]
47 [ -f $(PYTHON_SRCFILE) ] || wget http://www.python.org/ftp/python/$(PYTHONVER)/$(PYTHON_SRCFILE) || curl -OL http://www.python.org/ftp/python/$(PYTHONVER)/$(PYTHON_SRCFILE) || [ -f $(PYTHON_SRCFILE) ]
48 rm -rf $(PYTHON_SRCDIR)
48 rm -rf $(PYTHON_SRCDIR)
49 tar xf $(PYTHON_SRCFILE)
49 tar xf $(PYTHON_SRCFILE)
50 # Debian/Ubuntu disables SSLv2,3 the hard way, disable it on old Pythons too
50 # Debian/Ubuntu disables SSLv2,3 the hard way, disable it on old Pythons too
51 -sed -i 's,self.*SSLv[23]_method(),0;//\0,g' $(PYTHON_SRCDIR)/Modules/_ssl.c
51 -sed -i 's,self.*SSLv[23]_method(),0;//\0,g' $(PYTHON_SRCDIR)/Modules/_ssl.c
52 # Find multiarch system libraries on Ubuntu and disable fortify error when setting argv
52 # Find multiarch system libraries on Ubuntu and disable fortify error when setting argv
53 LDFLAGS="-L/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`"; \
53 LDFLAGS="-L/usr/lib/`dpkg-architecture -qDEB_HOST_MULTIARCH`"; \
54 BASECFLAGS=-U_FORTIFY_SOURCE; \
54 BASECFLAGS=-U_FORTIFY_SOURCE; \
55 export LDFLAGS BASECFLAGS; \
55 export LDFLAGS BASECFLAGS; \
56 cd $(PYTHON_SRCDIR) && ./configure --prefix=$(PREFIX) && make all SVNVERSION=pwd && make install
56 cd $(PYTHON_SRCDIR) && ./configure --prefix=$(PREFIX) && make all SVNVERSION=pwd && make install
57 printf 'import sys, zlib, bz2, ssl' | $(PREFIX)/bin/python
57 printf 'import sys, zlib, bz2, ssl' | $(PREFIX)/bin/python
58 rm -rf $(PYTHON_SRCDIR)
58 rm -rf $(PYTHON_SRCDIR)
59
59
60 DOCUTILSVER=0.12
60 DOCUTILSVER=0.12
61 DOCUTILS_SRCDIR=docutils-$(DOCUTILSVER)
61 DOCUTILS_SRCDIR=docutils-$(DOCUTILSVER)
62 DOCUTILS_SRCFILE=$(DOCUTILS_SRCDIR).tar.gz
62 DOCUTILS_SRCFILE=$(DOCUTILS_SRCDIR).tar.gz
63
63
64 docutils: $(PREFIX)/bin/python
64 docutils: $(PREFIX)/bin/python
65 @$(PREFIX)/bin/python -c 'import docutils' || ( set -ex; \
65 @$(PREFIX)/bin/python -c 'import docutils' || ( set -ex; \
66 [ -f $(DOCUTILS_SRCFILE) ] || wget http://downloads.sourceforge.net/project/docutils/docutils/$(DOCUTILSVER)/$(DOCUTILS_SRCFILE) || [ -f $(DOCUTILS_SRCFILE) ]; \
66 [ -f $(DOCUTILS_SRCFILE) ] || wget http://downloads.sourceforge.net/project/docutils/docutils/$(DOCUTILSVER)/$(DOCUTILS_SRCFILE) || [ -f $(DOCUTILS_SRCFILE) ]; \
67 rm -rf $(DOCUTILS_SRCDIR); \
67 rm -rf $(DOCUTILS_SRCDIR); \
68 tar xf $(DOCUTILS_SRCFILE); \
68 tar xf $(DOCUTILS_SRCFILE); \
69 cd $(DOCUTILS_SRCDIR) && $(PREFIX)/bin/python setup.py install --prefix=$(PREFIX); \
69 cd $(DOCUTILS_SRCDIR) && $(PREFIX)/bin/python setup.py install --prefix=$(PREFIX); \
70 $(PREFIX)/bin/python -c 'import docutils'; \
70 $(PREFIX)/bin/python -c 'import docutils'; \
71 rm -rf $(DOCUTILS_SRCDIR); )
71 rm -rf $(DOCUTILS_SRCDIR); )
72
72
73 symlink: python $(SYMLINKDIR)
73 symlink: python $(SYMLINKDIR)
74 ln -sf $(PREFIX)/bin/python $(SYMLINKDIR)/$(PYTHONNAME)$(PYTHONVER)
74 ln -sf $(PREFIX)/bin/python $(SYMLINKDIR)/$(PYTHONNAME)$(PYTHONVER)
75
75
76 .PHONY: help python docutils symlink
76 .PHONY: help python docutils symlink
@@ -1,160 +1,160 b''
1 #!/bin/bash -e
1 #!/bin/bash -e
2 #
2 #
3 # Build a Mercurial RPM from the current repo
3 # Build a Mercurial RPM from the current repo
4 #
4 #
5 # Tested on
5 # Tested on
6 # - Fedora 20
6 # - Fedora 20
7 # - CentOS 5
7 # - CentOS 5
8 # - centOS 6
8 # - centOS 6
9
9
10 . $(dirname $0)/packagelib.sh
10 . $(dirname $0)/packagelib.sh
11
11
12 BUILD=1
12 BUILD=1
13 RPMBUILDDIR="$PWD/rpmbuild"
13 RPMBUILDDIR="$PWD/rpmbuild"
14
14
15 while [ "$1" ]; do
15 while [ "$1" ]; do
16 case "$1" in
16 case "$1" in
17 --prepare )
17 --prepare )
18 shift
18 shift
19 BUILD=
19 BUILD=
20 ;;
20 ;;
21 --withpython | --with-python)
21 --withpython | --with-python)
22 shift
22 shift
23 PYTHONVER=2.7.14
23 PYTHONVER=2.7.16
24 PYTHONMD5=cee2e4b33ad3750da77b2e85f2f8b724
24 PYTHONMD5=f1a2ace631068444831d01485466ece0
25 ;;
25 ;;
26 --rpmbuilddir )
26 --rpmbuilddir )
27 shift
27 shift
28 RPMBUILDDIR="$1"
28 RPMBUILDDIR="$1"
29 shift
29 shift
30 ;;
30 ;;
31 * )
31 * )
32 echo "Invalid parameter $1!" 1>&2
32 echo "Invalid parameter $1!" 1>&2
33 exit 1
33 exit 1
34 ;;
34 ;;
35 esac
35 esac
36 done
36 done
37
37
38 cd "`dirname $0`/../.."
38 cd "`dirname $0`/../.."
39
39
40 specfile=$PWD/contrib/packaging/mercurial.spec
40 specfile=$PWD/contrib/packaging/mercurial.spec
41 if [ ! -f $specfile ]; then
41 if [ ! -f $specfile ]; then
42 echo "Cannot find $specfile!" 1>&2
42 echo "Cannot find $specfile!" 1>&2
43 exit 1
43 exit 1
44 fi
44 fi
45
45
46 if [ ! -d .hg ]; then
46 if [ ! -d .hg ]; then
47 echo 'You are not inside a Mercurial repository!' 1>&2
47 echo 'You are not inside a Mercurial repository!' 1>&2
48 exit 1
48 exit 1
49 fi
49 fi
50
50
51 gethgversion
51 gethgversion
52
52
53 if [ -z "$type" ] ; then
53 if [ -z "$type" ] ; then
54 release=1
54 release=1
55 else
55 else
56 release=0.9_$type
56 release=0.9_$type
57 fi
57 fi
58
58
59 if [ -n "$distance" ] ; then
59 if [ -n "$distance" ] ; then
60 release=$release+${distance}_${node}
60 release=$release+${distance}_${node}
61 fi
61 fi
62
62
63 if [ "$PYTHONVER" ]; then
63 if [ "$PYTHONVER" ]; then
64 release=$release+$PYTHONVER
64 release=$release+$PYTHONVER
65 RPMPYTHONVER=$PYTHONVER
65 RPMPYTHONVER=$PYTHONVER
66 else
66 else
67 RPMPYTHONVER=%{nil}
67 RPMPYTHONVER=%{nil}
68 fi
68 fi
69
69
70 mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
70 mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
71 $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
71 $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
72 if [ "$PYTHONVER" ]; then
72 if [ "$PYTHONVER" ]; then
73 (
73 (
74 mkdir -p build
74 mkdir -p build
75 cd build
75 cd build
76 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
76 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
77 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
77 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
78 if [ "$PYTHONMD5" ]; then
78 if [ "$PYTHONMD5" ]; then
79 echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
79 echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
80 fi
80 fi
81 ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
81 ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
82
82
83 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
83 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
84 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
84 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
85 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
85 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
86 DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
86 DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
87 if [ "$DOCUTILSMD5" ]; then
87 if [ "$DOCUTILSMD5" ]; then
88 echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
88 echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
89 fi
89 fi
90 ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
90 ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
91 )
91 )
92 fi
92 fi
93
93
94 mkdir -p $RPMBUILDDIR/SPECS
94 mkdir -p $RPMBUILDDIR/SPECS
95 rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
95 rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
96
96
97 sed -e "s,^Version:.*,Version: $version," \
97 sed -e "s,^Version:.*,Version: $version," \
98 -e "s,^Release:.*,Release: $release," \
98 -e "s,^Release:.*,Release: $release," \
99 $specfile > $rpmspec
99 $specfile > $rpmspec
100
100
101 echo >> $rpmspec
101 echo >> $rpmspec
102 echo "%changelog" >> $rpmspec
102 echo "%changelog" >> $rpmspec
103
103
104 if echo $version | grep '+' > /dev/null 2>&1; then
104 if echo $version | grep '+' > /dev/null 2>&1; then
105 latesttag="`echo $version | sed -e 's/+.*//'`"
105 latesttag="`echo $version | sed -e 's/+.*//'`"
106 $HG log -r .:"$latesttag" -fM \
106 $HG log -r .:"$latesttag" -fM \
107 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
107 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
108 import sys, time
108 import sys, time
109
109
110 def datestr(date, format):
110 def datestr(date, format):
111 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
111 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
112
112
113 changelog = []
113 changelog = []
114 for l in sys.stdin.readlines():
114 for l in sys.stdin.readlines():
115 tok = l.split("\t")
115 tok = l.split("\t")
116 hgdate = tuple(int(v) for v in tok[0].split())
116 hgdate = tuple(int(v) for v in tok[0].split())
117 changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
117 changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
118 prevtitle = ""
118 prevtitle = ""
119 for l in sorted(changelog, reverse=True):
119 for l in sorted(changelog, reverse=True):
120 title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
120 title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
121 if prevtitle != title:
121 if prevtitle != title:
122 prevtitle = title
122 prevtitle = title
123 print
123 print
124 print title
124 print title
125 print "- %s" % l[3].strip()
125 print "- %s" % l[3].strip()
126 ' >> $rpmspec
126 ' >> $rpmspec
127
127
128 else
128 else
129
129
130 $HG log \
130 $HG log \
131 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
131 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
132 .hgtags | python -c '
132 .hgtags | python -c '
133 import sys, time
133 import sys, time
134
134
135 def datestr(date, format):
135 def datestr(date, format):
136 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
136 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
137
137
138 for l in sys.stdin.readlines():
138 for l in sys.stdin.readlines():
139 tok = l.split("\t")
139 tok = l.split("\t")
140 hgdate = tuple(int(v) for v in tok[0].split())
140 hgdate = tuple(int(v) for v in tok[0].split())
141 print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
141 print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
142 ' >> $rpmspec
142 ' >> $rpmspec
143
143
144 fi
144 fi
145
145
146 sed -i \
146 sed -i \
147 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
147 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
148 $rpmspec
148 $rpmspec
149
149
150 if [ "$BUILD" ]; then
150 if [ "$BUILD" ]; then
151 rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
151 rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
152 if [ $? = 0 ]; then
152 if [ $? = 0 ]; then
153 echo
153 echo
154 echo "Built packages for $version-$release:"
154 echo "Built packages for $version-$release:"
155 find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
155 find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
156 fi
156 fi
157 else
157 else
158 echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
158 echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
159 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
159 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
160 fi
160 fi
General Comments 0
You need to be logged in to leave comments. Login now