@@ -19,47 +19,51 @@ shift $((OPTIND-1))
1919
2020[ " $1 " = " --" ] && shift
2121
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-
30- from_arch=" x86_64"
31- to_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-
3322# Build container images creating the directory.
3423# containers/
3524# latest/ - An image including /usr/bin/qemu-$arch-status and /register script.
3625# ${from_arch}_qemu-${to_arch}/ - Images including /usr/bin/qemu-$arch-status
3726# register/ - An image including /register script.
27+
28+ from_arch=" x86_64"
29+ root_dir=$( pwd)
3830out_dir=" containers"
31+ releases_dir=" releases/usr/bin/"
32+
33+ cd ${releases_dir}
34+ for file in * ; do
35+ tar -czf $file .tar.gz $file ;
36+ mv $file .tar.gz x86_64_$file .tar.gz
37+ done
38+ cd ${root_dir}
3939
4040# Generate register files.
4141cp -p " ${out_dir} /latest/register.sh" " ${out_dir} /register/"
4242cp -p " ${out_dir} /latest/Dockerfile" " ${out_dir} /register/"
4343# Comment out the line to copy qemu-*-static not to provide those.
4444sed -i ' /^COPY qemu/ s/^/#/' " ${out_dir} /register/Dockerfile"
4545
46- for to_arch in $to_archs ; do
47- if [ " $from_arch " != " $to_arch " ]; then
48- work_dir=" ${out_dir} /${from_arch} _qemu-${to_arch} "
49- mkdir -p " ${work_dir} "
50- cp -p " releases/usr/bin/qemu-${to_arch} -static" ${work_dir}
51- cp -p " ${work_dir} /qemu-${to_arch} -static" " ${out_dir} /latest/"
52- cat > ${work_dir} /Dockerfile -<< EOF
46+ for file in ${releases_dir} *
47+ do
48+ if [[ $file =~ qemu-(.+)-static ]]; then
49+ to_arch=${BASH_REMATCH[1]}
50+ if [ " $from_arch " != " $to_arch " ]; then
51+ work_dir=" ${out_dir} /${from_arch} _qemu-${to_arch} "
52+ mkdir -p " ${work_dir} "
53+ cp -p " ${releases_dir} qemu-${to_arch} -static" ${work_dir}
54+ cp -p " ${work_dir} /qemu-${to_arch} -static" " ${out_dir} /latest/"
55+ cat > ${work_dir} /Dockerfile -<< EOF
5356FROM scratch
5457COPY qemu-${to_arch} -static /usr/bin/
5558EOF
56- docker build -t ${DOCKER_REPO} :$from_arch -$to_arch -${TAG_VER} ${work_dir}
57- for target in " ${DOCKER_REPO} :$from_arch -$to_arch " \
58- " ${DOCKER_REPO} :$to_arch -${TAG_VER} " \
59- " ${DOCKER_REPO} :$to_arch " ; do
60- docker tag ${DOCKER_REPO} :$from_arch -$to_arch -${TAG_VER} ${target}
61- done
62- rm -rf " ${work_dir} "
59+ docker build -t ${DOCKER_REPO} :$from_arch -$to_arch -${TAG_VER} ${work_dir}
60+ for target in " ${DOCKER_REPO} :$from_arch -$to_arch " \
61+ " ${DOCKER_REPO} :$to_arch -${TAG_VER} " \
62+ " ${DOCKER_REPO} :$to_arch " ; do
63+ docker tag ${DOCKER_REPO} :$from_arch -$to_arch -${TAG_VER} ${target}
64+ done
65+ rm -rf " ${work_dir} "
66+ fi
6367 fi
6468done
6569
0 commit comments