Skip to content

Commit

Permalink
chore: build armhf on GNU/Linux
Browse files Browse the repository at this point in the history
This commit makes use of the `resin/armv7hf-debian` Docker image to
test and generate armhf builds.

We needed to add a slash before `build` in `.gitignore` given that git
was refusing to include any changes on `scripts/build` otherwise.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
Juan Cruz Viotti authored and jviotti committed Jun 26, 2017
1 parent f350d28 commit 70c88a0
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -21,7 +21,7 @@ coverage
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build
/build

# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Expand Up @@ -22,12 +22,15 @@ env:
matrix:
- TARGET_ARCH=x64
- TARGET_ARCH=x86
- TARGET_ARCH=armv7hf

matrix:
fast_finish: true
exclude:
- os: osx
env: TARGET_ARCH=x86
- os: osx
env: TARGET_ARCH=armv7hf

os:
- linux
Expand All @@ -41,7 +44,7 @@ before_install:
fi

install:
- travis_wait ./scripts/ci/install.sh -o $HOST_OS -r $TARGET_ARCH
- travis_wait 90 ./scripts/ci/install.sh -o $HOST_OS -r $TARGET_ARCH

script:
- ./scripts/ci/test.sh -o $HOST_OS -r $TARGET_ARCH
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -75,7 +75,7 @@ else
HOST_ARCH = x86
endif
ifeq ($(shell uname -m),armv7l)
HOST_ARCH = armv7l
HOST_ARCH = armv7hf
endif
endif
ifeq ($(shell uname -s),Darwin)
Expand Down
16 changes: 13 additions & 3 deletions scripts/build/architecture-convert.sh
Expand Up @@ -25,7 +25,7 @@ function usage() {
echo "Options"
echo ""
echo " -r <architecture>"
echo " -t <type (debian|redhat|node)>"
echo " -t <type (debian|redhat|node|docker)>"
exit 1
}

Expand All @@ -51,22 +51,32 @@ if [ "$ARGV_TYPE" == "node" ]; then
RESULT=ia32
elif [ "$ARGV_ARCHITECTURE" == "x64" ]; then
RESULT=x64
elif [ "$ARGV_ARCHITECTURE" == "armv7l" ]; then
elif [ "$ARGV_ARCHITECTURE" == "armv7hf" ]; then
RESULT=arm
fi
elif [ "$ARGV_TYPE" == "debian" ]; then
if [ "$ARGV_ARCHITECTURE" == "x86" ]; then
RESULT=i386
elif [ "$ARGV_ARCHITECTURE" == "x64" ]; then
RESULT=amd64
elif [ "$ARGV_ARCHITECTURE" == "armv7l" ]; then
elif [ "$ARGV_ARCHITECTURE" == "armv7hf" ]; then
RESULT=armhf
fi
elif [ "$ARGV_TYPE" == "redhat" ]; then
if [ "$ARGV_ARCHITECTURE" == "x86" ]; then
RESULT=i386
elif [ "$ARGV_ARCHITECTURE" == "x64" ]; then
RESULT='x86_64'
elif [ "$ARGV_ARCHITECTURE" == "armv7hf" ]; then
RESULT=armhf
fi
elif [ "$ARGV_TYPE" == "docker" ]; then
if [ "$ARGV_ARCHITECTURE" == "x64" ]; then
RESULT=x86_64
elif [ "$ARGV_ARCHITECTURE" == "x86" ]; then
RESULT=i686
elif [ "$ARGV_ARCHITECTURE" == "armv7hf" ]; then
RESULT=armv7hf
fi
else
echo "Unsupported architecture type: $ARGV_TYPE" 1>&2
Expand Down
56 changes: 56 additions & 0 deletions scripts/build/docker/Dockerfile-armv7hf
@@ -0,0 +1,56 @@
FROM resin/armv7hf-debian-qemu:latest


RUN [ "cross-build-start" ]


# Setup APT sources



RUN echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list


# Install dependencies
RUN apt-get update \
&& apt-get install -y \
build-essential \
curl \
fuse \
git \
jq \
libasound2 \
libgconf-2-4 \
libgtk2.0-0 \
libx11-xcb1 \
libnss3 \
libxss1 \
libxtst6 \
libyaml-dev \
python \
python-pip \
python-dev \
python-software-properties \
unzip \
xvfb \
zip



# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& apt-get install -y nodejs

# See https://github.com/mapbox/node-pre-gyp/issues/165
RUN npm config set unsafe-perm=true

RUN npm config set spin=false
RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1

# Python
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt


RUN [ "cross-build-end" ]

7 changes: 7 additions & 0 deletions scripts/build/docker/Dockerfile-i686
@@ -1,12 +1,15 @@
FROM erwinchang/ubuntu-12.04-32bit-build



# Setup APT sources

RUN sed s,ubuntu\.stu\.edu\.tw,archive.ubuntu.com, /etc/apt/sources.list > /tmp/sources.list \
&& mv /tmp/sources.list /etc/apt/sources.list




# Install dependencies
RUN apt-get update \
&& apt-get install -y \
Expand All @@ -32,11 +35,13 @@ RUN apt-get update \
zip \
rpm


# Install a C++11 compiler
RUN add-apt-repository ppa:ubuntu-toolchain-r/test \
&& apt-get update && apt-get install -y gcc-4.8 g++-4.8 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50


# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& apt-get install -y nodejs
Expand All @@ -50,3 +55,5 @@ RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 electron-inst
# Python
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt


7 changes: 7 additions & 0 deletions scripts/build/docker/Dockerfile-x86_64
@@ -1,11 +1,14 @@
FROM ubuntu:12.04



# Setup APT sources


RUN echo "deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse" >> /etc/apt/sources.list



# Install dependencies
RUN apt-get update \
&& apt-get install -y \
Expand All @@ -31,11 +34,13 @@ RUN apt-get update \
zip \
rpm


# Install a C++11 compiler
RUN add-apt-repository ppa:ubuntu-toolchain-r/test \
&& apt-get update && apt-get install -y gcc-4.8 g++-4.8 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50


# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
&& apt-get install -y nodejs
Expand All @@ -49,3 +54,5 @@ RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 electron-inst
# Python
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt


13 changes: 13 additions & 0 deletions scripts/build/docker/Dockerfile.template
@@ -1,5 +1,9 @@
FROM <%= image %>

<% if (architecture == 'armv7hf') { %>
RUN [ "cross-build-start" ]
<% } %>

# Setup APT sources
<% if (architecture == 'i686') { %>
RUN sed s,ubuntu\.stu\.edu\.tw,archive.ubuntu.com, /etc/apt/sources.list > /tmp/sources.list \
Expand All @@ -8,6 +12,9 @@ RUN sed s,ubuntu\.stu\.edu\.tw,archive.ubuntu.com, /etc/apt/sources.list > /tmp/
<% if (architecture == 'x86_64') { %>
RUN echo "deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse" >> /etc/apt/sources.list
<% } %>
<% if (architecture == 'armv7hf') { %>
RUN echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list
<% } %>

# Install dependencies
RUN apt-get update \
Expand Down Expand Up @@ -35,10 +42,12 @@ RUN apt-get update \
zip \
rpm

<% if (architecture != 'armv7hf') { %>
# Install a C++11 compiler
RUN add-apt-repository ppa:ubuntu-toolchain-r/test \
&& apt-get update && apt-get install -y gcc-4.8 g++-4.8 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
<% } %>

# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - \
Expand All @@ -53,3 +62,7 @@ RUN npm install -g uglify-es@3.0.3 electron-installer-debian@0.5.1 electron-inst
# Python
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

<% if (architecture == 'armv7hf') { %>
RUN [ "cross-build-end" ]
<% } %>
4 changes: 4 additions & 0 deletions scripts/build/docker/compile-template.js
Expand Up @@ -36,6 +36,10 @@ _.each([
{
architecture: 'x86_64',
image: 'ubuntu:12.04'
},
{
architecture: 'armv7hf',
image: 'resin/armv7hf-debian-qemu:latest'
}
], (options) => {
const result = _.template(template)(options);
Expand Down
15 changes: 5 additions & 10 deletions scripts/build/docker/run-command.sh
Expand Up @@ -54,16 +54,9 @@ then
usage
fi

if [ "$ARGV_ARCHITECTURE" == "x64" ]; then
DOCKERFILE="$HERE/Dockerfile-x86_64"
elif [ "$ARGV_ARCHITECTURE" == "x86" ]; then
DOCKERFILE="$HERE/Dockerfile-i686"
else
echo "Unsupported architecture: $ARGV_ARCHITECTURE" 1>&2
exit 1
fi

IMAGE_ID="etcher-build-$ARGV_ARCHITECTURE"
DOCKER_ARCHITECTURE=$(./scripts/build/architecture-convert.sh -r "$ARGV_ARCHITECTURE" -t docker)
DOCKERFILE="$HERE/Dockerfile-$DOCKER_ARCHITECTURE"
IMAGE_ID="etcher-build-$DOCKER_ARCHITECTURE"

docker build -f "$DOCKERFILE" -t "$IMAGE_ID" "$ARGV_SOURCE_CODE_DIRECTORY"

Expand Down Expand Up @@ -91,6 +84,8 @@ docker run -t \
--env "TERM=xterm-256color" \
--env "TARGET_ARCH=$ARGV_ARCHITECTURE" \
${DOCKER_ENVVARS[@]+"${DOCKER_ENVVARS[@]}"} \
--entrypoint=qemu-arm-static \
--env "QEMU_EXECVE=1" \
--privileged \
--cap-add SYS_ADMIN \
--device /dev/fuse:/dev/fuse:mrw \
Expand Down

0 comments on commit 70c88a0

Please sign in to comment.