diff --git a/kotlin-native/tools/qemu/Dockerfile b/kotlin-native/tools/qemu/Dockerfile new file mode 100644 index 00000000000..751a646274f --- /dev/null +++ b/kotlin-native/tools/qemu/Dockerfile @@ -0,0 +1,20 @@ +FROM ubuntu:20.04 + +ENV TZ=Europe/Moscow +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y build-essential git gcc pkg-config glib-2.0 libglib2.0-dev libsdl1.2-dev libaio-dev libcap-dev libattr1-dev libpixman-1-dev + +RUN git clone --branch v5.1.0 --depth 1 git://git.qemu.org/qemu.git && \ + cd qemu && \ + git checkout d0ed6a69d399ae193959225cdeaa9382746c91cc && \ + git submodule update --init --recursive + +WORKDIR /qemu + +COPY build.sh . + +ENV OUTPUT_DIR="/output" + +ENTRYPOINT "/bin/bash" "build.sh" ${OUTPUT_DIR} \ No newline at end of file diff --git a/kotlin-native/tools/qemu/build.sh b/kotlin-native/tools/qemu/build.sh new file mode 100644 index 00000000000..3b365bacde8 --- /dev/null +++ b/kotlin-native/tools/qemu/build.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -eou pipefail + +INSTALL_PATH=$1 +QEMU_VERSION=5.1.0 +DEPENDENCY_VERSION=2 + +function build_qemu() { + mkdir build + ./configure \ + --prefix="$PWD/build" \ + --static \ + --disable-debug-info \ + --disable-werror \ + --disable-system \ + --enable-linux-user \ + + make -j"$(nproc)" + make install +} + +function build_archives() { + cd build/bin + for f in qemu-* ; do + DEPENDENCY_NAME="$f-static-$QEMU_VERSION-linux-$DEPENDENCY_VERSION" + mkdir -p $DEPENDENCY_NAME + mv $f $DEPENDENCY_NAME/$f + tar -czvf $INSTALL_PATH/"$DEPENDENCY_NAME.tar.gz" "$DEPENDENCY_NAME" + done +} + +build_qemu +build_archives \ No newline at end of file diff --git a/kotlin-native/tools/qemu/create_image.sh b/kotlin-native/tools/qemu/create_image.sh new file mode 100755 index 00000000000..f4cf94f9bf2 --- /dev/null +++ b/kotlin-native/tools/qemu/create_image.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +docker build -t kotlin-qemu-builder . \ No newline at end of file diff --git a/kotlin-native/tools/qemu/run_container.sh b/kotlin-native/tools/qemu/run_container.sh new file mode 100755 index 00000000000..f7818edebfc --- /dev/null +++ b/kotlin-native/tools/qemu/run_container.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eou pipefail + +CONTAINER_NAME=kotlin-qemu-builder +IMAGE_NAME=kotlin-qemu-builder + + +docker ps -a | grep $CONTAINER_NAME > /dev/null \ + && docker stop $CONTAINER_NAME 1> /dev/null \ + && docker rm $CONTAINER_NAME 1> /dev/null + +docker run -it -v "$PWD"/out:/output --name=$CONTAINER_NAME $IMAGE_NAME