diff --git a/.travis.yml b/.travis.yml index 970f2046..49ae6596 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: bash sudo: false -install: gem install mdl +install: gem install chef-utils:16.6.14 mdl script: - bash -c 'shopt -s globstar; shellcheck **/*.sh' - mdl --verbose --rules '~MD013, ~MD036' . diff --git a/BUILD.md b/BUILD.md index 967210f5..bf52e0d2 100644 --- a/BUILD.md +++ b/BUILD.md @@ -46,5 +46,6 @@ To set buildroot options, create a file named `buildroot.conf`, which contains t - `compress_bz2=1` - create a bz2-compressed image - `compress_xz=1` - create a xz-compressed image +- `use_sudo=1` - use passwordless-sudo for operations which require root privileges By default both bzip2 and xz compressed versions of the image will be created and the uncompressed image will deleted, but either or both can be disabled. If both are disabled, the uncompressed image will be left in place. diff --git a/LICENSE b/LICENSE index 135c6d62..b8b02f08 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2018 Andreas Eberlein +Copyright (c) 2016-2020 Andreas Eberlein Copyright (c) 2013 Toni Spets Permission to use, copy, modify, and distribute this software for any diff --git a/README.md b/README.md index f043e546..d22e3c93 100644 --- a/README.md +++ b/README.md @@ -147,10 +147,12 @@ When an error occurs during install, the logfile is placed in the `raspberrypi-u ## Reinstalling or replacing an existing system -If you want to reinstall with the same settings you did your first install you can just move the original _config.txt_ back and reboot. +If you want to reinstall with the same settings you did your first install you can just copy the original _config.txt_ back and reboot. + +Note: If the original installation was performed with `cleanup` set to `1`, then the files necessary for a reinstallation will not be available. ``` -mv /boot/raspberrypi-ua-netinst/reinstall/config.txt /boot/config.txt +cp /boot/raspberrypi-ua-netinst/config.txt /boot/config.txt reboot ``` diff --git a/build.sh b/build.sh index 34dec2d3..3254be61 100755 --- a/build.sh +++ b/build.sh @@ -8,6 +8,8 @@ packages_dir=./packages resources_dir=./res scripts_dir=./scripts +libs_to_copy=() + # update version and date version_tag="$(git describe --exact-match --tags HEAD 2> /dev/null || true)" version_commit="$(git rev-parse --short "@{0}" 2> /dev/null || true)" @@ -38,7 +40,7 @@ function get_kernels { # copies files replacing "kernel*" with kernel versions in path function cp_kernelfiles { for kernel in "${kernels[@]}"; do - eval cp --preserve=xattr,timestamps -r "${1//kernel\*/${kernel}}" "${2//kernel\*/${kernel}}" + eval cp --preserve=xattr,timestamps -r "${1//kernel\*/${kernel}}" "${2//kernel\*/${kernel}}" || true done } @@ -108,6 +110,37 @@ function create_tempfile { fi } +# copy an executable file and add all needed libraries to libs_to_copy array +function cp_executable { + echo "Copying executable $1" + cp --preserve=xattr,timestamps "$1" "$2" + + LIB_PATH=("tmp/lib" "tmp/usr/lib") + libs_todo=("$1") + while true; do + needed_libs=($(readelf -d "${libs_todo[0]}" 2>/dev/null | grep \(NEEDED\) | sed -e 's/.*\[//' -e 's/\]//')) + for lib in "${needed_libs[@]}"; do + if printf '%s\n' "${libs_to_copy[@]}" | grep -q "/$lib$"; then + continue + fi + echo -n " Adding dependency $lib => " + lib_found=$(find -L "${LIB_PATH[@]}" -name "$lib" 2>/dev/null | head -n 1) + if [ -n "$lib_found" ]; then + echo "$lib_found" + libs_to_copy+=("$lib_found") + libs_todo+=("$lib_found") + else + echo " not found!" + exit 1 + fi + done + libs_todo=("${libs_todo[@]:1}") + if [ ${#libs_todo[@]} -eq 0 ]; then + break + fi + done +} + function create_cpio { # initialize rootfs rm -rf rootfs @@ -116,7 +149,7 @@ function create_cpio { mkdir -p rootfs/bin/ mkdir -p rootfs/lib/arm-linux-gnueabihf/ mkdir -p rootfs/lib/lsb/init-functions.d/ - mkdir -p rootfs/etc/{alternatives,cron.daily,default,init,init.d,iproute2,ld.so.conf.d,logrotate.d,network/if-up.d/} + mkdir -p rootfs/etc/{alternatives,cron.daily,default,init,init.d,ld.so.conf.d,logrotate.d,network/if-up.d/} mkdir -p rootfs/etc/dpkg/dpkg.cfg.d/ mkdir -p rootfs/etc/network/{if-down.d,if-post-down.d,if-pre-up.d,if-up.d,interfaces.d} mkdir -p rootfs/lib/ifupdown/ @@ -124,10 +157,7 @@ function create_cpio { mkdir -p rootfs/lib/modules/ mkdir -p rootfs/sbin/ mkdir -p rootfs/usr/bin/ - mkdir -p rootfs/usr/lib/mime/packages/ - mkdir -p rootfs/usr/lib/openssl-1.0.2/engines/ - mkdir -p rootfs/usr/lib/engines-1.1/ - mkdir -p rootfs/usr/lib/{tar,tc} + mkdir -p rootfs/usr/lib/arm-linux-gnueabihf/ mkdir -p rootfs/usr/sbin/ mkdir -p rootfs/usr/share/{dpkg,keyrings,libc-bin} mkdir -p rootfs/var/lib/dpkg/{alternatives,info,parts,updates} @@ -181,6 +211,7 @@ function create_cpio { mkdir -p "rootfs/lib/modules/${kernel}/kernel/drivers/net" mkdir -p "rootfs/lib/modules/${kernel}/kernel/net" done + cp_kernelfiles tmp/lib/modules/kernel*/kernel/net/ipv6 rootfs/lib/modules/kernel*/kernel/net/ cp_kernelfiles tmp/lib/modules/kernel*/kernel/net/mac80211 rootfs/lib/modules/kernel*/kernel/net/ cp_kernelfiles tmp/lib/modules/kernel*/kernel/net/rfkill rootfs/lib/modules/kernel*/kernel/net/ cp_kernelfiles tmp/lib/modules/kernel*/kernel/net/wireless rootfs/lib/modules/kernel*/kernel/net/ @@ -193,8 +224,8 @@ function create_cpio { for kernel in "${kernels[@]}"; do mkdir -p "rootfs/lib/modules/${kernel}/kernel/drivers/i2c/busses" done - cp_kernelfiles tmp/lib/modules/kernel*/kernel/drivers/i2c/busses/i2c-bcm2708.ko rootfs/lib/modules/kernel*/kernel/drivers/i2c/busses/ - cp_kernelfiles tmp/lib/modules/kernel*/kernel/drivers/i2c/busses/i2c-bcm2835.ko rootfs/lib/modules/kernel*/kernel/drivers/i2c/busses/ + cp_kernelfiles tmp/lib/modules/kernel*/kernel/drivers/i2c/busses/i2c-bcm2708.ko* rootfs/lib/modules/kernel*/kernel/drivers/i2c/busses/ + cp_kernelfiles tmp/lib/modules/kernel*/kernel/drivers/i2c/busses/i2c-bcm2835.ko* rootfs/lib/modules/kernel*/kernel/drivers/i2c/busses/ # copy rtc drivers for kernel in "${kernels[@]}"; do @@ -202,7 +233,7 @@ function create_cpio { mkdir -p "rootfs/lib/modules/${kernel}/kernel/drivers/hwmon" done cp_kernelfiles tmp/lib/modules/kernel*/kernel/drivers/rtc rootfs/lib/modules/kernel*/kernel/drivers/ - cp_kernelfiles tmp/lib/modules/kernel*/kernel/drivers/hwmon/hwmon.ko rootfs/lib/modules/kernel*/kernel/drivers/hwmon/ + cp_kernelfiles tmp/lib/modules/kernel*/kernel/drivers/hwmon/raspberrypi-hwmon.ko* rootfs/lib/modules/kernel*/kernel/drivers/hwmon/ # create dependency lists for kernel in "${kernels[@]}"; do @@ -217,11 +248,10 @@ function create_cpio { sed -i "s/__DATE__/$(date)/" rootfs/opt/raspberrypi-ua-netinst/install.sh # btrfs-progs components - cp --preserve=xattr,timestamps tmp/bin/mkfs.btrfs rootfs/bin/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/libbtrfs.so.0 rootfs/lib/ + cp_executable tmp/sbin/mkfs.btrfs rootfs/sbin/ # busybox components - cp --preserve=xattr,timestamps tmp/bin/busybox rootfs/bin + 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 @@ -234,49 +264,41 @@ function create_cpio { cp --preserve=xattr,timestamps tmp/usr/bin/cdebootstrap-static rootfs/usr/bin/ # coreutils components - cp --preserve=xattr,timestamps tmp/bin/cat rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/chgrp rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/chmod rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/chown rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/cp --preserve=xattr,timestamps rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/date rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/dd rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/df rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/dir rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/echo rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/false rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/ln rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/ls rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/mkdir rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/mknod rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/mktemp rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/mv rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/pwd rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/readlink rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/rm rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/rmdir rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/sleep rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/stty rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/sync rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/touch rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/true rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/uname rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/vdir rootfs/bin/ + cp_executable tmp/bin/cat rootfs/bin/ + cp_executable tmp/bin/chgrp rootfs/bin/ + cp_executable tmp/bin/chmod rootfs/bin/ + cp_executable tmp/bin/chown rootfs/bin/ + cp_executable tmp/bin/cp rootfs/bin/ + cp_executable tmp/bin/date rootfs/bin/ + cp_executable tmp/bin/dd rootfs/bin/ + cp_executable tmp/bin/df rootfs/bin/ + cp_executable tmp/bin/dir rootfs/bin/ + cp_executable tmp/bin/echo rootfs/bin/ + cp_executable tmp/bin/false rootfs/bin/ + cp_executable tmp/bin/ln rootfs/bin/ + cp_executable tmp/bin/ls rootfs/bin/ + cp_executable tmp/bin/mkdir rootfs/bin/ + cp_executable tmp/bin/mknod rootfs/bin/ + cp_executable tmp/bin/mktemp rootfs/bin/ + cp_executable tmp/bin/mv rootfs/bin/ + cp_executable tmp/bin/pwd rootfs/bin/ + cp_executable tmp/bin/readlink rootfs/bin/ + cp_executable tmp/bin/rm rootfs/bin/ + cp_executable tmp/bin/rmdir rootfs/bin/ + cp_executable tmp/bin/sleep rootfs/bin/ + cp_executable tmp/bin/stty rootfs/bin/ + cp_executable tmp/bin/sync rootfs/bin/ + cp_executable tmp/bin/touch rootfs/bin/ + cp_executable tmp/bin/true rootfs/bin/ + cp_executable tmp/bin/uname rootfs/bin/ + cp_executable tmp/bin/vdir rootfs/bin/ # diffutils components - cp --preserve=xattr,timestamps tmp/usr/bin/cmp rootfs/usr/bin/ + cp_executable tmp/usr/bin/cmp rootfs/usr/bin/ # dosfstools components - cp --preserve=xattr,timestamps tmp/sbin/fatlabel rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/fsck.fat rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/mkfs.fat rootfs/sbin/ + cp_executable tmp/sbin/mkfs.fat rootfs/sbin/ cd rootfs/sbin - ln -s fatlabel dosfslabel - ln -s fsck.fat dosfsck - ln -s fsck.fat fsck.msdos - ln -s fsck.fat fsck.vfat - ln -s mkfs.fat mkdosfs - ln -s mkfs.fat mkfs.msdos ln -s mkfs.fat mkfs.vfat cd ../.. @@ -285,16 +307,16 @@ 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 --preserve=xattr,timestamps tmp/sbin/start-stop-daemon rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/usr/bin/dpkg rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/dpkg-deb rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/dpkg-divert rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/dpkg-maintscript-helper rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/dpkg-query rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/dpkg-split rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/dpkg-statoverride rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/dpkg-trigger rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/update-alternatives rootfs/usr/bin/ + cp_executable tmp/sbin/start-stop-daemon rootfs/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/ + cp_executable tmp/usr/bin/dpkg-maintscript-helper rootfs/usr/bin/ + cp_executable tmp/usr/bin/dpkg-query rootfs/usr/bin/ + cp_executable tmp/usr/bin/dpkg-split rootfs/usr/bin/ + cp_executable tmp/usr/bin/dpkg-statoverride rootfs/usr/bin/ + cp_executable tmp/usr/bin/dpkg-trigger rootfs/usr/bin/ + cp_executable tmp/usr/bin/update-alternatives rootfs/usr/bin/ cp --preserve=xattr,timestamps tmp/usr/share/dpkg/abitable rootfs/usr/share/dpkg/ cp --preserve=xattr,timestamps tmp/usr/share/dpkg/cputable rootfs/usr/share/dpkg/ cp --preserve=xattr,timestamps tmp/usr/share/dpkg/ostable rootfs/usr/share/dpkg/ @@ -306,98 +328,35 @@ function create_cpio { cd ../../.. touch rootfs/var/lib/dpkg/status - # libext2fs2 components - cp --preserve=xattr,timestamps tmp/lib/*/libe2p.so.2.* rootfs/lib/libe2p.so.2 - cp --preserve=xattr,timestamps tmp/lib/*/libext2fs.so.2.* rootfs/lib/libext2fs.so.2 - # e2fsprogs components cp --preserve=xattr,timestamps tmp/etc/mke2fs.conf rootfs/etc/ - cp --preserve=xattr,timestamps tmp/sbin/badblocks rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/debugfs rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/dumpe2fs rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/e2fsck rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/e2image rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/e2undo rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/logsave rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/mke2fs rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/resize2fs rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/tune2fs rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/usr/bin/chattr rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/lsattr rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/sbin/e2freefrag rootfs/usr/sbin/ - cp --preserve=xattr,timestamps tmp/usr/sbin/e4defrag rootfs/usr/sbin/ - cp --preserve=xattr,timestamps tmp/usr/sbin/filefrag rootfs/usr/sbin/ - cp --preserve=xattr,timestamps tmp/usr/sbin/mklost+found rootfs/usr/sbin/ + cp_executable tmp/sbin/mke2fs rootfs/sbin/ cd rootfs/sbin - ln -s tune2fs e2lablel - ln -s e2fsck fsck.ext2 - ln -s e2fsck fsck.ext3 - ln -s e2fsck fsck.ext4 - ln -s e2fsck fsck.ext4dev - ln -s mke2fs mkfs.ext2 - ln -s mke2fs mkfs.ext3 ln -s mke2fs mkfs.ext4 - ln -s mke2fs mkfs.ext4dev cd ../.. - # libf2fs5 components - cp --preserve=xattr,timestamps tmp/lib/*/libf2fs.so.5.* rootfs/lib/libf2fs.so.5 - # f2fs-tools components - cp --preserve=xattr,timestamps tmp/sbin/mkfs.f2fs rootfs/sbin/ + cp_executable tmp/sbin/mkfs.f2fs rootfs/sbin/ # gpgv components - cp --preserve=xattr,timestamps tmp/usr/bin/gpgv rootfs/usr/bin/ + cp_executable tmp/usr/bin/gpgv rootfs/usr/bin/ # ifupdown components cp --preserve=xattr,timestamps tmp/etc/default/networking rootfs/etc/default/ cp --preserve=xattr,timestamps tmp/etc/init.d/networking rootfs/etc/init.d/ cp --preserve=xattr,timestamps tmp/lib/ifupdown/settle-dad.sh rootfs/lib/ifupdown/ - cp --preserve=xattr,timestamps tmp/sbin/ifup rootfs/sbin/ + cp_executable tmp/sbin/ifup rootfs/sbin/ cd rootfs/sbin ln -s ifup ifdown ln -s ifup ifquery cd ../.. # iproute2 components - cp --preserve=xattr,timestamps tmp/bin/ip rootfs/bin/ - cp --preserve=xattr,timestamps tmp/bin/ss rootfs/bin/ - cp --preserve=xattr,timestamps tmp/etc/iproute2/ematch_map rootfs/etc/iproute2/ - cp --preserve=xattr,timestamps tmp/etc/iproute2/group rootfs/etc/iproute2/ - cp --preserve=xattr,timestamps tmp/etc/iproute2/rt_dsfield rootfs/etc/iproute2/ - cp --preserve=xattr,timestamps tmp/etc/iproute2/rt_protos rootfs/etc/iproute2/ - cp --preserve=xattr,timestamps tmp/etc/iproute2/rt_realms rootfs/etc/iproute2/ - cp --preserve=xattr,timestamps tmp/etc/iproute2/rt_scopes rootfs/etc/iproute2/ - cp --preserve=xattr,timestamps tmp/etc/iproute2/rt_tables rootfs/etc/iproute2/ - cp --preserve=xattr,timestamps tmp/sbin/bridge rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/rtacct rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/rtmon rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/tc rootfs/sbin/ - cd rootfs/sbin - ln -s ../bin/ip ip - cd ../.. - cp --preserve=xattr,timestamps tmp/usr/bin/lnstat rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/nstat rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/routef rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/routel rootfs/usr/bin/ - cd rootfs/usr/bin - ln -s lnstat ctstat - ln -s lnstat rtstat - cd ../../.. - cp --preserve=xattr,timestamps tmp/usr/lib/tc/experimental.dist rootfs/usr/lib/tc - cp --preserve=xattr,timestamps tmp/usr/lib/tc/m_xt.so rootfs/usr/lib/tc - cp --preserve=xattr,timestamps tmp/usr/lib/tc/normal.dist rootfs/usr/lib/tc - cp --preserve=xattr,timestamps tmp/usr/lib/tc/pareto.dist rootfs/usr/lib/tc - cp --preserve=xattr,timestamps tmp/usr/lib/tc/paretonormal.dist rootfs/usr/lib/tc - cp --preserve=xattr,timestamps tmp/usr/lib/tc/q_atm.so rootfs/usr/lib/tc - cd rootfs/usr/lib/tc - ln -s m_xt.so m_ipt.so - cd ../../../.. - cp --preserve=xattr,timestamps tmp/usr/sbin/arpd rootfs/usr/sbin/ + cp_executable tmp/bin/ip rootfs/bin/ # 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/20-left-info-blocks rootfs/lib/lsb/init-functions.d/ + cp --preserve=xattr,timestamps tmp/lib/lsb/init-functions.d/00-verbose rootfs/lib/lsb/init-functions.d/ # netbase components cp --preserve=xattr,timestamps tmp/etc/protocols rootfs/etc/ @@ -405,262 +364,83 @@ function create_cpio { cp --preserve=xattr,timestamps tmp/etc/services rootfs/etc/ # netcat-openbsd - cp --preserve=xattr,timestamps tmp/bin/nc.openbsd rootfs/bin/nc + 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 --preserve=xattr,timestamps tmp/usr/sbin/ntpdate rootfs/usr/sbin/ - cp --preserve=xattr,timestamps tmp/usr/sbin/ntpdate-debian rootfs/usr/sbin/ + cp_executable tmp/usr/sbin/ntpdate rootfs/usr/sbin/ + cp_executable tmp/usr/sbin/ntpdate-debian rootfs/usr/sbin/ # raspberrypi.org GPG key cp --preserve=xattr,timestamps ../"${packages_dir}"/raspberrypi.gpg.key rootfs/usr/share/keyrings/ - # raspbian-archive-keyring components - cp --preserve=xattr,timestamps tmp/usr/share/keyrings/raspbian-archive-keyring.gpg rootfs/usr/share/keyrings/ + # *-archive-keyring components + cp --preserve=xattr,timestamps tmp/usr/share/keyrings/*.gpg rootfs/usr/share/keyrings/ - # rng-tools components - cp --preserve=xattr,timestamps tmp/usr/bin/rngtest rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/sbin/rngd rootfs/usr/sbin/ - cp --preserve=xattr,timestamps tmp/etc/default/rng-tools rootfs/etc/default/ - cp --preserve=xattr,timestamps tmp/etc/init.d/rng-tools rootfs/etc/init.d/ + # rng-tools5 components + cp_executable tmp/usr/sbin/rngd rootfs/usr/sbin/ # tar components - cp --preserve=xattr,timestamps tmp/bin/tar rootfs/bin/ - cp --preserve=xattr,timestamps tmp/etc/rmt rootfs/etc/ - cp --preserve=xattr,timestamps tmp/usr/lib/mime/packages/tar rootfs/usr/lib/mime/packages/ - cp --preserve=xattr,timestamps tmp/usr/sbin/rmt-tar rootfs/usr/sbin/ - cp --preserve=xattr,timestamps tmp/usr/sbin/tarcat rootfs/usr/sbin/ + cp_executable tmp/bin/tar rootfs/bin/ # fdisk components - cp --preserve=xattr,timestamps tmp/sbin/fdisk rootfs/sbin/ + cp_executable tmp/sbin/fdisk rootfs/sbin/ # util-linux components - cp --preserve=xattr,timestamps tmp/sbin/blkid rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/blockdev rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/fsck rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/mkswap rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/sbin/swaplabel rootfs/sbin/ + cp_executable tmp/sbin/blkid rootfs/sbin/ + cp_executable tmp/sbin/mkswap rootfs/sbin/ # wpa_supplicant components - cp --preserve=xattr,timestamps tmp/sbin/wpa_supplicant rootfs/sbin/wpa_supplicant + cp_executable tmp/sbin/wpa_supplicant rootfs/sbin/wpa_supplicant cp --preserve=xattr,timestamps -r tmp/etc/wpa_supplicant rootfs/etc/wpa_supplicant - # libacl1 components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libacl.so.1.* rootfs/usr/lib/libacl.so.1 - - # libatm1 components - cp --preserve=xattr,timestamps tmp/lib/*/libatm.so.1.* rootfs/lib/libatm.so.1 - - # libattr1 components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libattr.so.1.* rootfs/usr/lib/libattr.so.1 - - # libaudit-common components - cp --preserve=xattr,timestamps tmp/etc/libaudit.conf rootfs/etc/ - - # libaudit1 components - cp --preserve=xattr,timestamps tmp/lib/*/libaudit.so.1.* rootfs/lib/libaudit.so.1 - - # libblkid1 components - cp --preserve=xattr,timestamps tmp/lib/*/libblkid.so.1.* rootfs/lib/libblkid.so.1 - - # libbsd0 components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libbsd.so.0.* rootfs/usr/lib/libbsd.so.0 - - # libbz2-1.0 components - cp --preserve=xattr,timestamps tmp/lib/*/libbz2.so.1.0.* rootfs/lib/libbz2.so.1.0 - # libc-bin components cp --preserve=xattr,timestamps tmp/etc/default/nss rootfs/etc/default/ - cp --preserve=xattr,timestamps tmp/etc/ld.so.conf.d/libc.conf rootfs/etc/ld.so.conf.d/ + cp --preserve=xattr,timestamps tmp/etc/ld.so.conf.d/* rootfs/etc/ld.so.conf.d/ cp --preserve=xattr,timestamps tmp/etc/bindresvport.blacklist rootfs/etc/ cp --preserve=xattr,timestamps tmp/etc/gai.conf rootfs/etc/ cp --preserve=xattr,timestamps tmp/etc/ld.so.conf rootfs/etc/ - cp --preserve=xattr,timestamps tmp/sbin/ldconfig rootfs/sbin/ - cp --preserve=xattr,timestamps tmp/usr/bin/catchsegv rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/getconf rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/getent rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/iconv rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/ldd rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/locale rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/localedef rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/pldd rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/tzselect rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/bin/zdump rootfs/usr/bin/ + cp_executable tmp/sbin/ldconfig rootfs/sbin/ # lib/locale ? - cp --preserve=xattr,timestamps tmp/usr/sbin/iconvconfig rootfs/usr/sbin/ - cp --preserve=xattr,timestamps tmp/usr/sbin/zic rootfs/usr/sbin/ cp --preserve=xattr,timestamps tmp/usr/share/libc-bin/nsswitch.conf rootfs/usr/share/libc-bin/ # libc6 components - cp --preserve=xattr,timestamps tmp/lib/*/ld-*.so rootfs/lib/ld-linux-armhf.so.3 - # some executables require the dynamic linker to be found - # at this path, so leave a symlink there - ln -s /lib/ld-linux-armhf.so.3 rootfs/lib/arm-linux-gnueabihf/ld-linux.so.3 - cp --preserve=xattr,timestamps tmp/lib/*/libanl-*.so rootfs/lib/libanl.so.1 - cp --preserve=xattr,timestamps tmp/lib/*/libBrokenLocale-*.so rootfs/lib/libBrokenLocale.so.1 - cp --preserve=xattr,timestamps tmp/lib/*/libc-*.so rootfs/lib/libc.so.6 - cp --preserve=xattr,timestamps tmp/lib/*/libcrypt-*.so rootfs/lib/libcrypt.so.1 - cp --preserve=xattr,timestamps tmp/lib/*/libdl-*.so rootfs/lib/libdl.so.2 - cp --preserve=xattr,timestamps tmp/lib/*/libm-*.so rootfs/lib/libm.so.6 - cp --preserve=xattr,timestamps tmp/lib/*/libmemusage.so rootfs/lib/ - cp --preserve=xattr,timestamps tmp/lib/*/libnsl-*.so rootfs/lib/libnsl.so.1 - cp --preserve=xattr,timestamps tmp/lib/*/libnss_compat-*.so rootfs/lib/libnss_compat.so.2 - cp --preserve=xattr,timestamps tmp/lib/*/libnss_dns-*.so rootfs/lib/libnss_dns.so.2 - cp --preserve=xattr,timestamps tmp/lib/*/libnss_files-*.so rootfs/lib/libnss_files.so.2 - cp --preserve=xattr,timestamps tmp/lib/*/libnss_hesiod-*.so rootfs/lib/libnss_hesiod.so.2 - cp --preserve=xattr,timestamps tmp/lib/*/libnss_nis-*.so rootfs/lib/libnss_nis.so.2 - cp --preserve=xattr,timestamps tmp/lib/*/libpcprofile.so rootfs/lib/ - cp --preserve=xattr,timestamps tmp/lib/*/libpthread-*.so rootfs/lib/libpthread.so.0 - cp --preserve=xattr,timestamps tmp/lib/*/libresolv-*.so rootfs/lib/libresolv.so.2 - cp --preserve=xattr,timestamps tmp/lib/*/librt-*.so rootfs/lib/librt.so.1 - cp --preserve=xattr,timestamps tmp/lib/*/libSegFault.so rootfs/lib/ - cp --preserve=xattr,timestamps tmp/lib/*/libthread_db-*.so rootfs/lib/libthread_db.so.1 - cp --preserve=xattr,timestamps tmp/lib/*/libutil-*.so rootfs/lib/libutil.so.1 - - # libcap2 components - cp --preserve=xattr,timestamps tmp/lib/*/libcap.so.2.* rootfs/lib/libcap.so.2 - - # libcom-err2 components - cp --preserve=xattr,timestamps tmp/lib/*/libcom_err.so.2.* rootfs/lib/libcom_err.so.2 - - # libdb5.3 components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libdb-5.3.so rootfs/usr/lib/libdb5.3.so - - # libdbus-1-3 components - cp --preserve=xattr,timestamps tmp/lib/*/libdbus-1.so.3 rootfs/lib/libdbus-1.so.3 - cp --preserve=xattr,timestamps tmp/lib/*/libdl.so.2 rootfs/lib/libdl.so.2 - - # libelf1 components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libelf.so.1 rootfs/usr/lib/libelf.so.1 - - # libfdisk1 components - cp --no-dereference --preserve=xattr,timestamps tmp/lib/*/libfdisk.so.1.* rootfs/lib/libfdisk.so.1 - - # libgcc1 components - cp --preserve=xattr,timestamps tmp/lib/*/libgcc_s.so.1 rootfs/lib/ - cp --preserve=xattr,timestamps tmp/lib/*/librt.so.1 rootfs/lib/ - - # libgcrypt20 components - cp --no-dereference --preserve=xattr,timestamps tmp/lib/*/libgcrypt.so.20.* rootfs/lib/libgcrypt.so.20 - - # libgpg-error0 components - cp --no-dereference --preserve=xattr,timestamps tmp/lib/*/libgpg-error.so.0.* rootfs/lib/libgpg-error.so.0 - - # liblz4-1 components - cp --no-dereference --preserve=xattr,timestamps tmp/usr/lib/*/liblz4.so.1.* rootfs/usr/lib/liblz4.so.1 - - # liblzma5 components - cp --preserve=xattr,timestamps tmp/lib/*/liblzma.so.5.* rootfs/lib/liblzma.so.5 - - # liblzo2-2 components - cp --preserve=xattr,timestamps tmp/lib/*/liblzo2.so.2 rootfs/lib/ - - # libmount1 components - cp --preserve=xattr,timestamps tmp/lib/*/libmount.so.1.* rootfs/lib/libmount.so.1 - - # libmnl0 components - cp --preserve=xattr,timestamps tmp/lib/*/libmnl.so.0.* rootfs/lib/libmnl.so.0 - - # libncurses5 components - cp --preserve=xattr,timestamps tmp/lib/*/libncurses.so.5.* rootfs/lib/libncurses.so.5 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libform.so.5.* rootfs/usr/lib/libform.so.5 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libmenu.so.5.* rootfs/usr/lib/libmenu.so.5 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libpanel.so.5.* rootfs/usr/lib/libpanel.so.5 - - # libnl-3-200 components - cp --preserve=xattr,timestamps tmp/lib/*/libnl-3.so.200 rootfs/lib/libnl-3.so.200 - - # libnl-genl-3-200 components - cp --preserve=xattr,timestamps tmp/lib/*/libnl-genl-3.so.200 rootfs/lib/libnl-genl-3.so.200 - - # libnl-route-3-200 components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libnl-route-3.so.200.* rootfs/usr/lib/libnl-route-3.so.200 - - # libpam0g components - cp --preserve=xattr,timestamps tmp/lib/*/libpam.so.0.* rootfs/lib/libpam.so.0 - cp --preserve=xattr,timestamps tmp/lib/*/libpam_misc.so.0.* rootfs/lib/libpam_misc.so.0 - cp --preserve=xattr,timestamps tmp/lib/*/libpamc.so.0.* rootfs/lib/libpamc.so.0 - - # libpcre3 components - cp --preserve=xattr,timestamps tmp/lib/*/libpcre.so.3.* rootfs/lib/libpcre.so.3 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libpcreposix.so.3.* rootfs/usr/lib/libpcreposix.so.3 - - # libpcsclite components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libpcsclite.so.1 rootfs/lib/libpcsclite.so.1 - - # libselinux1 components - cp --preserve=xattr,timestamps tmp/lib/*/libselinux.so.1 rootfs/lib/ - - # libslang2 components - cp --preserve=xattr,timestamps tmp/lib/*/libslang.so.2.* rootfs/lib/libslang.so.2 - - # libsmartcols1 components - cp --preserve=xattr,timestamps tmp/lib/*/libsmartcols.so.1.* rootfs/lib/libsmartcols.so.1 - - # libssl1.0.2 components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libcrypto.so.1.0.2 rootfs/usr/lib/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/libssl.so.1.0.2 rootfs/usr/lib/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/lib4758cca.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libaep.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libatalla.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libcapi.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libchil.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libcswift.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libgmp.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libgost.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libnuron.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libpadlock.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libsureware.so rootfs/usr/lib/openssl-1.0.2/engines/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/openssl-1.0.2/engines/libubsec.so rootfs/usr/lib/openssl-1.0.2/engines/ - - # libssl1.1 components - cp --preserve=xattr,timestamps tmp/usr/lib/*/libcrypto.so.1.1 rootfs/usr/lib/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/libssl.so.1.1 rootfs/usr/lib/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/engines-1.1/capi.so rootfs/usr/lib/engines-1.1/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/engines-1.1/padlock.so rootfs/usr/lib/engines-1.1/ - - # libsystemd0 components - cp --no-dereference --preserve=xattr,timestamps tmp/lib/*/libsystemd.so* rootfs/lib/ - - # libtinfo6 components - cp --preserve=xattr,timestamps tmp/lib/*/libtinfo.so.6.* rootfs/lib/libtinfo.so.6 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libtic.so.6.* rootfs/usr/lib/libtinfo.so.6 - - # libuuid1 components - cp --preserve=xattr,timestamps tmp/lib/*/libuuid.so.1.* rootfs/lib/libuuid.so.1 + cp_executable tmp/lib/*/libnss_dns.so.* rootfs/lib/arm-linux-gnueabihf/ + cp_executable tmp/lib/*/libnss_files.so.* rootfs/lib/arm-linux-gnueabihf/ - # zlib1g components - cp --preserve=xattr,timestamps tmp/lib/*/libz.so.1 rootfs/lib/ - - # Binary firmware for version 3 Model B wireless - mkdir -p rootfs/lib/firmware/brcm - cp --preserve=xattr,timestamps -r tmp/lib/firmware/brcm/brcmfmac43430-sdio.bin rootfs/lib/firmware/brcm/ - cp --preserve=xattr,timestamps -r tmp/lib/firmware/brcm/brcmfmac43430-sdio.txt rootfs/lib/firmware/brcm/ - - # Binary firmware for version 3 Model B+ wireless + # Binary firmware for version 3 Model B, Zero W wireless mkdir -p rootfs/lib/firmware/brcm - cp --preserve=xattr,timestamps -r tmp/lib/firmware/brcm/brcmfmac43455-sdio.bin rootfs/lib/firmware/brcm/ - cp --preserve=xattr,timestamps -r tmp/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob rootfs/lib/firmware/brcm/ - cp --preserve=xattr,timestamps -r tmp/lib/firmware/brcm/brcmfmac43455-sdio.txt rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43430-sdio.bin rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43430-sdio.txt rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43430-sdio.clm_blob rootfs/lib/firmware/brcm/ + + # Binary firmware for Zero 2 W wireless + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43436-sdio.bin rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43436-sdio.clm_blob rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43436-sdio.txt rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43436s-sdio.bin rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43436s-sdio.txt rootfs/lib/firmware/brcm/ + + # Binary firmware for version 3 Model A+/B+, 4 Model B wireless + ln -s cyfmac43455-sdio-standard.bin tmp/lib/firmware/cypress/cyfmac43455-sdio.bin + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43455-sdio.bin rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43455-sdio.txt rootfs/lib/firmware/brcm/ + + # Binary firmware for version 4 Compute Module, 400 wireless + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43456-sdio.bin rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43456-sdio.clm_blob rootfs/lib/firmware/brcm/ + cp --preserve=xattr,timestamps tmp/lib/firmware/brcm/brcmfmac43456-sdio.txt rootfs/lib/firmware/brcm/ # vcgencmd ## libraspberrypi-bin - mkdir -p rootfs/opt/vc/bin - cp --preserve=xattr,timestamps tmp/opt/vc/bin/vcgencmd rootfs/opt/vc/bin/ mkdir -p rootfs/usr/bin - ln -s /opt/vc/bin/vcgencmd rootfs/usr/bin/vcgencmd - cp --preserve=xattr,timestamps tmp/usr/share/doc/libraspberrypi-bin/LICENCE rootfs/opt/vc/ - ## libraspberrypi0 - mkdir -p rootfs/etc/ld.so.conf.d - cp --preserve=xattr,timestamps tmp/etc/ld.so.conf.d/00-vmcs.conf rootfs/etc/ld.so.conf.d/ - mkdir -p rootfs/opt/vc/lib - cp --preserve=xattr,timestamps tmp/opt/vc/lib/libvcos.so rootfs/opt/vc/lib/ - cp --preserve=xattr,timestamps tmp/opt/vc/lib/libvchiq_arm.so rootfs/opt/vc/lib/ + cp_executable tmp/usr/bin/vcgencmd rootfs/usr/bin/ # xxd mkdir -p rootfs/usr/bin - cp --preserve=xattr,timestamps tmp/usr/bin/xxd rootfs/usr/bin/ + cp_executable tmp/usr/bin/xxd rootfs/usr/bin/ # install additional resources mkdir -p rootfs/opt/raspberrypi-ua-netinst/res @@ -669,35 +449,12 @@ function create_cpio { (cd ../"${resources_dir}"/initramfs/ && find . -type f -exec echo rootfs/opt/raspberrypi-ua-netinst/res/{} \;) | xargs chmod +r # curl - cp --preserve=xattr,timestamps tmp/usr/bin/curl rootfs/usr/bin/ - cp --preserve=xattr,timestamps tmp/usr/lib/*/libcurl.so.4 rootfs/lib/arm-linux-gnueabihf/libcurl.so.4 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libnghttp2.so.14 rootfs/lib/arm-linux-gnueabihf/libnghttp2.so.14 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libidn2.so.0 rootfs/lib/arm-linux-gnueabihf/libidn2.so.0 - cp --preserve=xattr,timestamps tmp/usr/lib/*/librtmp.so.1 rootfs/lib/arm-linux-gnueabihf/librtmp.so.1 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libssh2.so.1 rootfs/lib/arm-linux-gnueabihf/libssh2.so.1 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libpsl.so.5 rootfs/lib/arm-linux-gnueabihf/libpsl.so.5 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libgssapi_krb5.so.2 rootfs/lib/arm-linux-gnueabihf/libgssapi_krb5.so.2 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libkrb5.so.3 rootfs/lib/arm-linux-gnueabihf/libkrb5.so.3 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libk5crypto.so.3 rootfs/lib/arm-linux-gnueabihf/libk5crypto.so.3 - cp --preserve=xattr,timestamps tmp/usr/lib/*/liblber-2.4.so.2 rootfs/lib/arm-linux-gnueabihf/liblber-2.4.so.2 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libldap_r-2.4.so.2 rootfs/lib/arm-linux-gnueabihf/libldap_r-2.4.so.2 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libunistring.so.2.* rootfs/lib/arm-linux-gnueabihf/libunistring.so.2 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libgnutls.so.30 rootfs/lib/arm-linux-gnueabihf/libgnutls.so.30 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libhogweed.so.4 rootfs/lib/arm-linux-gnueabihf/libhogweed.so.4 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libnettle.so.6 rootfs/lib/arm-linux-gnueabihf/libnettle.so.6 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libgmp.so.10 rootfs/lib/arm-linux-gnueabihf/libgmp.so.10 - cp --preserve=xattr,timestamps tmp/lib/*/libgcrypt.so.20 rootfs/lib/arm-linux-gnueabihf/libgcrypt.so.20 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libkrb5support.so.0 rootfs/lib/arm-linux-gnueabihf/libkrb5support.so.0 - cp --preserve=xattr,timestamps tmp/lib/*/libkeyutils.so.1 rootfs/lib/arm-linux-gnueabihf/libkeyutils.so.1 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libsasl2.so.2 rootfs/lib/arm-linux-gnueabihf/libsasl2.so.2 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libp11-kit.so.0 rootfs/lib/arm-linux-gnueabihf/libp11-kit.so.0 - cp --preserve=xattr,timestamps tmp/lib/*/libidn.so.11 rootfs/lib/arm-linux-gnueabihf/libidn.so.11 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libtasn1.so.6 rootfs/lib/arm-linux-gnueabihf/libtasn1.so.6 - cp --preserve=xattr,timestamps tmp/lib/*/libgpg-error.so.0 rootfs/lib/arm-linux-gnueabihf/libgpg-error.so.0 - cp --preserve=xattr,timestamps tmp/usr/lib/*/libffi.so.6 rootfs/lib/arm-linux-gnueabihf/libffi.so.6 - - # libudev - cp --preserve=xattr,timestamps tmp/lib/*/libudev.so.1 rootfs/lib/arm-linux-gnueabihf/libudev.so.1 + cp_executable tmp/usr/bin/curl rootfs/usr/bin/ + + # copy all libraries needed by executable files above + for lib in "${libs_to_copy[@]}"; do + cp --preserve=xattr,timestamps "$lib" $(echo "$lib" | sed -e 's/^tmp\//rootfs\//') + done INITRAMFS="../raspberrypi-ua-netinst.cpio.gz" (cd rootfs && find . | cpio -H newc -ov | gzip --best > $INITRAMFS) @@ -718,7 +475,7 @@ rm -rf tmp && mkdir tmp # extract debs for i in ../packages/*.deb; do - cd tmp && ar x "../${i}" && tar -xf data.tar.*; rm data.tar.*; cd .. + cd tmp && ar x "../${i}" && tar -xf data.tar.*; rm -f data.tar.* control.tar.* debian-binary; cd .. done # get kernel versions @@ -726,28 +483,43 @@ get_kernels # initialize bootfs rm -rf bootfs -mkdir 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/ if [ ! -f bootfs/config.txt ] ; then touch bootfs/config.txt fi create_cpio -mkdir -p bootfs/raspberrypi-ua-netinst -mv raspberrypi-ua-netinst.cpio.gz bootfs/raspberrypi-ua-netinst/ +mv raspberrypi-ua-netinst.cpio.gz bootfs/raspberrypi-ua-netinst/initramfs.gz { echo "[all]" - echo "initramfs raspberrypi-ua-netinst/raspberrypi-ua-netinst.cpio.gz" + echo "os_prefix=raspberrypi-ua-netinst/" + echo "initramfs initramfs.gz" echo "gpu_mem=16" echo "[pi3]" - echo "enable_uart=1" -} >> bootfs/config.txt - -echo "dwc_otg.lpm_enable=0 consoleblank=0 console=serial0,115200 console=tty1 elevator=deadline rootwait" > bootfs/cmdline.txt + echo "dtoverlay=disable-bt" + echo "arm_64bit=1" + echo "[pi4]" + echo "dtoverlay=disable-bt" + echo "arm_64bit=1" + echo "[pi02]" + echo "arm_64bit=1" + echo "[board-type=a02042]" + echo "arm_64bit=1" + echo "[board-type=a22042]" + echo "arm_64bit=1" +} >> bootfs/raspberrypi-ua-netinst/config.txt + +cp bootfs/raspberrypi-ua-netinst/config.txt bootfs/config.txt + +echo "consoleblank=0 console=serial0,115200 console=tty1 rootwait" > bootfs/raspberrypi-ua-netinst/cmdline.txt if [ ! -f bootfs/TIMEOUT ] ; then touch bootfs/TIMEOUT diff --git a/buildroot.sh b/buildroot.sh index d286dd10..aecc6d33 100755 --- a/buildroot.sh +++ b/buildroot.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# shellcheck source=./buildroot.conf +# shellcheck disable=SC1091 set -e # exit if any command fails @@ -10,10 +12,16 @@ compress_bz2=1 # Controls production of an xz-compressed image compress_xz=1 +# Use 'sudo' for commands which require root privileges +use_sudo=0 + # If a configuration file exists, import its settings -if [ -e buildroot.conf ]; then - # shellcheck disable=SC1091 - source buildroot.conf +if [ -r buildroot.conf ]; then + source <(tr -d "\015" < buildroot.conf) +fi + +if [ "$use_sudo" = "1" ]; then + SUDO=sudo fi build_dir=build_dir @@ -33,11 +41,12 @@ image=${build_dir}/${imagename}.img # Prepare rm -f "${image}" +rm -rf "${build_dir:-build_dir}/mnt/" # Create image dd if=/dev/zero of="$image" bs=1M count=128 -fdisk "${image}" <,apt,kmod_ | +| `base` | _\,apt,gnupg,kmod_ | | `minimal` | _\,cpufrequtils,fake-hwclock,ifupdown,net-tools,ntp,openssh-server,dosfstools,raspberrypi-sys-mods_ | -| `server` | _\,systemd-sysv,vim-tiny,iputils-ping,wget,ca-certificates,rsyslog,cron,dialog,locales,tzdata,less,man-db,logrotate,bash-completion,console-setup,apt-utils,libraspberrypi-bin,raspi-copies-and-fills_ | +| `server` | _\,systemd-sysv,vim-tiny,iputils-ping,wget,ca-certificates,rsyslog,cron,dialog,locales,tzdata,less,man-db,logrotate,bash-completion,console-setup,apt-utils,libraspberrypi-bin,raspi-copies-and-fills (raspi-copies-and-fills is not available on arm64)_ | + +Note that if the networking configuration is set to use DHCP, `isc-dhcp-client` will also be installed. + +#### Advanced configuration (when `use_systemd_services` is set to `1`): + +| Preset | Packages | +|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `base` | _\,apt,kmod_ | +| `minimal` | _\,cpufrequtils,iproute2,openssh-server,dosfstools,raspberrypi-sys-mods_ | +| `server` | _\,systemd-sysv,vim-tiny,iputils-ping,wget,ca-certificates,rsyslog,cron,dialog,locales,tzdata,less,man-db,logrotate,bash-completion,console-setup,apt-utils,libraspberrypi-bin,raspi-copies-and-fills (raspi-copies-and-fills is not available on arm64)_ | + +Note that if the networking configuration is set to use DHCP, no additional packages will be installed as `systemd-networkd` provides DHCP client support. ## Device / peripheral @@ -41,7 +56,7 @@ | `sound_usb_first` | `0` | `0`/`1` | Set to "1" to define USB audio as default if onboard audio is also enabled. The options `sound_enable=1` and `sound_usb_enable=1` have to be set to take effect. | | `camera_enable` | `0` | `0`/`1` | Set to "1" to enable the camera module. This enables all camera-related parameters in config.txt. | | `camera_disable_led` | `0` | `0`/`1` | Disables the camera LED. The option `camera_enable=1` has to be set to take effect. | -| `rtc` | | `ds1307`/ `ds1339`/ `ds3231`/ `mcp7940x`/ `mcp7941x`/ `pcf2127`/ `pcf8523`/ `pcf8563` | Select an RTC if it is connected via I²C. | +| `rtc` | | `ds1307`/ `ds1339`/ `ds3231`/ `mcp7940x`/ `mcp7941x`/ `pcf2127`/ `pcf8523`/ `pcf8563`/ `abx80x` | Select an RTC if it is connected via I²C. | | `dt_overlays` | | | Enables additional device tree overlays (comma separated and quoted). (e.g. 'dt_overlays="hifiberry-dac,lirc-rpi"') | ## SSH @@ -125,9 +140,11 @@ | `disable_splash` | `0` | `0`/`1` | Disables the rainbow splash screen on boot. | | `cleanup` | `0` | `0`/`1` | Remove installer files after success. To also remove log files, note the option below. | | `cleanup_logfiles` | `0` | `0`/`1` | Removes installer log files after success. | -| `cmdline` | `"dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 elevator=deadline fsck.repair=yes"` | | | +| `cmdline` | `"console=serial0,115200 console=tty1 fsck.repair=yes"` | | | | `final_action` | `reboot` | `reboot`/ `poweroff`/ `halt`/ `console` | Action at the end of install. | -| `installer_telnet` | `1` | `0`/`1` | Send installer console output via telnet. | +| `installer_telnet` | `listen` | `none`/`connect`/`listen` | Connect to, or listen for, a telnet connection to send installer console output. | +| `installer_telnet_host` | | | Host name or address to use when `installer_telnet` is set to `connect`. | +| `installer_telnet_port` | '9923' | | Port number to use when `installer_telnet` is set to `connect`. | | `installer_retries` | `3` | | Number of retries if installation fails. | | `installer_networktimeout` | `15` | | Timeout in seconds for network interface initialization. | | `installer_pkg_updateretries` | `3` | | Number of retries if package update fails. | @@ -142,3 +159,4 @@ | `disable_predictable_nin` | `1` | `0`/`1` | Disable Predictable Network Interface Names. Set to 0 if you want to use predictable network interface names, which means if you use the same SD card on a different RPi board, your network device might be named differently. This will result in the board having no network connectivity. | | `drivers_to_load` | | | Loads additional kernel modules at installation (comma separated and quoted). | | `online_config` | | | URL to extra config that will be executed after installer-config.txt | +| `use_systemd_services` | `0` | `0`/`1` | Use systemd for networking and DNS resolution. | diff --git a/res/initramfs/etc/apt/sources.list b/res/initramfs/etc/apt/sources.list deleted file mode 100644 index 6ddf7d27..00000000 --- a/res/initramfs/etc/apt/sources.list +++ /dev/null @@ -1 +0,0 @@ -deb http://mirrordirector.raspbian.org/raspbian __RELEASE__ main contrib non-free firmware diff --git a/scripts/opt/raspberrypi-ua-netinst/install.sh b/scripts/opt/raspberrypi-ua-netinst/install.sh index 81244f4c..5b180e65 100644 --- a/scripts/opt/raspberrypi-ua-netinst/install.sh +++ b/scripts/opt/raspberrypi-ua-netinst/install.sh @@ -23,6 +23,7 @@ variables_reset() { mirror= mirror_cache= release= + arch= hostname= boot_volume_label= root_volume_label= @@ -77,6 +78,8 @@ variables_reset() { cmdline= rootfstype= installer_telnet= + installer_telnet_host= + installer_telnet_port= installer_retries= installer_networktimeout= installer_pkg_updateretries= @@ -96,6 +99,7 @@ variables_reset() { sound_usb_first= camera_enable= camera_disable_led= + use_systemd_services= } variable_set() { @@ -125,11 +129,25 @@ variables_set_defaults() { if [ -n "${ip_broadcast}" ]; then echo " Variable 'ip_broadcast' is deprecated. This variable will be ignored!" fi + if [ "${installer_telnet}" = "1" ]; then + echo "'installer_telnet' now accepts 'connect' and 'listen' settings, not '1'." + echo "'listen' mode is being enabled." + installer_telnet="listen" + elif [ "${installer_telnet}" = "0" ]; then + echo "'installer_telnet' now accepts 'connect' and 'listen' settings, not '0'." + echo "Neither mode is enabled." + installer_telnet="none" + fi # set config defaults variable_set "preset" "server" - variable_set "mirror" "http://mirrordirector.raspbian.org/raspbian/" - variable_set "release" "buster" + variable_set "arch" "armhf" + if [ "${arch}" = "arm64" ]; then + variable_set "mirror" "http://deb.debian.org/debian/" + else + variable_set "mirror" "http://mirrordirector.raspbian.org/raspbian/" + fi + variable_set "release" "bullseye" variable_set "hostname" "pi" variable_set "rootpw" "raspbian" variable_set "root_ssh_pwlogin" "1" @@ -149,10 +167,11 @@ variables_set_defaults() { variable_set "hdmi_system_only" "0" variable_set "usbroot" "0" variable_set "usbboot" "0" - variable_set "cmdline" "dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 elevator=deadline fsck.repair=yes" + variable_set "cmdline" "console=serial0,115200 console=tty1 fsck.repair=yes" variable_set "rootfstype" "f2fs" variable_set "final_action" "reboot" - variable_set "installer_telnet" "1" + variable_set "installer_telnet" "listen" + variable_set "installer_telnet_port" "9923" variable_set "installer_retries" "3" variable_set "installer_networktimeout" "15" variable_set "installer_pkg_updateretries" "3" @@ -171,11 +190,12 @@ variables_set_defaults() { variable_set "sound_usb_first" "0" variable_set "camera_enable" "0" variable_set "camera_disable_led" "0" + variable_set "use_systemd_services" "0" } led_sos() { - local led0=/sys/class/leds/led0 # Power LED - local led1=/sys/class/leds/led1 # Activity LED + local led0=/sys/class/leds/PWR # Power LED + local led1=/sys/class/leds/ACT # Activity LED local led_on local led_off @@ -189,32 +209,32 @@ led_sos() { led_off=1 fi - if [ -e /sys/class/leds/led0 ]; then (echo none > /sys/class/leds/led0/trigger || true) &> /dev/null; else led0=; fi - if [ -e /sys/class/leds/led1 ]; then (echo none > /sys/class/leds/led1/trigger || true) &> /dev/null; else led1=; fi + if [ -e "${led0}" ]; then (echo none > "${led0}/trigger" || true) &> /dev/null; else led0=; fi + if [ -e "${led1}" ]; then (echo none > "${led1}/trigger" || true) &> /dev/null; else led1=; fi for i in $(seq 1 3); do - if [ -n "$led0" ]; then (echo ${led_on} > "${led0}"/brightness || true) &> /dev/null; fi - if [ -n "$led1" ]; then (echo ${led_on} > "${led1}"/brightness || true) &> /dev/null; fi + if [ -n "${led0}" ]; then (echo ${led_on} > "${led0}"/brightness || true) &> /dev/null; fi + if [ -n "${led1}" ]; then (echo ${led_on} > "${led1}"/brightness || true) &> /dev/null; fi sleep 0.225s; - if [ -n "$led0" ]; then (echo ${led_off} > "${led0}"/brightness || true) &> /dev/null; fi - if [ -n "$led1" ]; then (echo ${led_off} > "${led1}"/brightness || true) &> /dev/null; fi + if [ -n "${led0}" ]; then (echo ${led_off} > "${led0}"/brightness || true) &> /dev/null; fi + if [ -n "${led1}" ]; then (echo ${led_off} > "${led1}"/brightness || true) &> /dev/null; fi sleep 0.15s; done sleep 0.075s; for i in $(seq 1 3); do - if [ -n "$led0" ]; then (echo ${led_on} > "${led0}"/brightness || true) &> /dev/null; fi - if [ -n "$led1" ]; then (echo ${led_on} > "${led1}"/brightness || true) &> /dev/null; fi + if [ -n "${led0}" ]; then (echo ${led_on} > "${led0}"/brightness || true) &> /dev/null; fi + if [ -n "${led1}" ]; then (echo ${led_on} > "${led1}"/brightness || true) &> /dev/null; fi sleep 0.6s; - if [ -n "$led0" ]; then (echo ${led_off} > "${led0}"/brightness || true) &> /dev/null; fi - if [ -n "$led1" ]; then (echo ${led_off} > "${led1}"/brightness || true) &> /dev/null; fi + if [ -n "${led0}" ]; then (echo ${led_off} > "${led0}"/brightness || true) &> /dev/null; fi + if [ -n "${led1}" ]; then (echo ${led_off} > "${led1}"/brightness || true) &> /dev/null; fi sleep 0.15s; done sleep 0.075s; for i in $(seq 1 3); do - if [ -n "$led0" ]; then (echo ${led_on} > "${led0}"/brightness || true) &> /dev/null; fi - if [ -n "$led1" ]; then (echo ${led_on} > "${led1}"/brightness || true) &> /dev/null; fi + if [ -n "${led0}" ]; then (echo ${led_on} > "${led0}"/brightness || true) &> /dev/null; fi + if [ -n "${led1}" ]; then (echo ${led_on} > "${led1}"/brightness || true) &> /dev/null; fi sleep 0.225s; - if [ -n "$led0" ]; then (echo ${led_off} > "${led0}"/brightness || true) &> /dev/null; fi - if [ -n "$led1" ]; then (echo ${led_off} > "${led1}"/brightness || true) &> /dev/null; fi + if [ -n "${led0}" ]; then (echo ${led_off} > "${led0}"/brightness || true) &> /dev/null; fi + if [ -n "${led1}" ]; then (echo ${led_off} > "${led1}"/brightness || true) &> /dev/null; fi sleep 0.15s; done sleep 1.225s; @@ -271,10 +291,11 @@ fail() { echo " The maximum number of retries is reached!" echo " Check the logfiles for errors. Then delete or edit \"installer-retries.txt\" in installer folder to (re)set the counter." fi - echo " The system is stopped to prevent an infinite loop." + sleep 3s while true; do led_sos - done + done & + exit else echo " ${installer_retries} retries left." fi @@ -485,6 +506,16 @@ dtoverlay_enable() { fi } +module_enable() { + local module="${1}" + local purpose="${2}" + if [ "${init_system}" = "systemd" ]; then + echo "${module}" > "/rootfs/etc/modules-load.d/${purpose}.conf" + else + echo "${module}" >> /rootfs/etc/modules + fi +} + ####################### ### INSTALLER ### ####################### @@ -508,7 +539,7 @@ mkdir -p /usr/bin mkdir -p /usr/sbin mkdir -p /var/run mkdir -p /etc/raspberrypi-ua-netinst -mkdir -p /rootfs/boot +mkdir -p /rootfs mkdir -p /tmp mkdir -p "${tmp_bootfs}" mkdir -p /opt/busybox/bin @@ -521,6 +552,7 @@ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bu echo "export PATH=${PATH}" > /etc/profile mount -t proc proc /proc +ln -sf /proc/mounts /etc/mtab mount -t sysfs sysfs /sys mount -t tmpfs -o size=64k,mode=0755 tmpfs /dev @@ -662,9 +694,19 @@ case "${rpi_hardware}" in "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 @@ -707,15 +749,6 @@ variables_set_defaults preinstall_reboot=0 echo echo "Checking if config.txt needs to be modified before starting installation..." -# Reinstallation -if [ -e "/boot/raspberrypi-ua-netinst/reinstall/kernel.img" ] && [ -e "/boot/raspberrypi-ua-netinst/reinstall/kernel7.img" ] && [ -e "/boot/raspberrypi-ua-netinst/reinstall/kernel7l.img" ] ; then - echo -n " Reinstallation requested! Restoring files... " - mv /boot/raspberrypi-ua-netinst/reinstall/kernel.img /boot/kernel.img - mv /boot/raspberrypi-ua-netinst/reinstall/kernel7.img /boot/kernel7.img - mv /boot/raspberrypi-ua-netinst/reinstall/kernel7l.img /boot/kernel7l.img - echo "OK" - preinstall_reboot=1 -fi # HDMI settings if [ "${hdmi_system_only}" = "0" ]; then echo -n " Setting HDMI options... " @@ -753,7 +786,7 @@ fi if [ -n "${rtc}" ] ; then echo -n " Enabling RTC configuration... " if ! grep -q "^dtoverlay=i2c-rtc,${rtc}\>" /boot/config.txt; then - echo -e "\ndtoverlay=i2c-rtc,${rtc}" >> /boot/config.txt + dtoverlay_enable "/boot/config.txt" "i2c-rtc,${rtc}" preinstall_reboot=1 fi echo "OK" @@ -798,6 +831,7 @@ echo echo "Network configuration:" echo " ifname = ${ifname}" echo " ip_addr = ${ip_addr}" +echo " ip_ipv6 = ${ip_ipv6}" if [ "${ip_addr}" != "dhcp" ]; then ip_addr_o1="$(echo "${ip_addr}" | awk -F. '{print $1}')" @@ -855,6 +889,7 @@ if [ "${ip_addr}" != "dhcp" ]; then fi if echo "${ifname}" | grep -q "wlan"; then + echo "netdev:x:111:" >> /etc/group if [ -e "${tmp_bootfs}"/raspberrypi-ua-netinst/config/wpa_supplicant.conf ]; then cp "${tmp_bootfs}"/raspberrypi-ua-netinst/config/wpa_supplicant.conf "${wlan_configfile}" inputfile_sanitize "${wlan_configfile}" @@ -911,6 +946,17 @@ if [ -n "${drivers_to_load}" ]; then echo fi +if [ -n "${rtc}" ] ; then + echo -n "Ensuring RTC module has been loaded... " + modprobe "rtc-${rtc}" || fail + echo "OK" + echo -n "Checking hardware clock access... " + mdev -s + sleep 3s + /opt/busybox/bin/hwclock --show &> /dev/null || fail + echo "OK" +fi + echo -n "Waiting for ${ifname}... " for i in $(seq 1 "${installer_networktimeout}"); do if ifconfig "${ifname}" &> /dev/null; then @@ -968,16 +1014,31 @@ else echo "OK" fi +if [ "${ip_ipv6}" = "1" ]; then + echo -n "Enabling IPv6 support... " + modprobe ipv6 || fail + echo "OK" +fi + # Start telnet console output -if [ "${installer_telnet}" = "1" ]; then +if [ "${installer_telnet}" = "listen" ] || [ "${installer_telnet}" = "connect" ]; then mkfifo telnet.pipe mkfifo /dev/installer-telnet tee < telnet.pipe /dev/installer-telnet & + if [ "${installer_telnet}" = "listen" ]; then + nc_opts=(-klC -p 23) + else # connect + if [ -z "${installer_telnet_host}" ]; then + echo "'installer_telnet' set to 'connect' but no 'installer_telnet_host' specified." + echo "Telnet mode will not be enabled." + fi + nc_opts=(-C "${installer_telnet_host}" "${installer_telnet_port}") + fi while IFS= read -r line; do if [[ ! "${line}" =~ userpw|rootpw ]]; then echo "${line}" fi - done < "/dev/installer-telnet" | /bin/nc -klC -p 23 > /dev/null & + done < "/dev/installer-telnet" | /bin/nc "${nc_opts[@]}" > /dev/null & exec &> telnet.pipe rm telnet.pipe echo "Printing console to telnet output started." @@ -1128,7 +1189,7 @@ fi # determine available releases mirror_base=http://archive.raspberrypi.org/debian/dists/ -release_fallback=buster +release_fallback=bullseye release_base="${release}" release_raspbian="${release}" if ! wget --spider "${mirror_base}/${release}/" &> /dev/null; then @@ -1138,13 +1199,23 @@ if ! wget --spider "${mirror}/dists/${release}/" &> /dev/null; then release_raspbian="${release_fallback}" fi +# if the configuration will install the sysvinit-core package, then the init system will +# be sysvinit, otherwise it will be systemd +if echo "${cdebootstrap_cmdline} ${syspackages} ${packages}" | grep -q "sysvinit-core"; then + init_system="sysvinit" + if [ "${use_systemd_services}" != "0" ]; then + echo "Ignoring 'use_systemd_services' setting because init system is 'sysvinit'" + use_systemd_services=0 + fi +else + init_system="systemd" +fi + # configure different kinds of presets if [ -z "${cdebootstrap_cmdline}" ]; then # from small to large: base, minimal, server # not very logical that minimal > base, but that's how it was historically defined - init_system="systemd" - # always add packages if requested or needed if [ "${firmware_packages}" = "1" ]; then custom_packages_postinstall="${custom_packages_postinstall},firmware-atheros,firmware-brcm80211,firmware-libertas,firmware-misc-nonfree,firmware-realtek" @@ -1167,7 +1238,8 @@ if [ -z "${cdebootstrap_cmdline}" ]; then fi # base - base_packages="kmod" + # gnupg is required for 'apt-key' used later in the script + base_packages="kmod,gnupg" base_packages="${custom_packages},${base_packages}" if [ "${init_system}" = "systemd" ]; then base_packages="${base_packages},libpam-systemd" @@ -1178,24 +1250,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 - if [ "${release}" != "wheezy" ]; then - base_packages_postinstall="${base_packages_postinstall},raspberrypi-kernel" - fi + base_packages_postinstall="raspberrypi-bootloader,raspberrypi-kernel" base_packages_postinstall="${custom_packages_postinstall},${base_packages_postinstall}" # minimal - minimal_packages="cpufrequtils,ifupdown,net-tools,openssh-server,dosfstools" - if [ "${init_system}" != "systemd" ]; then + minimal_packages="cpufrequtils,openssh-server,dosfstools" + if [ "${init_system}" != "systemd" ] || [ "${use_systemd_services}" = "0" ]; then minimal_packages="${minimal_packages},ntp" + if [ -z "${rtc}" ]; then + minimal_packages="${minimal_packages},fake-hwclock" + fi + minimal_packages="${minimal_packages},ifupdown,net-tools" + else + minimal_packages="${minimal_packages},iproute2" fi - if [ -z "${rtc}" ]; then - minimal_packages="${minimal_packages},fake-hwclock" - fi - minimal_packages_postinstall="${base_packages_postinstall},${minimal_packages_postinstall}" - if [ "${release}" != "wheezy" ]; then - minimal_packages_postinstall="${minimal_packages_postinstall},raspberrypi-sys-mods" - fi + minimal_packages_postinstall="${base_packages_postinstall},${minimal_packages_postinstall},raspberrypi-sys-mods" if echo "${ifname}" | grep -q "wlan"; then minimal_packages_postinstall="${minimal_packages_postinstall},firmware-brcm80211" fi @@ -1206,7 +1275,25 @@ 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,raspi-copies-and-fills" + server_packages_postinstall="${server_packages_postinstall},libraspberrypi-bin" + if [ "${arch}" != "arm64" ]; then + server_packages_postinstall="${server_packages_postinstall},raspi-copies-and-fills" + fi + + # if using base or minimal preset and custom packages include console-setup, keyboard-configuration or tzdata, + # install them early using cdebootstrap or the initial configuration of keyboard layout or timezone will fail + if echo "${packages}" | grep -q "console-setup"; then + base_packages="${base_packages},console-setup" + minimal_packages="${minimal_packages},console-setup" + fi + if echo "${packages}" | grep -q "keyboard-configuration"; then + base_packages="${base_packages},keyboard-configuration" + minimal_packages="${minimal_packages},keyboard-configuration" + fi + if echo "${packages}" | grep -q "tzdata"; then + base_packages="${base_packages},tzdata" + minimal_packages="${minimal_packages},tzdata" + fi # cleanup package variables used by cdebootstrap_cmdline variable_sanitize base_packages @@ -1307,6 +1394,7 @@ echo " firmware_packages = ${firmware_packages}" echo " mirror = ${mirror}" echo " mirror_cache = ${mirror_cache}" echo " release = ${release_raspbian}" +echo " arch = ${arch}" echo " hostname = ${hostname}" echo " domainname = ${domainname}" echo " rootpw = ${rootpw}" @@ -1369,6 +1457,7 @@ echo " sound_usb_enable = ${sound_usb_enable}" echo " sound_usb_first = ${sound_usb_first}" echo " camera_enable = ${camera_enable}" echo " camera_disable_led = ${camera_disable_led}" +echo " use_systemd_services = ${use_systemd_services}" echo echo "OTP dump:" vcgencmd otp_dump | grep -v "..:00000000\|..:ffffffff" | sed 's/^/ /' @@ -1381,13 +1470,6 @@ for i in $(seq 1 5); do done echo -if [ -n "${rtc}" ] ; then - echo -n "Checking hardware clock access... " - /opt/busybox/bin/hwclock --show &> /dev/null || fail - echo "OK" - echo -fi - # fdisk's boot offset is 2048, so only handle $bootoffset is it's larger then that if [ -n "${bootoffset}" ] && [ "${bootoffset}" -gt 2048 ]; then emptyspaceend=$((bootoffset - 1)) @@ -1586,7 +1668,12 @@ for i in $(seq 1 "${installer_pkg_downloadretries}"); do if [ -n "${mirror_cache}" ]; then export http_proxy="http://${mirror_cache}/" fi - eval cdebootstrap-static --arch=armhf "${cdebootstrap_cmdline}" "${release_raspbian}" /rootfs "${mirror}" --keyring=/usr/share/keyrings/raspbian-archive-keyring.gpg 2>&1 | output_filter + if [ "${arch}" = "arm64" ]; then + keyring="debian-archive-keyring.gpg" + else + keyring="raspbian-archive-keyring.gpg" + fi + eval cdebootstrap-static --arch="${arch}" "${cdebootstrap_cmdline}" "${release_raspbian}" /rootfs "${mirror}" --keyring=/usr/share/keyrings/${keyring} 2>&1 | output_filter cdebootstrap_exitcode="${PIPESTATUS[0]}" if [ "${cdebootstrap_exitcode}" -eq 0 ]; then unset http_proxy @@ -1640,14 +1727,12 @@ if [ -n "${root_ssh_pubkey}" ]; then fail fi fi -# openssh-server in jessie and higher doesn't allow root to login with a password +# openssh-server doesn't allow root to login with a password if [ "${root_ssh_pwlogin}" = "1" ]; then - if [ "${release_raspbian}" != "wheezy" ]; then - if [ -f /rootfs/etc/ssh/sshd_config ]; then - echo -n " Allowing root to login with password... " - sed -i '/PermitRootLogin/s/.*/PermitRootLogin yes/' /rootfs/etc/ssh/sshd_config || fail - echo "OK" - fi + if [ -f /rootfs/etc/ssh/sshd_config ]; then + echo -n " Allowing root to login with password... " + sed -i '/PermitRootLogin/s/.*/PermitRootLogin yes/' /rootfs/etc/ssh/sshd_config || fail + echo "OK" fi fi # disable global password login if requested @@ -1680,6 +1765,7 @@ if [ -n "${username}" ]; then else echo -n "... " echo "${user_ssh_pubkey}" > "/rootfs/home/${username}/.ssh/authorized_keys" + echo "OK" fi echo -n " Setting owner as '${username}' on SSH directory... " chroot /rootfs /bin/chown -R "${username}:${username}" "/home/${username}/.ssh" || fail @@ -1739,17 +1825,20 @@ if [ -n "${username}" ]; then fi fi +bootpartition_uuid=PARTUUID=$(blkid -o value -s PARTUUID ${bootpartition}) +rootpartition_uuid=PARTUUID=$(blkid -o value -s PARTUUID ${rootpartition}) + # default mounts echo -n " Configuring /etc/fstab... " touch /rootfs/etc/fstab || fail { - echo "${bootpartition} /boot vfat defaults 0 2" + echo "${bootpartition_uuid} /boot vfat defaults 0 2" if [ "${rootfstype}" = "f2fs" ]; then - echo "${rootpartition} / ${rootfstype} ${rootfs_mount_options} 0 0" + echo "${rootpartition_uuid} / ${rootfstype} ${rootfs_mount_options} 0 0" elif [ "${rootfstype}" = "btrfs" ]; then - echo "${rootpartition} / ${rootfstype} ${rootfs_mount_options} 0 0" + echo "${rootpartition_uuid} / ${rootfstype} ${rootfs_mount_options} 0 0" else - echo "${rootpartition} / ${rootfstype} ${rootfs_mount_options} 0 1" + echo "${rootpartition_uuid} / ${rootfstype} ${rootfs_mount_options} 0 1" fi # also specify /tmp on tmpfs in /etc/fstab so it works across init systems echo "tmpfs /tmp tmpfs defaults,nodev,nosuid 0 0" @@ -1780,9 +1869,9 @@ else fi echo "OK" -# networking +# networking - ifupdown if echo "${cdebootstrap_cmdline} ${packages_postinstall}" | grep -q "ifupdown"; then - echo -n " Configuring network settings... " + echo -n " Configuring ifupdown network settings... " mkdir -p /rootfs/etc/network touch /rootfs/etc/network/interfaces || fail # lo interface may already be there, so first check for it @@ -1822,14 +1911,6 @@ if echo "${cdebootstrap_cmdline} ${packages_postinstall}" | grep -q "ifupdown"; } >> /rootfs/etc/network/interfaces fi - # Customize cmdline.txt - if [ "${disable_predictable_nin}" = "1" ]; then - # as described here: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames - # adding net.ifnames=0 to /boot/cmdline and disabling the persistent-net-generator.rules - line_add cmdline_custom "net.ifnames=0" - ln -s /dev/null /rootfs/etc/udev/rules.d/75-persistent-net-generator.rules - fi - echo "OK" # copy resolv.conf @@ -1847,6 +1928,65 @@ if echo "${cdebootstrap_cmdline} ${packages_postinstall}" | grep -q "ifupdown"; fi fi +# networking - systemd +if [ "${use_systemd_services}" != "0" ]; then + echo -n " Configuring systemd network settings... " + NETFILE=/rootfs/etc/systemd/network/primary.network + mkdir -p /rootfs/etc/systemd/network + + { + echo "[Match]" + echo "Name=${ifname}" + echo "[Network]" + } >> ${NETFILE} + + if [ "${ip_addr}" = "dhcp" ]; then + echo "DHCP=yes" >> ${NETFILE} + else + NETPREFIX=$(/bin/busybox ipcalc -p "${ip_addr}" "${ip_netmask}" | cut -f2 -d=) + { + echo "Address=${ip_addr}/${NETPREFIX}" + for i in ${ip_nameservers}; do + echo "DNS=${i}" + done + if [ -n "${timeserver}" ]; then + echo "NTP=${timeserver}" + fi + echo "[Route]" + echo "Gateway=${ip_gateway}" + } >> ${NETFILE} + fi + + # enable systemd-networkd service + ln -s /lib/systemd/system/systemd-networkd.service /rootfs/etc/systemd/system/multi-user.target.wants/systemd-networkd.service + + # enable systemd-resolved service + ln -s /lib/systemd/system/systemd-resolved.service /rootfs/etc/systemd/system/multi-user.target.wants/systemd-resolved.service + + # wlan config + if echo "${ifname}" | grep -q "wlan"; then + if [ -e "${wlan_configfile}" ]; then + # copy the installer version of `wpa_supplicant.conf` + mkdir -p /rootfs/etc/wpa_supplicant + cp "${wlan_configfile}" "/rootfs/etc/wpa_supplicant/wpa_supplicant-${ifname}.conf" + chmod 600 "/rootfs/etc/wpa_supplicant/wpa_supplicant-${ifname}.conf" + fi + # enable wpa_supplicant service + ln -s /lib/systemd/system/wpa_supplicant@.service "/rootfs/etc/systemd/system/multi-user.target.wants/wpa_supplicant@${ifname}.service" + rm /rootfs/etc/systemd/system/multi-user.target.wants/wpa_supplicant.service + fi + + echo "OK" +fi + +# Mask udev link files if predictable network interface names are not desired +if [ "${disable_predictable_nin}" = "1" ]; then + # as described here: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames + # masking 99-default.link and also 73-usb-net-by-mac.link (as raspi-config does) + ln -s /dev/null /rootfs/etc/systemd/network/99-default.link + ln -s /dev/null /rootfs/etc/systemd/network/73-usb-net-by-mac.link +fi + # set timezone and reconfigure tzdata package if [ -n "${timezone}" ]; then echo -n " Configuring tzdata (timezone \"${timezone}\")... " @@ -1919,9 +2059,9 @@ if [ -n "${system_default_locale}" ]; then system_default_locale="$(echo "${system_default_locale}" | grep -Eo "^\S+")" # trim to first space character echo -n "'${system_default_locale}'... " if chroot /rootfs /usr/sbin/update-locale LANG="${system_default_locale}" &> /dev/null; then - echo "OK" + echo "OK" else - echo "FAILED !" + echo "FAILED !" fi fi else @@ -1952,36 +2092,58 @@ fi echo -# if there is no hw clock on rpi -if [ -z "${rtc}" ]; then - if grep -q "#HWCLOCKACCESS=yes" /rootfs/etc/default/hwclock; then - sed -i "s/^#\(HWCLOCKACCESS=\)yes/\1no/" /rootfs/etc/default/hwclock - elif grep -q "HWCLOCKACCESS=yes" /rootfs/etc/default/hwclock; then - sed -i "s/^\(HWCLOCKACCESS=\)yes/\1no/m" /rootfs/etc/default/hwclock +if [ "${use_systemd_services}" = "0" ]; then + # if systemd is not in use, setup hwclock appropriately + if [ -z "${rtc}" ]; then + if grep -q "#HWCLOCKACCESS=yes" /rootfs/etc/default/hwclock; then + sed -i "s/^#\(HWCLOCKACCESS=\)yes/\1no/" /rootfs/etc/default/hwclock + elif grep -q "HWCLOCKACCESS=yes" /rootfs/etc/default/hwclock; then + sed -i "s/^\(HWCLOCKACCESS=\)yes/\1no/m" /rootfs/etc/default/hwclock + else + echo -e "HWCLOCKACCESS=no\n" >> /rootfs/etc/default/hwclock + fi else - echo -e "HWCLOCKACCESS=no\n" >> /rootfs/etc/default/hwclock + sed -i "s/^\(exit 0\)/\/sbin\/hwclock --hctosys\n\1/" /rootfs/etc/rc.local fi else - sed -i "s/^\(exit 0\)/\/sbin\/hwclock --hctosys\n\1/" /rootfs/etc/rc.local -fi + ln -s /lib/systemd/system/systemd-timesyncd.service /rootfs/etc/systemd/system/multi-user.target.wants/systemd-timesyncd.service + + if [ -n "${rtc}" ]; then + cat > /rootfs/etc/systemd/system/hwclock-to-sysclock.service << EOF +[Unit] +Description=Set system clock from hardware clock +After=systemd-modules-load.service -# enable NTP client on systemd releases -if [ "${init_system}" = "systemd" ]; then - ln -s /usr/lib/systemd/system/systemd-timesyncd.service /rootfs/etc/systemd/system/multi-user.target.wants/systemd-timesyncd.service +[Service] +Type=oneshot +ExecStart=/sbin/hwclock --hctosys --utc + +[Install] +WantedBy=basic.target + +EOF + mkdir /rootfs/etc/systemd/system/basic.target.wants + ln -s /etc/systemd/system/hwclock-to-sysclock.service /rootfs/etc/systemd/system/basic.target.wants/hwclock-to-sysclock.service + fi fi # copy apt's sources.list to the target system echo "Configuring apt:" -echo -n " Configuring Raspbian repository... " +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 - cp /rootfs/boot/raspberrypi-ua-netinst/config/apt/sources.list /rootfs/etc/apt/sources.list || fail else - sed "s/__RELEASE__/${release_raspbian}/g" "/opt/raspberrypi-ua-netinst/res/etc/apt/sources.list" > "/rootfs/etc/apt/sources.list" || fail + if [ "${arch}" = "arm64" ]; then + echo "deb ${mirror} ${release_raspbian} main contrib non-free" > "/rootfs/etc/apt/sources.list" || fail + echo "deb http://security.debian.org/debian-security ${release_raspbian}-security main contrib non-free" >> "/rootfs/etc/apt/sources.list" || fail + echo "deb ${mirror} ${release_raspbian}-updates main contrib non-free" >> "/rootfs/etc/apt/sources.list" || fail + else + echo "deb ${mirror} ${release_raspbian} main contrib non-free firmware" > "/rootfs/etc/apt/sources.list" || fail + fi fi echo "OK" # if __RELEASE__ is still present, something went wrong -echo -n " Checking Raspbian repository entry... " +echo -n " Checking Raspbian/Debian repository entry... " if grep -l '__RELEASE__' /rootfs/etc/apt/sources.list > /dev/null; then fail else @@ -2131,14 +2293,6 @@ echo -n "Removing cdebootstrap-helper-rc.d... " chroot /rootfs /usr/bin/dpkg -r cdebootstrap-helper-rc.d &> /dev/null || fail echo "OK" -echo -n "Preserving original config.txt and kernels... " -mkdir -p /rootfs/boot/raspberrypi-ua-netinst/reinstall -cp /rootfs/boot/config.txt /rootfs/boot/raspberrypi-ua-netinst/reinstall/config.txt -cp /rootfs/boot/kernel.img /rootfs/boot/raspberrypi-ua-netinst/reinstall/kernel.img -cp /rootfs/boot/kernel7.img /rootfs/boot/raspberrypi-ua-netinst/reinstall/kernel7.img -cp /rootfs/boot/kernel7l.img /rootfs/boot/raspberrypi-ua-netinst/reinstall/kernel7l.img -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 @@ -2157,7 +2311,7 @@ echo "OK" # create cmdline.txt echo -n "Creating cmdline.txt... " -line_add cmdline "root=${rootpartition} rootfstype=${rootfstype} rootwait" +line_add cmdline "root=${rootpartition_uuid} rootfstype=${rootfstype} rootwait" line_add_if_boolean quiet_boot cmdline_custom "quiet" "loglevel=3" line_add_if_boolean disable_raspberries cmdline_custom "logo.nologo" line_add_if_set console_blank cmdline_custom "consoleblank=${console_blank}" @@ -2189,7 +2343,7 @@ if [ "${i2c_enable}" = "1" ]; then sed -i "s/^\(dtparam=i2c_arm=.*\)/#\1/" /rootfs/boot/config.txt echo "dtparam=i2c_arm=on" >> /rootfs/boot/config.txt fi - echo "i2c-dev" >> /rootfs/etc/modules + 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 @@ -2320,11 +2474,8 @@ fi # enable rtc if specified in the configuration file if [ -n "${rtc}" ]; then - sed -i "s/^#\(dtoverlay=i2c-rtc,${rtc}\)/\1/" /rootfs/boot/config.txt - if [ "$(grep -c "^dtoverlay=i2c-rtc,.*" /rootfs/boot/config.txt)" -ne 1 ]; then - sed -i "s/^\(dtoverlay=i2c-rtc,\)/#\1/" /rootfs/boot/config.txt - echo "dtoverlay=i2c-rtc,${rtc}" >> /rootfs/boot/config.txt - fi + dtoverlay_enable "/rootfs/boot/config.txt" "i2c-rtc,${rtc}" + module_enable "rtc-${rtc}" "rtc" fi # enable custom dtoverlays @@ -2381,6 +2532,14 @@ if [ -e "/rootfs/boot/raspberrypi-ua-netinst/config/post-install.txt" ]; then echo "=================================================" fi +# this must be done as the last step, after all package installation and post-install scripts, +# since it will break DNS resolution on the target system until it is rebooted +if [ "${use_systemd_services}" != "0" ]; then + # ensure that /etc/resolv.conf will be provided by systemd and use systemd's stub resolver + rm -f /rootfs/etc/resolv.conf + ln -s /run/systemd/resolve/stub-resolv.conf /rootfs/etc/resolv.conf +fi + # save current time if echo "${cdebootstrap_cmdline} ${packages_postinstall}" | grep -q "fake-hwclock"; then echo -n "Saving current time for fake-hwclock... " @@ -2389,7 +2548,7 @@ if echo "${cdebootstrap_cmdline} ${packages_postinstall}" | grep -q "fake-hwcloc echo "OK" elif [ -n "${rtc}" ]; then echo -n "Saving current time to RTC... " - /opt/busybox/bin/hwclock --systohc || fail + /opt/busybox/bin/hwclock --systohc --utc || fail echo "OK" fi @@ -2398,6 +2557,9 @@ DURATION=$((ENDTIME - REAL_STARTTIME)) echo echo -n "Installation finished at $(date --date="@${ENDTIME}" --utc)" echo " and took $((DURATION/60)) min $((DURATION%60)) sec (${DURATION} seconds)" +echo +killall -q nc +echo "Printing console to telnet output stopped." # copy logfile to standard log directory if [ "${cleanup_logfiles}" = "1" ]; then @@ -2427,7 +2589,7 @@ if [ "${final_action}" != "console" ]; then killall -q udhcpc echo "OK" fi - + echo -n "Unmounting filesystems... " for sysfolder in /sys /proc /dev/pts /dev; do umount "/rootfs${sysfolder}" diff --git a/update.sh b/update.sh index 0328d576..ef5cc0e1 100755 --- a/update.sh +++ b/update.sh @@ -2,21 +2,20 @@ # shellcheck source=./build.conf # shellcheck disable=SC1091 -RASPBIAN_ARCHIVE_KEY_DIRECTORY="https://archive.raspbian.org" -RASPBIAN_ARCHIVE_KEY_FILE_NAME="raspbian.public.key" -RASPBIAN_ARCHIVE_KEY_URL="${RASPBIAN_ARCHIVE_KEY_DIRECTORY}/${RASPBIAN_ARCHIVE_KEY_FILE_NAME}" -RASPBIAN_ARCHIVE_KEY_FINGERPRINT="A0DA38D0D76E8B5D638872819165938D90FDDD2E" - -RASPBERRYPI_ARCHIVE_KEY_DIRECTORY="https://archive.raspberrypi.org/debian" -RASPBERRYPI_ARCHIVE_KEY_FILE_NAME="raspberrypi.gpg.key" -RASPBERRYPI_ARCHIVE_KEY_URL="${RASPBERRYPI_ARCHIVE_KEY_DIRECTORY}/${RASPBERRYPI_ARCHIVE_KEY_FILE_NAME}" -RASPBERRYPI_ARCHIVE_KEY_FINGERPRINT="CF8A1AF502A2AA2D763BAE7E82B129927FA3303E" +ARCHIVE_KEYS=() +ARCHIVE_KEYS+=("https://archive.raspbian.org;raspbian.public.key;A0DA38D0D76E8B5D638872819165938D90FDDD2E") +ARCHIVE_KEYS+=("https://archive.raspberrypi.org/debian;raspberrypi.gpg.key;CF8A1AF502A2AA2D763BAE7E82B129927FA3303E") +ARCHIVE_KEYS+=("https://ftp-master.debian.org/keys;archive-key-10.asc;80D15823B7FD1561F9F7BCDDDC30D7C23CBBABEE") +ARCHIVE_KEYS+=("https://ftp-master.debian.org/keys;archive-key-11.asc;1F89983E0081FDE018F3CC9673A4F27B8DD47936") +ARCHIVE_KEYS+=("https://ftp-master.debian.org/keys;release-11.asc;A4285295FC7B1A81600062A9605C66F00D6C9793") mirror_raspbian=http://mirrordirector.raspbian.org/raspbian mirror_raspberrypi=http://archive.raspberrypi.org/debian +mirror_debian=http://deb.debian.org/debian declare mirror_raspbian_cache declare mirror_raspberrypi_cache -release=buster +declare mirror_debian_cache +release=bullseye packages=() @@ -25,7 +24,6 @@ packages+=("raspberrypi-bootloader") packages+=("raspberrypi-kernel") packages+=("firmware-brcm80211") packages+=("btrfs-progs") -packages+=("libbtrfs0") packages+=("busybox") packages+=("bash-static") packages+=("cdebootstrap-static") @@ -33,7 +31,7 @@ packages+=("coreutils") packages+=("diffutils") packages+=("dosfstools") packages+=("dpkg") -packages+=("libext2fs2") +packages+=("libc-bin") packages+=("e2fsprogs") packages+=("f2fs-tools") packages+=("gpgv") @@ -44,7 +42,8 @@ packages+=("netbase") packages+=("netcat-openbsd") packages+=("ntpdate") packages+=("raspbian-archive-keyring") -packages+=("rng-tools") +packages+=("debian-archive-keyring") +packages+=("rng-tools5") packages+=("tar") packages+=("fdisk") packages+=("util-linux") @@ -52,77 +51,12 @@ packages+=("wpasupplicant") packages+=("libraspberrypi-bin") packages+=("xxd") packages+=("curl") - -# libraries -packages+=("libacl1") -packages+=("libatm1") -packages+=("libattr1") -packages+=("libaudit-common") -packages+=("libaudit1") -packages+=("libblkid1") -packages+=("libbsd0") -packages+=("libbz2-1.0") -packages+=("libc-bin") -packages+=("libc6") -packages+=("libcap2") -packages+=("libcom-err2") -packages+=("libcurl4") -packages+=("libdb5.3") -packages+=("libdbus-1-3") -packages+=("libelf1") -packages+=("libf2fs5") -packages+=("libfdisk1") -packages+=("libffi6") -packages+=("libgcc1") -packages+=("libgcrypt20") -packages+=("libgmp10") -packages+=("libgnutls30") -packages+=("libgpg-error0") -packages+=("libgssapi-krb5-2") -packages+=("libhogweed4") -packages+=("libidn11") -packages+=("libidn2-0") -packages+=("libk5crypto3") -packages+=("libkeyutils1") -packages+=("libkrb5-3") -packages+=("libkrb5support0") -packages+=("libldap-2.4-2") -packages+=("liblz4-1") -packages+=("liblzma5") -packages+=("liblzo2-2") -packages+=("libmount1") -packages+=("libmnl0") -packages+=("libncurses5") -packages+=("libnettle6") -packages+=("libnghttp2-14") -packages+=("libnl-3-200") -packages+=("libnl-genl-3-200") -packages+=("libnl-route-3-200") -packages+=("libpam0g") -packages+=("libpcre3") -packages+=("libpcsclite1") -packages+=("libp11-kit0") -packages+=("libpsl5") -packages+=("libraspberrypi0") -packages+=("librtmp1") -packages+=("libsasl2-2") -packages+=("libselinux1") -packages+=("libslang2") -packages+=("libsmartcols1") -packages+=("libssh2-1") -packages+=("libssl1.1") -packages+=("libssl1.0.2") -packages+=("libsystemd0") -packages+=("libtasn1-6") -packages+=("libtinfo6") -packages+=("libudev1") -packages+=("libunistring2") -packages+=("libuuid1") -packages+=("zlib1g") +packages+=("logsave") packages_debs= packages_sha256= +packages_done=() download_file() { local download_source=$1 @@ -206,49 +140,27 @@ setup_archive_keys() { # Let gpg set itself up already in the 'gnupg' dir before we actually use it echo "Setting up gpg... " gpg --homedir gnupg --list-secret-keys - echo "" - - echo "Downloading ${RASPBIAN_ARCHIVE_KEY_FILE_NAME}." - download_file ${RASPBIAN_ARCHIVE_KEY_URL} - if check_key "${RASPBIAN_ARCHIVE_KEY_FILE_NAME}" "${RASPBIAN_ARCHIVE_KEY_FINGERPRINT}"; then - # GPG key checks out, thus import it into our own keyring - echo -n "Importing '${RASPBIAN_ARCHIVE_KEY_FILE_NAME}' into keyring... " - if gpg -q --homedir gnupg --import "${RASPBIAN_ARCHIVE_KEY_FILE_NAME}"; then - echo "OK" - else - echo "FAILED!" - return 1 - fi - else - return 1 - fi - - echo "" - echo "Downloading ${RASPBERRYPI_ARCHIVE_KEY_FILE_NAME}." - download_file ${RASPBERRYPI_ARCHIVE_KEY_URL} - if check_key "${RASPBERRYPI_ARCHIVE_KEY_FILE_NAME}" "${RASPBERRYPI_ARCHIVE_KEY_FINGERPRINT}"; then - # GPG key checks out, thus import it into our own keyring - echo -n "Importing '${RASPBERRYPI_ARCHIVE_KEY_FILE_NAME}' into keyring..." - if gpg -q --homedir gnupg --import "${RASPBERRYPI_ARCHIVE_KEY_FILE_NAME}"; then - echo "OK" + for archive_key in ${ARCHIVE_KEYS[@]}; do + echo "" + IFS=';' read -r KEY_URL KEY_FILE KEY_FINGERPRINT <<< "$archive_key" + echo "Downloading ${KEY_FILE}." + download_file ${KEY_URL}/${KEY_FILE} + if check_key "${KEY_FILE}" "${KEY_FINGERPRINT}"; then + # GPG key checks out, thus import it into our own keyring + echo -n "Importing '${KEY_FILE}' into keyring... " + if gpg -q --homedir gnupg --import "${KEY_FILE}"; then + echo "OK" + else + echo "FAILED!" + return 1 + fi else - echo "FAILED!" return 1 fi - else - return 1 - fi + done return 0 - -} - -required() { - for i in "${packages[@]}"; do - [[ $i = "${1}" ]] && return 0 - done - return 1 } unset_required() { @@ -264,7 +176,7 @@ allfound() { } filter_package_list() { - grep -E 'Package:|Filename:|SHA256:|^$' + grep -E '^Package:|^Pre-Depends:|^Depends:|^Filename:|^SHA256:|^$' } download_package_list() { @@ -314,12 +226,6 @@ download_package_list() { } download_package_lists() { - if ! setup_archive_keys; then - echo -e "ERROR\nSetting up the archives failed! Exiting." - cd .. - exit 1 - fi - echo -e "\nDownloading Release file and its signature..." download_file "${2}/dists/$release/Release" "${1}_Release" download_file "${2}/dists/$release/Release.gpg" "${1}_Release.gpg" @@ -343,28 +249,51 @@ download_package_lists() { add_packages() { echo -e "\nAdding required packages..." - while read -r k v - do - if [ "${k}" = "Package:" ]; then - current_package=${v} - elif [ "${k}" = "Filename:" ]; then - current_filename=${v} - elif [ "${k}" = "SHA256:" ]; then - current_sha256=${v} - elif [ "${k}" = "" ]; then - if required "${current_package}"; then - printf " %-32s %s\n" "${current_package}" "$(basename "${current_filename}")" - unset_required "${current_package}" - packages_debs+=("${2}/${current_filename}") - packages_sha256+=("${current_sha256} $(basename "${current_filename}")") - allfound && break - fi - + filter_package_list < "${1}_Packages" >"${1}_Packages.tmp" + while true; do + libs=() + for pkg in "${packages[@]}"; do current_package= + current_depends=() current_filename= current_sha256= + while read -r k v + do + if [ "${k}" = "Package:" ]; then + current_package=${v} + elif [ "${k}" = "Pre-Depends:" ]; then + current_depends+=($(echo "${v}" | sed -e 's/, /\n/g' -e 's/\ Pre-Depends:\ //' -e 's/ ([^)]*)//g')) + elif [ "${k}" = "Depends:" ]; then + current_depends+=($(echo "${v}" | sed -e 's/, /\n/g' -e 's/\ Depends:\ //' -e 's/ ([^)]*)//g')) + elif [ "${k}" = "Filename:" ]; then + current_filename=${v} + elif [ "${k}" = "SHA256:" ]; then + current_sha256=${v} + elif [ "${k}" = "" ]; then + break + fi + done < <(grep -A 4 -m 1 ^Package:\ "$pkg"$ "${1}_Packages.tmp") + if [ -z ${current_package} ]; then # package not found + continue + fi + printf " %-32s %s\n" "${current_package}" "$(basename "${current_filename}")" + unset_required "${current_package}" + packages_debs+=("${2}/${current_filename}") + packages_sha256+=("${current_sha256} $(basename "${current_filename}")") + packages_done+=("${current_package}") + libs+=($(printf '%s\n' "${current_depends[@]}" | grep "lib")) + done + # remove duplicate libs + libs=($(printf '%s\n' "${libs[@]}" | sort | uniq)) + # remove libs already done + libs=($(printf '%s\n' "${packages_done[@]}" "${packages_done[@]}" "${libs[@]}" | sort | uniq -u)) + # we're done if no libs to add + if [ ${#libs[@]} -eq 0 ]; then + break fi - done < <(filter_package_list <"${1}_Packages") + packages+=(${libs[@]}) + echo -e "\nAdding dependency libraries..." + done } download_packages() { @@ -425,10 +354,20 @@ fi if [ -n "${mirror_raspberrypi_cache}" ]; then mirror_raspberrypi=${mirror_raspberrypi/:\/\//:\/\/${mirror_raspberrypi_cache}\/} fi + if [ -n "${mirror_debian_cache}" ]; then + mirror_debian=${mirror_debian/:\/\//:\/\/${mirror_debian_cache}\/} + fi + + if ! setup_archive_keys; then + echo -e "ERROR\nSetting up the archives failed! Exiting." + cd .. + exit 1 + fi ## Download package list download_package_lists raspberry ${mirror_raspberrypi} download_package_lists raspbian ${mirror_raspbian} + download_package_lists debian ${mirror_debian} ## Select packages for download packages_debs=() @@ -436,6 +375,7 @@ fi add_packages raspberry ${mirror_raspberrypi} add_packages raspbian ${mirror_raspbian} + add_packages debian ${mirror_debian} if ! allfound; then echo "ERROR: Unable to find all required packages in package list!" echo "Missing packages: '${packages[*]}'" @@ -453,13 +393,17 @@ fi ## Download default /boot/config.txt and do default changes mkdir -p initramfs/boot cd initramfs/boot || exit 1 - download_remote_file https://downloads.raspberrypi.org/raspbian/ "boot.tar.xz" xzcat ./config.txt + download_remote_file https://downloads.raspberrypi.org/raspios_armhf/ "boot.tar.xz" xzcat ./config.txt sed -i "s/^\(dtparam=audio=on\)/#\1/" config.txt # disable audio { - echo -e "\n[pi3]" - echo -e "# Enable serial port\nenable_uart=1" - echo -e "\n[all]" - echo -e "# Add other config parameters below this line." + echo "" + echo "[pi3]" + echo "dtoverlay=disable-bt" + echo "[pi4]" + echo "dtoverlay=disable-bt" + echo "" + echo "[all]" + echo "# Add other config parameters below this line." } >> config.txt chmod 644 config.txt cd ../.. || exit 1