Skip to content

Commit

Permalink
Merge pull request #19 from lafin/master
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
moul authored Mar 9, 2017
2 parents 720a9e5 + e09954c commit 97a6985
Show file tree
Hide file tree
Showing 35 changed files with 92 additions and 106 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.deb
archs
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sudo: required
services: docker
language: bash
env:
- VERSION=2.8.1
branches:
only:
- master
before_script:
- sudo apt-get install jq
- wget -N http://ftp.debian.org/debian/pool/main/q/qemu/qemu-user-static_2.8+dfsg-3_amd64.deb
- sudo dpkg -i qemu-user-static_2.8+dfsg-3_amd64.deb
script:
- sudo ./publish.sh -v "$VERSION" -t "$GITHUB_TOKEN"
- sudo ./update.sh -v "$VERSION"
after_success:
- if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" && docker push multiarch/qemu-user-static; fi
29 changes: 0 additions & 29 deletions all-archs

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-aarch64/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-alpha/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-arm/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-armeb/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-cris/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-i386/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-m68k/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-microblaze/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-microblazeel/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-mips/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-mips64/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-mips64el/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-mipsel/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-mipsn32/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-mipsn32el/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-or32/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-ppc/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-ppc64/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-ppc64abi32/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-ppc64le/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-s390x/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-sh4/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-sh4eb/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-sparc/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-sparc32plus/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-sparc64/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-tilegx/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-unicore32/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions archs/x86_64-x86_64/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions build.sh

This file was deleted.

48 changes: 48 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -e

# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.

while getopts "v:t:" opt; do
case "$opt" in
v) VERSION=$OPTARG
;;
t) GITHUB_TOKEN=$OPTARG
;;
esac
done

shift $((OPTIND-1))

[ "$1" = "--" ] && shift

mkdir releases
cp /usr/bin/qemu-*-static releases/
cd releases/
for file in *; do
tar -czf $file.tar.gz $file;
cp $file.tar.gz x86_64_$file.tar.gz
done

release_id=$(curl -sL -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Cache-Control: no-cache" -d "{
\"tag_name\": \"v${VERSION}\",
\"target_commitish\": \"master\",
\"name\": \"v${VERSION}\",
\"body\": \"# \`qemu-*-static\` @ ${VERSION}\",
\"draft\": false,
\"prerelease\": false
}" "https://api.github.com/repos/multiarch/qemu-user-static/releases" | jq -r ".id")

for file in *; do
content_type=$(file --mime-type -b ${file})
curl -sL \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Content-Type: ${content_type}" \
--upload-file ${file} \
"https://uploads.github.com/repos/multiarch/qemu-user-static/releases/${release_id}/assets?name=${file}"
done
39 changes: 26 additions & 13 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
#!/bin/sh
#!/bin/bash
set -e

from_archs="x86_64"
to_archs="$(cat all-archs)"
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.

for from_arch in $from_archs; do
for to_arch in $to_archs; do
mkdir -p archs/$from_arch-$to_arch
cat > archs/$from_arch-$to_arch/Dockerfile <<EOF
while getopts "v:" opt; do
case "$opt" in
v) VERSION=$OPTARG
;;
esac
done

shift $((OPTIND-1))

[ "$1" = "--" ] && shift

from_arch="x86_64"
to_archs=("aarch64" "alpha" "arm" "armeb" "cris" "i386" "m68k" "microblaze" "microblazeel" "mips" "mips64" "mips64el" "mipsel" "mipsn32" "mipsn32el" "or32" "ppc" "ppc64" "ppc64abi32" "ppc64le" "s390x" "sh4" "sh4eb" "sparc" "sparc32plus" "sparc64" "tilegx" "x86_64")

for to_arch in "${to_archs[@]}"; do
if [ "$from_arch" != "$to_arch" ]; then
mkdir -p archs/$from_arch-$to_arch
cat > archs/$from_arch-$to_arch/Dockerfile <<EOF
FROM scratch
ADD https://github.com/multiarch/qemu-user-static/releases/download/v2.8.0/${from_arch}_qemu-${to_arch}-static.tar.gz /usr/bin
ADD https://github.com/multiarch/qemu-user-static/releases/download/v${VERSION}/${from_arch}_qemu-${to_arch}-static.tar.gz /usr/bin
EOF
docker build -t multiarch/qemu-user-static:$from_arch-$to_arch archs/$from_arch-$to_arch
if [ "$from_arch" = "x86_64" ]; then
docker tag -f multiarch/qemu-user-static:$from_arch-$to_arch multiarch/qemu-user-static:$to_arch
fi
done
docker build -t multiarch/qemu-user-static:$from_arch-$to_arch archs/$from_arch-$to_arch
docker tag multiarch/qemu-user-static:$from_arch-$to_arch multiarch/qemu-user-static:$to_arch
fi
done

docker build -t multiarch/qemu-user-static:register register

0 comments on commit 97a6985

Please sign in to comment.