Skip to content

Commit 97a6985

Browse files
authored
Merge pull request #19 from lafin/master
refactoring
2 parents 720a9e5 + e09954c commit 97a6985

File tree

35 files changed

+92
-106
lines changed

35 files changed

+92
-106
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.deb
2+
archs

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
sudo: required
2+
services: docker
3+
language: bash
4+
env:
5+
- VERSION=2.8.1
6+
branches:
7+
only:
8+
- master
9+
before_script:
10+
- sudo apt-get install jq
11+
- wget -N http://ftp.debian.org/debian/pool/main/q/qemu/qemu-user-static_2.8+dfsg-3_amd64.deb
12+
- sudo dpkg -i qemu-user-static_2.8+dfsg-3_amd64.deb
13+
script:
14+
- sudo ./publish.sh -v "$VERSION" -t "$GITHUB_TOKEN"
15+
- sudo ./update.sh -v "$VERSION"
16+
after_success:
17+
- if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" && docker push multiarch/qemu-user-static; fi

all-archs

-29
This file was deleted.

archs/x86_64-aarch64/Dockerfile

-2
This file was deleted.

archs/x86_64-alpha/Dockerfile

-2
This file was deleted.

archs/x86_64-arm/Dockerfile

-2
This file was deleted.

archs/x86_64-armeb/Dockerfile

-2
This file was deleted.

archs/x86_64-cris/Dockerfile

-2
This file was deleted.

archs/x86_64-i386/Dockerfile

-2
This file was deleted.

archs/x86_64-m68k/Dockerfile

-2
This file was deleted.

archs/x86_64-microblaze/Dockerfile

-2
This file was deleted.

archs/x86_64-microblazeel/Dockerfile

-2
This file was deleted.

archs/x86_64-mips/Dockerfile

-2
This file was deleted.

archs/x86_64-mips64/Dockerfile

-2
This file was deleted.

archs/x86_64-mips64el/Dockerfile

-2
This file was deleted.

archs/x86_64-mipsel/Dockerfile

-2
This file was deleted.

archs/x86_64-mipsn32/Dockerfile

-2
This file was deleted.

archs/x86_64-mipsn32el/Dockerfile

-2
This file was deleted.

archs/x86_64-or32/Dockerfile

-2
This file was deleted.

archs/x86_64-ppc/Dockerfile

-2
This file was deleted.

archs/x86_64-ppc64/Dockerfile

-2
This file was deleted.

archs/x86_64-ppc64abi32/Dockerfile

-2
This file was deleted.

archs/x86_64-ppc64le/Dockerfile

-2
This file was deleted.

archs/x86_64-s390x/Dockerfile

-2
This file was deleted.

archs/x86_64-sh4/Dockerfile

-2
This file was deleted.

archs/x86_64-sh4eb/Dockerfile

-2
This file was deleted.

archs/x86_64-sparc/Dockerfile

-2
This file was deleted.

archs/x86_64-sparc32plus/Dockerfile

-2
This file was deleted.

archs/x86_64-sparc64/Dockerfile

-2
This file was deleted.

archs/x86_64-tilegx/Dockerfile

-2
This file was deleted.

archs/x86_64-unicore32/Dockerfile

-2
This file was deleted.

archs/x86_64-x86_64/Dockerfile

-2
This file was deleted.

build.sh

-6
This file was deleted.

publish.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# A POSIX variable
5+
OPTIND=1 # Reset in case getopts has been used previously in the shell.
6+
7+
while getopts "v:t:" opt; do
8+
case "$opt" in
9+
v) VERSION=$OPTARG
10+
;;
11+
t) GITHUB_TOKEN=$OPTARG
12+
;;
13+
esac
14+
done
15+
16+
shift $((OPTIND-1))
17+
18+
[ "$1" = "--" ] && shift
19+
20+
mkdir releases
21+
cp /usr/bin/qemu-*-static releases/
22+
cd releases/
23+
for file in *; do
24+
tar -czf $file.tar.gz $file;
25+
cp $file.tar.gz x86_64_$file.tar.gz
26+
done
27+
28+
release_id=$(curl -sL -X POST \
29+
-H "Content-Type: application/json" \
30+
-H "Accept: application/vnd.github.v3+json" \
31+
-H "Authorization: token ${GITHUB_TOKEN}" \
32+
-H "Cache-Control: no-cache" -d "{
33+
\"tag_name\": \"v${VERSION}\",
34+
\"target_commitish\": \"master\",
35+
\"name\": \"v${VERSION}\",
36+
\"body\": \"# \`qemu-*-static\` @ ${VERSION}\",
37+
\"draft\": false,
38+
\"prerelease\": false
39+
}" "https://api.github.com/repos/multiarch/qemu-user-static/releases" | jq -r ".id")
40+
41+
for file in *; do
42+
content_type=$(file --mime-type -b ${file})
43+
curl -sL \
44+
-H "Authorization: token ${GITHUB_TOKEN}" \
45+
-H "Content-Type: ${content_type}" \
46+
--upload-file ${file} \
47+
"https://uploads.github.com/repos/multiarch/qemu-user-static/releases/${release_id}/assets?name=${file}"
48+
done

update.sh

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
set -e
23

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

6-
for from_arch in $from_archs; do
7-
for to_arch in $to_archs; do
8-
mkdir -p archs/$from_arch-$to_arch
9-
cat > archs/$from_arch-$to_arch/Dockerfile <<EOF
7+
while getopts "v:" opt; do
8+
case "$opt" in
9+
v) VERSION=$OPTARG
10+
;;
11+
esac
12+
done
13+
14+
shift $((OPTIND-1))
15+
16+
[ "$1" = "--" ] && shift
17+
18+
from_arch="x86_64"
19+
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")
20+
21+
for to_arch in "${to_archs[@]}"; do
22+
if [ "$from_arch" != "$to_arch" ]; then
23+
mkdir -p archs/$from_arch-$to_arch
24+
cat > archs/$from_arch-$to_arch/Dockerfile <<EOF
1025
FROM scratch
11-
ADD https://github.com/multiarch/qemu-user-static/releases/download/v2.8.0/${from_arch}_qemu-${to_arch}-static.tar.gz /usr/bin
26+
ADD https://github.com/multiarch/qemu-user-static/releases/download/v${VERSION}/${from_arch}_qemu-${to_arch}-static.tar.gz /usr/bin
1227
EOF
13-
docker build -t multiarch/qemu-user-static:$from_arch-$to_arch archs/$from_arch-$to_arch
14-
if [ "$from_arch" = "x86_64" ]; then
15-
docker tag -f multiarch/qemu-user-static:$from_arch-$to_arch multiarch/qemu-user-static:$to_arch
16-
fi
17-
done
28+
docker build -t multiarch/qemu-user-static:$from_arch-$to_arch archs/$from_arch-$to_arch
29+
docker tag multiarch/qemu-user-static:$from_arch-$to_arch multiarch/qemu-user-static:$to_arch
30+
fi
1831
done
1932

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

0 commit comments

Comments
 (0)