@@ -4,33 +4,31 @@ set -xe
44# A POSIX variable
55OPTIND=1 # Reset in case getopts has been used previously in the shell.
66
7- while getopts " r:v: t:d:" opt; do
7+ while getopts " r:t:d:" opt; do
88 case " $opt " in
99 r) REPO=$OPTARG
1010 ;;
11- v) VERSION=$OPTARG
12- ;;
1311 t) TAG_VER=$OPTARG
1412 ;;
1513 d) DOCKER_REPO=$OPTARG
1614 ;;
1715 esac
1816done
1917
20- if [ -z " $VERSION " ]; then
21- echo " usage: $0 -v VERSION" 2>&1
22- echo " check https://github.com/${REPO} /releases for available versions" 2>&1
23- exit 1
24- fi
25-
2618shift $(( OPTIND- 1 ))
2719
2820[ " $1 " = " --" ] && shift
2921
22+ base_path=$( pwd)
23+ cd releases/usr/bin/
24+ for file in * ; do
25+ tar -czf $file .tar.gz $file ;
26+ mv $file .tar.gz x86_64_$file .tar.gz
27+ done
28+ cd ${base_path}
29+
3030from_arch=" x86_64"
3131to_archs=" aarch64 aarch64_be alpha arm armeb cris hppa i386 m68k microblaze microblazeel mips mips64 mips64el mipsel mipsn32 mipsn32el nios2 or1k ppc ppc64 ppc64le riscv32 riscv64 s390x sh4 sh4eb sparc sparc32plus sparc64 x86_64 xtensa xtensaeb"
32- # For casual test
33- # to_archs="aarch64"
3432
3533# Build container images creating the directory.
3634# containers/
@@ -49,18 +47,8 @@ for to_arch in $to_archs; do
4947 if [ " $from_arch " != " $to_arch " ]; then
5048 work_dir=" ${out_dir} /${from_arch} _qemu-${to_arch} "
5149 mkdir -p " ${work_dir} "
52- tar_gz_url=" https://github.com/${REPO} /releases/download/v${VERSION} /${from_arch} _qemu-${to_arch} -static.tar.gz"
53- http_status=" $( curl -s -o /dev/null -w " %{http_code}" " ${tar_gz_url} " ) "
54- if [ " ${http_status} " = 404 ]; then
55- echo " URL not found: ${tar_gz_url} " 1>&2
56- exit 1
57- fi
58- curl -sSL -o " ${work_dir} /${from_arch} _qemu-${to_arch} -static.tar.gz" " ${tar_gz_url} "
59- tar xzvf " ${work_dir} /${from_arch} _qemu-${to_arch} -static.tar.gz" -C " ${work_dir} "
60- rm -f " ${work_dir} /${from_arch} _qemu-${to_arch} -static.tar.gz"
61-
50+ cp -p " releases/usr/bin/qemu-${to_arch} -static" ${work_dir}
6251 cp -p " ${work_dir} /qemu-${to_arch} -static" " ${out_dir} /latest/"
63-
6452 cat > ${work_dir} /Dockerfile -<< EOF
6553FROM scratch
6654COPY qemu-${to_arch} -static /usr/bin/
6957 for target in " ${DOCKER_REPO} :$from_arch -$to_arch " \
7058 " ${DOCKER_REPO} :$to_arch -${TAG_VER} " \
7159 " ${DOCKER_REPO} :$to_arch " ; do
72- docker tag ${DOCKER_REPO} :$from_arch -$to_arch -${TAG_VER} " ${target} "
60+ docker tag ${DOCKER_REPO} :$from_arch -$to_arch -${TAG_VER} ${target}
7361 done
7462 rm -rf " ${work_dir} "
7563 fi
7664done
7765
78- docker build -t ${DOCKER_REPO} :${TAG_VER} " ${out_dir} /latest"
66+ docker build -t ${DOCKER_REPO} :${TAG_VER} ${out_dir} /latest
7967docker tag ${DOCKER_REPO} :${TAG_VER} ${DOCKER_REPO} :latest
80- docker build -t ${DOCKER_REPO} :register " ${out_dir} /register"
68+ docker build -t ${DOCKER_REPO} :register ${out_dir} /register
0 commit comments