FROM phusion/baseimage:0.11

RUN DEBIAN_FRONTEND=noninteractive apt-get update -q -y && apt-get upgrade -q -y
RUN DEBIAN_FRONTEND=noninteractive apt-get -q -y install net-tools openssh-client build-essential \
    git autoconf libtool pkg-config flex bison apt-utils python-minimal zlib1g-dev libglib2.0-dev \
    libpixman-1-dev libsdl2-dev libx11-6

ADD patches/qemu.patch /root/qemu.patch

# libosmocore
RUN cd /root && git clone https://github.com/qemu/qemu.git \
    && cd qemu \
    && git checkout 38441756b70eec5807b5f60dad11a93a91199866 \
    && git submodule update --init \
    && patch -p1 < /root/qemu.patch \
    && ./configure --disable-werror --target-list=arm-softmmu --enable-sdl \
    && make \
    && make install \
    && cd ..

ADD image /image

ADD misc/runqemu.sh /runqemu.sh
RUN chmod 755 /runqemu.sh

CMD ["/runqemu.sh"]
