Show More
@@ -1,104 +1,106 b'' | |||||
1 | #!/bin/sh -e |
|
1 | #!/bin/sh -e | |
2 | # |
|
2 | # | |
3 | # Build a Mercurial debian package from the current repo |
|
3 | # Build a Mercurial debian package from the current repo | |
4 | # |
|
4 | # | |
5 | # Tested on Jessie (stable as of original script authoring.) |
|
5 | # Tested on Jessie (stable as of original script authoring.) | |
6 |
|
6 | |||
7 | . $(dirname $0)/packagelib.sh |
|
7 | . $(dirname $0)/packagelib.sh | |
8 |
|
8 | |||
|
9 | ROOTDIR=$(cd $(dirname $0)/../.. > /dev/null; pwd) | |||
|
10 | ||||
9 | BUILD=1 |
|
11 | BUILD=1 | |
10 | CLEANUP=1 |
|
12 | CLEANUP=1 | |
11 | DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian` |
|
13 | DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian` | |
12 | CODENAME=`lsb_release -cs 2> /dev/null || echo unknown` |
|
14 | CODENAME=`lsb_release -cs 2> /dev/null || echo unknown` | |
13 | DEBFLAGS=-b |
|
15 | DEBFLAGS=-b | |
14 | while [ "$1" ]; do |
|
16 | while [ "$1" ]; do | |
15 | case "$1" in |
|
17 | case "$1" in | |
16 | --distid ) |
|
18 | --distid ) | |
17 | shift |
|
19 | shift | |
18 | DISTID="$1" |
|
20 | DISTID="$1" | |
19 | shift |
|
21 | shift | |
20 | ;; |
|
22 | ;; | |
21 | --codename ) |
|
23 | --codename ) | |
22 | shift |
|
24 | shift | |
23 | CODENAME="$1" |
|
25 | CODENAME="$1" | |
24 | shift |
|
26 | shift | |
25 | ;; |
|
27 | ;; | |
26 | --cleanup ) |
|
28 | --cleanup ) | |
27 | shift |
|
29 | shift | |
28 | BUILD= |
|
30 | BUILD= | |
29 | ;; |
|
31 | ;; | |
30 | --build ) |
|
32 | --build ) | |
31 | shift |
|
33 | shift | |
32 | CLEANUP= |
|
34 | CLEANUP= | |
33 | ;; |
|
35 | ;; | |
34 | --source-only ) |
|
36 | --source-only ) | |
35 | shift |
|
37 | shift | |
36 | DEBFLAGS=-S |
|
38 | DEBFLAGS=-S | |
37 | ;; |
|
39 | ;; | |
38 | * ) |
|
40 | * ) | |
39 | echo "Invalid parameter $1!" 1>&2 |
|
41 | echo "Invalid parameter $1!" 1>&2 | |
40 | exit 1 |
|
42 | exit 1 | |
41 | ;; |
|
43 | ;; | |
42 | esac |
|
44 | esac | |
43 | done |
|
45 | done | |
44 |
|
46 | |||
45 | trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT |
|
47 | trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT | |
46 |
|
48 | |||
47 | set -u |
|
49 | set -u | |
48 |
|
50 | |||
49 | if [ ! -d .hg ]; then |
|
51 | if [ ! -d .hg ]; then | |
50 | echo 'You are not inside a Mercurial repository!' 1>&2 |
|
52 | echo 'You are not inside a Mercurial repository!' 1>&2 | |
51 | exit 1 |
|
53 | exit 1 | |
52 | fi |
|
54 | fi | |
53 |
|
55 | |||
54 | gethgversion |
|
56 | gethgversion | |
55 | debver="$version" |
|
57 | debver="$version" | |
56 | if [ -n "$type" ] ; then |
|
58 | if [ -n "$type" ] ; then | |
57 | debver="$debver~$type" |
|
59 | debver="$debver~$type" | |
58 | fi |
|
60 | fi | |
59 | if [ -n "$distance" ] ; then |
|
61 | if [ -n "$distance" ] ; then | |
60 | debver="$debver+$distance-$CODENAME-$node" |
|
62 | debver="$debver+$distance-$CODENAME-$node" | |
61 | elif [ "$DEBFLAGS" = "-S" ] ; then |
|
63 | elif [ "$DEBFLAGS" = "-S" ] ; then | |
62 | # for building a ppa (--source-only) for a release (distance == 0), we need |
|
64 | # for building a ppa (--source-only) for a release (distance == 0), we need | |
63 | # to version the distroseries so that we can upload to launchpad |
|
65 | # to version the distroseries so that we can upload to launchpad | |
64 | debver="$debver~${CODENAME}1" |
|
66 | debver="$debver~${CODENAME}1" | |
65 | fi |
|
67 | fi | |
66 |
|
68 | |||
67 | control=debian/control |
|
69 | control=debian/control | |
68 | changelog=debian/changelog |
|
70 | changelog=debian/changelog | |
69 |
|
71 | |||
70 | if [ "$BUILD" ]; then |
|
72 | if [ "$BUILD" ]; then | |
71 | if [ -d debian ] ; then |
|
73 | if [ -d debian ] ; then | |
72 | echo "Error! debian control directory already exists!" |
|
74 | echo "Error! debian control directory already exists!" | |
73 | exit 1 |
|
75 | exit 1 | |
74 | fi |
|
76 | fi | |
75 |
|
77 | |||
76 |
cp -r "$ |
|
78 | cp -r "$ROOTDIR"/contrib/packaging/debian debian | |
77 |
|
79 | |||
78 | sed -i.tmp "s/__VERSION__/$debver/" $changelog |
|
80 | sed -i.tmp "s/__VERSION__/$debver/" $changelog | |
79 | sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog |
|
81 | sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog | |
80 | sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog |
|
82 | sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog | |
81 | rm $changelog.tmp |
|
83 | rm $changelog.tmp | |
82 |
|
84 | |||
83 | # remove the node from the version string |
|
85 | # remove the node from the version string | |
84 | SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz" |
|
86 | SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz" | |
85 |
"$ |
|
87 | "$ROOTDIR/hg" archive $SRCFILE | |
86 | mv $SRCFILE .. |
|
88 | mv $SRCFILE .. | |
87 | debuild -us -uc -i -I $DEBFLAGS |
|
89 | debuild -us -uc -i -I $DEBFLAGS | |
88 | if [ $? != 0 ]; then |
|
90 | if [ $? != 0 ]; then | |
89 | echo 'debuild failed!' |
|
91 | echo 'debuild failed!' | |
90 | exit 1 |
|
92 | exit 1 | |
91 | fi |
|
93 | fi | |
92 |
|
94 | |||
93 | fi |
|
95 | fi | |
94 | if [ "$CLEANUP" ] ; then |
|
96 | if [ "$CLEANUP" ] ; then | |
95 | echo |
|
97 | echo | |
96 | OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME} |
|
98 | OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME} | |
97 | mkdir -p "$OUTPUTDIR" |
|
99 | mkdir -p "$OUTPUTDIR" | |
98 | find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \ |
|
100 | find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \ | |
99 | ../mercurial*.dsc ../mercurial*.gz \ |
|
101 | ../mercurial*.dsc ../mercurial*.gz \ | |
100 | -type f -newer $control -print0 2>/dev/null | \ |
|
102 | -type f -newer $control -print0 2>/dev/null | \ | |
101 | xargs -Inarf -0 mv narf "$OUTPUTDIR" |
|
103 | xargs -Inarf -0 mv narf "$OUTPUTDIR" | |
102 | echo "Built packages for $debver:" |
|
104 | echo "Built packages for $debver:" | |
103 | find "$OUTPUTDIR" -type f -newer $control -name '*.deb' |
|
105 | find "$OUTPUTDIR" -type f -newer $control -name '*.deb' | |
104 | fi |
|
106 | fi |
@@ -1,35 +1,35 b'' | |||||
1 | #!/bin/bash -eu |
|
1 | #!/bin/bash -eu | |
2 |
|
2 | |||
3 | . $(dirname $0)/dockerlib.sh |
|
3 | . $(dirname $0)/dockerlib.sh | |
4 | . $(dirname $0)/packagelib.sh |
|
4 | . $(dirname $0)/packagelib.sh | |
5 |
|
5 | |||
6 | BUILDDIR=$(dirname $0) |
|
6 | BUILDDIR=$(dirname $0) | |
7 | export ROOTDIR=$(cd $BUILDDIR/../.. > /dev/null; pwd) |
|
7 | export ROOTDIR=$(cd $BUILDDIR/../.. > /dev/null; pwd) | |
8 |
|
8 | |||
9 | checkdocker |
|
9 | checkdocker | |
10 |
|
10 | |||
11 | DISTID="$1" |
|
11 | DISTID="$1" | |
12 | CODENAME="$2" |
|
12 | CODENAME="$2" | |
13 | PLATFORM="$1-$2" |
|
13 | PLATFORM="$1-$2" | |
14 | shift; shift # extra params are passed to build process |
|
14 | shift; shift # extra params are passed to build process | |
15 |
|
15 | |||
16 | OUTPUTDIR=${OUTPUTDIR:=$ROOTDIR/packages/$PLATFORM} |
|
16 | OUTPUTDIR=${OUTPUTDIR:=$ROOTDIR/packages/$PLATFORM} | |
17 |
|
17 | |||
18 | initcontainer $PLATFORM |
|
18 | initcontainer $PLATFORM | |
19 |
|
19 | |||
20 | # debuild only appears to be able to save built debs etc to .., so we |
|
20 | # debuild only appears to be able to save built debs etc to .., so we | |
21 | # have to share the .. of the current directory with the docker |
|
21 | # have to share the .. of the current directory with the docker | |
22 | # container and hope it's writable. Whee. |
|
22 | # container and hope it's writable. Whee. | |
23 |
dn=$(basename $ |
|
23 | dn=$(basename $ROOTDIR) | |
24 |
|
24 | |||
25 | if [ $(uname) = "Darwin" ] ; then |
|
25 | if [ $(uname) = "Darwin" ] ; then | |
26 | $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \ |
|
26 | $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \ | |
27 | sh -c "cd /mnt/$dn && make clean && make local" |
|
27 | sh -c "cd /mnt/$dn && make clean && make local" | |
28 | fi |
|
28 | fi | |
29 |
$DOCKER run -u $DBUILDUSER --rm -v $ |
|
29 | $DOCKER run -u $DBUILDUSER --rm -v $ROOTDIR/..:/mnt $CONTAINER \ | |
30 | sh -c "cd /mnt/$dn && DEB_BUILD_OPTIONS='${DEB_BUILD_OPTIONS:=}' contrib/packaging/builddeb --build --distid $DISTID --codename $CODENAME $@" |
|
30 | sh -c "cd /mnt/$dn && DEB_BUILD_OPTIONS='${DEB_BUILD_OPTIONS:=}' contrib/packaging/builddeb --build --distid $DISTID --codename $CODENAME $@" | |
31 | contrib/packaging/builddeb --cleanup --distid $DISTID --codename $CODENAME |
|
31 | contrib/packaging/builddeb --cleanup --distid $DISTID --codename $CODENAME | |
32 | if [ $(uname) = "Darwin" ] ; then |
|
32 | if [ $(uname) = "Darwin" ] ; then | |
33 | $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \ |
|
33 | $DOCKER run -u $DBUILDUSER --rm -v $PWD/..:/mnt $CONTAINER \ | |
34 | sh -c "cd /mnt/$dn && make clean" |
|
34 | sh -c "cd /mnt/$dn && make clean" | |
35 | fi |
|
35 | fi |
@@ -1,37 +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/packaging/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $* |
|
16 | $ROOTDIR/contrib/packaging/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $* | |
17 |
|
17 | |||
18 | DSHARED=/mnt/shared |
|
18 | DSHARED=/mnt/shared | |
19 | $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \ |
|
19 | $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \ | |
20 | rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean |
|
20 | rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean | |
21 |
|
21 | |||
22 | $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \ |
|
22 | $DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \ | |
23 | createrepo $DSHARED |
|
23 | createrepo $DSHARED | |
24 |
|
24 | |||
25 | cat << EOF > $RPMBUILDDIR/mercurial.repo |
|
25 | cat << EOF > $RPMBUILDDIR/mercurial.repo | |
26 | # Place this file in /etc/yum.repos.d/mercurial.repo |
|
26 | # Place this file in /etc/yum.repos.d/mercurial.repo | |
27 | [mercurial] |
|
27 | [mercurial] | |
28 | name=Mercurial packages for $PLATFORM |
|
28 | name=Mercurial packages for $PLATFORM | |
29 | # baseurl=file://$RPMBUILDDIR/ |
|
29 | # baseurl=file://$RPMBUILDDIR/ | |
30 | baseurl=http://hg.example.com/build/$PLATFORM/ |
|
30 | baseurl=http://hg.example.com/build/$PLATFORM/ | |
31 | skip_if_unavailable=True |
|
31 | skip_if_unavailable=True | |
32 | gpgcheck=0 |
|
32 | gpgcheck=0 | |
33 | enabled=1 |
|
33 | enabled=1 | |
34 | EOF |
|
34 | EOF | |
35 |
|
35 | |||
36 | echo |
|
36 | echo | |
37 | 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