##// END OF EJS Templates
packaging: move packagelib.sh into contrib/packaging/...
Gregory Szorc -
r38025:ea70512b default
parent child Browse files
Show More
@@ -1,104 +1,104
1 1 #!/bin/sh -e
2 2 #
3 3 # Build a Mercurial debian package from the current repo
4 4 #
5 5 # Tested on Jessie (stable as of original script authoring.)
6 6
7 . $(dirname $0)/packagelib.sh
7 . $(dirname $0)/packaging/packagelib.sh
8 8
9 9 BUILD=1
10 10 CLEANUP=1
11 11 DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian`
12 12 CODENAME=`lsb_release -cs 2> /dev/null || echo unknown`
13 13 DEBFLAGS=-b
14 14 while [ "$1" ]; do
15 15 case "$1" in
16 16 --distid )
17 17 shift
18 18 DISTID="$1"
19 19 shift
20 20 ;;
21 21 --codename )
22 22 shift
23 23 CODENAME="$1"
24 24 shift
25 25 ;;
26 26 --cleanup )
27 27 shift
28 28 BUILD=
29 29 ;;
30 30 --build )
31 31 shift
32 32 CLEANUP=
33 33 ;;
34 34 --source-only )
35 35 shift
36 36 DEBFLAGS=-S
37 37 ;;
38 38 * )
39 39 echo "Invalid parameter $1!" 1>&2
40 40 exit 1
41 41 ;;
42 42 esac
43 43 done
44 44
45 45 trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT
46 46
47 47 set -u
48 48
49 49 if [ ! -d .hg ]; then
50 50 echo 'You are not inside a Mercurial repository!' 1>&2
51 51 exit 1
52 52 fi
53 53
54 54 gethgversion
55 55 debver="$version"
56 56 if [ -n "$type" ] ; then
57 57 debver="$debver~$type"
58 58 fi
59 59 if [ -n "$distance" ] ; then
60 60 debver="$debver+$distance-$CODENAME-$node"
61 61 elif [ "$DEBFLAGS" = "-S" ] ; then
62 62 # for building a ppa (--source-only) for a release (distance == 0), we need
63 63 # to version the distroseries so that we can upload to launchpad
64 64 debver="$debver~${CODENAME}1"
65 65 fi
66 66
67 67 control=debian/control
68 68 changelog=debian/changelog
69 69
70 70 if [ "$BUILD" ]; then
71 71 if [ -d debian ] ; then
72 72 echo "Error! debian control directory already exists!"
73 73 exit 1
74 74 fi
75 75
76 76 cp -r "$PWD"/contrib/debian debian
77 77
78 78 sed -i.tmp "s/__VERSION__/$debver/" $changelog
79 79 sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog
80 80 sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog
81 81 rm $changelog.tmp
82 82
83 83 # remove the node from the version string
84 84 SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz"
85 85 "$PWD/hg" archive $SRCFILE
86 86 mv $SRCFILE ..
87 87 debuild -us -uc -i -I $DEBFLAGS
88 88 if [ $? != 0 ]; then
89 89 echo 'debuild failed!'
90 90 exit 1
91 91 fi
92 92
93 93 fi
94 94 if [ "$CLEANUP" ] ; then
95 95 echo
96 96 OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME}
97 97 mkdir -p "$OUTPUTDIR"
98 98 find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \
99 99 ../mercurial*.dsc ../mercurial*.gz \
100 100 -type f -newer $control -print0 2>/dev/null | \
101 101 xargs -Inarf -0 mv narf "$OUTPUTDIR"
102 102 echo "Built packages for $debver:"
103 103 find "$OUTPUTDIR" -type f -newer $control -name '*.deb'
104 104 fi
@@ -1,162 +1,162
1 1 #!/bin/bash -e
2 2 #
3 3 # Build a Mercurial RPM from the current repo
4 4 #
5 5 # Tested on
6 6 # - Fedora 20
7 7 # - CentOS 5
8 8 # - centOS 6
9 9
10 . $(dirname $0)/packagelib.sh
10 . $(dirname $0)/packaging/packagelib.sh
11 11
12 12 BUILD=1
13 13 RPMBUILDDIR="$PWD/rpmbuild"
14 14
15 15 while [ "$1" ]; do
16 16 case "$1" in
17 17 --prepare )
18 18 shift
19 19 BUILD=
20 20 ;;
21 21 --withpython | --with-python)
22 22 shift
23 23 PYTHONVER=2.7.14
24 24 PYTHONMD5=cee2e4b33ad3750da77b2e85f2f8b724
25 25 ;;
26 26 --rpmbuilddir )
27 27 shift
28 28 RPMBUILDDIR="$1"
29 29 shift
30 30 ;;
31 31 * )
32 32 echo "Invalid parameter $1!" 1>&2
33 33 exit 1
34 34 ;;
35 35 esac
36 36 done
37 37
38 38 cd "`dirname $0`/.."
39 39
40 40 specfile=$PWD/contrib/mercurial.spec
41 41 if [ ! -f $specfile ]; then
42 42 echo "Cannot find $specfile!" 1>&2
43 43 exit 1
44 44 fi
45 45
46 46 if [ ! -d .hg ]; then
47 47 echo 'You are not inside a Mercurial repository!' 1>&2
48 48 exit 1
49 49 fi
50 50
51 51 gethgversion
52 52
53 53 # TODO: handle distance/node set, and type set
54 54
55 55 if [ -z "$type" ] ; then
56 56 release=1
57 57 else
58 58 release=0.9_$type
59 59 fi
60 60
61 61 if [ -n "$distance" ] ; then
62 62 release=$release+$distance_$node
63 63 fi
64 64
65 65 if [ "$PYTHONVER" ]; then
66 66 release=$release+$PYTHONVER
67 67 RPMPYTHONVER=$PYTHONVER
68 68 else
69 69 RPMPYTHONVER=%{nil}
70 70 fi
71 71
72 72 mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
73 73 $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz
74 74 if [ "$PYTHONVER" ]; then
75 75 (
76 76 mkdir -p build
77 77 cd build
78 78 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
79 79 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
80 80 if [ "$PYTHONMD5" ]; then
81 81 echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c
82 82 fi
83 83 ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE
84 84
85 85 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
86 86 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
87 87 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
88 88 DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile`
89 89 if [ "$DOCUTILSMD5" ]; then
90 90 echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c
91 91 fi
92 92 ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE
93 93 )
94 94 fi
95 95
96 96 mkdir -p $RPMBUILDDIR/SPECS
97 97 rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec
98 98
99 99 sed -e "s,^Version:.*,Version: $version," \
100 100 -e "s,^Release:.*,Release: $release," \
101 101 $specfile > $rpmspec
102 102
103 103 echo >> $rpmspec
104 104 echo "%changelog" >> $rpmspec
105 105
106 106 if echo $version | grep '+' > /dev/null 2>&1; then
107 107 latesttag="`echo $version | sed -e 's/+.*//'`"
108 108 $HG log -r .:"$latesttag" -fM \
109 109 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c '
110 110 import sys, time
111 111
112 112 def datestr(date, format):
113 113 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
114 114
115 115 changelog = []
116 116 for l in sys.stdin.readlines():
117 117 tok = l.split("\t")
118 118 hgdate = tuple(int(v) for v in tok[0].split())
119 119 changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2]))
120 120 prevtitle = ""
121 121 for l in sorted(changelog, reverse=True):
122 122 title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1])
123 123 if prevtitle != title:
124 124 prevtitle = title
125 125 print
126 126 print title
127 127 print "- %s" % l[3].strip()
128 128 ' >> $rpmspec
129 129
130 130 else
131 131
132 132 $HG log \
133 133 --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \
134 134 .hgtags | python -c '
135 135 import sys, time
136 136
137 137 def datestr(date, format):
138 138 return time.strftime(format, time.gmtime(float(date[0]) - date[1]))
139 139
140 140 for l in sys.stdin.readlines():
141 141 tok = l.split("\t")
142 142 hgdate = tuple(int(v) for v in tok[0].split())
143 143 print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2])
144 144 ' >> $rpmspec
145 145
146 146 fi
147 147
148 148 sed -i \
149 149 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
150 150 $rpmspec
151 151
152 152 if [ "$BUILD" ]; then
153 153 rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean
154 154 if [ $? = 0 ]; then
155 155 echo
156 156 echo "Built packages for $version-$release:"
157 157 find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec
158 158 fi
159 159 else
160 160 echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:"
161 161 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
162 162 fi
@@ -1,35 +1,35
1 1 #!/bin/bash -eu
2 2
3 3 . $(dirname $0)/dockerlib.sh
4 . $(dirname $0)/../packagelib.sh
4 . $(dirname $0)/packagelib.sh
5 5
6 6 BUILDDIR=$(dirname $0)
7 7 export ROOTDIR=$(cd $BUILDDIR/../.. > /dev/null; pwd)
8 8
9 9 checkdocker
10 10
11 11 DISTID="$1"
12 12 CODENAME="$2"
13 13 PLATFORM="$1-$2"
14 14 shift; shift # extra params are passed to build process
15 15
16 16 OUTPUTDIR=${OUTPUTDIR:=$ROOTDIR/packages/$PLATFORM}
17 17
18 18 initcontainer $PLATFORM
19 19
20 20 # debuild only appears to be able to save built debs etc to .., so we
21 21 # have to share the .. of the current directory with the docker
22 22 # container and hope it's writable. Whee.
23 23 dn=$(basename $PWD)
24 24
25 25 if [ $(uname) = "Darwin" ] ; then
26 26 $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \
27 27 sh -c "cd /mnt/$dn && make clean && make local"
28 28 fi
29 29 $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \
30 30 sh -c "cd /mnt/$dn && DEB_BUILD_OPTIONS='${DEB_BUILD_OPTIONS:=}' contrib/builddeb --build --distid $DISTID --codename $CODENAME $@"
31 31 contrib/builddeb --cleanup --distid $DISTID --codename $CODENAME
32 32 if [ $(uname) = "Darwin" ] ; then
33 33 $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \
34 34 sh -c "cd /mnt/$dn && make clean"
35 35 fi
1 NO CONTENT: file renamed from contrib/packagelib.sh to contrib/packaging/packagelib.sh
General Comments 0
You need to be logged in to leave comments. Login now