Updated control files for adding changelog entries.
[dcp.git] / dcp-build
CommitLineData
44955b68 1#!/bin/bash
9f26b93f
FT
2
3set -e
4
5usage() {
6 echo "usage: dcp-build [-Nh] REPODIR OUTDIR"
7}
8
9rungit() {
10 (
11 cd "$td/repo"
12 git "$@"
13 ) || false
14}
15
16defdir=/srv/dcp
17push=y
18
19while [ "${1:0:1}" = - ]; do
20 opt="${1:1}"
21 shift
22 if [ "$opt" = N ]; then
23 push=n
24 shift
25 elif [ "$opt" = h ]; then
26 usage
27 exit 0
28 else
29 echo "dcp-build: unknown option '$opt'" >&2
30 exit 1
31 fi
32done
33
34if [ $# -lt 2 ]; then
35 usage >&2
36 exit 1
37fi
38
39repodir="$1"
40outdir="$2"
41shift 2
42if [[ "$repodir" != */* ]]; then
43 repodir="$defdir/${repodir}.git"
44fi
45
46if [ ! -d "$repodir" ]; then
47 echo "dcp-build: could not find $repodir" >&2
48 exit 1
49fi
50if [ ! -d "$outdir" ]; then
51 echo "dcp-build: could not find $outdir" >&2
52 exit 1
53fi
54
55td="$(mktemp -d /tmp/dcp-XXXXXX)"
56exec >"$td/log" 2>"$td/err"
57dcp-runenv "$repodir" "$td"
58
59rungit tag -f lastbuild
60(cd "$td"; control/build) || false
61cp -a "$td/output"/* "$outdir/"
62
63if [ "$push" = y ]; then rungit push --tags; fi
64
65rm -rf "$td"