##// END OF EJS Templates
contrib: offer Python 2.7.10
Mads Kiilerich -
r26735:ec74ea54 default
parent child Browse files
Show More
@@ -1,76 +1,76 b''
1 PYTHONVER=2.7.9
1 PYTHONVER=2.7.10
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=2.6 PREFIX=/tmp/p26'
20 @echo ' $$ make -f Makefile.python python PYTHONVER=${PYTHONVER} PREFIX=/tmp/p27'
21 @echo ' $$ /tmp/p26/bin/python -V'
21 @echo ' $$ /tmp/p27/bin/python -V'
22 @echo ' Python 2.6'
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,.9}}; 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 # Ubuntu disables SSLv2 the hard way, disable it on old Pythons too
50 # Ubuntu disables SSLv2 the hard way, disable it on old Pythons too
51 -sed -i 's,self.*SSLv2_method(),0;//\0,g' $(PYTHON_SRCDIR)/Modules/_ssl.c
51 -sed -i 's,self.*SSLv2_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,149 +1,149 b''
1 #!/bin/sh -e
1 #!/bin/sh -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 while [ "$1" ]; do
14 while [ "$1" ]; do
15 case "$1" in
15 case "$1" in
16 --prepare )
16 --prepare )
17 shift
17 shift
18 BUILD=
18 BUILD=
19 ;;
19 ;;
20 --withpython | --with-python)
20 --withpython | --with-python)
21 shift
21 shift
22 PYTHONVER=2.7.9
22 PYTHONVER=2.7.10
23 PYTHONMD5=5eebcaa0030dc4061156d3429657fb83
23 PYTHONMD5=d7547558fd673bd9d38e2108c6b42521
24 ;;
24 ;;
25 --rpmbuilddir )
25 --rpmbuilddir )
26 shift
26 shift
27 RPMBUILDDIR="$1"
27 RPMBUILDDIR="$1"
28 shift
28 shift
29 ;;
29 ;;
30 * )
30 * )
31 echo "Invalid parameter $1!" 1>&2
31 echo "Invalid parameter $1!" 1>&2
32 exit 1
32 exit 1
33 ;;
33 ;;
34 esac
34 esac
35 done
35 done
36
36
37 cd "`dirname $0`/.."
37 cd "`dirname $0`/.."
38
38
39 specfile=$PWD/contrib/mercurial.spec
39 specfile=$PWD/contrib/mercurial.spec
40 if [ ! -f $specfile ]; then
40 if [ ! -f $specfile ]; then
41 echo "Cannot find $specfile!" 1>&2
41 echo "Cannot find $specfile!" 1>&2
42 exit 1
42 exit 1
43 fi
43 fi
44
44
45 if [ ! -d .hg ]; then
45 if [ ! -d .hg ]; then
46 echo 'You are not inside a Mercurial repository!' 1>&2
46 echo 'You are not inside a Mercurial repository!' 1>&2
47 exit 1
47 exit 1
48 fi
48 fi
49
49
50 gethgversion
50 gethgversion
51
51
52 if [ "$PYTHONVER" ]; then
52 if [ "$PYTHONVER" ]; then
53 release=$release+$PYTHONVER
53 release=$release+$PYTHONVER
54 RPMPYTHONVER=$PYTHONVER
54 RPMPYTHONVER=$PYTHONVER
55 else
55 else
56 RPMPYTHONVER=%{nil}
56 RPMPYTHONVER=%{nil}
57 fi
57 fi
58
58
59 mkdir -p $RPMBUILDDIR/SOURCES
59 mkdir -p $RPMBUILDDIR/SOURCES
60 $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
60 $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
61 if [ "$PYTHONVER" ]; then
61 if [ "$PYTHONVER" ]; then
62 (
62 (
63 mkdir -p build
63 mkdir -p build
64 cd build
64 cd build
65 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
65 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
66 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
66 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
67 if [ "$PYTHONMD5" ]; then
67 if [ "$PYTHONMD5" ]; then
68 echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
68 echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
69 fi
69 fi
70 ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
70 ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
71
71
72 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
72 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
73 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
73 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
74 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
74 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
75 DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
75 DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
76 if [ "$DOCUTILSMD5" ]; then
76 if [ "$DOCUTILSMD5" ]; then
77 echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
77 echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
78 fi
78 fi
79 ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
79 ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
80 )
80 )
81 fi
81 fi
82
82
83 mkdir -p $RPMBUILDDIR/SPECS
83 mkdir -p $RPMBUILDDIR/SPECS
84 rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
84 rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
85
85
86 sed -e "s,^Version:.*,Version: $version," \
86 sed -e "s,^Version:.*,Version: $version," \
87 -e "s,^Release:.*,Release: $release," \
87 -e "s,^Release:.*,Release: $release," \
88 $specfile > $rpmspec
88 $specfile > $rpmspec
89
89
90 echo >> $rpmspec
90 echo >> $rpmspec
91 echo "%changelog" >> $rpmspec
91 echo "%changelog" >> $rpmspec
92
92
93 if echo $version | grep '+' > /dev/null 2>&1; then
93 if echo $version | grep '+' > /dev/null 2>&1; then
94 latesttag="`echo $version | sed -e 's/+.*//'`"
94 latesttag="`echo $version | sed -e 's/+.*//'`"
95 $HG log -r .:"$latesttag" -fM \
95 $HG log -r .:"$latesttag" -fM \
96 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
96 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
97 import sys, time
97 import sys, time
98
98
99 def datestr(date, format):
99 def datestr(date, format):
100 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
100 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
101
101
102 changelog = []
102 changelog = []
103 for l in sys.stdin.readlines():
103 for l in sys.stdin.readlines():
104 tok = l.split("\t")
104 tok = l.split("\t")
105 hgdate = tuple(int(v) for v in tok[0].split())
105 hgdate = tuple(int(v) for v in tok[0].split())
106 changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
106 changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
107 prevtitle = ""
107 prevtitle = ""
108 for l in sorted(changelog, reverse=True):
108 for l in sorted(changelog, reverse=True):
109 title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
109 title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
110 if prevtitle != title:
110 if prevtitle != title:
111 prevtitle = title
111 prevtitle = title
112 print
112 print
113 print title
113 print title
114 print "- %s" % l[3].strip()
114 print "- %s" % l[3].strip()
115 ' >> $rpmspec
115 ' >> $rpmspec
116
116
117 else
117 else
118
118
119 $HG log \
119 $HG log \
120 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
120 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
121 .hgtags | python -c '
121 .hgtags | python -c '
122 import sys, time
122 import sys, time
123
123
124 def datestr(date, format):
124 def datestr(date, format):
125 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
125 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
126
126
127 for l in sys.stdin.readlines():
127 for l in sys.stdin.readlines():
128 tok = l.split("\t")
128 tok = l.split("\t")
129 hgdate = tuple(int(v) for v in tok[0].split())
129 hgdate = tuple(int(v) for v in tok[0].split())
130 print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
130 print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
131 ' >> $rpmspec
131 ' >> $rpmspec
132
132
133 fi
133 fi
134
134
135 sed -i \
135 sed -i \
136 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
136 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
137 $rpmspec
137 $rpmspec
138
138
139 if [ "$BUILD" ]; then
139 if [ "$BUILD" ]; then
140 rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
140 rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
141 if [ $? = 0 ]; then
141 if [ $? = 0 ]; then
142 echo
142 echo
143 echo "Built packages for $version-$release:"
143 echo "Built packages for $version-$release:"
144 find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
144 find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
145 fi
145 fi
146 else
146 else
147 echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
147 echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
148 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
148 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
149 fi
149 fi
General Comments 0
You need to be logged in to leave comments. Login now