Before this change, packaging on CentOS 8 failed because 'python'
is used instead of 'python3'.
Change was tested with:
- make docker-centos7
- make docker-centos8
- make docker-ubuntu-bionic
pulkit |
hg-reviewers |
Before this change, packaging on CentOS 8 failed because 'python'
is used instead of 'python3'.
Change was tested with:
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
exit 1 | exit 1 | ||||
fi | fi | ||||
if [ ! -d .hg ]; then | if [ ! -d .hg ]; then | ||||
echo 'You are not inside a Mercurial repository!' 1>&2 | echo 'You are not inside a Mercurial repository!' 1>&2 | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
gethgversion | gethgversion $PYTHONEXE | ||||
if [ -z "$type" ] ; then | if [ -z "$type" ] ; then | ||||
release=1 | release=1 | ||||
else | else | ||||
release=0.9_$type | release=0.9_$type | ||||
fi | fi | ||||
if [ -n "$distance" ] ; then | if [ -n "$distance" ] ; then | ||||
release=$release+${distance}_${node} | release=$release+${distance}_${node} | ||||
fi | fi | ||||
if [ "$PYTHONVER" ]; then | if [ "$PYTHONVER" ]; then | ||||
release=$release+$PYTHONVER | release=$release+$PYTHONVER | ||||
RPMPYTHONVER=$PYTHONVER | RPMPYTHONVER=$PYTHONVER | ||||
else | else | ||||
RPMPYTHONVER=%{nil} | RPMPYTHONVER=%{nil} | ||||
fi | fi | ||||
mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS} | mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS} | ||||
$HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz | $PYTHONEXE $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz | ||||
if [ "$PYTHONVER" ]; then | if [ "$PYTHONVER" ]; then | ||||
( | ( | ||||
mkdir -p build | mkdir -p build | ||||
cd build | cd build | ||||
PYTHON_SRCFILE=Python-$PYTHONVER.tgz | PYTHON_SRCFILE=Python-$PYTHONVER.tgz | ||||
[ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE | [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE | ||||
if [ "$PYTHONMD5" ]; then | if [ "$PYTHONMD5" ]; then | ||||
echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c | echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c | ||||
-e "s/^%global pythonexe .*/%global pythonexe $PYTHONEXE/" \ | -e "s/^%global pythonexe .*/%global pythonexe $PYTHONEXE/" \ | ||||
$specfile > $rpmspec | $specfile > $rpmspec | ||||
echo >> $rpmspec | echo >> $rpmspec | ||||
echo "%changelog" >> $rpmspec | echo "%changelog" >> $rpmspec | ||||
if echo $version | grep '+' > /dev/null 2>&1; then | if echo $version | grep '+' > /dev/null 2>&1; then | ||||
latesttag="`echo $version | sed -e 's/+.*//'`" | latesttag="`echo $version | sed -e 's/+.*//'`" | ||||
$HG log -r .:"$latesttag" -fM \ | $PYTHONEXE $HG log -r .:"$latesttag" -fM \ | ||||
--template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c ' | --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c ' | ||||
import sys, time | import sys, time | ||||
def datestr(date, format): | def datestr(date, format): | ||||
return time.strftime(format, time.gmtime(float(date[0]) - date[1])) | return time.strftime(format, time.gmtime(float(date[0]) - date[1])) | ||||
changelog = [] | changelog = [] | ||||
for l in sys.stdin.readlines(): | for l in sys.stdin.readlines(): | ||||
tok = l.split("\t") | tok = l.split("\t") | ||||
hgdate = tuple(int(v) for v in tok[0].split()) | hgdate = tuple(int(v) for v in tok[0].split()) | ||||
changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2])) | changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2])) | ||||
prevtitle = "" | prevtitle = "" | ||||
for l in sorted(changelog, reverse=True): | for l in sorted(changelog, reverse=True): | ||||
title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1]) | title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1]) | ||||
if prevtitle != title: | if prevtitle != title: | ||||
prevtitle = title | prevtitle = title | ||||
print(title) | print(title) | ||||
print("- %s" % l[3].strip()) | print("- %s" % l[3].strip()) | ||||
' >> $rpmspec | ' >> $rpmspec | ||||
else | else | ||||
$HG log \ | $PYTHONEXE $HG log \ | ||||
--template '{date|hgdate}\t{author}\t{desc|firstline}\n' \ | --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \ | ||||
.hgtags | python -c ' | .hgtags | $PYTHONEXE -c ' | ||||
import sys, time | import sys, time | ||||
def datestr(date, format): | def datestr(date, format): | ||||
return time.strftime(format, time.gmtime(float(date[0]) - date[1])) | return time.strftime(format, time.gmtime(float(date[0]) - date[1])) | ||||
for l in sys.stdin.readlines(): | for l in sys.stdin.readlines(): | ||||
tok = l.split("\t") | tok = l.split("\t") | ||||
hgdate = tuple(int(v) for v in tok[0].split()) | hgdate = tuple(int(v) for v in tok[0].split()) |
# Extract version number into 4 parts, some of which may be empty: | # Extract version number into 4 parts, some of which may be empty: | ||||
# | # | ||||
# version: the numeric part of the most recent tag. Will always look like 1.3. | # version: the numeric part of the most recent tag. Will always look like 1.3. | ||||
# | # | ||||
# type: if an rc build, "rc", otherwise empty | # type: if an rc build, "rc", otherwise empty | ||||
# | # | ||||
# distance: the distance from the nearest tag, or empty if built from a tag | # distance: the distance from the nearest tag, or empty if built from a tag | ||||
# | # | ||||
# node: the node|short hg was built from, or empty if built from a tag | # node: the node|short hg was built from, or empty if built from a tag | ||||
gethgversion() { | gethgversion() { | ||||
if [ -z "${1+x}" ]; then | |||||
python="python" | |||||
else | |||||
python="$1" | |||||
fi | |||||
export HGRCPATH= | export HGRCPATH= | ||||
export HGPLAIN= | export HGPLAIN= | ||||
make cleanbutpackages | make cleanbutpackages PYTHON=$python | ||||
make local PURE=--pure | make local PURE=--pure PYTHON=$python | ||||
HG="$PWD/hg" | HG="$PWD/hg" | ||||
"$HG" version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; } | $python "$HG" version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; } | ||||
hgversion=`LANGUAGE=C "$HG" version | sed -ne 's/.*(version \(.*\))$/\1/p'` | hgversion=`LANGUAGE=C $python "$HG" version | sed -ne 's/.*(version \(.*\))$/\1/p'` | ||||
if echo $hgversion | grep + > /dev/null 2>&1 ; then | if echo $hgversion | grep + > /dev/null 2>&1 ; then | ||||
tmp=`echo $hgversion | cut -d+ -f 2` | tmp=`echo $hgversion | cut -d+ -f 2` | ||||
hgversion=`echo $hgversion | cut -d+ -f 1` | hgversion=`echo $hgversion | cut -d+ -f 1` | ||||
distance=`echo $tmp | cut -d- -f 1` | distance=`echo $tmp | cut -d- -f 1` | ||||
node=`echo $tmp | cut -d- -f 2` | node=`echo $tmp | cut -d- -f 2` | ||||
else | else | ||||
distance='' | distance='' |