##// END OF EJS Templates
packaging: switch centos 7 packaging to python 3...
Mathias De Mare -
r46440:de1f4c43 default
parent child Browse files
Show More
@@ -1,134 +1,135 b''
1 1 $(eval HGROOT := $(shell cd ../..; pwd))
2 2
3 3 DEBIAN_CODENAMES := \
4 4 stretch \
5 5 buster \
6 6 bullseye
7 7
8 8 UBUNTU_CODENAMES := \
9 9 xenial \
10 10 bionic \
11 11 cosmic \
12 12 disco
13 13
14 14 FEDORA_RELEASE := 31
15 15
16 16 CENTOS_RELEASES := \
17 17 7 \
18 18 8
19 19
20 20 # Build a Python for these CentOS releases.
21 21 CENTOS_WITH_PYTHON_RELEASES :=
22 22 CENTOS_WITH_NONVERSIONED_PYTHON :=
23 CENTOS_WITH_36_DOCUTILS := 7
23 24
24 25 help:
25 26 @echo 'Packaging Make Targets'
26 27 @echo ''
27 28 @echo 'docker-centos{$(strip $(CENTOS_RELEASES))}'
28 29 @echo ' Build an RPM for a specific CentOS version using Docker.'
29 30 @echo ''
30 31 @echo 'docker-debian-{$(strip $(DEBIAN_CODENAMES))}'
31 32 @echo ' Build Debian packages specific to a Debian distro using Docker.'
32 33 @echo ''
33 34 @echo 'docker-fedora'
34 35 @echo ' Build an RPM for a Fedora $(FEDORA_RELEASE) using Docker.'
35 36 @echo ''
36 37 @echo 'docker-ubuntu-{$(strip $(UBUNTU_CODENAMES))}'
37 38 @echo ' Build Debian package specific to an Ubuntu distro using Docker.'
38 39 @echo ''
39 40 @echo 'docker-ubuntu-{$(strip $(UBUNTU_CODENAMES))}-ppa'
40 41 @echo ' Build a source-only Debian package specific to an Ubuntu distro'
41 42 @echo ' using Docker.'
42 43 @echo ''
43 44 @echo 'linux-wheels'
44 45 @echo ' Build Linux manylinux wheels using Docker.'
45 46 @echo ''
46 47 @echo 'linux-wheels-{x86_64, i686}'
47 48 @echo ' Build Linux manylinux wheels for a specific architecture using Docker'
48 49 @echo ''
49 50 @echo 'deb'
50 51 @echo ' Build a Debian package locally targeting the current system'
51 52 @echo ''
52 53 @echo 'ppa'
53 54 @echo ' Build a Debian source package locally targeting the current system'
54 55 @echo ''
55 56 @echo 'centos{$(strip $(CENTOS_RELEASES))}'
56 57 @echo ' Build an RPM for a specific CentOS version locally'
57 58 @echo ''
58 59 @echo 'fedora'
59 60 @echo ' Build an RPM for Fedora $(FEDORA_RELEASE) locally'
60 61
61 62 .PHONY: help
62 63
63 64 .PHONY: deb
64 65 deb:
65 66 ./builddeb
66 67
67 68 .PHONY: ppa
68 69 ppa:
69 70 ./builddeb --source-only
70 71
71 72 # Debian targets.
72 73 define debian_targets =
73 74 .PHONY: docker-debian-$(1)
74 75 docker-debian-$(1):
75 76 ./dockerdeb debian $(1)
76 77
77 78 endef
78 79
79 80 $(foreach codename,$(DEBIAN_CODENAMES),$(eval $(call debian_targets,$(codename))))
80 81
81 82 # Ubuntu targets.
82 83 define ubuntu_targets =
83 84 .PHONY: docker-ubuntu-$(1)
84 85 docker-ubuntu-$(1):
85 86 ./dockerdeb ubuntu $(1)
86 87
87 88 .PHONY: docker-ubuntu-$(1)-ppa
88 89 docker-ubuntu-$(1)-ppa:
89 90 ./dockerdeb ubuntu $(1) --source-only
90 91
91 92 endef
92 93
93 94 $(foreach codename,$(UBUNTU_CODENAMES),$(eval $(call ubuntu_targets,$(codename))))
94 95
95 96 # Fedora targets.
96 97 .PHONY: fedora
97 98 fedora:
98 99 mkdir -p $(HGROOT)/packages/fedora$(FEDORA_RELEASE)
99 100 ./buildrpm
100 101 cp $(HGROOT)/contrib/packaging/rpmbuild/RPMS/*/* $(HGROOT)/packages/fedora$(FEDORA_RELEASE)
101 102 cp $(HGROOT)/contrib/packaging/rpmbuild/SRPMS/* $(HGROOT)/packages/fedora$(FEDORA_RELEASE)
102 103 rm -rf $(HGROOT)/rpmbuild
103 104
104 105 .PHONY: docker-fedora
105 106 docker-fedora:
106 107 ./dockerrpm fedora$(FEDORA_RELEASE)
107 108
108 109 # CentOS targets.
109 110 define centos_targets
110 111 .PHONY: centos$(1)
111 112 centos$(1):
112 113 mkdir -p $$(HGROOT)/packages/centos$(1)
113 ./buildrpm $$(if $$(filter $(1),$$(CENTOS_WITH_PYTHON_RELEASES)),--withpython,$$(if $$(filter $(1),$$(CENTOS_WITH_NONVERSIONED_PYTHON)),--python python,))
114 ./buildrpm $$(if $$(filter $(1),$$(CENTOS_WITH_PYTHON_RELEASES)),--withpython,$$(if $$(filter $(1),$$(CENTOS_WITH_NONVERSIONED_PYTHON)),--python python,))$$(if $$(filter $(1),$$(CENTOS_WITH_36_DOCUTILS)), --docutilspackage python36-docutils,)
114 115 cp $$(HGROOT)/contrib/packaging/rpmbuild/RPMS/*/* $$(HGROOT)/packages/centos$(1)
115 116 cp $$(HGROOT)/contrib/packaging/rpmbuild/SRPMS/* $$(HGROOT)/packages/centos$(1)
116 117
117 118 .PHONY: docker-centos$(1)
118 119 docker-centos$(1):
119 ./dockerrpm centos$(1) $$(if $$(filter $(1),$$(CENTOS_WITH_PYTHON_RELEASES)),--withpython,$$(if $$(filter $(1),$$(CENTOS_WITH_NONVERSIONED_PYTHON)),--python python,))
120 ./dockerrpm centos$(1) $$(if $$(filter $(1),$$(CENTOS_WITH_PYTHON_RELEASES)),--withpython,$$(if $$(filter $(1),$$(CENTOS_WITH_NONVERSIONED_PYTHON)),--python python,))$$(if $$(filter $(1),$$(CENTOS_WITH_36_DOCUTILS)), --docutilspackage python36-docutils,)
120 121
121 122 endef
122 123
123 124 $(foreach release,$(CENTOS_RELEASES),$(eval $(call centos_targets,$(release))))
124 125
125 126 .PHONY: linux-wheels
126 127 linux-wheels: linux-wheels-x86_64 linux-wheels-i686
127 128
128 129 .PHONY: linux-wheels-x86_64
129 130 linux-wheels-x86_64:
130 131 docker run -e "HGTEST_JOBS=$(shell nproc)" --rm -ti -v `pwd`/../..:/src quay.io/pypa/manylinux1_x86_64 /src/contrib/packaging/build-linux-wheels.sh
131 132
132 133 .PHONY: linux-wheels-i686
133 134 linux-wheels-i686:
134 135 docker run -e "HGTEST_JOBS=$(shell nproc)" --rm -ti -v `pwd`/../..:/src quay.io/pypa/manylinux1_i686 linux32 /src/contrib/packaging/build-linux-wheels.sh
@@ -1,163 +1,172 b''
1 1 #!/bin/bash -e
2 2 #
3 3 # Build a Mercurial RPM from the current repo, mainly for Fedora/CentOS/RHEL
4 4
5 5 . $(dirname $0)/packagelib.sh
6 6
7 7 BUILD=1
8 8 RPMBUILDDIR="$PWD/rpmbuild"
9 9 PYTHONEXE=python3
10 DOCUTILSPACKAGE=python3-docutils
10 11
11 12 while [ "$1" ]; do
12 13 case "$1" in
13 14 --prepare )
14 15 shift
15 16 BUILD=
16 17 ;;
17 18 --python)
18 19 shift
19 20 PYTHONEXE=$1
20 21 shift
21 22 ;;
22 23 --withpython | --with-python)
23 24 shift
24 25 PYTHONVER=2.7.16
25 26 PYTHONMD5=f1a2ace631068444831d01485466ece0
26 27 PYTHONEXE=python
27 28 ;;
29 --docutilspackage)
30 shift
31 DOCUTILSPACKAGE="$1"
32 shift
33 ;;
28 34 --rpmbuilddir )
29 35 shift
30 36 RPMBUILDDIR="$1"
31 37 shift
32 38 ;;
33 39 * )
34 40 echo "Invalid parameter $1!" 1>&2
35 41 exit 1
36 42 ;;
37 43 esac
38 44 done
39 45
40 46 cd "`dirname $0`/../.."
41 47
42 48 specfile=$PWD/contrib/packaging/mercurial.spec
43 49 if [ ! -f $specfile ]; then
44 50 echo "Cannot find $specfile!" 1>&2
45 51 exit 1
46 52 fi
47 53
48 54 if [ ! -d .hg ]; then
49 55 echo 'You are not inside a Mercurial repository!' 1>&2
50 56 exit 1
51 57 fi
52 58
53 59 gethgversion
54 60
55 61 if [ -z "$type" ] ; then
56 62 release=1
57 63 else
58 64 release=0.9_$type
59 65 fi
60 66
61 67 if [ -n "$distance" ] ; then
62 68 release=$release+${distance}_${node}
63 69 fi
64 70
65 71 if [ "$PYTHONVER" ]; then
66 72 release=$release+$PYTHONVER
67 73 RPMPYTHONVER=$PYTHONVER
68 74 else
69 75 RPMPYTHONVER=%{nil}
70 76 fi
71 77
72 78 mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
73 79 $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
74 80 if [ "$PYTHONVER" ]; then
75 81 (
76 82 mkdir -p build
77 83 cd build
78 84 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
79 85 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
80 86 if [ "$PYTHONMD5" ]; then
81 87 echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
82 88 fi
83 89 ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
84 90
85 91 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
86 92 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
87 93 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
88 94 DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
89 95 if [ "$DOCUTILSMD5" ]; then
90 96 echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
91 97 fi
92 98 ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
93 99 )
94 100 fi
95 101
96 102 mkdir -p $RPMBUILDDIR/SPECS
97 103 rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
98 104
99 105 sed -e "s,^Version:.*,Version: $version," \
100 106 -e "s,^Release:.*,Release: $release," \
101 107 -e "s/^%global pythonexe .*/%global pythonexe $PYTHONEXE/" \
102 108 $specfile > $rpmspec
103 109
104 110 echo >> $rpmspec
105 111 echo "%changelog" >> $rpmspec
106 112
107 113 if echo $version | grep '+' > /dev/null 2>&1; then
108 114 latesttag="`echo $version | sed -e 's/+.*//'`"
109 115 $HG log -r .:"$latesttag" -fM \
110 116 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
111 117 import sys, time
112 118
113 119 def datestr(date, format):
114 120 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
115 121
116 122 changelog = []
117 123 for l in sys.stdin.readlines():
118 124 tok = l.split("\t")
119 125 hgdate = tuple(int(v) for v in tok[0].split())
120 126 changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
121 127 prevtitle = ""
122 128 for l in sorted(changelog, reverse=True):
123 129 title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
124 130 if prevtitle != title:
125 131 prevtitle = title
126 132 print
127 133 print(title)
128 134 print("- %s" % l[3].strip())
129 135 ' >> $rpmspec
130 136
131 137 else
132 138
133 139 $HG log \
134 140 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
135 141 .hgtags | python -c '
136 142 import sys, time
137 143
138 144 def datestr(date, format):
139 145 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
140 146
141 147 for l in sys.stdin.readlines():
142 148 tok = l.split("\t")
143 149 hgdate = tuple(int(v) for v in tok[0].split())
144 150 print("* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]))
145 151 ' >> $rpmspec
146 152
147 153 fi
148 154
149 155 sed -i \
150 156 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
151 157 $rpmspec
158 sed -i \
159 -e "s/^%global pythondocutils.*$/%global pythondocutils $DOCUTILSPACKAGE/" \
160 $rpmspec
152 161
153 162 if [ "$BUILD" ]; then
154 163 rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
155 164 if [ $? = 0 ]; then
156 165 echo
157 166 echo "Built packages for $version-$release:"
158 167 find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
159 168 fi
160 169 else
161 170 echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
162 171 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
163 172 fi
@@ -1,16 +1,17 b''
1 1 FROM centos:centos7
2 2
3 3 RUN groupadd -g %GID% build && \
4 4 useradd -u %UID% -g %GID% -s /bin/bash -d /build -m build
5 5
6 RUN yum install -y epel-release
6 7 RUN yum install -y \
7 8 gcc \
8 9 gettext \
9 10 make \
10 python-devel \
11 python-docutils \
11 python3-devel \
12 python36-docutils \
12 13 rpm-build \
13 14 tar
14 15
15 16 # For creating repo meta data
16 17 RUN yum install -y createrepo
@@ -1,172 +1,173 b''
1 1 %global emacs_lispdir %{_datadir}/emacs/site-lisp
2 2
3 3 %define withpython %{nil}
4 4
5 5 %global pythonexe python3
6 %global pythondocutils python3-docutils
6 7
7 8 %if "%{?withpython}"
8 9
9 10 %global pythonver %{withpython}
10 11 %global pythonname Python-%{withpython}
11 12 %global docutilsname docutils-0.14
12 13 %global docutilsmd5 c53768d63db3873b7d452833553469de
13 14 %global pythonhg python-hg
14 15 %global hgpyprefix /opt/%{pythonhg}
15 16 # byte compilation will fail on some some Python /test/ files
16 17 %global _python_bytecompile_errors_terminate_build 0
17 18
18 19 %else
19 20
20 21 %global pythonver %(%{pythonexe} -c 'import sys;print(".".join(map(str, sys.version_info[:2])))')
21 22
22 23 %endif
23 24
24 25 Summary: A fast, lightweight Source Control Management system
25 26 Name: mercurial
26 27 Version: snapshot
27 28 Release: 0
28 29 License: GPLv2+
29 30 Group: Development/Tools
30 31 URL: https://mercurial-scm.org/
31 32 Source0: %{name}-%{version}-%{release}.tar.gz
32 33 %if "%{?withpython}"
33 34 Source1: %{pythonname}.tgz
34 35 Source2: %{docutilsname}.tar.gz
35 36 %endif
36 37 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
37 38
38 39 BuildRequires: make, gcc, gettext
39 40 %if "%{?withpython}"
40 41 BuildRequires: readline-devel, openssl-devel, ncurses-devel, zlib-devel, bzip2-devel
41 42 %else
42 BuildRequires: %{pythonexe} >= %{pythonver}, %{pythonexe}-devel, %{pythonexe}-docutils >= 0.5
43 BuildRequires: %{pythonexe} >= %{pythonver}, %{pythonexe}-devel, %{pythondocutils}
43 44 Requires: %{pythonexe} >= %{pythonver}
44 45 %endif
45 46 # The hgk extension uses the wish tcl interpreter, but we don't enforce it
46 47 #Requires: tk
47 48
48 49 %description
49 50 Mercurial is a fast, lightweight source control management system designed
50 51 for efficient handling of very large distributed projects.
51 52
52 53 %prep
53 54
54 55 %if "%{?withpython}"
55 56 %setup -q -n mercurial-%{version}-%{release} -a1 -a2
56 57 # despite the comments in cgi.py, we do this to prevent rpmdeps from picking /usr/local/bin/python up
57 58 sed -i '1c#! /usr/bin/env %{pythonexe}' %{pythonname}/Lib/cgi.py
58 59 %else
59 60 %setup -q -n mercurial-%{version}-%{release}
60 61 %endif
61 62
62 63 %build
63 64
64 65 export HGPYTHON3=1
65 66
66 67 %if "%{?withpython}"
67 68
68 69 PYPATH=$PWD/%{pythonname}
69 70 cd $PYPATH
70 71 ./configure --prefix=%{hgpyprefix}
71 72 make all %{?_smp_mflags}
72 73 cd -
73 74
74 75 cd %{docutilsname}
75 76 LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py build
76 77 cd -
77 78
78 79 # verify Python environment
79 80 LD_LIBRARY_PATH=$PYPATH PYTHONPATH=$PWD/%{docutilsname} $PYPATH/python -c 'import sys, zlib, bz2, ssl, curses, readline'
80 81
81 82 # set environment for make
82 83 export PATH=$PYPATH:$PATH
83 84 export LD_LIBRARY_PATH=$PYPATH
84 85 export CFLAGS="-L $PYPATH"
85 86 export PYTHONPATH=$PWD/%{docutilsname}
86 87
87 88 %endif
88 89
89 90 make all PYTHON=%{pythonexe}
90 91 make -C contrib/chg
91 92
92 93 sed -i -e '1s|#!/usr/bin/env python$|#!/usr/bin/env %{pythonexe}|' contrib/hg-ssh
93 94
94 95 %install
95 96 rm -rf $RPM_BUILD_ROOT
96 97
97 98 export HGPYTHON3=1
98 99
99 100 %if "%{?withpython}"
100 101
101 102 PYPATH=$PWD/%{pythonname}
102 103 cd $PYPATH
103 104 make install DESTDIR=$RPM_BUILD_ROOT
104 105 # these .a are not necessary and they are readonly and strip fails - kill them!
105 106 rm -f %{buildroot}%{hgpyprefix}/lib/{,python2.*/config}/libpython2.*.a
106 107 cd -
107 108
108 109 cd %{docutilsname}
109 110 LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py install --root="$RPM_BUILD_ROOT"
110 111 cd -
111 112
112 113 PATH=$PYPATH:$PATH LD_LIBRARY_PATH=$PYPATH make install PYTHON=%{pythonexe} DESTDIR=$RPM_BUILD_ROOT PREFIX=%{hgpyprefix} MANDIR=%{_mandir}
113 114 mkdir -p $RPM_BUILD_ROOT%{_bindir}
114 115 ( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/hg . )
115 116 ( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/python2.? %{pythonhg} )
116 117
117 118 %else
118 119
119 120 make install PYTHON=%{pythonexe} DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} MANDIR=%{_mandir}
120 121
121 122 %endif
122 123
123 124 install -m 755 contrib/chg/chg $RPM_BUILD_ROOT%{_bindir}/
124 125 install -m 755 contrib/hgk $RPM_BUILD_ROOT%{_bindir}/
125 126 install -m 755 contrib/hg-ssh $RPM_BUILD_ROOT%{_bindir}/
126 127
127 128 bash_completion_dir=$RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
128 129 mkdir -p $bash_completion_dir
129 130 install -m 644 contrib/bash_completion $bash_completion_dir/mercurial.sh
130 131
131 132 zsh_completion_dir=$RPM_BUILD_ROOT%{_datadir}/zsh/site-functions
132 133 mkdir -p $zsh_completion_dir
133 134 install -m 644 contrib/zsh_completion $zsh_completion_dir/_mercurial
134 135
135 136 mkdir -p $RPM_BUILD_ROOT%{emacs_lispdir}
136 137 install -m 644 contrib/mercurial.el $RPM_BUILD_ROOT%{emacs_lispdir}/
137 138 install -m 644 contrib/mq.el $RPM_BUILD_ROOT%{emacs_lispdir}/
138 139
139 140 mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/mercurial/hgrc.d
140 141
141 142 %clean
142 143 rm -rf $RPM_BUILD_ROOT
143 144
144 145 %files
145 146 %defattr(-,root,root,-)
146 147 %doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html *.cgi contrib/*.fcgi contrib/*.wsgi
147 148 %doc %attr(644,root,root) %{_mandir}/man?/hg*
148 149 %doc %attr(644,root,root) contrib/*.svg
149 150 %dir %{_datadir}/zsh/
150 151 %dir %{_datadir}/zsh/site-functions/
151 152 %{_datadir}/zsh/site-functions/_mercurial
152 153 %dir %{_datadir}/emacs/site-lisp/
153 154 %{_datadir}/emacs/site-lisp/mercurial.el
154 155 %{_datadir}/emacs/site-lisp/mq.el
155 156 %{_bindir}/hg
156 157 %{_bindir}/chg
157 158 %{_bindir}/hgk
158 159 %{_bindir}/hg-ssh
159 160 %dir %{_sysconfdir}/bash_completion.d/
160 161 %config(noreplace) %{_sysconfdir}/bash_completion.d/mercurial.sh
161 162 %dir %{_sysconfdir}/mercurial
162 163 %dir %{_sysconfdir}/mercurial/hgrc.d
163 164 %if "%{?withpython}"
164 165 %{_bindir}/%{pythonhg}
165 166 %{hgpyprefix}
166 167 %else
167 168 %{_libdir}/python%{pythonver}/site-packages/%{name}-*-py%{pythonver}.egg-info
168 169 %{_libdir}/python%{pythonver}/site-packages/%{name}
169 170 %{_libdir}/python%{pythonver}/site-packages/hgext
170 171 %{_libdir}/python%{pythonver}/site-packages/hgext3rd
171 172 %{_libdir}/python%{pythonver}/site-packages/hgdemandimport
172 173 %endif
General Comments 0
You need to be logged in to leave comments. Login now