Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Few updates for Golang build script #14

Merged
merged 6 commits into from Aug 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile.alpine.tpl
@@ -1,6 +1,8 @@
FROM #{FROM}

RUN apk add --no-cache git build-base gcc curl python python-dev py-pip wget ca-certificates musl-dev openssl coreutils
#{QEMU}

RUN apk add --no-cache git build-base gcc curl python python-dev py-pip wget ca-certificates musl-dev openssl coreutils go

# Install AWS CLI
RUN pip install awscli
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile.debian.tpl
@@ -1,7 +1,10 @@
FROM #{FROM}

RUN apt-get -q update \
&& apt-get install -y git-core build-essential mercurial gcc libc6-dev curl python python-dev python-pip wget ca-certificates libssl-dev --no-install-recommends \
#{QEMU}

RUN echo deb http://ftp.debian.org/debian jessie-backports main > /etc/apt/sources.list.d/backports.list \
&& apt-get -q update \
&& apt-get install -y git-core build-essential mercurial gcc libc6-dev curl python python-dev python-pip wget ca-certificates libssl-dev golang-go --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
28 changes: 20 additions & 8 deletions automation/jenkins_build.sh
Expand Up @@ -6,28 +6,40 @@ for ARCH in $ARCHS
do
case "$ARCH" in
'armv6hf')
sed -e s~#{FROM}~resin/rpi-raspbian:latest~g Dockerfile.debian.tpl > Dockerfile
sed -e s~#{FROM}~resin/rpi-raspbian:jessie~g \
-e s~#{QEMU}~"COPY qemu/qemu-arm-static /usr/bin/"~g Dockerfile.debian.tpl > Dockerfile
;;
'armv7hf')
sed -e s~#{FROM}~resin/armv7hf-debian:latest~g Dockerfile.debian.tpl > Dockerfile
sed -e s~#{FROM}~resin/armv7hf-debian:jessie~g \
-e s~#{QEMU}~"COPY qemu/qemu-arm-static /usr/bin/"~g Dockerfile.debian.tpl > Dockerfile
;;
'armel')
sed -e s~#{FROM}~resin/armel-debian:latest~g Dockerfile.debian.tpl > Dockerfile
sed -e s~#{FROM}~resin/armel-debian:jessie~g \
-e s~#{QEMU}~"COPY qemu/qemu-arm-static /usr/bin/"~g Dockerfile.debian.tpl > Dockerfile
;;
'aarch64')
sed -e s~#{FROM}~resin/aarch64-debian:latest~g Dockerfile.debian.tpl > Dockerfile
sed -e s~#{FROM}~resin/aarch64-debian:jessie~g \
-e s~#{QEMU}~"COPY qemu/qemu-aarch64-static /usr/bin/"~g Dockerfile.debian.tpl > Dockerfile
;;
'i386')
sed -e s~#{FROM}~resin/i386-debian:latest~g Dockerfile.debian.tpl > Dockerfile
sed -e s~#{FROM}~resin/i386-debian:jessie~g \
-e s~#{QEMU}~""~g Dockerfile.debian.tpl > Dockerfile
;;
'alpine-armhf')
sed -e s~#{FROM}~resin/armhf-alpine:latest~g Dockerfile.alpine.tpl > Dockerfile
sed -e s~#{FROM}~resin/armhf-alpine:3.6~g \
-e s~#{QEMU}~"COPY qemu/qemu-arm-static /usr/bin/"~g Dockerfile.alpine.tpl > Dockerfile
;;
'alpine-i386')
sed -e s~#{FROM}~resin/i386-alpine:latest~g Dockerfile.alpine.tpl > Dockerfile
sed -e s~#{FROM}~resin/i386-alpine:3.6~g \
-e s~#{QEMU}~""~g Dockerfile.alpine.tpl > Dockerfile
;;
'alpine-amd64')
sed -e s~#{FROM}~resin/amd64-alpine:latest~g Dockerfile.alpine.tpl > Dockerfile
sed -e s~#{FROM}~resin/amd64-alpine:3.6~g \
-e s~#{QEMU}~""~g Dockerfile.alpine.tpl > Dockerfile
;;
'alpine-aarch64')
sed -e s~#{FROM}~resin/aarch64-alpine:3.6~g \
-e s~#{QEMU}~"COPY qemu/qemu-aarch64-static /usr/bin/"~g Dockerfile.alpine.tpl > Dockerfile
;;
esac
docker build -t go-$ARCH-builder .
Expand Down
18 changes: 8 additions & 10 deletions build.sh
Expand Up @@ -5,23 +5,15 @@ set -o pipefail
# set env var
GOLANG_VERSION=$1
# Go 1.4 required to build Go 1.5
GOROOT_BOOTSTRAP_VERSION=1.4.3
#GOROOT_BOOTSTRAP_VERSION=1.4.3
TAR_FILE=go$GOLANG_VERSION.linux-$ARCH.tar.gz
BUCKET_NAME=$BUCKET_NAME

# comparing version: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" == "$1"; }
function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" != "$1"; }

# in order to build Go 1.5, need to download Go 1.4 first
if version_ge $GOLANG_VERSION "1.5"; then
mkdir /go-bootstrap
wget http://resin-packages.s3.amazonaws.com/golang/v$GOROOT_BOOTSTRAP_VERSION/go$GOROOT_BOOTSTRAP_VERSION.linux-$ARCH.tar.gz
echo "$(grep " go$GOROOT_BOOTSTRAP_VERSION.linux-$ARCH.tar.gz" /checksums-commit-table)" | sha256sum -c -
tar -xzf "go$GOROOT_BOOTSTRAP_VERSION.linux-$ARCH.tar.gz" -C /go-bootstrap --strip-components=1
rm go$GOROOT_BOOTSTRAP_VERSION.linux-$ARCH.tar.gz
export GOROOT_BOOTSTRAP=/go-bootstrap
fi
export GOROOT_BOOTSTRAP=$(go env GOROOT)

case "$ARCH" in
'armv6hf')
Expand Down Expand Up @@ -73,6 +65,12 @@ if [[ $ARCH == *"alpine"* ]]; then
fi
fi

# Fix for https://github.com/golang/go/issues/20763, Apply on Go v1.7 and v1.8.
# Ref: https://github.com/golang/go/commit/2673f9ed23348c634f6331ee589d489e4d9c7a9b
if (version_ge $GOLANG_VERSION "1.7"); then
patch -p1 < /patches/0001-runtime-pass-CLONE_SYSVSEM-to-clone.patch
fi

# Fix for i386 platforms without MMX instructions
cd src
if [[ $ARCH == *"386"* ]] && ( version_ge $GOLANG_VERSION "1.6" ); then
Expand Down
6 changes: 5 additions & 1 deletion checksums-commit-table
Expand Up @@ -24,5 +24,9 @@ a96cce8ce43a9bf9b2a4c7d470bc7ee0cb00410da815980681c8353218dcf146 go1.6.src.tar.g
79430a0027a09b0b3ad57e214c4c1acfdd7af290961dd08d322818895af1ef44 go1.7.3.src.tar.gz
4c189111e9ba651a2bb3ee868aa881fab36b2f2da3409e80885ca758a6b614cc go1.7.4.src.tar.gz
4e834513a2079f8cbbd357502cccaac9507fd00a1efe672375798858ff291815 go1.7.5.src.tar.gz
1a67a4e688673fdff7ba41e73482b0e59ac5bd0f7acf703bc6d50cc775c5baba go1.7.6.src.tar.gz

406865f587b44be7092f206d73fc1de252600b79b3cacc587b74b5ef5c623596 go1.8.src.tar.gz
406865f587b44be7092f206d73fc1de252600b79b3cacc587b74b5ef5c623596 go1.8.src.tar.gz
5f5dea2447e7dcfdc50fa6b94c512e58bfba5673c039259fd843f68829d99fa6 go1.8.3.src.tar.gz

a4ab229028ed167ba1986825751463605264e44868362ca8e7accc8be057e993 go1.9.src.tar.gz
39 changes: 39 additions & 0 deletions patches/0001-runtime-pass-CLONE_SYSVSEM-to-clone.patch
@@ -0,0 +1,39 @@
From 2673f9ed23348c634f6331ee589d489e4d9c7a9b Mon Sep 17 00:00:00 2001
From: Austin Clements <austin@google.com>
Date: Wed, 12 Jul 2017 10:12:50 -0600
Subject: [PATCH] runtime: pass CLONE_SYSVSEM to clone

SysV semaphore undo lists should be shared by threads, just like
several other resources listed in cloneFlags. Currently we don't do
this, but it probably doesn't affect anything because 1) probably
nobody uses SysV semaphores from Go and 2) Go-created threads never
exit until the process does. Beyond being the right thing to do,
user-level QEMU requires this flag because it depends on glibc to
create new threads and glibc uses this flag.

Fixes #20763.

Change-Id: I1d1dafec53ed87e0f4d4d432b945e8e68bb72dcd
Reviewed-on: https://go-review.googlesource.com/48170
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
---
src/runtime/os_linux.go | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go
index a6efc0e..7889973 100644
--- a/src/runtime/os_linux.go
+++ b/src/runtime/os_linux.go
@@ -132,6 +132,7 @@ const (
_CLONE_FS | /* share cwd, etc */
_CLONE_FILES | /* share fd table */
_CLONE_SIGHAND | /* share sig handler table */
+ _CLONE_SYSVSEM | /* share SysV semaphore undo lists (see issue #20763) */
_CLONE_THREAD /* revisit - okay for now */
)

--
2.7.4

Binary file added qemu/qemu-aarch64-static
Binary file not shown.
Binary file added qemu/qemu-arm-static
Binary file not shown.