mirror of
https://github.com/commaai/agnos-builder.git
synced 2026-07-09 16:52:05 +08:00
226 lines
8.2 KiB
Docker
226 lines
8.2 KiB
Docker
# check=error=true
|
|
|
|
# ################## #
|
|
# ###### Base ###### #
|
|
# ################## #
|
|
FROM scratch AS agnos-base
|
|
ADD ubuntu-base-24.04-base-arm64.tar.gz /
|
|
|
|
# Build folder
|
|
RUN mkdir -p /tmp/agnos
|
|
|
|
# Stop on error
|
|
RUN set -xe
|
|
|
|
ARG USERNAME=comma
|
|
|
|
# Base system setup
|
|
RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections
|
|
COPY ./userspace/base_setup.sh /tmp/agnos
|
|
RUN /tmp/agnos/base_setup.sh
|
|
|
|
# Install openpilot dependencies
|
|
COPY ./userspace/openpilot_dependencies.sh /tmp/agnos/
|
|
RUN /tmp/agnos/openpilot_dependencies.sh
|
|
COPY ./userspace/openpilot_python_dependencies.sh /tmp/agnos/
|
|
RUN /tmp/agnos/openpilot_python_dependencies.sh
|
|
|
|
# Install old Qt 5.12.8, libwayland 1.9.0-1 and deps
|
|
COPY ./userspace/qtwayland/*.deb /tmp/agnos/
|
|
RUN apt-get -o Dpkg::Options::="--force-overwrite" install -yq \
|
|
/tmp/agnos/qt-5.12.8.deb \
|
|
/tmp/agnos/libwayland-1.9.0-1.deb \
|
|
/tmp/agnos/libicu66_66.1-2ubuntu2.1_arm64.deb \
|
|
/tmp/agnos/libssl1.1_1.1.1f-1ubuntu2.22_arm64.deb \
|
|
/tmp/agnos/libffi6_3.2.1-8_arm64.deb
|
|
|
|
# ################## #
|
|
# #### Compiler #### #
|
|
# ################## #
|
|
FROM agnos-base AS agnos-compiler
|
|
|
|
RUN apt-fast update && apt-fast install --no-install-recommends -yq checkinstall
|
|
|
|
# Individual compiling images
|
|
FROM agnos-compiler AS agnos-compiler-pyqt5
|
|
COPY ./userspace/compile-pyqt5.sh /tmp/agnos/
|
|
RUN /tmp/agnos/compile-pyqt5.sh
|
|
|
|
FROM agnos-compiler AS agnos-compiler-capnp
|
|
COPY ./userspace/compile-capnp.sh /tmp/agnos/
|
|
RUN /tmp/agnos/compile-capnp.sh
|
|
|
|
FROM agnos-compiler AS agnos-compiler-ffmpeg
|
|
COPY ./userspace/compile-ffmpeg.sh /tmp/agnos/
|
|
RUN /tmp/agnos/compile-ffmpeg.sh
|
|
|
|
FROM agnos-compiler AS agnos-compiler-qtwayland5
|
|
COPY ./userspace/compile-qtwayland5.sh /tmp/agnos/
|
|
COPY ./userspace/qtwayland/patch* /tmp/agnos/
|
|
RUN /tmp/agnos/compile-qtwayland5.sh
|
|
|
|
# ################### #
|
|
# ###### AGNOS ###### #
|
|
# ################### #
|
|
FROM agnos-base
|
|
|
|
# Hardware setup
|
|
RUN mkdir -p /tmp/agnos/debs
|
|
COPY ./userspace/debs /tmp/agnos/debs
|
|
COPY ./userspace/hardware_setup.sh /tmp/agnos
|
|
RUN /tmp/agnos/hardware_setup.sh
|
|
RUN mv /data/persist /system/ && rm -rf /data/*
|
|
|
|
# Build ModemManager
|
|
COPY ./userspace/compile-modemmanager.sh /tmp/agnos/
|
|
RUN /tmp/agnos/compile-modemmanager.sh
|
|
|
|
# Pre-compiled capnp (must be before python install)
|
|
COPY --from=agnos-compiler-capnp /tmp/capnproto.deb /tmp/capnproto.deb
|
|
RUN cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq ./capnproto.deb
|
|
|
|
# Use other pre-compiled packages
|
|
COPY --from=agnos-compiler-ffmpeg /tmp/ffmpeg.deb /tmp/ffmpeg.deb
|
|
RUN cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq ./ffmpeg.deb
|
|
|
|
# Use pre-compiled PyQt5 wheel
|
|
COPY --from=agnos-compiler-pyqt5 /tmp/PyQt5-5.15.9/PyQt5-5.15.9-cp38-abi3-manylinux_2_17_aarch64.whl /tmp/PyQt5-5.15.9-cp38-abi3-manylinux_2_17_aarch64.whl
|
|
|
|
RUN export PATH="/usr/local/pyenv/bin:/usr/local/pyenv/shims:$PATH" && \
|
|
export PYENV_ROOT="/usr/local/pyenv" && \
|
|
eval "$(pyenv init -)" && \
|
|
eval "$(pyenv virtualenv-init -)" && \
|
|
export MAKEFLAGS="-j$(nproc)" && \
|
|
pip install pyqt5-sip==12.12.1 && \
|
|
pip install /tmp/PyQt5-5.15.9-cp38-abi3-manylinux_2_17_aarch64.whl --verbose --config-settings --confirm-license= && \
|
|
pyenv rehash
|
|
|
|
# Install openpilot python packages
|
|
RUN mkdir -p /tmp/agnos/uv
|
|
COPY ./userspace/pyproject.toml ./userspace/uv.lock /tmp/agnos/uv
|
|
RUN export PATH="/usr/local/pyenv/bin:/usr/local/pyenv/shims:$PATH" && \
|
|
export PYENV_ROOT="/usr/local/pyenv" && \
|
|
eval "$(pyenv init -)" && \
|
|
eval "$(pyenv virtualenv-init -)" && \
|
|
cd /tmp/agnos/uv && \
|
|
export PYOPENCL_CL_PRETEND_VERSION="2.0" && \
|
|
MAKEFLAGS="-j$(nproc)" UV_NO_CACHE=1 uv pip install --no-cache-dir --system . && \
|
|
pyenv rehash
|
|
|
|
# Install nice to haves
|
|
COPY ./userspace/install_extras.sh /tmp/agnos/
|
|
RUN /tmp/agnos/install_extras.sh
|
|
|
|
COPY --from=agnos-compiler-qtwayland5 /tmp/qtwayland5.deb /tmp/qtwayland5.deb
|
|
RUN cd /tmp && apt-get -o Dpkg::Options::="--force-overwrite" install -yq --allow-downgrades ./qtwayland5.deb
|
|
|
|
# Patched libeglSubDriverWayland with fixed nullptr deref in CommitBuffer
|
|
COPY ./userspace/files/libeglSubDriverWayland.so.patched /lib/aarch64-linux-gnu/libeglSubDriverWayland.so
|
|
|
|
COPY ./userspace/home/ /home/$USERNAME/
|
|
COPY ./userspace/home/.config/ /root/.config
|
|
RUN chown -R $USERNAME: /home/$USERNAME/.config
|
|
|
|
# populate /lib
|
|
COPY ./userspace/files/*.path /lib/systemd/system/
|
|
COPY ./userspace/files/*.mount /lib/systemd/system/
|
|
COPY ./userspace/files/*.service /lib/systemd/system/
|
|
COPY ./userspace/files/*.timer /lib/systemd/system/
|
|
COPY ./userspace/files/serial-getty@ttyMSM0_override.conf /lib/systemd/system/serial-getty@ttyMSM0.service.d/serial-getty@ttyMSM0_override.conf
|
|
COPY ./userspace/files/ssh_override.conf /lib/systemd/system/ssh.service.d/override.conf
|
|
COPY ./userspace/firmware/* /lib/firmware/
|
|
|
|
# populate /etc
|
|
COPY ./userspace/files/fstab /etc
|
|
COPY ./userspace/files/profile /etc/profile
|
|
COPY ./userspace/files/ethernet.yaml /etc/netplan/
|
|
COPY ./userspace/files/allow-network-control.pkla /etc/polkit-1/localauthority/50-local.d/allow-network-control.pkla
|
|
COPY ./userspace/files/allow-modem-control.pkla /etc/polkit-1/localauthority/50-local.d/allow-modem-control.pkla
|
|
COPY ./userspace/files/*.rules /etc/udev/rules.d/
|
|
COPY ./userspace/files/ssh*_config /etc/ssh/
|
|
COPY ./userspace/files/logrotate.conf /etc/
|
|
RUN chmod 644 /etc/logrotate.conf
|
|
|
|
# populate /usr
|
|
COPY ./userspace/usr/comma/ /usr/$USERNAME/
|
|
COPY ./userspace/usr/share/fonts/* /usr/share/fonts/
|
|
COPY ./userspace/libs/* /usr/lib/aarch64-linux-gnu/
|
|
COPY ./userspace/libs32/* /usr/lib/arm-linux-gnueabihf/
|
|
|
|
# kernel headers for the AGNOS kernel (built on device)
|
|
COPY ./userspace/files/linux-headers-4.9.103+_4.9.103+-1_arm64.deb /tmp/
|
|
RUN dpkg -i /tmp/linux-headers-4.9.103+_4.9.103+-1_arm64.deb
|
|
|
|
# Weston with hacked touch rotate and color correction
|
|
COPY ./userspace/files/weston /usr/bin/weston
|
|
COPY ./userspace/files/gl-renderer.so /usr/lib/arm-linux-gnueabihf/weston
|
|
|
|
# Setup systemd services
|
|
COPY ./userspace/services.sh /tmp/agnos
|
|
RUN /tmp/agnos/services.sh
|
|
|
|
# MOTD
|
|
RUN rm -r /etc/update-motd.d/*
|
|
COPY --chown=root:root ./userspace/motd/* /etc/update-motd.d/
|
|
|
|
# Let NetworkManager manage eth0
|
|
COPY ./userspace/files/10-globally-managed-devices.conf /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
|
|
COPY ./userspace/files/NetworkManager.conf /etc/NetworkManager/NetworkManager.conf
|
|
|
|
# Add cellular connections
|
|
COPY ./userspace/files/*.nmconnection /usr/lib/NetworkManager/system-connections/
|
|
RUN chmod 600 /usr/lib/NetworkManager/system-connections/*.nmconnection
|
|
|
|
# Prefer ipv4 over ipv6
|
|
RUN echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf
|
|
|
|
# Don't let logind delete /dev/shm
|
|
COPY ./userspace/files/logind.conf /etc/systemd/logind.conf
|
|
|
|
# Remove qt network bearer plugins
|
|
RUN rm -rf /usr/lib/aarch64-linux-gnu/qt5/plugins/bearer
|
|
|
|
# Add iptable rules to block incoming traffic on wwan0
|
|
COPY ./userspace/etc/iptables/rules.v4 /etc/iptables/rules.v4
|
|
|
|
# Run ModemManager in debug mode to allow AT commands
|
|
COPY ./userspace/files/ModemManager.service /lib/systemd/system/
|
|
RUN systemctl enable ModemManager
|
|
|
|
# Add more T-Mobile networks to mobile-broadband-provider-info (do we still need the package?)
|
|
COPY ./userspace/files/serviceproviders.xml /usr/share/mobile-broadband-provider-info/serviceproviders.xml
|
|
|
|
# Setup hostname resolution for our custom hostname
|
|
RUN sed -i 's/hosts: files dns myhostname/hosts: files myhostname dns/g' /etc/nsswitch.conf
|
|
|
|
# TODO: move this to base_setup.sh or build gcc from source
|
|
# Remove unused architectures from arm-none-eabi
|
|
RUN cd /usr/lib/gcc/arm-none-eabi/* && \
|
|
rm -rf arm/ && \
|
|
rm -rf thumb/nofp thumb/v6* thumb/v8* thumb/v7+fp thumb/v7-r+fp.sp
|
|
|
|
# keep this last
|
|
RUN ldconfig
|
|
|
|
# Setup RO rootfs
|
|
RUN mkdir -p /tmptmp
|
|
COPY ./userspace/files/comma.conf /usr/lib/tmpfiles.d/
|
|
COPY ./userspace/readonly_setup.sh /tmptmp/readonly_setup.sh
|
|
RUN /tmptmp/readonly_setup.sh && rm -rf /tmptmp
|
|
|
|
# copy at the end, after all apt usage
|
|
COPY ./userspace/files/apt.conf /etc/apt/apt.conf
|
|
|
|
# copy version file
|
|
COPY VERSION /VERSION
|
|
|
|
# ################## #
|
|
# #### Cleaunup #### #
|
|
# ################## #
|
|
|
|
RUN rm -rf /usr/share/icons/* && \
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
rm -rf /home/$USERNAME/.cache && \
|
|
rm -rf /root/.cache && \
|
|
apt-get clean
|