##// END OF EJS Templates
buildrpm: move creation of RPM directories from dockerrpm...
Mathias De Maré -
r27788:d713fa93 default
parent child Browse files
Show More
@@ -1,161 +1,161 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.10
22 PYTHONVER=2.7.10
23 PYTHONMD5=d7547558fd673bd9d38e2108c6b42521
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 # TODO: handle distance/node set, and type set
52 # TODO: handle distance/node set, and type set
53
53
54 if [ -z "$type" ] ; then
54 if [ -z "$type" ] ; then
55 release=1
55 release=1
56 else
56 else
57 release=0.9_$type
57 release=0.9_$type
58 fi
58 fi
59
59
60 if [ -n "$distance" ] ; then
60 if [ -n "$distance" ] ; then
61 release=$release+$distance_$node
61 release=$release+$distance_$node
62 fi
62 fi
63
63
64 if [ "$PYTHONVER" ]; then
64 if [ "$PYTHONVER" ]; then
65 release=$release+$PYTHONVER
65 release=$release+$PYTHONVER
66 RPMPYTHONVER=$PYTHONVER
66 RPMPYTHONVER=$PYTHONVER
67 else
67 else
68 RPMPYTHONVER=%{nil}
68 RPMPYTHONVER=%{nil}
69 fi
69 fi
70
70
71 mkdir -p $RPMBUILDDIR/SOURCES
71 mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
72 $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
72 $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
73 if [ "$PYTHONVER" ]; then
73 if [ "$PYTHONVER" ]; then
74 (
74 (
75 mkdir -p build
75 mkdir -p build
76 cd build
76 cd build
77 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
77 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
78 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
78 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
79 if [ "$PYTHONMD5" ]; then
79 if [ "$PYTHONMD5" ]; then
80 echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
80 echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
81 fi
81 fi
82 ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
82 ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
83
83
84 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
84 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
85 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
85 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
86 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
86 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
87 DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
87 DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
88 if [ "$DOCUTILSMD5" ]; then
88 if [ "$DOCUTILSMD5" ]; then
89 echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
89 echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
90 fi
90 fi
91 ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
91 ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
92 )
92 )
93 fi
93 fi
94
94
95 mkdir -p $RPMBUILDDIR/SPECS
95 mkdir -p $RPMBUILDDIR/SPECS
96 rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
96 rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
97
97
98 sed -e "s,^Version:.*,Version: $version," \
98 sed -e "s,^Version:.*,Version: $version," \
99 -e "s,^Release:.*,Release: $release," \
99 -e "s,^Release:.*,Release: $release," \
100 $specfile > $rpmspec
100 $specfile > $rpmspec
101
101
102 echo >> $rpmspec
102 echo >> $rpmspec
103 echo "%changelog" >> $rpmspec
103 echo "%changelog" >> $rpmspec
104
104
105 if echo $version | grep '+' > /dev/null 2>&1; then
105 if echo $version | grep '+' > /dev/null 2>&1; then
106 latesttag="`echo $version | sed -e 's/+.*//'`"
106 latesttag="`echo $version | sed -e 's/+.*//'`"
107 $HG log -r .:"$latesttag" -fM \
107 $HG log -r .:"$latesttag" -fM \
108 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
108 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
109 import sys, time
109 import sys, time
110
110
111 def datestr(date, format):
111 def datestr(date, format):
112 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
112 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
113
113
114 changelog = []
114 changelog = []
115 for l in sys.stdin.readlines():
115 for l in sys.stdin.readlines():
116 tok = l.split("\t")
116 tok = l.split("\t")
117 hgdate = tuple(int(v) for v in tok[0].split())
117 hgdate = tuple(int(v) for v in tok[0].split())
118 changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
118 changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
119 prevtitle = ""
119 prevtitle = ""
120 for l in sorted(changelog, reverse=True):
120 for l in sorted(changelog, reverse=True):
121 title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
121 title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
122 if prevtitle != title:
122 if prevtitle != title:
123 prevtitle = title
123 prevtitle = title
124 print
124 print
125 print title
125 print title
126 print "- %s" % l[3].strip()
126 print "- %s" % l[3].strip()
127 ' >> $rpmspec
127 ' >> $rpmspec
128
128
129 else
129 else
130
130
131 $HG log \
131 $HG log \
132 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
132 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
133 .hgtags | python -c '
133 .hgtags | python -c '
134 import sys, time
134 import sys, time
135
135
136 def datestr(date, format):
136 def datestr(date, format):
137 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
137 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
138
138
139 for l in sys.stdin.readlines():
139 for l in sys.stdin.readlines():
140 tok = l.split("\t")
140 tok = l.split("\t")
141 hgdate = tuple(int(v) for v in tok[0].split())
141 hgdate = tuple(int(v) for v in tok[0].split())
142 print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
142 print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
143 ' >> $rpmspec
143 ' >> $rpmspec
144
144
145 fi
145 fi
146
146
147 sed -i \
147 sed -i \
148 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
148 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
149 $rpmspec
149 $rpmspec
150
150
151 if [ "$BUILD" ]; then
151 if [ "$BUILD" ]; then
152 rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
152 rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
153 if [ $? = 0 ]; then
153 if [ $? = 0 ]; then
154 echo
154 echo
155 echo "Built packages for $version-$release:"
155 echo "Built packages for $version-$release:"
156 find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
156 find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
157 fi
157 fi
158 else
158 else
159 echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
159 echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
160 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
160 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
161 fi
161 fi
@@ -1,39 +1,37 b''
1 #!/bin/bash -e
1 #!/bin/bash -e
2
2
3 . $(dirname $0)/dockerlib.sh
3 . $(dirname $0)/dockerlib.sh
4
4
5 BUILDDIR=$(dirname $0)
5 BUILDDIR=$(dirname $0)
6 export ROOTDIR=$(cd $BUILDDIR/..; pwd)
6 export ROOTDIR=$(cd $BUILDDIR/..; pwd)
7
7
8 checkdocker
8 checkdocker
9
9
10 PLATFORM="$1"
10 PLATFORM="$1"
11 shift # extra params are passed to buildrpm
11 shift # extra params are passed to buildrpm
12
12
13 initcontainer $PLATFORM
13 initcontainer $PLATFORM
14
14
15 RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM
15 RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM
16 contrib/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*
16 contrib/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*
17
17
18 mkdir -p $RPMBUILDDIR/{BUILD,SRPMS,RPMS}
19
20 DSHARED=/mnt/shared
18 DSHARED=/mnt/shared
21 $DOCKER run -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
19 $DOCKER run -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
22 rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean
20 rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean
23
21
24 $DOCKER run -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
22 $DOCKER run -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
25 createrepo $DSHARED
23 createrepo $DSHARED
26
24
27 cat << EOF > $RPMBUILDDIR/mercurial.repo
25 cat << EOF > $RPMBUILDDIR/mercurial.repo
28 # Place this file in /etc/yum.repos.d/mercurial.repo
26 # Place this file in /etc/yum.repos.d/mercurial.repo
29 [mercurial]
27 [mercurial]
30 name=Mercurial packages for $PLATFORM
28 name=Mercurial packages for $PLATFORM
31 # baseurl=file://$RPMBUILDDIR/
29 # baseurl=file://$RPMBUILDDIR/
32 baseurl=http://hg.example.com/build/$PLATFORM/
30 baseurl=http://hg.example.com/build/$PLATFORM/
33 skip_if_unavailable=True
31 skip_if_unavailable=True
34 gpgcheck=0
32 gpgcheck=0
35 enabled=1
33 enabled=1
36 EOF
34 EOF
37
35
38 echo
36 echo
39 echo "Build complete - results can be found in $RPMBUILDDIR"
37 echo "Build complete - results can be found in $RPMBUILDDIR"
General Comments 0
You need to be logged in to leave comments. Login now