Skip to content

Commit

Permalink
build specific box64 for devices + qemu-static from source
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol authored Jul 3, 2024
1 parent 5605f0e commit dba039f
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 43 deletions.
87 changes: 67 additions & 20 deletions bookworm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,55 @@ ENV DEBIAN_FRONTEND noninteractive
# Set SHELL option explicitly
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# hadolint ignore=DL3008
RUN set -x \
# Install, update & upgrade packages
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
qemu-user-static=1:7.2+dfsg-7+deb12u6 \
&& rm -rf /var/lib/apt/lists/*
&& -y --no-install-recommends --no-install-suggests \
git \
libglib2.0-dev \
libfdt-dev \
libpixman-1-dev \
zlib1g-dev \
ninja-build \
build-essential \
python3-venv \
flex \
bison \
libaio-dev \
libattr1-dev \
libbrlapi-dev \
libcacard-dev \
libcap-ng-dev \
libgcrypt20-dev \
libgnutls28-dev \
libgtk-3-dev \
libiscsi-dev \
liblttng-ust-dev \
libncurses5-dev \
libnfs-dev \
libpng-dev \
librados-dev \
libsdl2-dev \
libseccomp-dev \
liburcu-dev \
libusb-1.0-0-dev \
libvdeplug-dev \
libvte-2.91-dev \
&& rm -rf /var/lib/apt/lists/* \
&& git clone https://gitlab.com/qemu-project/qemu.git \
&& cd qemu \
&& git checkout master -b stable-9.0 \
&& git submodule update --init --recursive \
&& ./configure \
--prefix=/build/qemu-user-static \
--static \
--disable-system \
&& make -j$(nproc)

############################################################

FROM arm64v8/python:slim-bookworm as box64_8k_build
FROM arm64v8/python:slim-bookworm as box64_m1

ENV DEBIAN_FRONTEND noninteractive

Expand All @@ -28,16 +67,17 @@ RUN set -x \
ca-certificates=20230311 \
build-essential=12.9 \
cmake=3.25.1-1 \
mold=1.10.1+dfsg-1 \
&& git clone https://github.com/ptitSeb/box64.git \
&& mkdir /box64/build \
&& cd /box64/build \
&& cmake .. -DARM_DYNAREC=ON -DPAGE8K=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
&& make -j$(nproc) \
&& cmake .. -D M1=1 -D CMAKE_BUILD_TYPE=RelWithDebInfo -D WITH_MOLD=1 \
&& mold -run make -j$(nproc) \
&& make install DESTDIR=/tmp/install

############################################################

FROM arm64v8/python:slim-bookworm as box64_16k_build
FROM arm64v8/python:slim-bookworm as box64_rpi5

ENV DEBIAN_FRONTEND noninteractive

Expand All @@ -51,16 +91,17 @@ RUN set -x \
ca-certificates=20230311 \
build-essential=12.9 \
cmake=3.25.1-1 \
mold=1.10.1+dfsg-1 \
&& git clone https://github.com/ptitSeb/box64.git \
&& mkdir /box64/build \
&& cd /box64/build \
&& cmake .. -DARM_DYNAREC=ON -DPAGE16K=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
&& make -j$(nproc) \
&& cmake .. -D RPI5ARM64=1 -D CMAKE_BUILD_TYPE=RelWithDebInfo -D WITH_MOLD=1 \
&& mold -run make -j$(nproc) \
&& make install DESTDIR=/tmp/install

############################################################

FROM arm64v8/python:slim-bookworm as box64_64k_build
FROM arm64v8/python:slim-bookworm as box64_adlink

ENV DEBIAN_FRONTEND noninteractive

Expand All @@ -70,15 +111,16 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
git=1:2.39.2-1.1 \
git=1:2.39.2-1.1 \
ca-certificates=20230311 \
build-essential=12.9 \
cmake=3.25.1-1 \
build-essential=12.9 \
cmake=3.25.1-1 \
mold=1.10.1+dfsg-1 \
&& git clone https://github.com/ptitSeb/box64.git \
&& mkdir /box64/build \
&& mkdir /box64/build \
&& cd /box64/build \
&& cmake .. -DARM_DYNAREC=ON -DPAGE64K=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
&& make -j$(nproc) \
&& cmake .. -D ADLINK=1 -D CMAKE_BUILD_TYPE=RelWithDebInfo -D WITH_MOLD=1 \
&& mold -run make -j$(nproc) \
&& make install DESTDIR=/tmp/install

############################################################
Expand All @@ -102,9 +144,9 @@ ENV DEBUGGER "/usr/local/bin/box86"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

COPY --from=qemu_build /usr/bin/qemu-i386-static /usr/bin/qemu-i386-static
COPY --from=box64_8k_build /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-8k
COPY --from=box64_16k_build /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-16k
COPY --from=box64_64k_build /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-64k
COPY --from=box64_m1 /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-m1
COPY --from=box64_rpi5 /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-rpi5
COPY --from=box64_adlink /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-adlink

# hadolint ignore=DL3008
RUN set -x \
Expand All @@ -114,6 +156,7 @@ RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
libc6:i386=2.36-9+deb12u7 \
libstdc++6:i386=12.2.0-14 \
libc6:armhf=2.36-9+deb12u7 \
libstdc++6:armhf=12.2.0-14 \
ca-certificates=20230311 \
Expand Down Expand Up @@ -150,7 +193,11 @@ RUN set -x \
# Symlink steamclient.so; So misconfigured dedicated servers can find it
&& mkdir -p /usr/lib/x86_64-linux-gnu \
&& ln -s "${STEAMCMDDIR}/linux64/steamclient.so" "/usr/lib/x86_64-linux-gnu/steamclient.so" \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& mv /usr/local/bin/box64 /usr/local/bin/box64-generic

COPY box64.sh /usr/local/bin/box64
RUN chmod +x /usr/local/bin/box64

FROM build_stage AS bookworm-root
WORKDIR ${STEAMCMDDIR}
Expand Down
30 changes: 30 additions & 0 deletions bookworm/box64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

if [[ -z "$ARM64_DEVICE" ]]; then
echo "ARM64_DEVICE environment variable is not set, using generic Box64 build."
fi

# Define the path to binaries based on the ARM64_DEVICE environment variable
case $ARM64_DEVICE in
rpi5)
BINARY_PATH="/usr/local/bin/box64-rpi5"
;;
m1)
BINARY_PATH="/usr/local/bin/box64-m1"
;;
adlink)
BINARY_PATH="/usr/local/bin/box64-adlink"
;;
*)
BINARY_PATH="/usr/local/bin/box64-generic"
;;
esac

# Check if the box64 exists
if [[ ! -f $BINARY_PATH ]]; then
echo "Error: Box64 file '$BINARY_PATH' not found for architecture '$ARM64_DEVICE'."
exit 1
fi

# Pass all arguments to box64
"$BINARY_PATH" "$@"
90 changes: 67 additions & 23 deletions bullseye/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,55 @@ ENV DEBIAN_FRONTEND noninteractive
# Set SHELL option explicitly
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# hadolint ignore=DL3008
RUN set -x \
# Install, update & upgrade packages
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
qemu-user-static=1:5.2+dfsg-11+deb11u3 \
&& rm -rf /var/lib/apt/lists/*
&& -y --no-install-recommends --no-install-suggests \
git \
libglib2.0-dev \
libfdt-dev \
libpixman-1-dev \
zlib1g-dev \
ninja-build \
build-essential \
python3-venv \
flex \
bison \
libaio-dev \
libattr1-dev \
libbrlapi-dev \
libcacard-dev \
libcap-ng-dev \
libgcrypt20-dev \
libgnutls28-dev \
libgtk-3-dev \
libiscsi-dev \
liblttng-ust-dev \
libncurses5-dev \
libnfs-dev \
libpng-dev \
librados-dev \
libsdl2-dev \
libseccomp-dev \
liburcu-dev \
libusb-1.0-0-dev \
libvdeplug-dev \
libvte-2.91-dev \
&& rm -rf /var/lib/apt/lists/* \
&& git clone https://gitlab.com/qemu-project/qemu.git \
&& cd qemu \
&& git checkout master -b stable-9.0 \
&& git submodule update --init --recursive \
&& ./configure \
--prefix=/build/qemu-user-static \
--static \
--disable-system \
&& make -j$(nproc)

############################################################

FROM arm64v8/python:slim-bullseye as box64_8k_build
FROM arm64v8/python:slim-bullseye as box64_m1

ENV DEBIAN_FRONTEND noninteractive

Expand All @@ -23,21 +62,21 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
&& -y --no-install-recommends --no-install-suggests \
git=1:2.30.2-1+deb11u2 \
ca-certificates=20210119 \
build-essential=12.9 \
cmake=3.18.4-2+deb11u1 \
&& git clone https://github.com/ptitSeb/box64.git \
&& mkdir /box64/build \
&& cd /box64/build \
&& cmake .. -DARM_DYNAREC=ON -DPAGE8K=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
&& cmake .. -D M1=1 -D CMAKE_BUILD_TYPE=RelWithDebInfo \
&& make -j$(nproc) \
&& make install DESTDIR=/tmp/install

############################################################

FROM arm64v8/python:slim-bullseye as box64_16k_build
FROM arm64v8/python:slim-bullseye as box64_rpi5

ENV DEBIAN_FRONTEND noninteractive

Expand All @@ -46,21 +85,21 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
&& -y --no-install-recommends --no-install-suggests \
git=1:2.30.2-1+deb11u2 \
ca-certificates=20210119 \
build-essential=12.9 \
cmake=3.18.4-2+deb11u1 \
&& git clone https://github.com/ptitSeb/box64.git \
&& mkdir /box64/build \
&& cd /box64/build \
&& cmake .. -DARM_DYNAREC=ON -DPAGE16K=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
&& cmake .. -D RPI5ARM64=1 -D CMAKE_BUILD_TYPE=RelWithDebInfo \
&& make -j$(nproc) \
&& make install DESTDIR=/tmp/install

############################################################

FROM arm64v8/python:slim-bullseye as box64_64k_build
FROM arm64v8/python:slim-bullseye as box64_adlink

ENV DEBIAN_FRONTEND noninteractive

Expand All @@ -69,15 +108,15 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
git=1:2.30.2-1+deb11u2 \
&& -y --no-install-recommends --no-install-suggests \
git=1:2.30.2-1+deb11u2 \
ca-certificates=20210119 \
build-essential=12.9 \
cmake=3.18.4-2+deb11u1 \
build-essential=12.9 \
cmake=3.18.4-2+deb11u1 \
&& git clone https://github.com/ptitSeb/box64.git \
&& mkdir /box64/build \
&& mkdir /box64/build \
&& cd /box64/build \
&& cmake .. -DARM_DYNAREC=ON -DPAGE64K=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
&& cmake .. -D ADLINK=1 -D CMAKE_BUILD_TYPE=RelWithDebInfo \
&& make -j$(nproc) \
&& make install DESTDIR=/tmp/install

Expand All @@ -101,19 +140,20 @@ ENV DEBUGGER "/usr/local/bin/box86"
# Set SHELL option explicitly
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

COPY --from=qemu_build /usr/bin/qemu-i386-static /usr/bin/qemu-i386-static
COPY --from=box64_8k_build /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-8k
COPY --from=box64_16k_build /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-16k
COPY --from=box64_64k_build /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-64k
COPY --from=qemu_build /build/qemu-user-static/bin/qemu-i386 /usr/bin/qemu-i386-static
COPY --from=box64_m1 /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-m1
COPY --from=box64_rpi5 /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-rpi5
COPY --from=box64_adlink /tmp/install/usr/local/bin/box64 /usr/local/bin/box64-adlink

# hadolint ignore=DL3008
RUN set -x \
# Install, update & upgrade packages
&& dpkg --add-architecture armhf \
&& dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
&& -y --no-install-recommends --no-install-suggests \
libc6:i386=2.31-13+deb11u10 \
libstdc++6:i386=10.2.1-6 \
libc6:armhf=2.31-13+deb11u10 \
libstdc++6:armhf=10.2.1-6 \
ca-certificates=20210119 \
Expand All @@ -127,7 +167,7 @@ RUN set -x \
&& wget --progress=dot:giga https://ryanfortner.github.io/box86-debs/box86.list -O /etc/apt/sources.list.d/box86.list \
&& (wget -qO- https://ryanfortner.github.io/box86-debs/KEY.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/box86-debs-archive-keyring.gpg) \
&& apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
&& -y --no-install-recommends --no-install-suggests \
box64 \
box86-generic-arm \
&& sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
Expand All @@ -150,7 +190,11 @@ RUN set -x \
# Symlink steamclient.so; So misconfigured dedicated servers can find it
&& mkdir -p /usr/lib/x86_64-linux-gnu \
&& ln -s "${STEAMCMDDIR}/linux64/steamclient.so" "/usr/lib/x86_64-linux-gnu/steamclient.so" \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& mv /usr/local/bin/box64 /usr/local/bin/box64-generic

COPY box64.sh /usr/local/bin/box64
RUN chmod +x /usr/local/bin/box64

FROM build_stage AS bullseye-root
WORKDIR ${STEAMCMDDIR}
Expand Down
Loading

0 comments on commit dba039f

Please sign in to comment.