/
build-deb
executable file
·61 lines (49 loc) · 1.89 KB
/
build-deb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -x
set -e
# untar sources
mkdir -p /root/build-deb/engine
tar -C /root/build-deb -xzf /sources/engine.tgz
mkdir -p /root/build-deb/cli
tar -C /root/build-deb -xzf /sources/cli.tgz
mkdir -p /root/build-deb/compose
tar -C /root/build-deb -xzf /sources/compose.tgz
mkdir -p /root/build-deb/scan-cli-plugin
tar -C /root/build-deb -xzf /sources/scan-cli-plugin.tgz
# link them to their canonical path
mkdir -p /go/src/github.com/docker
ln -snf /root/build-deb/engine /go/src/github.com/docker/docker
ln -snf /root/build-deb/cli /go/src/github.com/docker/cli
ln -snf /root/build-deb/compose /go/src/github.com/docker/compose
ln -snf /root/build-deb/scan-cli-plugin /go/src/github.com/docker/scan-cli-plugin
EPOCH="${EPOCH:-}"
EPOCH_SEP=""
if [[ ! -z "$EPOCH" ]]; then
EPOCH_SEP=":"
fi
if [[ -z "$DEB_VERSION" ]]; then
echo "DEB_VERSION is required to build deb packages"
exit 1
fi
echo VERSION AAA $VERSION
VERSION=${VERSION:-$(cat cli/VERSION)}
echo VERSION bbb $VERSION
debSource="$(awk -F ': ' '$1 == "Source" { print $2; exit }' debian/control)"
debMaintainer="$(awk -F ': ' '$1 == "Maintainer" { print $2; exit }' debian/control)"
debDate="$(date --rfc-2822)"
cat > "debian/changelog" <<-EOF
$debSource (${EPOCH}${EPOCH_SEP}${DEB_VERSION}-0~${DISTRO}-${SUITE}) $SUITE; urgency=low
* Version: $VERSION
-- $debMaintainer $debDate
EOF
# The space above at the start of the line for the debMaintainer is very important
# Give the script a git commit because it wants it
export CLI_GITCOMMIT=${CLI_GITCOMMIT-$(cd cli; $GIT_COMMAND rev-parse --short HEAD)}
export ENGINE_GITCOMMIT=${ENGINE_GITCOMMIT-$(cd engine; $GIT_COMMAND rev-parse --short HEAD)}
# Scan plugin
export SCAN_GITCOMMIT=${SCAN_GITCOMMIT-$(cd scan-cli-plugin; $GIT_COMMAND rev-parse --short HEAD)}
echo VERSION BBB $VERSION
dpkg-buildpackage -uc -us -I.git
destination="/build"
mkdir -p "$destination"
mv -v /root/docker* "$destination"