From 4ed63af963f8a438ceee719e5460500b8165a734 Mon Sep 17 00:00:00 2001 From: Luigi Cruz Date: Tue, 9 Nov 2021 15:10:28 -0300 Subject: [PATCH] upgrade to bullseye --- Dockerfile | 4 +- LICENSE | 14 ++++++ build-docker.sh | 14 +++--- build.sh | 2 +- depends | 4 +- scripts/common | 7 ++- scripts/dependencies_check | 25 ++++++++--- scripts/qcow2_handling | 6 +-- stage1/00-boot-files/files/cmdline.txt | 2 +- stage1/00-boot-files/files/config.txt | 31 +++++++++---- stage1/02-net-tweaks/00-run.sh | 4 +- stage1/03-install-packages/00-packages | 2 +- stage2/01-sys-tweaks/00-packages | 7 ++- .../00-patches/07-resize-init.diff | 4 +- stage2/02-net-tweaks/01-run.sh | 7 +-- stage2/02-net-tweaks/files/wait.conf | 3 -- stage3/00-install-packages/00-packages | 2 +- stage3/01-tweaks/00-run.sh | 4 +- stage4/00-install-packages/00-packages | 20 ++++----- stage4/00-install-packages/01-packages | 44 +++++++++---------- stage4/04-pisdr-system/00-packages | 2 + stage4/04-pisdr-system/05-run.sh | 19 -------- 22 files changed, 128 insertions(+), 99 deletions(-) delete mode 100644 stage2/02-net-tweaks/files/wait.conf delete mode 100755 stage4/04-pisdr-system/05-run.sh diff --git a/Dockerfile b/Dockerfile index cb2b4ba..e7fc561 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=debian:buster +ARG BASE_IMAGE=debian:bullseye FROM ${BASE_IMAGE} ENV DEBIAN_FRONTEND noninteractive @@ -7,7 +7,7 @@ RUN apt-get -y update && \ apt-get -y install --no-install-recommends \ git vim parted \ quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \ - bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\ + libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\ binfmt-support ca-certificates qemu-utils kpartx \ && rm -rf /var/lib/apt/lists/* diff --git a/LICENSE b/LICENSE index 665af33..e66b2c0 100644 --- a/LICENSE +++ b/LICENSE @@ -19,3 +19,17 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Copyright (c) 2015 Raspberry Pi (Trading) Ltd. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/build-docker.sh b/build-docker.sh index c46c9b6..85200e4 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -48,6 +48,7 @@ fi CONTAINER_NAME=${CONTAINER_NAME:-pigen_work} CONTINUE=${CONTINUE:-0} PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-0} +PIGEN_DOCKER_OPTS=${PIGEN_DOCKER_OPTS:-""} if [ -z "${IMG_NAME}" ]; then echo "IMG_NAME not set in 'config'" 1>&2 @@ -77,17 +78,10 @@ BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')" # Check the arch of the machine we're running on. If it's 64-bit, use a 32-bit base image instead case "$(uname -m)" in x86_64|aarch64) - case "$(uname -m)" in - aarch64) - BASE_IMAGE=arm32v7/debian:buster - ;; - *) - BASE_IMAGE=i386/debian:buster - ;; - esac + BASE_IMAGE=i386/debian:bullseye ;; *) - BASE_IMAGE=debian:buster + BASE_IMAGE=debian:bullseye ;; esac ${DOCKER} build --build-arg BASE_IMAGE=${BASE_IMAGE} -t pi-gen "${DIR}" @@ -98,6 +92,7 @@ if [ "${CONTAINER_EXISTS}" != "" ]; then --cap-add=ALL \ -v /dev:/dev \ -v /lib/modules:/lib/modules \ + ${PIGEN_DOCKER_OPTS} \ --volume "${CONFIG_FILE}":/config:ro \ -e "GIT_HASH=${GIT_HASH}" \ --volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ @@ -112,6 +107,7 @@ else --cap-add=ALL \ -v /dev:/dev \ -v /lib/modules:/lib/modules \ + ${PIGEN_DOCKER_OPTS} \ --volume "${CONFIG_FILE}":/config:ro \ -e "GIT_HASH=${GIT_HASH}" \ pi-gen \ diff --git a/build.sh b/build.sh index 9ebbdbf..aaf34aa 100755 --- a/build.sh +++ b/build.sh @@ -219,7 +219,7 @@ export TARGET_HOSTNAME=${TARGET_HOSTNAME:-raspberrypi} export FIRST_USER_NAME=${FIRST_USER_NAME:-pi} export FIRST_USER_PASS=${FIRST_USER_PASS:-raspberry} -export RELEASE=${RELEASE:-buster} +export RELEASE=${RELEASE:-bullseye} export WPA_ESSID export WPA_PASSWORD export WPA_COUNTRY diff --git a/depends b/depends index a86bc82..eeb2490 100644 --- a/depends +++ b/depends @@ -7,7 +7,7 @@ zerofree zip mkdosfs:dosfstools capsh:libcap2-bin -bsdtar +bsdtar:libarchive-tools grep rsync xz:xz-utils @@ -17,3 +17,5 @@ file git lsmod:kmod bc +qemu-nbd:qemu-utils +kpartx diff --git a/scripts/common b/scripts/common index e2048d9..5b0df12 100644 --- a/scripts/common +++ b/scripts/common @@ -16,13 +16,16 @@ bootstrap(){ BOOTSTRAP_ARGS+=(--arch armhf) BOOTSTRAP_ARGS+=(--components "main,contrib,non-free") BOOTSTRAP_ARGS+=(--keyring "${STAGE_DIR}/files/raspberrypi.gpg") + BOOTSTRAP_ARGS+=(--exclude=info) BOOTSTRAP_ARGS+=("$@") printf -v BOOTSTRAP_STR '%q ' "${BOOTSTRAP_ARGS[@]}" setarch linux32 capsh --drop=cap_setfcap -- -c "'${BOOTSTRAP_CMD}' $BOOTSTRAP_STR" || true - if [ -d "$2/debootstrap" ]; then - rmdir "$2/debootstrap" + if [ -d "$2/debootstrap" ] && ! rmdir "$2/debootstrap"; then + cp "$2/debootstrap/debootstrap.log" "${STAGE_WORK_DIR}" + log "bootstrap failed: please check ${STAGE_WORK_DIR}/debootstrap.log" + return 1 fi } export -f bootstrap diff --git a/scripts/dependencies_check b/scripts/dependencies_check index 375512b..32c42ef 100644 --- a/scripts/dependencies_check +++ b/scripts/dependencies_check @@ -28,11 +28,26 @@ dependencies_check() false fi + # If we're building on a native arm platform, we don't need to check for + # binfmt_misc or require it to be loaded. - if ! grep -q "/proc/sys/fs/binfmt_misc" /proc/mounts; then - echo "Module binfmt_misc not loaded in host" - echo "Please run:" - echo " sudo modprobe binfmt_misc" - exit 1 + binfmt_misc_required=1 + + case $(uname -m) in + aarch64) + binfmt_misc_required=0 + ;; + arm*) + binfmt_misc_required=0 + ;; + esac + + if [[ "${binfmt_misc_required}" == "1" ]]; then + if ! grep -q "/proc/sys/fs/binfmt_misc" /proc/mounts; then + echo "Module binfmt_misc not loaded in host" + echo "Please run:" + echo " sudo modprobe binfmt_misc" + exit 1 + fi fi } diff --git a/scripts/qcow2_handling b/scripts/qcow2_handling index f722937..6b2a56b 100644 --- a/scripts/qcow2_handling +++ b/scripts/qcow2_handling @@ -36,7 +36,7 @@ connect_blkdev() { init_nbd qemu-nbd --discard=unmap -c $NBD_DEV "$1" sync - kpartx -a $NBD_DEV + kpartx -as $NBD_DEV sync CURRENT_IMAGE="$1" } @@ -108,7 +108,7 @@ load_qimage() { 254MiB,,83; EOF sync - kpartx -a $NBD_DEV + kpartx -as $NBD_DEV mkdosfs -n boot -F 32 -v $MAP_BOOT_DEV mkfs.ext4 -L rootfs -O "^huge_file,^metadata_csum,^64bit" $MAP_ROOT_DEV sync @@ -123,7 +123,7 @@ EOF sync qemu-nbd --discard=unmap -c $NBD_DEV image-${STAGE}.qcow2 sync - kpartx -a $NBD_DEV + kpartx -as $NBD_DEV fi mount -v -t ext4 $MAP_ROOT_DEV "${ROOTFS_DIR}" diff --git a/stage1/00-boot-files/files/cmdline.txt b/stage1/00-boot-files/files/cmdline.txt index b815bd8..03cde68 100644 --- a/stage1/00-boot-files/files/cmdline.txt +++ b/stage1/00-boot-files/files/cmdline.txt @@ -1 +1 @@ -console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait +console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait diff --git a/stage1/00-boot-files/files/config.txt b/stage1/00-boot-files/files/config.txt index 1494cdc..a976ef2 100644 --- a/stage1/00-boot-files/files/config.txt +++ b/stage1/00-boot-files/files/config.txt @@ -5,10 +5,6 @@ # uncomment if you get no picture on HDMI for a default "safe" mode #hdmi_safe=1 -# uncomment this if your display has a black border of unused pixels visible -# and your display can output without overscan -#disable_overscan=1 - # uncomment the following to adjust overscan. Use positive numbers if console # goes off screen, and negative if there is too much border #overscan_left=16 @@ -56,10 +52,29 @@ # Enable audio (loads snd_bcm2835) dtparam=audio=on -[pi4] -# Enable DRM VC4 V3D driver on top of the dispmanx display stack -dtoverlay=vc4-fkms-v3d +# Automatically load overlays for detected cameras +camera_auto_detect=1 + +# Automatically load overlays for detected DSI displays +display_auto_detect=1 + +# Enable DRM VC4 V3D driver +dtoverlay=vc4-kms-v3d max_framebuffers=2 +# Disable compensation for displays with overscan +disable_overscan=1 + +[cm4] +# Enable host mode on the 2711 built-in XHCI USB controller. +# This line should be removed if the legacy DWC2 controller is required +# (e.g. for USB device mode) or if USB support is not required. +otg_mode=1 + +[all] + +[pi4] +# Run as fast as firmware / board allows +arm_boost=1 + [all] -#dtoverlay=vc4-fkms-v3d diff --git a/stage1/02-net-tweaks/00-run.sh b/stage1/02-net-tweaks/00-run.sh index 4943cab..95dfbdc 100755 --- a/stage1/02-net-tweaks/00-run.sh +++ b/stage1/02-net-tweaks/00-run.sh @@ -3,4 +3,6 @@ echo "${TARGET_HOSTNAME}" > "${ROOTFS_DIR}/etc/hostname" echo "127.0.1.1 ${TARGET_HOSTNAME}" >> "${ROOTFS_DIR}/etc/hosts" -ln -sf /dev/null "${ROOTFS_DIR}/etc/systemd/network/99-default.link" +on_chroot << EOF + SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_net_names 1 +EOF diff --git a/stage1/03-install-packages/00-packages b/stage1/03-install-packages/00-packages index e8c148c..73edcc9 100644 --- a/stage1/03-install-packages/00-packages +++ b/stage1/03-install-packages/00-packages @@ -1 +1 @@ -libraspberrypi-bin libraspberrypi0 raspi-config +libraspberrypi-bin libraspberrypi0 diff --git a/stage2/01-sys-tweaks/00-packages b/stage2/01-sys-tweaks/00-packages index a1f4b59..55f8451 100644 --- a/stage2/01-sys-tweaks/00-packages +++ b/stage2/01-sys-tweaks/00-packages @@ -1,8 +1,8 @@ ssh less fbset sudo psmisc strace ed ncdu crda console-setup keyboard-configuration debconf-utils parted unzip -build-essential manpages-dev python bash-completion gdb pkg-config -python-rpi.gpio v4l-utils -python-gpiozero +build-essential manpages-dev bash-completion gdb pkg-config +python-is-python3 +python3-rpi.gpio v4l-utils python3-gpiozero avahi-daemon lua5.1 @@ -26,7 +26,6 @@ policykit-1 ssh-import-id rng-tools ethtool -vl805fw ntfs-3g pciutils rpi-eeprom diff --git a/stage2/01-sys-tweaks/00-patches/07-resize-init.diff b/stage2/01-sys-tweaks/00-patches/07-resize-init.diff index 8c41357..cb160ae 100644 --- a/stage2/01-sys-tweaks/00-patches/07-resize-init.diff +++ b/stage2/01-sys-tweaks/00-patches/07-resize-init.diff @@ -1,5 +1,5 @@ --- stage2.orig/rootfs/boot/cmdline.txt +++ stage2/rootfs/boot/cmdline.txt @@ -1 +1 @@ --console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait -+console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh +-console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait ++console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh diff --git a/stage2/02-net-tweaks/01-run.sh b/stage2/02-net-tweaks/01-run.sh index d82381b..837e861 100755 --- a/stage2/02-net-tweaks/01-run.sh +++ b/stage2/02-net-tweaks/01-run.sh @@ -1,11 +1,12 @@ #!/bin/bash -e -install -v -d "${ROOTFS_DIR}/etc/systemd/system/dhcpcd.service.d" -install -v -m 644 files/wait.conf "${ROOTFS_DIR}/etc/systemd/system/dhcpcd.service.d/" - install -v -d "${ROOTFS_DIR}/etc/wpa_supplicant" install -v -m 600 files/wpa_supplicant.conf "${ROOTFS_DIR}/etc/wpa_supplicant/" +on_chroot << EOF + SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_wait 0 +EOF + if [ -v WPA_COUNTRY ]; then echo "country=${WPA_COUNTRY}" >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" fi diff --git a/stage2/02-net-tweaks/files/wait.conf b/stage2/02-net-tweaks/files/wait.conf deleted file mode 100644 index 595cc2d..0000000 --- a/stage2/02-net-tweaks/files/wait.conf +++ /dev/null @@ -1,3 +0,0 @@ -[Service] -ExecStart= -ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w diff --git a/stage3/00-install-packages/00-packages b/stage3/00-install-packages/00-packages index eac74ea..4ab0380 100644 --- a/stage3/00-install-packages/00-packages +++ b/stage3/00-install-packages/00-packages @@ -3,7 +3,6 @@ qpdfview gtk2-engines alsa-utils desktop-base git omxplayer -raspberrypi-artwork policykit-1 gvfs rfkill @@ -13,3 +12,4 @@ fonts-droid-fallback fonts-liberation2 obconf arandr +libcamera-tools diff --git a/stage3/01-tweaks/00-run.sh b/stage3/01-tweaks/00-run.sh index 5da7c1a..79b749e 100755 --- a/stage3/01-tweaks/00-run.sh +++ b/stage3/01-tweaks/00-run.sh @@ -1,3 +1,5 @@ #!/bin/bash -e -rm -f "${ROOTFS_DIR}/etc/systemd/system/dhcpcd.service.d/wait.conf" +on_chroot << EOF + SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_wait 1 +EOF diff --git a/stage4/00-install-packages/00-packages b/stage4/00-install-packages/00-packages index 85a9f80..e76d411 100644 --- a/stage4/00-install-packages/00-packages +++ b/stage4/00-install-packages/00-packages @@ -1,11 +1,11 @@ -python python3-pygame python-pygame python-tk -python3 python3-tk thonny +python3-pygame +python3-tk thonny python3-pgzero -python-serial python3-serial -python-picamera python3-picamera +python3-serial +python3-picamera debian-reference-en dillo raspberrypi-net-mods raspberrypi-ui-mods -python-pip python3-pip +python3-pip python3-numpy pypy alacarte rc-gui sense-hat @@ -13,11 +13,11 @@ tree libgl1-mesa-dri libgles1 libgles2-mesa xcompmgr geany piclone -wiringpi pigpio python-pigpio python3-pigpio raspi-gpio python3-rpi.gpio -python-spidev python3-spidev -python-twython python3-twython -python-smbus python3-smbus -python-flask python3-flask +pigpio python3-pigpio raspi-gpio python3-rpi.gpio +python3-spidev +python3-twython +python3-smbus +python3-flask pprompt piwiz rp-prefapps diff --git a/stage4/00-install-packages/01-packages b/stage4/00-install-packages/01-packages index fdf5e73..5441d9d 100644 --- a/stage4/00-install-packages/01-packages +++ b/stage4/00-install-packages/01-packages @@ -1,22 +1,22 @@ -python-automationhat python3-automationhat -python-blinkt python3-blinkt -python-cap1xxx python3-cap1xxx -python-drumhat python3-drumhat -python-envirophat python3-envirophat -python-explorerhat python3-explorerhat -python-fourletterphat python3-fourletterphat -python-microdotphat python3-microdotphat -python-mote python3-mote -python-motephat python3-motephat -python-phatbeat python3-phatbeat -python-pianohat python3-pianohat -python-piglow python3-piglow -python-rainbowhat python3-rainbowhat -python-scrollphat python3-scrollphat -python-scrollphathd python3-scrollphathd -python-sn3218 python3-sn3218 -python-skywriter python3-skywriter -python-touchphat python3-touchphat -python-buttonshim python3-buttonshim -python-unicornhathd python3-unicornhathd -python-pantilthat python3-pantilthat +python3-automationhat +python3-blinkt +python3-cap1xxx +python3-drumhat +python3-envirophat +python3-explorerhat +python3-fourletterphat +python3-microdotphat +python3-mote +python3-motephat +python3-phatbeat +python3-pianohat +python3-piglow +python3-rainbowhat +python3-scrollphat +python3-scrollphathd +python3-sn3218 +python3-skywriter +python3-touchphat +python3-buttonshim +python3-unicornhathd +python3-pantilthat diff --git a/stage4/04-pisdr-system/00-packages b/stage4/04-pisdr-system/00-packages index eb6bc3b..e5d4908 100644 --- a/stage4/04-pisdr-system/00-packages +++ b/stage4/04-pisdr-system/00-packages @@ -9,3 +9,5 @@ libssl-dev libboost-dev python3-pytest +pybind11-dev +python3-pybind11 \ No newline at end of file diff --git a/stage4/04-pisdr-system/05-run.sh b/stage4/04-pisdr-system/05-run.sh deleted file mode 100755 index 2b86f88..0000000 --- a/stage4/04-pisdr-system/05-run.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -e - -on_chroot << EOF -mkdir -p "/home/${FIRST_USER_NAME}/PiSDR/System" -cd "/home/${FIRST_USER_NAME}/PiSDR/System" - -if [ ! -d "pybind11" ]; then - git clone --depth 1 https://github.com/pybind/pybind11.git -fi - -cd pybind11 -mkdir -p build -cd build -cmake -GNinja .. -ninja install -ldconfig -cd .. -rm -fr build -EOF