diff --git a/build.sh b/build.sh index e2bb729..b3d839b 100755 --- a/build.sh +++ b/build.sh @@ -163,7 +163,6 @@ function create_cpio { mkdir -p rootfs/usr/sbin/ mkdir -p rootfs/usr/share/{dpkg,keyrings,libc-bin} mkdir -p rootfs/var/lib/dpkg/{alternatives,info,parts,updates} - mkdir -p rootfs/var/lib/ntpdate mkdir -p rootfs/var/log/ mkdir -p rootfs/var/run/ @@ -256,6 +255,8 @@ function create_cpio { cp_executable tmp/bin/busybox rootfs/bin cd rootfs && ln -s bin/busybox init; cd .. echo "\$MODALIAS=.* 0:0 660 @/opt/busybox/bin/modprobe \"\$MODALIAS\"" > rootfs/etc/mdev.conf + # some devices in /dev must have 666 permissions + echo "(full|null|ptmx|random|tty|urandom|zero) 0:0 666" >> rootfs/etc/mdev.conf # bash-static components cp --preserve=xattr,timestamps tmp/bin/bash-static rootfs/bin @@ -309,7 +310,7 @@ function create_cpio { cp --preserve=xattr,timestamps tmp/etc/cron.daily/dpkg rootfs/etc/cron.daily/ cp --preserve=xattr,timestamps tmp/etc/dpkg/dpkg.cfg rootfs/etc/dpkg/ cp --preserve=xattr,timestamps tmp/etc/logrotate.d/dpkg rootfs/etc/logrotate.d/ - cp_executable tmp/sbin/start-stop-daemon rootfs/sbin/ + cp_executable tmp/usr/sbin/start-stop-daemon rootfs/usr/sbin/ cp_executable tmp/usr/bin/dpkg rootfs/usr/bin/ cp_executable tmp/usr/bin/dpkg-deb rootfs/usr/bin/ cp_executable tmp/usr/bin/dpkg-divert rootfs/usr/bin/ @@ -356,7 +357,7 @@ function create_cpio { # iproute2 components cp_executable tmp/bin/ip rootfs/bin/ - # lsb-base components + # sysvinit-utils (previously lsb-base) components cp --preserve=xattr,timestamps tmp/lib/lsb/init-functions rootfs/lib/lsb/ cp --preserve=xattr,timestamps tmp/lib/lsb/init-functions.d/00-verbose rootfs/lib/lsb/init-functions.d/ @@ -368,11 +369,8 @@ function create_cpio { # netcat-openbsd cp_executable tmp/bin/nc.openbsd rootfs/bin/nc - # ntpdate components - cp --preserve=xattr,timestamps tmp/etc/default/ntpdate rootfs/etc/default/ - sed -i s/NTPDATE_USE_NTP_CONF=yes/NTPDATE_USE_NTP_CONF=no/ rootfs/etc/default/ntpdate - cp_executable tmp/usr/sbin/ntpdate rootfs/usr/sbin/ - cp_executable tmp/usr/sbin/ntpdate-debian rootfs/usr/sbin/ + # rdate + cp_executable tmp/usr/sbin/rdate rootfs/usr/sbin/ # raspberrypi.org GPG key cp --preserve=xattr,timestamps ../"${packages_dir}"/raspberrypi.gpg.key rootfs/usr/share/keyrings/ @@ -440,13 +438,10 @@ function create_cpio { cp --preserve=xattr,timestamps tmp/lib/firmware/regulatory.db-debian rootfs/lib/firmware/regulatory.db cp --preserve=xattr,timestamps tmp/lib/firmware/regulatory.db.p7s-debian rootfs/lib/firmware/regulatory.db.p7s - # vcgencmd - ## libraspberrypi-bin - mkdir -p rootfs/usr/bin + # vcgencmd (raspi-utils-core) cp_executable tmp/usr/bin/vcgencmd rootfs/usr/bin/ # xxd - mkdir -p rootfs/usr/bin cp_executable tmp/usr/bin/xxd rootfs/usr/bin/ # install additional resources @@ -463,6 +458,11 @@ function create_cpio { cp --preserve=xattr,timestamps "${lib}" "$(echo "${lib}" | sed -e 's/^tmp\//rootfs\//')" done + # if /lib/ld-linux-armhf.so.3 is not present, create it as a symlink + if [ ! -e rootfs/lib/ld-linux-armhf.so.3 ]; then + ln -s arm-linux-gnueabihf/ld-linux-armhf.so.3 rootfs/lib/ld-linux-armhf.so.3 + fi + INITRAMFS="../raspberrypi-ua-netinst.cpio.gz" (cd rootfs && find . | cpio -H newc -ov | gzip --best > $INITRAMFS) @@ -493,10 +493,16 @@ rm -rf bootfs mkdir -p bootfs/raspberrypi-ua-netinst # raspberrypi-bootloader components and kernel -cp --preserve=xattr,timestamps -r tmp/boot/* bootfs/ -mv bootfs/kernel*.img bootfs/raspberrypi-ua-netinst/ -mv bootfs/*.dtb bootfs/raspberrypi-ua-netinst/ -mv bootfs/overlays bootfs/raspberrypi-ua-netinst/ +cp --preserve=xattr,timestamps -r tmp/usr/lib/raspi-firmware/* bootfs/ +cp --preserve=xattr,timestamps tmp/boot/vmlinuz-*-v6 bootfs/raspberrypi-ua-netinst/kernel.img +cp --preserve=xattr,timestamps tmp/boot/vmlinuz-*-v7 bootfs/raspberrypi-ua-netinst/kernel7.img +cp --preserve=xattr,timestamps tmp/boot/vmlinuz-*-v7l bootfs/raspberrypi-ua-netinst/kernel7l.img +cp --preserve=xattr,timestamps tmp/boot/vmlinuz-*-v8 bootfs/raspberrypi-ua-netinst/kernel8.img +# *.dtb are the same v6,v7 and v7l kernels but there are additional ones in v8 kernel +cp --preserve=xattr,timestamps tmp/usr/lib/linux-image-*-v6/*.dtb bootfs/raspberrypi-ua-netinst/ +cp --preserve=xattr,timestamps tmp/usr/lib/linux-image-*-v8/broadcom/*.dtb bootfs/raspberrypi-ua-netinst/ +# overlays are the same in all kernels, copy any of them +cp --preserve=xattr,timestamps -r tmp/usr/lib/linux-image-*-v6/overlays bootfs/raspberrypi-ua-netinst/ if [ ! -f bootfs/config.txt ] ; then touch bootfs/config.txt diff --git a/scripts/opt/raspberrypi-ua-netinst/install.sh b/scripts/opt/raspberrypi-ua-netinst/install.sh index 02886fc..43f46ca 100644 --- a/scripts/opt/raspberrypi-ua-netinst/install.sh +++ b/scripts/opt/raspberrypi-ua-netinst/install.sh @@ -9,7 +9,6 @@ variables_reset() { am_subscript= final_action= rpi_hardware= - rpi_hardware_version= preinstall_reboot= bootpartition= rootdev= @@ -150,7 +149,7 @@ variables_set_defaults() { else variable_set "mirror" "http://mirrordirector.raspbian.org/raspbian/" fi - variable_set "release" "bullseye" + variable_set "release" "bookworm" variable_set "hostname" "pi" variable_set "rootpw" "raspbian" variable_set "root_ssh_pwlogin" "1" @@ -204,7 +203,7 @@ led_sos() { # Setting leds on and off works the other way round on Pi Zero and Pi Zero W # Also led0 (the only led on the Zeros) is the activity led - if [ "${rpi_hardware_version:0:4}" != "Zero" ]; then + if [ "${rpi_hardware:0:10}" != "model-zero" ]; then led_on=1 led_off=0 else @@ -369,15 +368,15 @@ convert_listvariable() { install_files() { local file_to_read="${1}" echo "Adding files & folders listed in /boot/raspberrypi-ua-netinst/config/files/${file_to_read}..." - inputfile_sanitize "/rootfs/boot/raspberrypi-ua-netinst/config/files/${file_to_read}" - grep -v "^[[:space:]]*#\|^[[:space:]]*$" "/rootfs/boot/raspberrypi-ua-netinst/config/files/${file_to_read}" | while read -r line; do + inputfile_sanitize "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/${file_to_read}" + grep -v "^[[:space:]]*#\|^[[:space:]]*$" "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/${file_to_read}" | while read -r line; do owner=$(echo "${line}" | awk '{ print $1 }') perms=$(echo "${line}" | awk '{ print $2 }') file=$(echo "${line}" | awk '{ print $3 }') echo " ${file}" - if [ ! -d "/rootfs/boot/raspberrypi-ua-netinst/config/files/root${file}" ]; then + if [ ! -d "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/root${file}" ]; then mkdir -p "/rootfs$(dirname "${file}")" - cp "/rootfs/boot/raspberrypi-ua-netinst/config/files/root${file}" "/rootfs${file}" + cp "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/root${file}" "/rootfs${file}" else mkdir -p "/rootfs/${file}" fi @@ -659,57 +658,7 @@ tee < "${logfile}.pipe" "${logfile}" & exec &> "${logfile}.pipe" rm "${logfile}.pipe" -# detecting model based on http://elinux.org/RPi_HardwareHistory -rpi_hardware="$(grep Revision /proc/cpuinfo | cut -d " " -f 2 | sed 's/^1000//')" -case "${rpi_hardware}" in - "0002") rpi_hardware_version="B" ;; - "0003") rpi_hardware_version="B" ;; - "0004") rpi_hardware_version="B" ;; - "0005") rpi_hardware_version="B" ;; - "0006") rpi_hardware_version="B" ;; - "0007") rpi_hardware_version="A" ;; - "0008") rpi_hardware_version="A" ;; - "0009") rpi_hardware_version="A" ;; - "000d") rpi_hardware_version="B" ;; - "000e") rpi_hardware_version="B" ;; - "000f") rpi_hardware_version="B" ;; - "0010") rpi_hardware_version="B+" ;; - "0011") rpi_hardware_version="Compute Module 1" ;; - "0012") rpi_hardware_version="A+" ;; - "0013") rpi_hardware_version="B+" ;; - "0014") rpi_hardware_version="Compute Module 1" ;; - "0015") rpi_hardware_version="A+" ;; - "a01040") rpi_hardware_version="2 Model B" ;; - "a01041") rpi_hardware_version="2 Model B" ;; - "a21041") rpi_hardware_version="2 Model B" ;; - "a22042") rpi_hardware_version="2 Model B+" ;; - "900021") rpi_hardware_version="A+" ;; - "900032") rpi_hardware_version="B+" ;; - "900092") rpi_hardware_version="Zero" ;; - "900093") rpi_hardware_version="Zero" ;; - "920093") rpi_hardware_version="Zero" ;; - "9000c1") rpi_hardware_version="Zero W" ;; - "a02082") rpi_hardware_version="3 Model B" ;; - "a020a0") rpi_hardware_version="Compute Module 3 (Lite)" ;; - "a22082") rpi_hardware_version="3 Model B" ;; - "a32082") rpi_hardware_version="3 Model B" ;; - "a020d3") rpi_hardware_version="3 Model B+" ;; - "9020e0") rpi_hardware_version="3 Model A+" ;; - "a02100") rpi_hardware_version="Compute Module 3+" ;; - "a03111") rpi_hardware_version="4 Model B" ;; - "b03111") rpi_hardware_version="4 Model B" ;; - "b03112") rpi_hardware_version="4 Model B" ;; - "b03114") rpi_hardware_version="4 Model B" ;; - "b03115") rpi_hardware_version="4 Model B" ;; - "c03111") rpi_hardware_version="4 Model B" ;; - "c03112") rpi_hardware_version="4 Model B" ;; - "c03114") rpi_hardware_version="4 Model B" ;; - "c03115") rpi_hardware_version="4 Model B" ;; - "d03114") rpi_hardware_version="4 Model B" ;; - "d03115") rpi_hardware_version="4 Model B" ;; - "902120") rpi_hardware_version="Zero 2 W" ;; - *) rpi_hardware_version="unknown (${rpi_hardware})" ;; -esac +rpi_hardware="$(cat /proc/device-tree/compatible | tr '\0' '\n' | head -1 | cut -d, -f 2)" echo echo "==================================================" @@ -717,7 +666,7 @@ echo "raspberrypi-ua-netinst" echo "==================================================" echo "Revision __VERSION__" echo "Built on __DATE__" -echo "Running on Raspberry Pi version ${rpi_hardware_version}" +echo "Running on $(tr '\0' '\n' /dev/null; then @@ -1258,7 +1207,21 @@ if [ -z "${cdebootstrap_cmdline}" ]; then if [ "$(find "${tmp_bootfs}"/raspberrypi-ua-netinst/config/apt/ -maxdepth 1 -type f -name "*.list" 2> /dev/null | wc -l)" != 0 ]; then base_packages="${base_packages},apt-transport-https" fi - base_packages_postinstall="raspberrypi-bootloader,raspberrypi-kernel" + # determine which kernel package to install + # v8 kernel is for everything running in 64-bit mode + if [ "${arch}" = "arm64" ]; then + kernel_type="v8" + # v7l kernel is for 4 and 400 + elif [ "${rpi_hardware:0:1}" = "4" ]; then + kernel_type="v7l" + # v6 kernel is for everything armv6l-based + elif [ "$(uname -m)" = "armv6l" ]; then + kernel_type="v6" + # v7 kernel is for anything other + else + kernel_type="v7" + fi + base_packages_postinstall="raspi-firmware,linux-image-rpi-${kernel_type}" base_packages_postinstall="${custom_packages_postinstall},${base_packages_postinstall}" # minimal @@ -1283,7 +1246,6 @@ if [ -z "${cdebootstrap_cmdline}" ]; then server_packages="${server_packages},systemd-sysv" fi server_packages_postinstall="${minimal_packages_postinstall},${server_packages_postinstall}" - server_packages_postinstall="${server_packages_postinstall},libraspberrypi-bin" if [ "${arch}" != "arm64" ]; then server_packages_postinstall="${server_packages_postinstall},raspi-copies-and-fills" fi @@ -1643,7 +1605,8 @@ echo "OK" echo -n "Mounting new filesystems... " mount "${rootpartition}" /rootfs -o "${rootfs_install_mount_options}" || fail mkdir /rootfs/boot || fail -mount "${bootpartition}" /rootfs/boot || fail +mkdir /rootfs/boot/firmware || fail +mount "${bootpartition}" /rootfs/boot/firmware || fail echo "OK" # use 256MB file based swap during installation if needed @@ -1719,9 +1682,9 @@ fi if [ -n "${root_ssh_pubkey}" ]; then echo -n " Setting root SSH key" if mkdir -p /rootfs/root/.ssh && chmod 700 /rootfs/root/.ssh; then - if [ -f "/rootfs/boot/raspberrypi-ua-netinst/config/files/${root_ssh_pubkey}" ]; then + if [ -f "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/${root_ssh_pubkey}" ]; then echo -n " from file '${root_ssh_pubkey}'... " - cp "/rootfs/boot/raspberrypi-ua-netinst/config/files/${root_ssh_pubkey}" /rootfs/root/.ssh/authorized_keys || fail + cp "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/${root_ssh_pubkey}" /rootfs/root/.ssh/authorized_keys || fail echo "OK" else echo -n "... " @@ -1766,9 +1729,9 @@ if [ -n "${username}" ]; then if [ -n "${user_ssh_pubkey}" ]; then echo -n " Setting SSH key for '${username}'" if mkdir -p "/rootfs/home/${username}/.ssh" && chmod 700 "/rootfs/home/${username}/.ssh"; then - if [ -f "/rootfs/boot/raspberrypi-ua-netinst/config/files/${user_ssh_pubkey}" ]; then + if [ -f "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/${user_ssh_pubkey}" ]; then echo -n " from file '${user_ssh_pubkey}'... " - cp "/rootfs/boot/raspberrypi-ua-netinst/config/files/${user_ssh_pubkey}" "/rootfs/home/${username}/.ssh/authorized_keys" || fail + cp "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/${user_ssh_pubkey}" "/rootfs/home/${username}/.ssh/authorized_keys" || fail echo "OK" else echo -n "... " @@ -1840,7 +1803,7 @@ rootpartition_uuid=PARTUUID=$(blkid -o value -s PARTUUID ${rootpartition}) echo -n " Configuring /etc/fstab... " touch /rootfs/etc/fstab || fail { - echo "${bootpartition_uuid} /boot vfat defaults 0 2" + echo "${bootpartition_uuid} /boot/firmware vfat defaults 0 2" if [ "${rootfstype}" = "f2fs" ]; then echo "${rootpartition_uuid} / ${rootfstype} ${rootfs_mount_options} 0 0" elif [ "${rootfstype}" = "btrfs" ]; then @@ -2138,8 +2101,8 @@ fi # copy apt's sources.list to the target system echo "Configuring apt:" echo -n " Configuring Raspbian/Debian repository... " -if [ -e "/rootfs/boot/raspberrypi-ua-netinst/config/apt/sources.list" ]; then - sed "s/__RELEASE__/${release_raspbian}/g" "/rootfs/boot/raspberrypi-ua-netinst/config/apt/sources.list" > "/rootfs/etc/apt/sources.list" || fail +if [ -e "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/apt/sources.list" ]; then + sed "s/__RELEASE__/${release_raspbian}/g" "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/apt/sources.list" > "/rootfs/etc/apt/sources.list" || fail else if [ "${arch}" = "arm64" ]; then echo "deb ${mirror} ${release_raspbian} main contrib non-free" > "/rootfs/etc/apt/sources.list" || fail @@ -2162,15 +2125,15 @@ echo -n " Adding raspberrypi.org GPG key to apt-key... " echo "OK" echo -n " Configuring RaspberryPi repository... " -if [ -e "/rootfs/boot/raspberrypi-ua-netinst/config/apt/raspberrypi.org.list" ]; then - sed "s/__RELEASE__/${release_base}/g" "/rootfs/boot/raspberrypi-ua-netinst/config/apt/raspberrypi.org.list" > "/rootfs/etc/apt/sources.list.d/raspberrypi.org.list" || fail +if [ -e "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/apt/raspberrypi.org.list" ]; then + sed "s/__RELEASE__/${release_base}/g" "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/apt/raspberrypi.org.list" > "/rootfs/etc/apt/sources.list.d/raspberrypi.org.list" || fail else sed "s/__RELEASE__/${release_base}/g" "/opt/raspberrypi-ua-netinst/res/etc/apt/raspberrypi.org.list" > "/rootfs/etc/apt/sources.list.d/raspberrypi.org.list" || fail fi echo "OK" echo -n " Configuring RaspberryPi preference... " -if [ -e "/rootfs/boot/raspberrypi-ua-netinst/config/apt/archive_raspberrypi_org.pref" ]; then - sed "s/__RELEASE__/${release_base}/g" "/rootfs/boot/raspberrypi-ua-netinst/config/apt/archive_raspberrypi_org.pref" > "/rootfs/etc/apt/preferences.d/archive_raspberrypi_org.pref" || fail +if [ -e "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/apt/archive_raspberrypi_org.pref" ]; then + sed "s/__RELEASE__/${release_base}/g" "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/apt/archive_raspberrypi_org.pref" > "/rootfs/etc/apt/preferences.d/archive_raspberrypi_org.pref" || fail else sed "s/__RELEASE__/${release_base}/g" "/opt/raspberrypi-ua-netinst/res/etc/apt/archive_raspberrypi_org.pref" > "/rootfs/etc/apt/preferences.d/archive_raspberrypi_org.pref" || fail fi @@ -2178,7 +2141,7 @@ echo "OK" # save the current location so that we can go back to it later on old_dir=$(pwd) -cd /rootfs/boot/raspberrypi-ua-netinst/config/apt/ || fail +cd /rootfs/boot/firmware/raspberrypi-ua-netinst/config/apt/ || fail # iterate through all the *.list files and add them to /etc/apt/sources.list.d for listfile in ./*.list @@ -2284,8 +2247,23 @@ for i in $(seq 1 "${installer_pkg_downloadretries}"); do fi done +# Install raspi-firmware and initramfs-tools first so we can disable initramfs (when not needed) +# before it gets trigered by a kernel package +echo +echo "Installing bootloader (=firmware) and initramfs-tools..." +eval chroot /rootfs /usr/bin/apt-get -y install raspi-firmware initramfs-tools 2>&1 | output_filter +if [ "${PIPESTATUS[0]}" -eq 0 ]; then + echo "OK" +else + echo "FAILED !" +fi +if [ ! "${kernel_module}" = true ]; then + sed -i 's/#SKIP_INITRAMFS_GEN=no/SKIP_INITRAMFS_GEN=yes/' /rootfs/etc/default/raspi-firmware + sed -i 's/update_initramfs=yes/update_initramfs=no/' /rootfs/etc/initramfs-tools/update-initramfs.conf +fi + echo -echo "Installing kernel, bootloader (=firmware) and user packages..." +echo "Installing kernel and user packages..." eval chroot /rootfs /usr/bin/apt-get -y upgrade "${packages_postinstall}" 2>&1 | output_filter if [ "${PIPESTATUS[0]}" -eq 0 ]; then echo "OK" @@ -2302,18 +2280,18 @@ chroot /rootfs /usr/bin/dpkg -r cdebootstrap-helper-rc.d &> /dev/null || fail echo "OK" echo -n "Configuring bootloader to start the installed system..." -if [ -e "/rootfs/boot/raspberrypi-ua-netinst/config/boot/config.txt" ]; then - cp /rootfs/boot/raspberrypi-ua-netinst/config/boot/config.txt /rootfs/boot/config.txt +if [ -e "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/boot/config.txt" ]; then + cp /rootfs/boot/firmware/raspberrypi-ua-netinst/config/boot/config.txt /rootfs/boot/firmware/config.txt else - cp /opt/raspberrypi-ua-netinst/res/boot/config.txt /rootfs/boot/config.txt + cp /opt/raspberrypi-ua-netinst/res/boot/config.txt /rootfs/boot/firmware/config.txt fi -if [ -n "$(tail -c1 /rootfs/boot/config.txt)" ]; then - echo >> /rootfs/boot/config.txt +if [ -n "$(tail -c1 /rootfs/boot/firmware/config.txt)" ]; then + echo >> /rootfs/boot/firmware/config.txt fi # extend device initialization time when booting from usb if [ "${usbboot}" = "1" ]; then - touch /rootfs/boot/TIMEOUT + touch /rootfs/boot/firmware/TIMEOUT fi echo "OK" @@ -2325,7 +2303,7 @@ line_add_if_boolean disable_raspberries cmdline_custom "logo.nologo" line_add_if_set console_blank cmdline_custom "consoleblank=${console_blank}" line_add_if_boolean_not ip_ipv6 cmdline_custom "ipv6.disable=1" line_add_if_set cmdline_custom cmdline "${cmdline_custom}" -echo "${cmdline}" > /rootfs/boot/cmdline.txt +echo "${cmdline}" > /rootfs/boot/firmware/cmdline.txt echo "OK" # Password warning @@ -2337,42 +2315,42 @@ fi # enable spi if specified in the configuration file if [ "${spi_enable}" = "1" ]; then - if [ "$(grep -c "^dtparam=spi=.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^#\(dtparam=spi=on\)/\1/" /rootfs/boot/config.txt - sed -i "s/^\(dtparam=spi=.*\)/#\1/" /rootfs/boot/config.txt - echo "dtparam=spi=on" >> /rootfs/boot/config.txt + if [ "$(grep -c "^dtparam=spi=.*" /rootfs/boot/firmware/config.txt)" -ne 1 ]; then + sed -i "s/^#\(dtparam=spi=on\)/\1/" /rootfs/boot/firmware/config.txt + sed -i "s/^\(dtparam=spi=.*\)/#\1/" /rootfs/boot/firmware/config.txt + echo "dtparam=spi=on" >> /rootfs/boot/firmware/config.txt fi fi # enable i2c if specified in the configuration file if [ "${i2c_enable}" = "1" ]; then - sed -i "s/^#\(dtparam=i2c_arm=on\)/\1/" /rootfs/boot/config.txt - if [ "$(grep -c "^dtparam=i2c_arm=.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^\(dtparam=i2c_arm=.*\)/#\1/" /rootfs/boot/config.txt - echo "dtparam=i2c_arm=on" >> /rootfs/boot/config.txt + sed -i "s/^#\(dtparam=i2c_arm=on\)/\1/" /rootfs/boot/firmware/config.txt + if [ "$(grep -c "^dtparam=i2c_arm=.*" /rootfs/boot/firmware/config.txt)" -ne 1 ]; then + sed -i "s/^\(dtparam=i2c_arm=.*\)/#\1/" /rootfs/boot/firmware/config.txt + echo "dtparam=i2c_arm=on" >> /rootfs/boot/firmware/config.txt fi module_enable "i2c-dev" "i2c" if [ -n "${i2c_baudrate}" ]; then - if grep -q "i2c_baudrate=" /rootfs/boot/config.txt; then - sed -i "s/\(.*i2c_baudrate=.*\)/#\1/" /rootfs/boot/config.txt + if grep -q "i2c_baudrate=" /rootfs/boot/firmware/config.txt; then + sed -i "s/\(.*i2c_baudrate=.*\)/#\1/" /rootfs/boot/firmware/config.txt fi - if grep -q "i2c_arm_baudrate=" /rootfs/boot/config.txt; then - sed -i "s/\(.*i2c_arm_baudrate=.*\)/#\1/" /rootfs/boot/config.txt + if grep -q "i2c_arm_baudrate=" /rootfs/boot/firmware/config.txt; then + sed -i "s/\(.*i2c_arm_baudrate=.*\)/#\1/" /rootfs/boot/firmware/config.txt fi - sed -i "s/^#\(dtparam=i2c_arm_baudrate=${i2c_baudrate}\)/\1/" /rootfs/boot/config.txt - if [ "$(grep -c "^dtparam=i2c_arm_baudrate=.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^\(dtparam=i2c_arm_baudrate=.*\)/#\1/" /rootfs/boot/config.txt - echo "dtparam=i2c_arm_baudrate=${i2c_baudrate}" >> /rootfs/boot/config.txt + sed -i "s/^#\(dtparam=i2c_arm_baudrate=${i2c_baudrate}\)/\1/" /rootfs/boot/firmware/config.txt + if [ "$(grep -c "^dtparam=i2c_arm_baudrate=.*" /rootfs/boot/firmware/config.txt)" -ne 1 ]; then + sed -i "s/^\(dtparam=i2c_arm_baudrate=.*\)/#\1/" /rootfs/boot/firmware/config.txt + echo "dtparam=i2c_arm_baudrate=${i2c_baudrate}" >> /rootfs/boot/firmware/config.txt fi fi fi # enable sound if specified in the configuration file if [ "${sound_enable}" = "1" ]; then - sed -i "s/^#\(dtparam=audio=on\)/\1/" /rootfs/boot/config.txt - if [ "$(grep -c "^dtparam=audio=.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^\(dtparam=audio=.*\)/#\1/" /rootfs/boot/config.txt - echo "dtparam=audio=on" >> /rootfs/boot/config.txt + sed -i "s/^#\(dtparam=audio=on\)/\1/" /rootfs/boot/firmware/config.txt + if [ "$(grep -c "^dtparam=audio=.*" /rootfs/boot/firmware/config.txt)" -ne 1 ]; then + sed -i "s/^\(dtparam=audio=.*\)/#\1/" /rootfs/boot/firmware/config.txt + echo "dtparam=audio=on" >> /rootfs/boot/firmware/config.txt fi fi @@ -2381,35 +2359,35 @@ if [ "${camera_enable}" = "1" ]; then if [ "0${gpu_mem}" -lt "128" ]; then gpu_mem=128 fi - sed -i "s/^#\(start_x=1\)/\1/" /rootfs/boot/config.txt - if [ "$(grep -c "^start_x=.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^\(start_x=.*\)/#\1/" /rootfs/boot/config.txt - echo "start_x=1" >> /rootfs/boot/config.txt + sed -i "s/^#\(start_x=1\)/\1/" /rootfs/boot/firmware/config.txt + if [ "$(grep -c "^start_x=.*" /rootfs/boot/firmware/config.txt)" -ne 1 ]; then + sed -i "s/^\(start_x=.*\)/#\1/" /rootfs/boot/firmware/config.txt + echo "start_x=1" >> /rootfs/boot/firmware/config.txt fi if [ "${camera_disable_led}" = "1" ]; then - sed -i "s/^#\(disable_camera_led=1\)/\1/" /rootfs/boot/config.txt - if [ "$(grep -c "^disable_camera_led=.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^\(disable_camera_led=.*\)/#\1/" /rootfs/boot/config.txt - echo "disable_camera_led=1" >> /rootfs/boot/config.txt + sed -i "s/^#\(disable_camera_led=1\)/\1/" /rootfs/boot/firmware/config.txt + if [ "$(grep -c "^disable_camera_led=.*" /rootfs/boot/firmware/config.txt)" -ne 1 ]; then + sed -i "s/^\(disable_camera_led=.*\)/#\1/" /rootfs/boot/firmware/config.txt + echo "disable_camera_led=1" >> /rootfs/boot/firmware/config.txt fi fi fi # set gpu_mem if specified in the configuration file if [ -n "${gpu_mem}" ]; then - sed -i "s/^#\(gpu_mem=${gpu_mem}\)/\1/" /rootfs/boot/config.txt - if [ "$(grep -c "^gpu_mem=.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^\(gpu_mem=.*\)/#\1/" /rootfs/boot/config.txt - echo "gpu_mem=${gpu_mem}" >> /rootfs/boot/config.txt + sed -i "s/^#\(gpu_mem=${gpu_mem}\)/\1/" /rootfs/boot/firmware/config.txt + if [ "$(grep -c "^gpu_mem=.*" /rootfs/boot/firmware/config.txt)" -ne 1 ]; then + sed -i "s/^\(gpu_mem=.*\)/#\1/" /rootfs/boot/firmware/config.txt + echo "gpu_mem=${gpu_mem}" >> /rootfs/boot/firmware/config.txt fi fi # enable hardware watchdog and set up systemd to use it if [ "${watchdog_enable}" = "1" ]; then - sed -i "s/^#\(dtparam=watchdog=on\)/\1/" /rootfs/boot/config.txt - if [ "$(grep -c "^dtparam=watchdog=.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^\(dtparam=watchdog=.*\)/#\1/" /rootfs/boot/config.txt - echo "dtparam=watchdog=on" >> /rootfs/boot/config.txt + sed -i "s/^#\(dtparam=watchdog=on\)/\1/" /rootfs/boot/firmware/config.txt + if [ "$(grep -c "^dtparam=watchdog=.*" /rootfs/boot/firmware/config.txt)" -ne 1 ]; then + sed -i "s/^\(dtparam=watchdog=.*\)/#\1/" /rootfs/boot/firmware/config.txt + echo "dtparam=watchdog=on" >> /rootfs/boot/firmware/config.txt fi if [ "${init_system}" = "systemd" ]; then sed -i 's/^.*RuntimeWatchdogSec=.*$/RuntimeWatchdogSec=14s/' /rootfs/etc/systemd/system.conf @@ -2445,44 +2423,44 @@ fi # set hdmi options if [ "${hdmi_type}" = "tv" ] || [ "${hdmi_type}" = "monitor" ]; then - config_set "/rootfs/boot/config.txt" "hdmi_ignore_edid" "0xa5000080" - config_set "/rootfs/boot/config.txt" "hdmi_drive" "2" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_ignore_edid" "0xa5000080" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_drive" "2" if [ "${hdmi_type}" = "tv" ]; then - config_set "/rootfs/boot/config.txt" "hdmi_group" "1" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_group" "1" if [ "${hdmi_tv_res}" = "720p" ]; then #hdmi_mode=4 720p@60Hz - config_set "/rootfs/boot/config.txt" "hdmi_mode" "4" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_mode" "4" elif [ "${hdmi_tv_res}" = "1080i" ]; then #hdmi_mode=5 1080i@60Hz - config_set "/rootfs/boot/config.txt" "hdmi_mode" "5" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_mode" "5" else #hdmi_mode=16 1080p@60Hz - config_set "/rootfs/boot/config.txt" "hdmi_mode" "16" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_mode" "16" fi elif [ "${hdmi_type}" = "monitor" ]; then - config_set "/rootfs/boot/config.txt" "hdmi_group" "2" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_group" "2" if [ "${hdmi_monitor_res}" = "640x480" ]; then #hdmi_mode=4 640x480@60Hz - config_set "/rootfs/boot/config.txt" "hdmi_mode" "4" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_mode" "4" elif [ "${hdmi_monitor_res}" = "800x600" ]; then #hdmi_mode=9 800x600@60Hz - config_set "/rootfs/boot/config.txt" "hdmi_mode" "9" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_mode" "9" elif [ "${hdmi_monitor_res}" = "1280x1024" ]; then #hdmi_mode=35 1280x1024@60Hz - config_set "/rootfs/boot/config.txt" "hdmi_mode" "35" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_mode" "35" else #hdmi_mode=16 1024x768@60Hz - config_set "/rootfs/boot/config.txt" "hdmi_mode" "16" + config_set "/rootfs/boot/firmware/config.txt" "hdmi_mode" "16" fi fi fi if [ "${hdmi_disable_overscan}" = "1" ]; then - config_set "/rootfs/boot/config.txt" "disable_overscan" "1" + config_set "/rootfs/boot/firmware/config.txt" "disable_overscan" "1" fi # enable rtc if specified in the configuration file if [ -n "${rtc}" ]; then - dtoverlay_enable "/rootfs/boot/config.txt" "i2c-rtc,${rtc}" + dtoverlay_enable "/rootfs/boot/firmware/config.txt" "i2c-rtc,${rtc}" module_enable "rtc-${rtc}" "rtc" fi @@ -2492,14 +2470,14 @@ if [ -n "${dt_overlays}" ]; then convert_listvariable dt_overlays for dtoverlay in ${dt_overlays}; do echo " ${dtoverlay}" - dtoverlay_enable "/rootfs/boot/config.txt" "${dtoverlay}" + dtoverlay_enable "/rootfs/boot/firmware/config.txt" "${dtoverlay}" done echo "OK" fi # disable splash if specified in the configuration file if [ "${disable_splash}" = "1" ]; then - config_set "/rootfs/boot/config.txt" "disable_splash" "1" + config_set "/rootfs/boot/firmware/config.txt" "disable_splash" "1" fi if [ "${sound_enable}" = "1" ] && [ "${sound_usb_enable}" = "1" ] && [ "${sound_usb_first}" = "1" ]; then @@ -2515,12 +2493,12 @@ fi # set mmc1 (USB) as default trigger for activity led if [ "${usbroot}" = "1" ]; then - dtoverlay_enable "/rootfs/boot/config.txt" "act_led_trigger" "mmc1" + dtoverlay_enable "/rootfs/boot/firmware/config.txt" "act_led_trigger" "mmc1" fi # iterate through all the file lists and call the install_files method for them old_dir=$(pwd) -cd /rootfs/boot/raspberrypi-ua-netinst/config/files/ || fail +cd /rootfs/boot/firmware/raspberrypi-ua-netinst/config/files/ || fail for listfile in ./*.list do if [ -e "${listfile}" ]; then @@ -2530,11 +2508,11 @@ done cd "${old_dir}" || fail # run post install script if exists -if [ -e "/rootfs/boot/raspberrypi-ua-netinst/config/post-install.txt" ]; then +if [ -e "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/post-install.txt" ]; then echo "=================================================" echo "=== Start executing post-install.txt. ===" - inputfile_sanitize /rootfs/boot/raspberrypi-ua-netinst/config/post-install.txt - source /rootfs/boot/raspberrypi-ua-netinst/config/post-install.txt + inputfile_sanitize /rootfs/boot/firmware/raspberrypi-ua-netinst/config/post-install.txt + source /rootfs/boot/firmware/raspberrypi-ua-netinst/config/post-install.txt echo "=== Finished executing post-install.txt. ===" echo "=================================================" fi @@ -2570,7 +2548,7 @@ echo "Printing console to telnet output stopped." # copy logfile to standard log directory if [ "${cleanup_logfiles}" = "1" ]; then - rm -f /rootfs/boot/raspberrypi-ua-netinst/error-*.log + rm -f /rootfs/boot/firmware/raspberrypi-ua-netinst/error-*.log else sleep 1 # root, user and wifi passwords are deleted from logfile before it is written to the filesystem @@ -2580,7 +2558,7 @@ fi # remove clear text wifi password from installer config if [ -n "${wlan_psk}" ]; then - sed -i "s/wlan_psk=.*/wlan_psk_encrypted=${wlan_psk_encrypted}/" "/rootfs/boot/raspberrypi-ua-netinst/config/installer-config.txt" + sed -i "s/wlan_psk=.*/wlan_psk_encrypted=${wlan_psk_encrypted}/" "/rootfs/boot/firmware/raspberrypi-ua-netinst/config/installer-config.txt" fi # Cleanup installer files @@ -2591,7 +2569,7 @@ if [ -e "${installer_swapfile}" ]; then fi if [ "${cleanup}" = "1" ]; then echo -n "Removing installer files... " - rm -rf /rootfs/boot/raspberrypi-ua-netinst/ + rm -rf /rootfs/boot/firmware/raspberrypi-ua-netinst/ echo "OK" fi @@ -2607,7 +2585,7 @@ if [ "${final_action}" != "console" ]; then umount "/rootfs${sysfolder}" done sync - umount /rootfs/boot + umount /rootfs/boot/firmware umount /rootfs echo "OK" fi diff --git a/update.sh b/update.sh index 229ba0a..b9030ea 100755 --- a/update.sh +++ b/update.sh @@ -21,8 +21,11 @@ release=bookworm packages=() # programs -packages+=("raspberrypi-bootloader") -packages+=("raspberrypi-kernel") +packages+=("raspi-firmware") +packages+=("linux-image-rpi-v6") +packages+=("linux-image-rpi-v7") +packages+=("linux-image-rpi-v7l") +packages+=("linux-image-rpi-v8") packages+=("firmware-brcm80211") packages+=("wireless-regdb") packages+=("btrfs-progs") @@ -39,10 +42,10 @@ packages+=("f2fs-tools") packages+=("gpgv") packages+=("ifupdown") packages+=("iproute2") -packages+=("lsb-base") +packages+=("sysvinit-utils") packages+=("netbase") packages+=("netcat-openbsd") -packages+=("ntpdate") +packages+=("rdate") packages+=("raspbian-archive-keyring") packages+=("debian-archive-keyring") packages+=("rng-tools5") @@ -50,7 +53,7 @@ packages+=("tar") packages+=("fdisk") packages+=("util-linux") packages+=("wpasupplicant") -packages+=("libraspberrypi-bin") +packages+=("raspi-utils-core") packages+=("xxd") packages+=("curl") packages+=("logsave") @@ -189,22 +192,22 @@ download_package_list() { for extension in "${extensions[@]}"; do # Check that this extension is available - if grep -q "${package_section}/binary-armhf/Packages${extension}" "${1}_Release"; then + if grep -q "${package_section}/binary-${3}/Packages${extension}" "${1}_Release"; then # Download Packages file echo -e "\nDownloading ${package_section} package list..." - if ! download_file "${2}/dists/$release/$package_section/binary-armhf/Packages${extension}" "tmp${extension}"; then + if ! download_file "${2}/dists/$release/$package_section/binary-${3}/Packages${extension}" "tmp${extension}"; then echo -e "ERROR\nDownloading '${package_section}' package list failed! Exiting." cd .. exit 1 fi - # Verify the checksum of the Packages file, assuming that the last checksums in the Release file are SHA256 sums + # Verify the SHA256 checksum of the Packages file echo -n "Verifying ${package_section} package list... " - if [ "$(grep "${package_section}/binary-armhf/Packages${extension}" "${1}_Release" | tail -n1 | awk '{print $1}')" = "$(sha256sum "tmp${extension}" | awk '{print $1}')" ]; then + if [ "$(sed '1,/^SHA256:$/d' "${1}_Release" | grep "${package_section}/binary-${3}/Packages${extension}" | head -n1 | awk '{print $1}')" = "$(sha256sum "tmp${extension}" | awk '{print $1}')" ]; then echo "OK" else - echo -e "ERROR\nThe checksum of file '${package_section}/binary-armhf/Packages${extension}' doesn't match!" + echo -e "ERROR\nThe checksum of file '${package_section}/binary-${3}/Packages${extension}' doesn't match!" cd .. exit 1 fi @@ -219,7 +222,7 @@ download_package_list() { elif [ "${extension}" = "" ]; then decompressor="cat " fi - ${decompressor} "tmp${extension}" >> "${1}_Packages" + ${decompressor} "tmp${extension}" >> "${1}-${3}_Packages" rm "tmp${extension}" break fi @@ -242,20 +245,20 @@ download_package_lists() { echo -n > "${1}_Packages" if [ "${1}" != "debian" ]; then package_section=firmware - download_package_list "${1}" "${2}" + download_package_list "${1}" "${2}" "${3}" else package_section=non-free-firmware - download_package_list "${1}" "${2}" + download_package_list "${1}" "${2}" "${3}" fi package_section=main - download_package_list "${1}" "${2}" + download_package_list "${1}" "${2}" "${3}" package_section=non-free - download_package_list "${1}" "${2}" + download_package_list "${1}" "${2}" "${3}" } add_packages() { echo -e "\nAdding required packages..." - filter_package_list < "${1}_Packages" >"${1}_Packages.tmp" + filter_package_list < "${1}-${3}_Packages" >"${1}-${3}_Packages.tmp" while true; do libs=() for pkg in "${packages[@]}"; do @@ -278,7 +281,7 @@ add_packages() { elif [ "${k}" = "" ]; then break fi - done < <(grep -A 4 -m 1 ^Package:\ "$pkg"$ "${1}_Packages.tmp") + done < <(grep -A 4 -m 1 ^Package:\ "$pkg"$ "${1}-${3}_Packages.tmp") if [ -z "${current_package}" ]; then # package not found continue fi @@ -287,7 +290,7 @@ add_packages() { packages_debs+=("${2}/${current_filename}") packages_sha256+=("${current_sha256} $(basename "${current_filename}")") packages_done+=("${current_package}") - while IFS='' read -r line; do libs+=("$line"); done < <(printf '%s\n' "${current_depends[@]}" | grep "lib") + while IFS='' read -r line; do libs+=("$line"); done < <(printf '%s\n' "${current_depends[@]}" | grep -E "lib|linux-image") done # remove duplicate libs mapfile -t libs < <(printf '%s\n' "${libs[@]}" | sort | uniq) @@ -371,17 +374,19 @@ fi fi ## Download package list - download_package_lists raspberry "${mirror_raspberrypi}" - download_package_lists raspbian "${mirror_raspbian}" - download_package_lists debian "${mirror_debian}" + download_package_lists raspberry "${mirror_raspberrypi}" armhf + download_package_lists raspberry "${mirror_raspberrypi}" arm64 + download_package_lists raspbian "${mirror_raspbian}" armhf + download_package_lists debian "${mirror_debian}" armhf ## Select packages for download packages_debs=() packages_sha256=() - add_packages raspberry "${mirror_raspberrypi}" - add_packages raspbian "${mirror_raspbian}" - add_packages debian "${mirror_debian}" + add_packages raspberry "${mirror_raspberrypi}" armhf + add_packages raspbian "${mirror_raspbian}" armhf + add_packages debian "${mirror_debian}" armhf + add_packages raspberry "${mirror_raspberrypi}" arm64 if ! allfound; then echo "ERROR: Unable to find all required packages in package list!" echo "Missing packages: '${packages[*]}'"