diff --git a/Dockerfile b/Dockerfile index 378d079..3d090c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,28 +2,20 @@ 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 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 -RUN 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 -# 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 - ############################################################################################ @@ -34,7 +26,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,13 +37,11 @@ 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 WORKDIR /build -RUN git clone --depth 1 --branch ${KERNEL_TAG} https://github.com/smaeul/linux -WORKDIR /build/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 @@ -59,21 +49,19 @@ 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 make -j $(nproc) -C linux-build ARCH=riscv $CROSS INSTALL_MOD_PATH=/build/modules modules_install - # # 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 @@ -85,8 +73,6 @@ RUN ls -l # Module resides in /build/xr829/xr829.ko - - ############################################################################################ # # Build u-boot @@ -94,9 +80,8 @@ RUN ls -l FROM builder as build_uboot ARG UBOOT_TAG ARG BOARD -RUN 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 @@ -108,16 +93,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 @@ -128,12 +113,10 @@ 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 - - ############################################################################################ # # Build the root filesystem @@ -141,17 +124,10 @@ RUN ./u-boot/tools/mkimage -T script -C none -O linux -A riscv -d bootscr_${BOAR 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 - 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 WORKDIR /build @@ -159,21 +135,18 @@ 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 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 @@ -181,7 +154,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 @@ -197,24 +169,14 @@ ENV GNU_TOOLS_TAG=$GNU_TOOLS_TAG ENV DISK_MB=$DISK_MB ENV BOARD=$BOARD -RUN apt-get install -y kpartx parted - WORKDIR /builder -COPY --from=build_rootfs /kernel_ver ./kernel_ver +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 ./ -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 rootfs/setup_rootfs.sh ./rv64-port/ +COPY scripts/build.sh scripts/create_image.sh ./ RUN ls -l -RUN 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 diff --git a/kernel/update_kernel_config.sh b/kernel/update_kernel_config.sh index be2128e..21701b4 100755 --- a/kernel/update_kernel_config.sh +++ b/kernel/update_kernel_config.sh @@ -6,9 +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() { + grep -F -v "$1" "${CONF_FILE}" > tmp_conf + echo "# $1 is not set" >> tmp_conf + mv tmp_conf "${CONF_FILE}" } add_config 'CONFIG_DEFAULT_HOSTNAME' '"lichee"' @@ -110,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} +cat "${CONF_FILE}" diff --git a/rootfs/multistrap_lichee_rv_86.conf b/rootfs/multistrap_lichee_rv_86.conf index fb95192..6617fd6 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 @@ -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 60eb36f..8a1072b 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 @@ -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 fb95192..6617fd6 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 @@ -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/setup_rootfs.sh b/rootfs/setup_rootfs.sh index d1c85f5..3d238a3 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 @@ -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 diff --git a/scripts/build.sh b/scripts/build.sh index 0f0b55f..da072f0 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,8 +1,8 @@ -#/bin/sh +#!/bin/sh # 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 diff --git a/scripts/create_image.sh b/scripts/create_image.sh index d142bd9..ce5ca7d 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,39 +55,40 @@ 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} /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" < -/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 echo "Cleaning Up..." -umount ${MNTPOINT} -rm -rf ${MNTPOINT} +umount "${MNTPOINT}" +rm -rf "${MNTPOINT}" -kpartx -d ${LOOPDEV} -losetup -d ${LOOPDEV} +kpartx -d "${LOOPDEV}" +losetup -d "${LOOPDEV}" # Now compress the image echo "Compressing the image: ${IMG}" -(cd ${OUTPORT}; xz -9 ${IMG}) +(cd "${OUTPORT}" && xz -T0 "${IMG}")