From 122523e9cd4e5d3474e9323a97784bd19ba599cf Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Sun, 10 Mar 2019 15:00:31 -0700 Subject: [PATCH] Download qemu in container --- Dockerfile | 10 +++++++++- Makefile | 4 ++-- get_qemu2.sh | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 get_qemu2.sh diff --git a/Dockerfile b/Dockerfile index 7bac3ef..d22e416 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,16 @@ ARG REPO=library FROM ${REPO}/python:3-alpine ARG ARCH=x86_64 -COPY ./build/qemu-${ARCH}-static /usr/bin/ +ARG HOST_ARCH=x86_64 +ARG QEMU_VERSION=v2.9.1-1 + +RUN [ $ARCH == $HOST_ARCH ] || { \ + wget https://github.com/multiarch/qemu-user-static/releases/download/${QEMU_VERSION}/${HOST_ARCH}_qemu-${ARCH}-static.tar.gz && \ + tar -xvf ${HOST_ARCH}_qemu-${ARCH}-static.tar.gz && \ + rm ${HOST_ARCH}_qemu-${ARCH}-static.tar.gz && \ + mv qemu-${ARCH}-static /usr/bin/ ; \ + } RUN echo "OK" > /foo diff --git a/Makefile b/Makefile index 9a87fe2..e5e696c 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ test: @echo ok .PHONY: build -build: build/qemu-x86_64-static +build: docker build . -t ${DOCKER_TAG} build/qemu-arm-static: @@ -21,7 +21,7 @@ build/qemu-aarch64-static: ./get_qemu.sh .PHONY: cross-build-arm -cross-build-arm: build/qemu-arm-static +cross-build-arm: docker build --build-arg REPO=arm32v6 --build-arg ARCH=arm . -t ${DOCKER_TAG}-arm32v6 .PHONY: run diff --git a/get_qemu2.sh b/get_qemu2.sh new file mode 100755 index 0000000..6132e06 --- /dev/null +++ b/get_qemu2.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +HOST_ARCH=x86_64 +VERSION=v2.9.1-1 + +mkdir -p build +cd build + +for target_arch in $*; do + wget -N https://github.com/multiarch/qemu-user-static/releases/download/$VERSION/${HOST_ARCH}_qemu-${target_arch}-static.tar.gz + tar -xvf ${HOST_ARCH}_qemu-${target_arch}-static.tar.gz + rm ${HOST_ARCH}_qemu-${target_arch}-static.tar.gz + mv qemu-${target_arch}-static /usr/bin/ +done