From be4443ff9aab12520a384af6b3a0c6e943948590 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:07:11 +0100 Subject: [PATCH 01/34] Install `eatmydata` package and use it to minimize amount of disk I/O --- Dockerfile | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6e033d8..2308b75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,9 @@ FROM debian:bullseye as builder MAINTAINER Tim Molteno "tim@molteno.net" ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev swig libssl-dev python3-distutils python3-dev git +RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install -y autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev swig libssl-dev python3-distutils python3-dev git -RUN apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu +RUN eatmydata apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 # WORKDIR /build @@ -34,7 +34,7 @@ FROM builder as build_opensbi WORKDIR /build RUN git clone --depth 1 https://github.com/riscv-software-src/opensbi WORKDIR /build/opensbi -RUN make $CROSS PLATFORM=generic FW_PIC=y FW_OPTIONS=0x2 +RUN eatmydata make $CROSS PLATFORM=generic FW_PIC=y FW_OPTIONS=0x2 # The binary is located here: /build/opensbi/build/platform/generic/firmware/fw_dynamic.bin @@ -45,12 +45,12 @@ RUN make $CROSS PLATFORM=generic FW_PIC=y FW_OPTIONS=0x2 FROM builder as build_kernel ARG KERNEL_TAG ARG KERNEL_COMMIT -RUN apt-get install -y cpio # Required for kernel build +RUN eatmydata apt-get install -y cpio # Required for kernel build WORKDIR /build -RUN git clone --depth 1 --branch ${KERNEL_TAG} https://github.com/smaeul/linux -RUN git checkout ${KERNEL_COMMIT} +RUN eatmydata git clone --depth 1 --branch ${KERNEL_TAG} https://github.com/smaeul/linux +RUN cd linux && eatmydata git checkout ${KERNEL_COMMIT} && cd - WORKDIR /build/linux/drivers/net/wireless -RUN git clone --depth 1 https://github.com/YuzukiHD/Xradio-XR829.git +RUN eatmydata git clone --depth 1 https://github.com/YuzukiHD/Xradio-XR829.git RUN echo 'obj-$(CONFIG_XR829_WLAN) += Xradio-XR829/' >> Makefile WORKDIR /build/linux #RUN git checkout riscv/d1-wip @@ -58,10 +58,10 @@ WORKDIR /build/linux COPY kernel/update_kernel_config.sh . RUN ./update_kernel_config.sh defconfig WORKDIR /build -RUN make ARCH=riscv -C linux O=../linux-build defconfig -RUN make -j $(nproc) -C linux-build ARCH=riscv $CROSS V=0 +RUN eatmydata make ARCH=riscv -C linux O=../linux-build defconfig +RUN eatmydata make -j $(nproc) -C linux-build ARCH=riscv $CROSS V=0 # Files reside in /build/linux-build/arch/riscv/boot/Image.gz -RUN apt-get install -y kmod +RUN eatmydata apt-get install -y kmod # RUN make -j $(nproc) -C linux-build ARCH=riscv $CROSS INSTALL_MOD_PATH=/build/modules modules_install @@ -70,9 +70,9 @@ RUN apt-get install -y kmod # Build wifi modules # WORKDIR /build -RUN git clone --depth 1 https://github.com/lwfinger/rtl8723ds.git +RUN eatmydata git clone --depth 1 https://github.com/lwfinger/rtl8723ds.git WORKDIR /build/rtl8723ds -RUN make -j $(nproc) ARCH=riscv $CROSS KSRC=../linux-build modules +RUN eatmydata make -j $(nproc) ARCH=riscv $CROSS KSRC=../linux-build modules RUN ls -l # Module resides in /build/rtl8723ds/8723ds.ko @@ -93,9 +93,9 @@ RUN ls -l FROM builder as build_uboot ARG UBOOT_TAG ARG BOARD -RUN apt-get install -y python3-setuptools git +RUN eatmydata apt-get install -y python3-setuptools git WORKDIR /build -RUN git clone --depth 1 --branch ${UBOOT_TAG} https://github.com/smaeul/u-boot.git +RUN eatmydata git clone --depth 1 --branch ${UBOOT_TAG} https://github.com/smaeul/u-boot.git WORKDIR /build/u-boot # Make sure we update the device tree and add the overlays @@ -107,16 +107,16 @@ RUN cat ./arch/riscv/dts/Makefile RUN if [ "$BOARD" = "lichee_rv_86" ] ; then \ echo "Building for the RV_86_Panel"; \ ./update_uboot_config.sh lichee_rv_86_panel_defconfig; \ - make $CROSS lichee_rv_86_panel_defconfig; \ + eatmydata make $CROSS lichee_rv_86_panel_defconfig; \ elif [ "$BOARD" = "lichee_rv_dock" ] || [ "$BOARD" = "lichee_rv_lcd" ] ; then \ echo "Building for Lichee RV Dock"; \ ./update_uboot_config.sh lichee_rv_dock_defconfig; \ - make $CROSS lichee_rv_dock_defconfig; \ + eatmydata make $CROSS lichee_rv_dock_defconfig; \ else \ echo "ERROR: unknown board"; \ fi COPY --from=build_opensbi /build/opensbi/build/platform/generic/firmware/fw_dynamic.bin ./ -RUN make -j $(nproc) $CROSS all OPENSBI=fw_dynamic.bin V=1 +RUN eatmydata make -j $(nproc) $CROSS all OPENSBI=fw_dynamic.bin V=1 RUN ls -l arch/riscv/dts/ # The binary is located here: u-boot/arch/riscv/dts/sun20i-d1-lichee-rv-dock.dtb # The binary is located here: u-boot/arch/riscv/dts/sun20i-d1-lichee-rv-86-panel.dtb @@ -127,7 +127,7 @@ RUN ls -l arch/riscv/dts/ WORKDIR /build RUN ls -l COPY config/bootscr_${BOARD}.txt . -RUN ./u-boot/tools/mkimage -T script -C none -O linux -A riscv -d bootscr_${BOARD}.txt boot.scr +RUN eatmydata ./u-boot/tools/mkimage -T script -C none -O linux -A riscv -d bootscr_${BOARD}.txt boot.scr # The boot script is here: boot.scr @@ -141,15 +141,15 @@ FROM builder as build_rootfs ARG BOARD -RUN apt-get install -y mmdebstrap qemu-user-static binfmt-support debian-ports-archive-keyring -RUN apt-get install -y multistrap systemd-container -RUN apt-get install -y kmod +RUN eatmydata apt-get install -y mmdebstrap qemu-user-static binfmt-support debian-ports-archive-keyring +RUN eatmydata apt-get install -y multistrap systemd-container +RUN eatmydata apt-get install -y kmod WORKDIR /build COPY rootfs/multistrap_$BOARD.conf multistrap.conf RUN ls -RUN multistrap -f multistrap.conf +RUN eatmydata multistrap -f multistrap.conf # Now install the kernel modules into the rootfs @@ -158,7 +158,7 @@ COPY --from=build_kernel /build/linux-build/ ./linux-build/ COPY --from=build_kernel /build/linux/ ./linux/ COPY --from=build_kernel /build/rtl8723ds/8723ds.ko . WORKDIR /build/linux-build -RUN make ARCH=riscv INSTALL_MOD_PATH=/port/rv64-port modules_install +RUN eatmydata make ARCH=riscv INSTALL_MOD_PATH=/port/rv64-port modules_install RUN ls /port/rv64-port/lib/modules/ > /kernel_ver @@ -196,7 +196,7 @@ ENV GNU_TOOLS_TAG=$GNU_TOOLS_TAG ENV DISK_MB=$DISK_MB ENV BOARD=$BOARD -RUN apt-get install -y kpartx parted +RUN eatmydata apt-get install -y kpartx parted WORKDIR /builder COPY --from=build_rootfs /kernel_ver ./kernel_ver @@ -210,10 +210,10 @@ COPY --from=build_uboot /build/u-boot/u-boot-sunxi-with-spl.bin . COPY --from=build_uboot /build/u-boot/arch/riscv/dts/ov_lichee_rv_mini_lcd.dtb . RUN ls -l -RUN apt-get install -y kpartx openssl fdisk dosfstools e2fsprogs kmod parted +RUN eatmydata apt-get install -y kpartx openssl fdisk dosfstools e2fsprogs kmod parted COPY rootfs/setup_rootfs.sh ./rv64-port/setup_rootfs.sh COPY scripts/build.sh . COPY scripts/create_image.sh . -CMD /builder/build.sh +CMD eatmydata /builder/build.sh From be093b3ca6cf815e99119390bfc622fcdd03cb0c Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:08:23 +0100 Subject: [PATCH 02/34] Collapse all `builder` packages installation into one command --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2308b75..43fb48f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,7 @@ FROM debian:bullseye as builder MAINTAINER Tim Molteno "tim@molteno.net" ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install -y autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev swig libssl-dev python3-distutils python3-dev git - -RUN eatmydata apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu +RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install -y autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev swig libssl-dev python3-distutils python3-dev git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 # WORKDIR /build From 85555cbb2db0661cf5f36b125e3c9dddf8f9ade8 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:10:50 +0100 Subject: [PATCH 03/34] Beautify `builder` image package installation --- Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 43fb48f..b37b242 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,13 @@ FROM debian:bullseye as builder MAINTAINER Tim Molteno "tim@molteno.net" ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y eatmydata && eatmydata apt-get install -y autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev swig libssl-dev python3-distutils python3-dev git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu +RUN apt-get update \ + && apt-get install -y eatmydata \ + && eatmydata apt-get install -y autoconf automake autotools-dev curl python3 \ + libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \ + bison flex texinfo gperf libtool patchutils bc zlib1g-dev \ + libexpat-dev swig libssl-dev python3-distutils python3-dev \ + git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 # WORKDIR /build From b2efdd7e43846366229db59dae47ce6d3bbd04b0 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:13:06 +0100 Subject: [PATCH 04/34] Move `build_kernel` dependencies installation to `builder` image --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index b37b242..4081716 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN apt-get update \ libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \ bison flex texinfo gperf libtool patchutils bc zlib1g-dev \ libexpat-dev swig libssl-dev python3-distutils python3-dev \ - git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu + git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 # WORKDIR /build @@ -49,7 +49,6 @@ RUN eatmydata make $CROSS PLATFORM=generic FW_PIC=y FW_OPTIONS=0x2 FROM builder as build_kernel ARG KERNEL_TAG ARG KERNEL_COMMIT -RUN eatmydata apt-get install -y cpio # Required for kernel build WORKDIR /build RUN eatmydata git clone --depth 1 --branch ${KERNEL_TAG} https://github.com/smaeul/linux RUN cd linux && eatmydata git checkout ${KERNEL_COMMIT} && cd - @@ -65,7 +64,6 @@ WORKDIR /build RUN eatmydata make ARCH=riscv -C linux O=../linux-build defconfig RUN eatmydata make -j $(nproc) -C linux-build ARCH=riscv $CROSS V=0 # Files reside in /build/linux-build/arch/riscv/boot/Image.gz -RUN eatmydata apt-get install -y kmod # RUN make -j $(nproc) -C linux-build ARCH=riscv $CROSS INSTALL_MOD_PATH=/build/modules modules_install From ebd4bfebfafab2d7e8d28a6a364172247bf2ee1f Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:14:20 +0100 Subject: [PATCH 05/34] Move `build_uboot` dependencies installation to `builder` image --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4081716..4992085 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,8 @@ RUN apt-get update \ libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \ bison flex texinfo gperf libtool patchutils bc zlib1g-dev \ libexpat-dev swig libssl-dev python3-distutils python3-dev \ - git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod + git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod \ + python3-setuptools git ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 # WORKDIR /build @@ -95,7 +96,6 @@ RUN ls -l FROM builder as build_uboot ARG UBOOT_TAG ARG BOARD -RUN eatmydata apt-get install -y python3-setuptools git WORKDIR /build RUN eatmydata git clone --depth 1 --branch ${UBOOT_TAG} https://github.com/smaeul/u-boot.git WORKDIR /build/u-boot From d049b0221bcc581d0c3520a9e743ccda5db00802 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:14:54 +0100 Subject: [PATCH 06/34] deduplicate packages --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4992085..29a7be2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get update \ bison flex texinfo gperf libtool patchutils bc zlib1g-dev \ libexpat-dev swig libssl-dev python3-distutils python3-dev \ git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod \ - python3-setuptools git + python3-setuptools ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 # WORKDIR /build From d0fd7421df0aa3223e1abd7b908da69349d4edc1 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:17:12 +0100 Subject: [PATCH 07/34] Move `build_rootfs` dependencies installation to `builder` image --- Dockerfile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 29a7be2..e2652cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,9 @@ RUN apt-get update \ bison flex texinfo gperf libtool patchutils bc zlib1g-dev \ libexpat-dev swig libssl-dev python3-distutils python3-dev \ git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod \ - python3-setuptools + python3-setuptools mmdebstrap qemu-user-static binfmt-support \ + debian-ports-archive-keyring multistrap systemd-container kmod + ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 # WORKDIR /build @@ -142,11 +144,6 @@ RUN eatmydata ./u-boot/tools/mkimage -T script -C none -O linux -A riscv -d boot FROM builder as build_rootfs ARG BOARD - -RUN eatmydata apt-get install -y mmdebstrap qemu-user-static binfmt-support debian-ports-archive-keyring -RUN eatmydata apt-get install -y multistrap systemd-container -RUN eatmydata apt-get install -y kmod - WORKDIR /build COPY rootfs/multistrap_$BOARD.conf multistrap.conf From 5baa6838c81fe841a73cc2041d7f09f14e2d64f9 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:17:36 +0100 Subject: [PATCH 08/34] deduplicate packages --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e2652cc..1afb917 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN apt-get update \ libexpat-dev swig libssl-dev python3-distutils python3-dev \ git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod \ python3-setuptools mmdebstrap qemu-user-static binfmt-support \ - debian-ports-archive-keyring multistrap systemd-container kmod + debian-ports-archive-keyring multistrap systemd-container ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 From 2408d4365b4a7de3404c37a15e6067bb00ffd21c Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:48:31 +0100 Subject: [PATCH 09/34] Move `build_image` dependencies installation to `builder` image --- Dockerfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1afb917..22b23a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,8 @@ RUN apt-get update \ libexpat-dev swig libssl-dev python3-distutils python3-dev \ git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod \ python3-setuptools mmdebstrap qemu-user-static binfmt-support \ - debian-ports-archive-keyring multistrap systemd-container + debian-ports-archive-keyring multistrap systemd-container \ + kpartx parted kpartx openssl fdisk dosfstools e2fsprogs kmod parted ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 @@ -195,8 +196,6 @@ ENV GNU_TOOLS_TAG=$GNU_TOOLS_TAG ENV DISK_MB=$DISK_MB ENV BOARD=$BOARD -RUN eatmydata apt-get install -y kpartx parted - WORKDIR /builder COPY --from=build_rootfs /kernel_ver ./kernel_ver COPY --from=build_rootfs /port/rv64-port/ ./rv64-port/ @@ -207,9 +206,7 @@ COPY --from=build_kernel /build/linux/arch/riscv/configs/defconfig . COPY --from=build_uboot /build/boot.scr . COPY --from=build_uboot /build/u-boot/u-boot-sunxi-with-spl.bin . COPY --from=build_uboot /build/u-boot/arch/riscv/dts/ov_lichee_rv_mini_lcd.dtb . - RUN ls -l -RUN eatmydata apt-get install -y kpartx openssl fdisk dosfstools e2fsprogs kmod parted COPY rootfs/setup_rootfs.sh ./rv64-port/setup_rootfs.sh From b3a0fafbed6cc0a506236f8ea7934fe4f57d72a2 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:49:21 +0100 Subject: [PATCH 10/34] deduplicate packages --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 22b23a3..12d2449 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update \ git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod \ python3-setuptools mmdebstrap qemu-user-static binfmt-support \ debian-ports-archive-keyring multistrap systemd-container \ - kpartx parted kpartx openssl fdisk dosfstools e2fsprogs kmod parted + kpartx parted openssl fdisk dosfstools e2fsprogs ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 From b7647775fc2e21db5efea05ebafdf37759be3fb0 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:52:57 +0100 Subject: [PATCH 11/34] sort packages alphabetically --- Dockerfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 12d2449..0f8e67c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,14 +4,15 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ && apt-get install -y eatmydata \ - && eatmydata apt-get install -y autoconf automake autotools-dev curl python3 \ - libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \ - bison flex texinfo gperf libtool patchutils bc zlib1g-dev \ - libexpat-dev swig libssl-dev python3-distutils python3-dev \ - git gcc-riscv64-linux-gnu g++-riscv64-linux-gnu cpio kmod \ - python3-setuptools mmdebstrap qemu-user-static binfmt-support \ - debian-ports-archive-keyring multistrap systemd-container \ - kpartx parted openssl fdisk dosfstools e2fsprogs + && eatmydata apt-get install -y autoconf automake autotools-dev bc binfmt-support \ + bison build-essential cpio curl debian-ports-archive-keyring \ + dosfstools e2fsprogs fdisk flex gawk gcc-riscv64-linux-gnu \ + git gperf g++-riscv64-linux-gnu kmod kpartx libexpat-dev \ + libgmp-dev libmpc-dev libmpfr-dev libssl-dev \ + libtool mmdebstrap multistrap openssl parted \ + patchutils python3 python3-dev python3-distutils \ + python3-setuptools qemu-user-static swig \ + systemd-container texinfo zlib1g-dev ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 From 76cd5178dd8e0e879ca27674d65d305d7d2e7f21 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 19:55:23 +0100 Subject: [PATCH 12/34] Remove excessive whitespaces --- Dockerfile | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0f8e67c..199fc16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,6 @@ RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 # RUN rm -rf riscv-gnu-toolchain - ############################################################################################ # # Build opensbi @@ -72,7 +71,6 @@ RUN eatmydata make -j $(nproc) -C linux-build ARCH=riscv $CROSS V=0 # RUN make -j $(nproc) -C linux-build ARCH=riscv $CROSS INSTALL_MOD_PATH=/build/modules modules_install - # # Build wifi modules # @@ -91,8 +89,6 @@ RUN ls -l # Module resides in /build/xr829/xr829.ko - - ############################################################################################ # # Build u-boot @@ -137,8 +133,6 @@ RUN eatmydata ./u-boot/tools/mkimage -T script -C none -O linux -A riscv -d boot # The boot script is here: boot.scr - - ############################################################################################ # # Build the root filesystem @@ -152,7 +146,6 @@ COPY rootfs/multistrap_$BOARD.conf multistrap.conf RUN ls RUN eatmydata multistrap -f multistrap.conf - # Now install the kernel modules into the rootfs WORKDIR /build COPY --from=build_kernel /build/linux-build/ ./linux-build/ @@ -161,15 +154,12 @@ COPY --from=build_kernel /build/rtl8723ds/8723ds.ko . WORKDIR /build/linux-build RUN eatmydata make ARCH=riscv INSTALL_MOD_PATH=/port/rv64-port modules_install - RUN ls /port/rv64-port/lib/modules/ > /kernel_ver RUN echo "export MODDIR=$(ls /port/rv64-port/lib/modules/)" > /moddef RUN ls /port/rv64-port/lib/modules/ RUN . /moddef; echo "Creating wireless module in ${MODDIR}" RUN . /moddef; install -v -D -p -m 644 /build/8723ds.ko /port/rv64-port/lib/modules/${MODDIR}/kernel/drivers/net/wireless/8723ds.ko - - RUN . /moddef; rm /port/rv64-port/lib/modules/${MODDIR}/build RUN . /moddef; rm /port/rv64-port/lib/modules/${MODDIR}/source @@ -181,7 +171,6 @@ RUN echo 'xr829' >> /port/rv64-port/etc/modules # RUN cp /etc/resolv.conf /port/rv64-port/etc/resolv.conf - ############################################################################################ # # Now Build the disk image From 7793fcf80fe931295ec78a2bcdb7ec46f314e440 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 20:22:03 +0100 Subject: [PATCH 13/34] Remove Risc-V toolchain build instructions --- Dockerfile | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 199fc16..b84c3f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,22 +16,6 @@ RUN apt-get update \ ENV CROSS="CROSS_COMPILE=riscv64-linux-gnu-" RUN riscv64-linux-gnu-gcc --version | grep gcc | cut -d')' -f2 -# WORKDIR /build -# ARG GNU_TOOLS_TAG -# RUN git config --global advice.detachedHead false -# RUN git clone --recursive --depth 1 --branch ${GNU_TOOLS_TAG} https://github.com/riscv/riscv-gnu-toolchain -# WORKDIR /build/riscv-gnu-toolchain -# RUN git checkout ${GNU_TOOLS_TAG} -# RUN ./configure --prefix=/opt/riscv64-unknown-linux-gnu --with-arch=rv64gc --with-abi=lp64d -# RUN make linux -j $(nproc) -# ENV PATH="/opt/riscv64-unknown-linux-gnu/bin:$PATH" - -# ARG CROSS=CROSS_COMPILE=/build/riscv64-unknown-linux-gnu/bin/riscv64-unknown-linux-gnu- -# ENV CROSS=CROSS_COMPILE=riscv64-unknown-linux-gnu- - -# Clean up -# WORKDIR /build -# RUN rm -rf riscv-gnu-toolchain ############################################################################################ From d21ef9b4dc24eaf19d2b37bec2d21071ae234cbd Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 20:29:04 +0100 Subject: [PATCH 14/34] Collapse `build_image` COPY operations --- Dockerfile | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index b84c3f0..cc8e680 100644 --- a/Dockerfile +++ b/Dockerfile @@ -171,18 +171,12 @@ ENV DISK_MB=$DISK_MB ENV BOARD=$BOARD WORKDIR /builder -COPY --from=build_rootfs /kernel_ver ./kernel_ver -COPY --from=build_rootfs /port/rv64-port/ ./rv64-port/ - -COPY --from=build_kernel /build/linux-build/arch/riscv/boot/Image.gz . -COPY --from=build_kernel /build/linux/arch/riscv/configs/defconfig . - -COPY --from=build_uboot /build/boot.scr . -COPY --from=build_uboot /build/u-boot/u-boot-sunxi-with-spl.bin . -COPY --from=build_uboot /build/u-boot/arch/riscv/dts/ov_lichee_rv_mini_lcd.dtb . +COPY --from=build_rootfs /kernel_ver /port/rv64-port ./ +COPY --from=build_kernel /build/linux-build/arch/riscv/boot/Image.gz /build/linux/arch/riscv/configs/defconfig ./ +COPY --from=build_uboot /build/boot.scr /build/u-boot/u-boot-sunxi-with-spl.bin /build/u-boot/arch/riscv/dts/ov_lichee_rv_mini_lcd.dtb ./ +COPY rootfs/setup_rootfs.sh ./rv64-port/setup_rootfs.sh RUN ls -l -COPY rootfs/setup_rootfs.sh ./rv64-port/setup_rootfs.sh COPY scripts/build.sh . COPY scripts/create_image.sh . From 6029d2b33ed0b5a10344b3ec0282245d2112711a Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 21:13:30 +0100 Subject: [PATCH 15/34] Add function to unset options from kernel config --- kernel/update_kernel_config.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/update_kernel_config.sh b/kernel/update_kernel_config.sh index be2128e..1d5d1f4 100755 --- a/kernel/update_kernel_config.sh +++ b/kernel/update_kernel_config.sh @@ -11,6 +11,12 @@ function add_config() { mv tmp_conf ${CONF_FILE} } +function unset_config() { + fgrep -v $1 ${CONF_FILE} > tmp_conf + echo "# $1 is not set" >> tmp_conf + mv tmp_conf ${CONF_FILE} +} + add_config 'CONFIG_DEFAULT_HOSTNAME' '"lichee"' # enable WiFi add_config 'CONFIG_WIRELESS' 'y' From 5a50da23cd852220456fa70aef9e52cad86d9d3e Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 21:14:30 +0100 Subject: [PATCH 16/34] Exclude time-consuming board-irrelevant modules from build --- kernel/update_kernel_config.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/update_kernel_config.sh b/kernel/update_kernel_config.sh index 1d5d1f4..87907b7 100755 --- a/kernel/update_kernel_config.sh +++ b/kernel/update_kernel_config.sh @@ -116,5 +116,11 @@ add_config 'CONFIG_CRC32' 'y' add_config 'CONFIG_USE_OF' 'y' add_config 'CONFIG_OF_LIBFDT_OVERLAY' 'y' +# +# Disable irrelevant time consuming modules build +# +unset_config 'CONFIG_DRM_RADEON' +unset_config 'CONFIG_DRM_NOUVEAU' + echo "Config File Follows #####################" cat ${CONF_FILE} From 3cdf57f148b7b43b767a57b6d57de92224c6567b Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 21:15:56 +0100 Subject: [PATCH 17/34] Fix linter warnings --- kernel/update_kernel_config.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/update_kernel_config.sh b/kernel/update_kernel_config.sh index 87907b7..21701b4 100755 --- a/kernel/update_kernel_config.sh +++ b/kernel/update_kernel_config.sh @@ -6,15 +6,15 @@ CONF_FILE=./arch/riscv/configs/$1 function add_config() { - fgrep -v $1 ${CONF_FILE} > tmp_conf + grep -F -v "$1" "${CONF_FILE}" > tmp_conf echo "$1=$2" >> tmp_conf - mv tmp_conf ${CONF_FILE} + mv tmp_conf "${CONF_FILE}" } function unset_config() { - fgrep -v $1 ${CONF_FILE} > tmp_conf + grep -F -v "$1" "${CONF_FILE}" > tmp_conf echo "# $1 is not set" >> tmp_conf - mv tmp_conf ${CONF_FILE} + mv tmp_conf "${CONF_FILE}" } add_config 'CONFIG_DEFAULT_HOSTNAME' '"lichee"' @@ -123,4 +123,4 @@ unset_config 'CONFIG_DRM_RADEON' unset_config 'CONFIG_DRM_NOUVEAU' echo "Config File Follows #####################" -cat ${CONF_FILE} +cat "${CONF_FILE}" From 29ce1ff56bcc478a646bb34a3b0daec0cc657c3f Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 21:26:15 +0100 Subject: [PATCH 18/34] exclude non-existing packages --- rootfs/multistrap_lichee_rv_86.conf | 2 +- rootfs/multistrap_lichee_rv_dock.conf | 2 +- rootfs/multistrap_lichee_rv_lcd.conf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rootfs/multistrap_lichee_rv_86.conf b/rootfs/multistrap_lichee_rv_86.conf index fb95192..95ad36d 100644 --- a/rootfs/multistrap_lichee_rv_86.conf +++ b/rootfs/multistrap_lichee_rv_86.conf @@ -9,7 +9,7 @@ cleanup=true [Debian] packages=adduser apt base-files base-passwd bash bsdutils coreutils dash debconf debian-archive-keyring debianutils diffutils dpkg e2fsprogs findutils gcc-12-base gcc-9-base gpgv grep gzip hostname libacl1 libapt-pkg6.0 libattr1 libaudit-common libaudit1 libblkid1 libbz2-1.0 libc-bin libc6 libcap-ng0 libcap2 libcom-err2 libcrypt1 libdb5.3 libdebconfclient0 libext2fs2 libffi8 libgcc-s1 libgcrypt20 libgmp10 libgnutls30 libgpg-error0 libhogweed6 libidn2-0 liblz4-1 liblzma5 libmount1 libnettle8 libp11-kit0 libpam-modules libpam-modules-bin libpam-runtime libpam0g libpcre2-8-0 libpcre3 libseccomp2 libselinux1 libsemanage-common libsemanage2 libsepol2 libsmartcols1 libss2 libstdc++6 libtasn1-6 libtinfo6 libudev1 libunistring2 libuuid1 libxxhash0 libzstd1 login logsave lsb-base mawk mount ncurses-base ncurses-bin passwd perl-base sed tar tzdata -packages=zlib1g apt-utils cpio cron debconf-i18n dmidecode dmsetup fdisk ifupdown iproute2 iputils-ping isc-dhcp-client isc-dhcp-common kmod less libapparmor1 libargon2-1 libbpf1 libbsd0 libcap2-bin libcryptsetup12 libdevmapper1.02.1 libedit2 libelf1 libestr0 libfastjson4 libfdisk1 libip4tc2 libjansson4 libjson-c5 libkmod2 liblocale-gettext-perl liblognorm5 libmd0 libmnl0 libncurses6 libncursesw6 libnewt0.52 libnftables1 libnftnl11 libpopt0 libprocps8 libreadline8 libslang2 libssl3 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libxtables12 logrotate nano netbase nftables procps readline-common sensible-utils +packages=zlib1g apt-utils cpio cron debconf-i18n dmidecode dmsetup fdisk ifupdown iproute2 iputils-ping isc-dhcp-client isc-dhcp-common kmod less libapparmor1 libargon2-1 libbpf1 libbsd0 libcap2-bin libcryptsetup12 libdevmapper1.02.1 libedit2 libelf1 libestr0 libfastjson4 libfdisk1 libip4tc2 libjansson4 libjson-c5 libkmod2 liblocale-gettext-perl liblognorm5 libmd0 libmnl0 libncurses6 libncursesw6 libnewt0.52 libnftables1 libnftnl11 libpopt0 libreadline8 libslang2 libssl3 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libxtables12 logrotate nano netbase nftables procps readline-common sensible-utils packages=pciutils p11-kit udev vim whiptail xxd packages=util-linux util-linux-extra rsyslog dbus packages=systemd systemd-sysv libsystemd0 sysvinit-utils init-system-helpers init diff --git a/rootfs/multistrap_lichee_rv_dock.conf b/rootfs/multistrap_lichee_rv_dock.conf index 60eb36f..0adb0c5 100644 --- a/rootfs/multistrap_lichee_rv_dock.conf +++ b/rootfs/multistrap_lichee_rv_dock.conf @@ -10,7 +10,7 @@ cleanup=true [Debian] packages=adduser base-passwd base-files bash bsdutils coreutils dash packages=apt debconf debian-archive-keyring debianutils diffutils dpkg e2fsprogs findutils gcc-12-base gcc-9-base gpgv grep gzip hostname libacl1 libapt-pkg6.0 libattr1 libaudit-common libaudit1 libblkid1 libbz2-1.0 libc-bin libc6 libcap-ng0 libcap2 libcom-err2 libcrypt1 libdb5.3 libdebconfclient0 libext2fs2 libffi8 libgcc-s1 libgcrypt20 libgmp10 libgnutls30 libgpg-error0 libhogweed6 libidn2-0 liblz4-1 liblzma5 libmount1 libnettle8 libp11-kit0 libpam-modules libpam-modules-bin libpam-runtime libpam0g libpcre2-8-0 libpcre3 libseccomp2 libselinux1 libsemanage-common libsemanage2 libsepol2 libsmartcols1 libss2 libstdc++6 libtasn1-6 libtinfo6 libudev1 libunistring2 libuuid1 libxxhash0 libzstd1 login logsave lsb-base mawk mount ncurses-base ncurses-bin passwd perl-base sed tar tzdata -packages=zlib1g apt-utils cpio cron debconf-i18n dmidecode dmsetup fdisk ifupdown iproute2 iputils-ping isc-dhcp-client isc-dhcp-common kmod less libapparmor1 libargon2-1 libbpf1 libbsd0 libcap2-bin libcryptsetup12 libdevmapper1.02.1 libedit2 libelf1 libestr0 libfastjson4 libfdisk1 libip4tc2 libjansson4 libjson-c5 libkmod2 liblocale-gettext-perl liblognorm5 libmd0 libmnl0 libncurses6 libncursesw6 libnewt0.52 libnftables1 libnftnl11 libpopt0 libprocps8 libreadline8 libslang2 libssl3 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libxtables12 logrotate nano netbase nftables procps readline-common sensible-utils +packages=zlib1g apt-utils cpio cron debconf-i18n dmidecode dmsetup fdisk ifupdown iproute2 iputils-ping isc-dhcp-client isc-dhcp-common kmod less libapparmor1 libargon2-1 libbpf1 libbsd0 libcap2-bin libcryptsetup12 libdevmapper1.02.1 libedit2 libelf1 libestr0 libfastjson4 libfdisk1 libip4tc2 libjansson4 libjson-c5 libkmod2 liblocale-gettext-perl liblognorm5 libmd0 libmnl0 libncurses6 libncursesw6 libnewt0.52 libnftables1 libnftnl11 libpopt0 libreadline8 libslang2 libssl3 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libxtables12 logrotate nano netbase nftables procps readline-common sensible-utils packages=pciutils p11-kit udev vim whiptail xxd packages=util-linux util-linux-extra rsyslog dbus packages=systemd systemd-sysv libsystemd0 sysvinit-utils init-system-helpers init diff --git a/rootfs/multistrap_lichee_rv_lcd.conf b/rootfs/multistrap_lichee_rv_lcd.conf index fb95192..95ad36d 100644 --- a/rootfs/multistrap_lichee_rv_lcd.conf +++ b/rootfs/multistrap_lichee_rv_lcd.conf @@ -9,7 +9,7 @@ cleanup=true [Debian] packages=adduser apt base-files base-passwd bash bsdutils coreutils dash debconf debian-archive-keyring debianutils diffutils dpkg e2fsprogs findutils gcc-12-base gcc-9-base gpgv grep gzip hostname libacl1 libapt-pkg6.0 libattr1 libaudit-common libaudit1 libblkid1 libbz2-1.0 libc-bin libc6 libcap-ng0 libcap2 libcom-err2 libcrypt1 libdb5.3 libdebconfclient0 libext2fs2 libffi8 libgcc-s1 libgcrypt20 libgmp10 libgnutls30 libgpg-error0 libhogweed6 libidn2-0 liblz4-1 liblzma5 libmount1 libnettle8 libp11-kit0 libpam-modules libpam-modules-bin libpam-runtime libpam0g libpcre2-8-0 libpcre3 libseccomp2 libselinux1 libsemanage-common libsemanage2 libsepol2 libsmartcols1 libss2 libstdc++6 libtasn1-6 libtinfo6 libudev1 libunistring2 libuuid1 libxxhash0 libzstd1 login logsave lsb-base mawk mount ncurses-base ncurses-bin passwd perl-base sed tar tzdata -packages=zlib1g apt-utils cpio cron debconf-i18n dmidecode dmsetup fdisk ifupdown iproute2 iputils-ping isc-dhcp-client isc-dhcp-common kmod less libapparmor1 libargon2-1 libbpf1 libbsd0 libcap2-bin libcryptsetup12 libdevmapper1.02.1 libedit2 libelf1 libestr0 libfastjson4 libfdisk1 libip4tc2 libjansson4 libjson-c5 libkmod2 liblocale-gettext-perl liblognorm5 libmd0 libmnl0 libncurses6 libncursesw6 libnewt0.52 libnftables1 libnftnl11 libpopt0 libprocps8 libreadline8 libslang2 libssl3 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libxtables12 logrotate nano netbase nftables procps readline-common sensible-utils +packages=zlib1g apt-utils cpio cron debconf-i18n dmidecode dmsetup fdisk ifupdown iproute2 iputils-ping isc-dhcp-client isc-dhcp-common kmod less libapparmor1 libargon2-1 libbpf1 libbsd0 libcap2-bin libcryptsetup12 libdevmapper1.02.1 libedit2 libelf1 libestr0 libfastjson4 libfdisk1 libip4tc2 libjansson4 libjson-c5 libkmod2 liblocale-gettext-perl liblognorm5 libmd0 libmnl0 libncurses6 libncursesw6 libnewt0.52 libnftables1 libnftnl11 libpopt0 libreadline8 libslang2 libssl3 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libxtables12 logrotate nano netbase nftables procps readline-common sensible-utils packages=pciutils p11-kit udev vim whiptail xxd packages=util-linux util-linux-extra rsyslog dbus packages=systemd systemd-sysv libsystemd0 sysvinit-utils init-system-helpers init From 750e2b36958207841bf816056c58c9cf8d5943b6 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 22:17:50 +0100 Subject: [PATCH 19/34] Collapse `build_image` COPY operations even more --- Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index cc8e680..d4ec38e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -174,10 +174,9 @@ WORKDIR /builder COPY --from=build_rootfs /kernel_ver /port/rv64-port ./ COPY --from=build_kernel /build/linux-build/arch/riscv/boot/Image.gz /build/linux/arch/riscv/configs/defconfig ./ COPY --from=build_uboot /build/boot.scr /build/u-boot/u-boot-sunxi-with-spl.bin /build/u-boot/arch/riscv/dts/ov_lichee_rv_mini_lcd.dtb ./ -COPY rootfs/setup_rootfs.sh ./rv64-port/setup_rootfs.sh -RUN ls -l +COPY rootfs/setup_rootfs.sh ./rv64-port/ +COPY scripts/build.sh scripts/create_image.sh ./ +RUN ls -l -COPY scripts/build.sh . -COPY scripts/create_image.sh . CMD eatmydata /builder/build.sh From 85eb60ea77169548b4a3f55b69556cad53f81c8d Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 22:19:30 +0100 Subject: [PATCH 20/34] copy file in `archive` mode --- scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 0f0b55f..734b68f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,7 +2,7 @@ # Author. Tim Molteno tim@molteno.net # (C) 2022. -cp /etc/resolv.conf /builder/rv64-port/etc/resolv.conf +cp -av /etc/resolv.conf /builder/rv64-port/etc/resolv.conf # Run the script to create the disk image From c6d7ffd904f96f8353573d1e8f74975b1d5758a5 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 22:19:54 +0100 Subject: [PATCH 21/34] fix shebang --- scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 734b68f..da072f0 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh # Author. Tim Molteno tim@molteno.net # (C) 2022. From 1d9ac62157880d6fa43500492f61b35adcadf1af Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 22:20:33 +0100 Subject: [PATCH 22/34] utilize all CPU cores to compress resulting images --- scripts/create_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_image.sh b/scripts/create_image.sh index d142bd9..5a0d85d 100755 --- a/scripts/create_image.sh +++ b/scripts/create_image.sh @@ -90,4 +90,4 @@ losetup -d ${LOOPDEV} # Now compress the image echo "Compressing the image: ${IMG}" -(cd ${OUTPORT}; xz -9 ${IMG}) +(cd ${OUTPORT}; xz -T0 -9 ${IMG}) From 95e21bce90cfa3487a9da6c1730f619cc064341a Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 22:25:22 +0100 Subject: [PATCH 23/34] explicitly specify shell to execute in chroot --- scripts/create_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_image.sh b/scripts/create_image.sh index 5a0d85d..e535571 100755 --- a/scripts/create_image.sh +++ b/scripts/create_image.sh @@ -68,7 +68,7 @@ mount /dev/mapper/${LOOP}p2 ${MNTPOINT} cp -a /builder/rv64-port/* ${MNTPOINT} # Set up the rootfs -chroot ${MNTPOINT} /setup_rootfs.sh +chroot ${MNTPOINT} /bin/sh /setup_rootfs.sh rm ${MNTPOINT}/setup_rootfs.sh # Set up fstab From 872897e8202dee4d062a16ca97e693263bbf1441 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Wed, 14 Dec 2022 22:30:35 +0100 Subject: [PATCH 24/34] Sprinkle with quotes to make linter happy --- scripts/create_image.sh | 58 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/scripts/create_image.sh b/scripts/create_image.sh index e535571..53e5580 100755 --- a/scripts/create_image.sh +++ b/scripts/create_image.sh @@ -6,47 +6,47 @@ # Make Image the first parameter of this script is the directory containing all the files needed # This is done to allow the script to be run outside of Docker for testing. -OUTPORT=$1 +OUTPORT="$1" -KERNEL_TAG="$(echo ${KERNEL_TAG} | tr '/' '_')" +KERNEL_TAG="$(echo "${KERNEL_TAG}" | tr '/' '_')" IMG_NAME="${BOARD}_gcc_${GNU_TOOLS_TAG}_kernel_${KERNEL_TAG}.img" -IMG=${OUTPORT}/${IMG_NAME} +IMG="${OUTPORT}/${IMG_NAME}" echo "Creating Blank Image ${IMG}" -dd if=/dev/zero of=${IMG} bs=1M count=${DISK_MB} +dd if=/dev/zero "of=${IMG}" bs=1M "count=${DISK_MB}" # Setup Loopback device -LOOP=`losetup -f --show ${IMG} | cut -d'/' -f3` -LOOPDEV=/dev/${LOOP} +LOOP="$(losetup -f --show "${IMG}" | cut -d'/' -f3)" +LOOPDEV="/dev/${LOOP}" echo "Partitioning loopback device ${LOOPDEV}" # dd if=/dev/zero of=${LOOPDEV} bs=1M count=200 -parted -s -a optimal -- ${LOOPDEV} mklabel gpt -parted -s -a optimal -- ${LOOPDEV} mkpart primary ext2 40MiB 100MiB -parted -s -a optimal -- ${LOOPDEV} mkpart primary ext4 100MiB -1GiB -parted -s -a optimal -- ${LOOPDEV} mkpart primary linux-swap -1GiB 100% +parted -s -a optimal -- "${LOOPDEV}" mklabel gpt +parted -s -a optimal -- "${LOOPDEV}" mkpart primary ext2 40MiB 100MiB +parted -s -a optimal -- "${LOOPDEV}" mkpart primary ext4 100MiB -1GiB +parted -s -a optimal -- "${LOOPDEV}" mkpart primary linux-swap -1GiB 100% -kpartx -av ${LOOPDEV} +kpartx -av "${LOOPDEV}" -mkfs.ext2 /dev/mapper/${LOOP}p1 -mkfs.ext4 /dev/mapper/${LOOP}p2 -mkswap /dev/mapper/${LOOP}p3 +mkfs.ext2 "/dev/mapper/${LOOP}p1" +mkfs.ext4 "/dev/mapper/${LOOP}p2" +mkswap "/dev/mapper/${LOOP}p3" # Burn U-boot echo "Burning u-boot to ${LOOPDEV}" # Copy files https://linux-sunxi.org/Allwinner_Nezha -dd if=/builder/u-boot-sunxi-with-spl.bin of=${LOOPDEV} bs=1024 seek=128 +dd if=/builder/u-boot-sunxi-with-spl.bin "of=${LOOPDEV}" bs=1024 seek=128 # Copy Files, first the boot partition echo "Mounting partitions ${LOOPDEV}" BOOTPOINT=/sdcard_boot -mkdir -p ${BOOTPOINT} -mount /dev/mapper/${LOOP}p1 ${BOOTPOINT} +mkdir -p "${BOOTPOINT}" +mount "/dev/mapper/${LOOP}p1" "${BOOTPOINT}" # Boot partition cp /builder/Image.gz "${BOOTPOINT}/" @@ -55,21 +55,21 @@ cp /builder/Image.gz "${BOOTPOINT}/" cp /builder/boot.scr "${BOOTPOINT}/" cp /builder/ov_lichee_rv_mini_lcd.dtb "${BOOTPOINT}/" -umount ${BOOTPOINT} -rm -rf ${BOOTPOINT} +umount "${BOOTPOINT}" +rm -rf "${BOOTPOINT}" # Now create the root partition MNTPOINT=/sdcard_rootfs -mkdir -p ${MNTPOINT} -mount /dev/mapper/${LOOP}p2 ${MNTPOINT} +mkdir -p "${MNTPOINT}" +mount "/dev/mapper/${LOOP}p2" "${MNTPOINT}" # Copy the rootfs -cp -a /builder/rv64-port/* ${MNTPOINT} +cp -a /builder/rv64-port/* "${MNTPOINT}" # Set up the rootfs -chroot ${MNTPOINT} /bin/sh /setup_rootfs.sh -rm ${MNTPOINT}/setup_rootfs.sh +chroot "${MNTPOINT}" /bin/sh /setup_rootfs.sh +rm "${MNTPOINT}/setup_rootfs.sh" # Set up fstab cat >> "${MNTPOINT}/etc/fstab" < Date: Wed, 14 Dec 2022 22:32:19 +0100 Subject: [PATCH 25/34] Enable (if supported by controller + kernel) `discard` (aka `TRIM`) on all target partitions to save some lifetime of sdcard --- scripts/create_image.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/create_image.sh b/scripts/create_image.sh index 53e5580..e5ae88f 100755 --- a/scripts/create_image.sh +++ b/scripts/create_image.sh @@ -74,9 +74,9 @@ rm "${MNTPOINT}/setup_rootfs.sh" # Set up fstab cat >> "${MNTPOINT}/etc/fstab" < -/dev/mmcblk0p1 /boot ext2 rw,defaults,noatime 1 1 -/dev/mmcblk0p2 / ext4 rw,defaults,noatime 1 1 -/dev/mmcblk0p3 none swap sw 0 0 +/dev/mmcblk0p1 /boot ext2 rw,defaults,noatime,discard 1 1 +/dev/mmcblk0p2 / ext4 rw,defaults,noatime,discard 1 1 +/dev/mmcblk0p3 none swap sw,discard 0 0 EOF # Clean Up From 716b93c464f29414c89479282f13079e9dd7de41 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Thu, 15 Dec 2022 00:18:29 +0100 Subject: [PATCH 26/34] Un-collapse `build_rootfs` COPY instructions --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d4ec38e..9415668 100644 --- a/Dockerfile +++ b/Dockerfile @@ -171,7 +171,8 @@ ENV DISK_MB=$DISK_MB ENV BOARD=$BOARD WORKDIR /builder -COPY --from=build_rootfs /kernel_ver /port/rv64-port ./ +COPY --from=build_rootfs /kernel_ver ./ +COPY --from=build_rootfs /port/rv64-port/ ./rv64-port/ COPY --from=build_kernel /build/linux-build/arch/riscv/boot/Image.gz /build/linux/arch/riscv/configs/defconfig ./ COPY --from=build_uboot /build/boot.scr /build/u-boot/u-boot-sunxi-with-spl.bin /build/u-boot/arch/riscv/dts/ov_lichee_rv_mini_lcd.dtb ./ From 510bb396d84ce8045e79ac4b8192930dd516a067 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Thu, 15 Dec 2022 00:19:04 +0100 Subject: [PATCH 27/34] remove debug output --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9415668..ec90cec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -127,7 +127,6 @@ ARG BOARD WORKDIR /build COPY rootfs/multistrap_$BOARD.conf multistrap.conf -RUN ls RUN eatmydata multistrap -f multistrap.conf # Now install the kernel modules into the rootfs From 9918bb2cd05b4cab79a0448eaab5fc0b290657fe Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Thu, 15 Dec 2022 00:19:53 +0100 Subject: [PATCH 28/34] use more logical construct to import env var --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ec90cec..3d090c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -140,13 +140,13 @@ RUN eatmydata make ARCH=riscv INSTALL_MOD_PATH=/port/rv64-port modules_install RUN ls /port/rv64-port/lib/modules/ > /kernel_ver RUN echo "export MODDIR=$(ls /port/rv64-port/lib/modules/)" > /moddef RUN ls /port/rv64-port/lib/modules/ -RUN . /moddef; echo "Creating wireless module in ${MODDIR}" -RUN . /moddef; install -v -D -p -m 644 /build/8723ds.ko /port/rv64-port/lib/modules/${MODDIR}/kernel/drivers/net/wireless/8723ds.ko +RUN . /moddef && echo "Creating wireless module in ${MODDIR}" +RUN . /moddef && install -v -D -p -m 644 /build/8723ds.ko /port/rv64-port/lib/modules/${MODDIR}/kernel/drivers/net/wireless/8723ds.ko -RUN . /moddef; rm /port/rv64-port/lib/modules/${MODDIR}/build -RUN . /moddef; rm /port/rv64-port/lib/modules/${MODDIR}/source +RUN . /moddef && rm /port/rv64-port/lib/modules/${MODDIR}/build +RUN . /moddef && rm /port/rv64-port/lib/modules/${MODDIR}/source -RUN . /moddef; depmod -a -b /port/rv64-port "${MODDIR}" +RUN . /moddef && depmod -a -b /port/rv64-port "${MODDIR}" RUN echo '8723ds' >> /port/rv64-port/etc/modules RUN echo 'xr829' >> /port/rv64-port/etc/modules From af788b5d5025add46174d87ce53cebb912f2703f Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Thu, 15 Dec 2022 00:22:33 +0100 Subject: [PATCH 29/34] remove explicit shell call --- scripts/create_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_image.sh b/scripts/create_image.sh index e5ae88f..196fa75 100755 --- a/scripts/create_image.sh +++ b/scripts/create_image.sh @@ -68,7 +68,7 @@ mount "/dev/mapper/${LOOP}p2" "${MNTPOINT}" cp -a /builder/rv64-port/* "${MNTPOINT}" # Set up the rootfs -chroot "${MNTPOINT}" /bin/sh /setup_rootfs.sh +chroot "${MNTPOINT}" /setup_rootfs.sh rm "${MNTPOINT}/setup_rootfs.sh" # Set up fstab From 42faeb830471904a2ca4b11871e2b4d1aff3f6e2 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Thu, 15 Dec 2022 01:27:16 +0100 Subject: [PATCH 30/34] use less aggressive (memory- and cpu-wise) compression --- scripts/create_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create_image.sh b/scripts/create_image.sh index 196fa75..d5e5429 100755 --- a/scripts/create_image.sh +++ b/scripts/create_image.sh @@ -90,4 +90,4 @@ losetup -d "${LOOPDEV}" # Now compress the image echo "Compressing the image: ${IMG}" -(cd "${OUTPORT}" && xz -T0 -9 "${IMG}") +(cd "${OUTPORT}" && xz -T0 "${IMG}") From d0cc0fa1c4c3b74aa4b74b02fd1357e5bc33cab6 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Thu, 15 Dec 2022 01:28:09 +0100 Subject: [PATCH 31/34] chroot with qemu --- scripts/create_image.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/create_image.sh b/scripts/create_image.sh index d5e5429..ce5ca7d 100755 --- a/scripts/create_image.sh +++ b/scripts/create_image.sh @@ -68,8 +68,9 @@ mount "/dev/mapper/${LOOP}p2" "${MNTPOINT}" cp -a /builder/rv64-port/* "${MNTPOINT}" # Set up the rootfs -chroot "${MNTPOINT}" /setup_rootfs.sh -rm "${MNTPOINT}/setup_rootfs.sh" +cp /usr/bin/qemu-riscv64-static "${MNTPOINT}/usr/bin/" +chroot "${MNTPOINT}" qemu-riscv64-static /bin/sh /setup_rootfs.sh +rm "${MNTPOINT}/setup_rootfs.sh" "${MNTPOINT}/usr/bin/qemu-riscv64-static" # Set up fstab cat >> "${MNTPOINT}/etc/fstab" < Date: Thu, 15 Dec 2022 01:28:57 +0100 Subject: [PATCH 32/34] Add quotes around sub-shell calls to calm down linter --- rootfs/setup_rootfs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/setup_rootfs.sh b/rootfs/setup_rootfs.sh index d1c85f5..c2d87cf 100755 --- a/rootfs/setup_rootfs.sh +++ b/rootfs/setup_rootfs.sh @@ -19,7 +19,7 @@ chmod 0666 /dev/null # # Change root password to 'licheerv' # -usermod --password $(echo licheerv | openssl passwd -1 -stdin) root +usermod --password "$(echo licheerv | openssl passwd -1 -stdin)" root # # Add a new user rv @@ -30,7 +30,7 @@ useradd --password dummy \ --home-dir /home/rv --shell /bin/bash rv chown rv:rv /home/rv # Set password to 'lichee' -usermod --password $(echo lichee | openssl passwd -1 -stdin) rv +usermod --password "$(echo lichee | openssl passwd -1 -stdin)" rv # # Enable system services From 2d8b04eb1aeb776a1f48385ae4f9ac55be9c649e Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Thu, 15 Dec 2022 01:29:22 +0100 Subject: [PATCH 33/34] Clean more --- rootfs/setup_rootfs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/setup_rootfs.sh b/rootfs/setup_rootfs.sh index c2d87cf..3d238a3 100755 --- a/rootfs/setup_rootfs.sh +++ b/rootfs/setup_rootfs.sh @@ -41,5 +41,5 @@ systemctl enable systemd-resolved.service # Clean apt cache on the system # apt-get clean -rm -rf /var/lib/apt/lists/* - +rm -rf /var/lib/apt/lists/* /var/cache/* +find /var/log -type f -print0 | xargs -0 truncate --size=0 From aacd421114560310b09f37fc631615fdbd7e9298 Mon Sep 17 00:00:00 2001 From: Ilya Esin Date: Thu, 15 Dec 2022 01:31:32 +0100 Subject: [PATCH 34/34] Add `eatmydata` package to avoid "ERROR: ld.so: object 'libeatmydata.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored." --- rootfs/multistrap_lichee_rv_86.conf | 1 + rootfs/multistrap_lichee_rv_dock.conf | 1 + rootfs/multistrap_lichee_rv_lcd.conf | 1 + 3 files changed, 3 insertions(+) diff --git a/rootfs/multistrap_lichee_rv_86.conf b/rootfs/multistrap_lichee_rv_86.conf index 95ad36d..6617fd6 100644 --- a/rootfs/multistrap_lichee_rv_86.conf +++ b/rootfs/multistrap_lichee_rv_86.conf @@ -17,6 +17,7 @@ packages=tasksel tasksel-data packages=net-tools wireless-tools firmware-realtek ntp ntpdate openssh-client openssh-server wireless-regdb wpasupplicant network-manager isc-dhcp-client packages=curl gpg openssl ca-certificates sudo psmisc swig iotop tmux packages=lshw lm-sensors +packages=eatmydata source=http://ftp.ports.debian.org/debian-ports/ keyring=debian-ports-archive-keyring suite=unstable diff --git a/rootfs/multistrap_lichee_rv_dock.conf b/rootfs/multistrap_lichee_rv_dock.conf index 0adb0c5..8a1072b 100644 --- a/rootfs/multistrap_lichee_rv_dock.conf +++ b/rootfs/multistrap_lichee_rv_dock.conf @@ -18,6 +18,7 @@ packages=tasksel tasksel-data packages=net-tools wireless-tools firmware-realtek ntp ntpdate openssh-client openssh-server wireless-regdb wpasupplicant network-manager isc-dhcp-client packages=curl gpg openssl ca-certificates sudo psmisc swig iotop tmux packages=lshw lm-sensors +packages=eatmydata source=http://ftp.ports.debian.org/debian-ports/ keyring=debian-ports-archive-keyring suite=unstable diff --git a/rootfs/multistrap_lichee_rv_lcd.conf b/rootfs/multistrap_lichee_rv_lcd.conf index 95ad36d..6617fd6 100644 --- a/rootfs/multistrap_lichee_rv_lcd.conf +++ b/rootfs/multistrap_lichee_rv_lcd.conf @@ -17,6 +17,7 @@ packages=tasksel tasksel-data packages=net-tools wireless-tools firmware-realtek ntp ntpdate openssh-client openssh-server wireless-regdb wpasupplicant network-manager isc-dhcp-client packages=curl gpg openssl ca-certificates sudo psmisc swig iotop tmux packages=lshw lm-sensors +packages=eatmydata source=http://ftp.ports.debian.org/debian-ports/ keyring=debian-ports-archive-keyring suite=unstable