Dockerfiles/raspberrypi.dockerfile

102 lines
4.7 KiB
Plaintext
Raw Permalink Normal View History

2022-12-29 19:45:59 +08:00
FROM ubuntu:22.04
LABEL maintainer 168062547@qq.com
ENV DEBIAN_FRONTEND=noninteractive
ARG PI_ADDRESS
RUN sed -i "s@http://.*archive.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list && \
sed -i "s@http://.*security.ubuntu.com@http://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list && \
apt-get update && \
apt-get install -y wget rsync openssh-client xz-utils cmake ninja-build pkg-config file gcc g++ python3
WORKDIR /opt/RaspberryPi
RUN mkdir -p sysroot sysroot/usr sysroot/opt && \
mkdir -p -m 0700 ~/.ssh && ssh-keyscan $PI_ADDRESS >> ~/.ssh/known_hosts
RUN --mount=type=ssh \
ssh pi@$PI_ADDRESS sudo apt install libalsa-ocaml-dev libffmpeg-ocaml-dev libcurl4-openssl-dev libssl-dev liblzma-dev libx264-dev && \
rsync -avz --ignore-errors pi@$PI_ADDRESS:/lib sysroot && \
rsync -avz --ignore-errors pi@$PI_ADDRESS:/usr/include sysroot/usr && \
rsync -avz --ignore-errors --exclude lib/chromium-browser --exclude lib/libreoffice --exclude lib/scratch3 \
2022-12-30 18:31:57 +08:00
--exclude lib/debug --exclude lib/arm-linux-gnueabihf/dri \
--exclude lib/kernel --exclude lib/firmware --exclude lib/modules \
--exclude lib/ruby --exclude lib/pypy --exclude lib/python2.7 --exclude lib/python3 --exclude lib/python3.9 \
pi@$PI_ADDRESS:/usr/lib sysroot/usr ;exit 0
2022-12-29 19:45:59 +08:00
ADD resources/sysroot-relativelinks.py resources/raspberrypi.cmake /opt/RaspberryPi/
RUN ./sysroot-relativelinks.py sysroot
WORKDIR /opt/RaspberryPi/sysroot/usr/lib
RUN ln -s arm-linux-gnueabihf/crt1.o crt1.o && \
ln -s arm-linux-gnueabihf/crti.o crti.o && \
ln -s arm-linux-gnueabihf/crtn.o crtn.o && \
ln -s arm-linux-gnueabihf/libc.a libc.a && \
ln -s arm-linux-gnueabihf/libc.so.6 libc.so.6 && \
ln -s arm-linux-gnueabihf/libpthread.a libpthread.a && \
ln -s arm-linux-gnueabihf/libm.a libm.a && \
ln -s arm-linux-gnueabihf/libdl.a libdl.a && \
ln -sb blas/libblas.so.3 arm-linux-gnueabihf/libblas.so.3 && \
ln -sb lapack/liblapack.so.3 arm-linux-gnueabihf/liblapack.so.3
WORKDIR /home/temp
RUN wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz && \
wget https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz && \
wget https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz && \
wget https://github.com/tfussell/xlnt/archive/refs/tags/v1.5.0.tar.gz -O xlnt-1.5.0.tar.gz
RUN tar xvf gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz -C /opt && \
tar xvf boost_1_81_0.tar.gz && \
tar xvf zeromq-4.3.4.tar.gz && \
tar xvf xlnt-1.5.0.tar.gz
WORKDIR /home/temp/boost_1_81_0
RUN ./bootstrap.sh --prefix=/opt/RaspberryPi/boost_1_81_0
RUN sed -i -e "s/using gcc ;/using gcc : : \/opt\/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf\/bin\/arm-none-linux-gnueabihf-gcc ;/g" project-config.jam
RUN ./b2 install -q --prefix=/opt/RaspberryPi/boost_1_81_0 link=shared threading=multi runtime-link=shared variant=release cxxstd=17
WORKDIR /home/temp/zeromq-4.3.4/build
RUN cmake \
-G Ninja \
-DCMAKE_TOOLCHAIN_FILE=/opt/RaspberryPi/raspberrypi.cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/opt/RaspberryPi/zeromq-4.3.4_debug \
..
RUN ninja install
RUN rm -fr ./*
RUN cmake \
-G Ninja \
-DCMAKE_TOOLCHAIN_FILE=/opt/RaspberryPi/raspberrypi.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/RaspberryPi/zeromq-4.3.4_release \
..
RUN ninja install
WORKDIR /home/temp/xlnt-1.5.0/build
RUN sed -i '1s/^/#include <limits>\n/' ../source/detail/number_format/number_formatter.cpp
RUN cmake \
-G Ninja \
-DCMAKE_TOOLCHAIN_FILE=/opt/RaspberryPi/raspberrypi.cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/opt/RaspberryPi/xlnt-1.5.0_debug \
..
RUN ninja install
RUN rm -fr ./*
RUN cmake \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/RaspberryPi/xlnt-1.5.0_release \
..
RUN ninja install
RUN bash -c "sed -i -e 's/set_and_check(XLNT_INCLUDE_DIR \"include\")/# set_and_check(XLNT_INCLUDE_DIR \"include\")/g' /opt/RaspberryPi/xlnt-1.5.0_debug/lib/cmake/xlnt/XlntConfig.cmake &&\
sed -i -e 's/set_and_check(XLNT_INCLUDE_DIR \"include\")/# set_and_check(XLNT_INCLUDE_DIR \"include\")/g' /opt/RaspberryPi/xlnt-1.5.0_release/lib/cmake/xlnt/XlntConfig.cmake"
RUN rm -fr /home/temp
ENV LANG C.UTF-8
# eval $(ssh-agent) && ssh-add ~/.ssh/id_rsa
2022-12-30 18:31:57 +08:00
# docker build -f raspberrypi.dockerfile -t develop:raspberrypi --build-arg PI_ADDRESS="192.168.1.2" --ssh default=$SSH_AUTH_SOCK .
# docker tag develop:raspberrypi registry.cn-shenzhen.aliyuncs.com/amass_toolset/develop:raspberrypi
# docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/develop:raspberrypi