Browse code

Add `make deb` support for aarch64

Fixes: #27045

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>

Qiang Huang authored on 2016/11/17 10:38:17
Showing 4 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,10 @@
0
+#!/bin/bash
1
+set -e
2
+
3
+cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
4
+
5
+set -x
6
+./generate.sh
7
+for d in */; do
8
+	docker build -t "dockercore/builder-deb:$(basename "$d")" "$d"
9
+done
0 10
new file mode 100755
... ...
@@ -0,0 +1,118 @@
0
+#!/bin/bash
1
+set -e
2
+
3
+# This file is used to auto-generate Dockerfiles for making debs via 'make deb'
4
+#
5
+# usage: ./generate.sh [versions]
6
+#    ie: ./generate.sh
7
+#        to update all Dockerfiles in this directory
8
+#    or: ./generate.sh ubuntu-trusty
9
+#        to only update ubuntu-trusty/Dockerfile
10
+#    or: ./generate.sh ubuntu-newversion
11
+#        to create a new folder and a Dockerfile within it
12
+#
13
+# Note: non-LTS versions are not guaranteed to work.
14
+
15
+cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
16
+
17
+versions=( "$@" )
18
+if [ ${#versions[@]} -eq 0 ]; then
19
+	versions=( */ )
20
+fi
21
+versions=( "${versions[@]%/}" )
22
+
23
+for version in "${versions[@]}"; do
24
+	echo "${versions[@]}"
25
+	distro="${version%-*}"
26
+	suite="${version##*-}"
27
+	from="aarch64/${distro}:${suite}"
28
+
29
+	mkdir -p "$version"
30
+	echo "$version -> FROM $from"
31
+	cat > "$version/Dockerfile" <<-EOF
32
+		#
33
+		# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/deb/aarch64/generate.sh"!
34
+		#
35
+
36
+		FROM $from
37
+
38
+	EOF
39
+
40
+	dockerBuildTags='apparmor pkcs11 selinux'
41
+	runcBuildTags='apparmor selinux'
42
+
43
+	# this list is sorted alphabetically; please keep it that way
44
+	packages=(
45
+		apparmor # for apparmor_parser for testing the profile
46
+		bash-completion # for bash-completion debhelper integration
47
+		btrfs-tools # for "btrfs/ioctl.h" (and "version.h" if possible)
48
+		build-essential # "essential for building Debian packages"
49
+		cmake # tini dep
50
+		curl ca-certificates # for downloading Go
51
+		debhelper # for easy ".deb" building
52
+		dh-apparmor # for apparmor debhelper
53
+		dh-systemd # for systemd debhelper integration
54
+		git # for "git commit" info in "docker -v"
55
+		libapparmor-dev # for "sys/apparmor.h"
56
+		libdevmapper-dev # for "libdevmapper.h"
57
+		libltdl-dev # for pkcs11 "ltdl.h"
58
+		libsqlite3-dev # for "sqlite3.h"
59
+		pkg-config # for detecting things like libsystemd-journal dynamically
60
+		vim-common # tini dep
61
+	)
62
+
63
+	case "$suite" in
64
+		trusty)
65
+			packages+=( libsystemd-journal-dev )
66
+			# aarch64 doesn't have an official downloadable binary for go.
67
+			# And gccgo for trusty only includes Go 1.2 implementation which
68
+			# is too old to build current go source, fortunately trusty has
69
+			# golang-1.6-go package can be used as bootstrap.
70
+			packages+=( golang-1.6-go )
71
+			;;
72
+		xenial)
73
+			packages+=( libsystemd-dev )
74
+			packages+=( golang-go libseccomp-dev)
75
+
76
+			dockerBuildTags="$dockerBuildTags seccomp"
77
+			runcBuildTags="$runcBuildTags seccomp"
78
+			;;
79
+		*)
80
+			echo "Unsupported distro:" $distro:$suite
81
+			rm -fr "$version"
82
+			exit 1
83
+			;;
84
+	esac
85
+
86
+	# update and install packages
87
+	echo "RUN apt-get update && apt-get install -y ${packages[*]} --no-install-recommends && rm -rf /var/lib/apt/lists/*" >> "$version/Dockerfile"
88
+	echo >> "$version/Dockerfile"
89
+
90
+	case "$suite" in
91
+		trusty)
92
+			echo 'RUN update-alternatives --install /usr/bin/go go /usr/lib/go-1.6/bin/go 100' >> "$version/Dockerfile"
93
+			echo >> "$version/Dockerfile"
94
+			;;
95
+		*)
96
+			;;
97
+	esac
98
+
99
+	echo "# Install Go" >> "$version/Dockerfile"
100
+	echo "# aarch64 doesn't have official go binaries, so use the version of go installed from" >> "$version/Dockerfile"
101
+	echo "# the image to build go from source." >> "$version/Dockerfile"
102
+
103
+	awk '$1 == "ENV" && $2 == "GO_VERSION" { print; exit }' ../../../../Dockerfile.aarch64 >> "$version/Dockerfile"
104
+	echo 'RUN mkdir /usr/src/go && curl -fsSL https://golang.org/dl/go${GO_VERSION}.src.tar.gz | tar -v -C /usr/src/go -xz --strip-components=1 \' >> "$version/Dockerfile"
105
+	echo '	&& cd /usr/src/go/src \' >> "$version/Dockerfile"
106
+	echo '	&& GOOS=linux GOARCH=arm64 GOROOT_BOOTSTRAP="$(go env GOROOT)" ./make.bash' >> "$version/Dockerfile"
107
+	echo >> "$version/Dockerfile"
108
+
109
+	echo 'ENV PATH $PATH:/usr/src/go/bin' >> "$version/Dockerfile"
110
+	echo >> "$version/Dockerfile"
111
+
112
+	echo "ENV AUTO_GOPATH 1" >> "$version/Dockerfile"
113
+	echo >> "$version/Dockerfile"
114
+
115
+	echo "ENV DOCKER_BUILDTAGS $dockerBuildTags" >> "$version/Dockerfile"
116
+	echo "ENV RUNC_BUILDTAGS $runcBuildTags" >> "$version/Dockerfile"
117
+done
0 118
new file mode 100644
... ...
@@ -0,0 +1,24 @@
0
+#
1
+# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/deb/aarch64/generate.sh"!
2
+#
3
+
4
+FROM aarch64/ubuntu:trusty
5
+
6
+RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libltdl-dev libsqlite3-dev pkg-config vim-common libsystemd-journal-dev golang-1.6-go --no-install-recommends && rm -rf /var/lib/apt/lists/*
7
+
8
+RUN update-alternatives --install /usr/bin/go go /usr/lib/go-1.6/bin/go 100
9
+
10
+# Install Go
11
+# aarch64 doesn't have official go binaries, so use the version of go installed from
12
+# the image to build go from source.
13
+ENV GO_VERSION 1.7.3
14
+RUN mkdir /usr/src/go && curl -fsSL https://golang.org/dl/go${GO_VERSION}.src.tar.gz | tar -v -C /usr/src/go -xz --strip-components=1 \
15
+	&& cd /usr/src/go/src \
16
+	&& GOOS=linux GOARCH=arm64 GOROOT_BOOTSTRAP="$(go env GOROOT)" ./make.bash
17
+
18
+ENV PATH $PATH:/usr/src/go/bin
19
+
20
+ENV AUTO_GOPATH 1
21
+
22
+ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux
23
+ENV RUNC_BUILDTAGS apparmor selinux
0 24
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+#
1
+# THIS FILE IS AUTOGENERATED; SEE "contrib/builder/deb/aarch64/generate.sh"!
2
+#
3
+
4
+FROM aarch64/ubuntu:xenial
5
+
6
+RUN apt-get update && apt-get install -y apparmor bash-completion btrfs-tools build-essential cmake curl ca-certificates debhelper dh-apparmor dh-systemd git libapparmor-dev libdevmapper-dev libltdl-dev libsqlite3-dev pkg-config vim-common libsystemd-dev golang-go libseccomp-dev --no-install-recommends && rm -rf /var/lib/apt/lists/*
7
+
8
+# Install Go
9
+# aarch64 doesn't have official go binaries, so use the version of go installed from
10
+# the image to build go from source.
11
+ENV GO_VERSION 1.7.3
12
+RUN mkdir /usr/src/go && curl -fsSL https://golang.org/dl/go${GO_VERSION}.src.tar.gz | tar -v -C /usr/src/go -xz --strip-components=1 \
13
+	&& cd /usr/src/go/src \
14
+	&& GOOS=linux GOARCH=arm64 GOROOT_BOOTSTRAP="$(go env GOROOT)" ./make.bash
15
+
16
+ENV PATH $PATH:/usr/src/go/bin
17
+
18
+ENV AUTO_GOPATH 1
19
+
20
+ENV DOCKER_BUILDTAGS apparmor pkcs11 selinux seccomp
21
+ENV RUNC_BUILDTAGS apparmor selinux seccomp