Skip to content

Commit

Permalink
fix hook scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
David Personette committed Sep 4, 2019
1 parent b204512 commit e7d9254
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 4 additions & 8 deletions hooks/post_checkout
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#!/usr/bin/env bash
env
set -x

BUILD_ARCH=$(echo "${DOCKERFILE_PATH}" | cut -d'.' -f2)

[ "${BUILD_ARCH}" == "Dockerfile" ] && \
[[ "${DOCKER_TAG}" == "latest" ]] && \
{ echo 'qemu-user-static: Download not required for this arch'; exit 0; }

TAGS_API="https://api.github.com/repos/multiarch/qemu-user-static/tags"
URL="https://github.com/multiarch/qemu-user-static/releases/download"
LATEST_TAG=$(curl -Ls $TAGS_API | \
awk -F'"' '/name.*v[0-9]/ {print $4; exit}')
STATIC_ARCH=$([ "${BUILD_ARCH}" == "armhf" ] && \
echo "${BUILD_ARCH::-2}" || echo "${BUILD_ARCH}")
ARCH=$([[ "${DOCKER_TAG}" == "armhf" ]] && \
echo "${DOCKER_TAG::-2}" || echo "${DOCKER_TAG}")

curl -Ls "${URL}/${LATEST_TAG}/x86_64_qemu-${STATIC_ARCH}-static.tar.gz" | \
curl -Ls "${URL}/${LATEST_TAG}/x86_64_qemu-${ARCH}-static.tar.gz" | \
tar xzv
4 changes: 1 addition & 3 deletions hooks/pre_build
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash

BUILD_ARCH=$(echo "${DOCKERFILE_PATH}" | cut -d'.' -f2)

[ "${BUILD_ARCH}" == "Dockerfile" ] && \
[[ "${DOCKER_TAG}" == "latest" ]] && \
{ echo 'qemu-user-static: Registration not required for this arch';exit 0; }

docker run --rm --privileged multiarch/qemu-user-static:register --reset

0 comments on commit e7d9254

Please sign in to comment.