Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta v8.23.0 #6686

Merged
merged 53 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
fb0db33
Release v8.22 (#6626)
MichaIng Sep 23, 2023
e44ed23
v8.22
MichaIng Sep 24, 2023
2e3135a
v8.23
MichaIng Sep 24, 2023
cabda5c
v8.23
MichaIng Sep 24, 2023
8079e2d
Init v8.23
MichaIng Sep 24, 2023
3090ab6
v8.23
MichaIng Sep 25, 2023
6a8dfb9
v8.23
MichaIng Sep 25, 2023
f943e3c
v8.23
MichaIng Sep 25, 2023
925d4ba
v8.23
MichaIng Sep 26, 2023
a5796c5
v8.23
MichaIng Sep 26, 2023
64f6ef8
v8.23 (#6639)
MichaIng Sep 26, 2023
c1d9640
v8.23
MichaIng Sep 27, 2023
970abad
v8.23
MichaIng Sep 28, 2023
675f3b8
v8.23
MichaIng Sep 28, 2023
d6b5242
v8.23
MichaIng Sep 28, 2023
561329b
v8.23
MichaIng Sep 28, 2023
50f8c74
v8.23
MichaIng Sep 29, 2023
b04b43b
v8.23
MichaIng Sep 30, 2023
77c9b12
v8.23
MichaIng Sep 30, 2023
fa0646e
v8.23
MichaIng Sep 30, 2023
c2ba4b9
v8.23
MichaIng Oct 1, 2023
144d374
v8.23
MichaIng Oct 1, 2023
ef13da5
v8.23
MichaIng Oct 1, 2023
c30cb7d
v8.23
MichaIng Oct 2, 2023
406ecfa
v8.23
MichaIng Oct 2, 2023
81121d4
v8.23
MichaIng Oct 2, 2023
bcceeda
v8.23
MichaIng Oct 2, 2023
0333330
v8.23
MichaIng Oct 4, 2023
e6f10a7
v8.23
MichaIng Oct 8, 2023
0812ad7
v8.23
MichaIng Oct 8, 2023
78c43aa
v8.23
MichaIng Oct 8, 2023
84cc7c4
v8.23
MichaIng Oct 8, 2023
c5e6013
v8.23
MichaIng Oct 9, 2023
c8c6d8e
v8.23
MichaIng Oct 12, 2023
3aafe6e
v8.23 (#6661)
dirkhh Oct 12, 2023
a3b5bc2
v8.23
MichaIng Oct 12, 2023
9106d7a
v8.23
MichaIng Oct 12, 2023
60934c6
v8.23
MichaIng Oct 12, 2023
5745845
v8.23
MichaIng Oct 12, 2023
6cab64c
v8.23
MichaIng Oct 13, 2023
26b2021
v8.23 (#6674)
TDuffinNTU Oct 14, 2023
8292733
v8.23
MichaIng Oct 14, 2023
a313f43
v8.23 (#6680)
MichaIng Oct 14, 2023
8a241ca
v8.23
MichaIng Oct 15, 2023
42a12f8
v8.23
MichaIng Oct 15, 2023
fa367d2
v8.23
MichaIng Oct 15, 2023
81cbb9d
v8.23
MichaIng Oct 15, 2023
76d6ce1
v8.23
MichaIng Oct 15, 2023
8fc8e4b
v8.23
MichaIng Oct 15, 2023
7ef8d6c
v8.23
MichaIng Oct 15, 2023
1438f7d
v8.23
MichaIng Oct 17, 2023
5bc833a
v8.23
MichaIng Oct 17, 2023
fbc2bf1
v8.23
MichaIng Oct 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .build/images/dietpi-build
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ case $HW_ARCH in
2) iarch='ARMv7' parch='armhf';;
3) iarch='ARMv8' parch='arm64';;
10) iarch='x86_64' parch='amd64';;
11) iarch='RISC-V' parch='riscv64' DISTRO=8 repo='https://deb.debian.org/debian-ports/' keyring='/usr/share/keyrings/debian-ports-archive-keyring.gpg';; # RISC-V architecture is available on Debian ports only
11) iarch='RISC-V' parch='riscv64' DISTRO=8;; # RISC-V architecture is available on Sid only, but internally DietPi handles it as Trixie
*) G_DIETPI-NOTIFY 1 "Invalid architecture \"$HW_ARCH\" passed, aborting..."; exit 1;;
esac

Expand All @@ -157,7 +157,7 @@ case $DISTRO in
7|8)
exclude=',gcc-8-base,gcc-9-base,gcc-10-base,gcc-11-base'
[[ $DISTRO == 7 ]] && distro='bookworm' || distro='trixie' exclude+=',gcc-12-base'
[[ $HW_ARCH == 11 ]] && distro='sid' # RISC-V architecture is available on Debian Sid/unstable only
[[ $HW_ARCH == 11 ]] && distro='sid' # RISC-V architecture is available on Sid only
# Raise root size where required
case $HW_MODEL in
1[256]|54|61|7[4569]) ((root_size+=128));;
Expand Down Expand Up @@ -207,8 +207,7 @@ fi
(( $efi_size )) || [[ $boot_size -gt 0 && $boot_fstype == 'fat'* ]] && apackages+=('dosfstools')

# Emulation support in case of incompatible architecture
# - TEMPORARY: Early exit for Trixie/Sid until systemd + QEMU incompatibility fix has been released: https://github.com/systemd/systemd/pull/28954
(( ( $G_HW_ARCH < 10 && $G_HW_ARCH < $HW_ARCH ) || ( ( $G_HW_ARCH == 10 || $G_HW_ARCH == 11 ) && $G_HW_ARCH != $HW_ARCH ) )) && { apackages+=('qemu-user-static' 'binfmt-support'); (( $DISTRO == 8 )) && { G_DIETPI-NOTIFY 1 'systemd on Trixie/Sid does currently not support QEMU emulation, aborting ...'; exit 0; } }
(( ( $G_HW_ARCH < 10 && $G_HW_ARCH < $HW_ARCH ) || ( ( $G_HW_ARCH == 10 || $G_HW_ARCH == 11 ) && $G_HW_ARCH != $HW_ARCH ) )) && apackages+=('qemu-user-static' 'binfmt-support')

# Virtual machine disk conversion
[[ $VMTYPE && $VMTYPE != 'raw' ]] && apackages+=('qemu-utils')
Expand All @@ -220,7 +219,6 @@ if [[ ! -f $keyring ]]
then
case $keyring in
*'raspbian'*) url='https://archive.raspbian.org/raspbian/pool/main/r/raspbian-archive-keyring/raspbian-archive-keyring_20120528.2_all.deb';;
*'debian-ports'*) url='https://deb.debian.org/debian/pool/main/d/debian-ports-archive-keyring/debian-ports-archive-keyring_2023.02.01~deb11u1_all.deb';;
*) url='https://deb.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2023.4_all.deb';;
esac
G_EXEC curl -sSf "$url" -o /tmp/keyring.deb
Expand Down Expand Up @@ -401,7 +399,6 @@ G_EXEC mount -o X-mount.mkdir -t tmpfs tmpfs rootfs/var/lib/apt/lists
G_EXEC mount -o X-mount.mkdir -t tmpfs tmpfs rootfs/var/log
packages='apt,bash-completion,bzip2,ca-certificates,cron,curl,fdisk,gnupg,htop,iputils-ping,locales,nano,p7zip,parted,procps,psmisc,sudo,systemd-sysv,tzdata,udev,unzip,wget,whiptail,'
[[ $HW_MODEL == 75 ]] && packages+='iproute2' || packages+='console-setup,dropbear,ethtool,fake-hwclock,ifupdown,isc-dhcp-client,kmod,rfkill,systemd-timesyncd,usbutils'
[[ $HW_ARCH == 11 ]] && packages+=',debian-ports-archive-keyring'
G_EXEC_POST_FUNC(){ [[ $exit_code == 0 ]] || cat /dev/shm/rootfs/debootstrap/debootstrap.log; }
G_EXEC_OUTPUT=1 G_EXEC debootstrap --variant=minbase --exclude="gcc-7-base$exclude" --include="$packages" --arch="$parch" --keyring="$keyring" "$distro" ./rootfs "$repo"
G_EXEC umount rootfs/dev rootfs/run rootfs/var/cache/apt rootfs/var/lib/apt/lists rootfs/var/log
Expand Down Expand Up @@ -582,7 +579,7 @@ then

# Workaround invalid TERM on login
# shellcheck disable=SC2016
G_EXEC eval 'echo '\''infocmp "$TERM" > /dev/null 2>&1 || export TERM=dumb'\'' > rootfs/etc/bashrc.d/00-dietpi-build.sh'
G_EXEC eval 'echo '\''infocmp "$TERM" > /dev/null 2>&1 || { echo "[ INFO ] Unsupported TERM=\"$TERM\", switching to TERM=\"dumb\""; export TERM=dumb; }'\'' > rootfs/etc/bashrc.d/00-dietpi-build.sh'

# Workaround for failing IPv4 network connectivity check as GitHub Actions runners do not receive external ICMP echo replies.
G_CONFIG_INJECT 'CONFIG_CHECK_CONNECTION_IP=' 'CONFIG_CHECK_CONNECTION_IP=127.0.0.1' rootfs/boot/dietpi.txt
Expand Down Expand Up @@ -619,7 +616,7 @@ G_EXEC rm -R /var/tmp/dietpi/logs
/boot/dietpi/func/dietpi-set_software apt-cache clean
G_EXEC rm /boot/dietpi/.{hw_model,dietpi-services_include_exclude} /boot/dietpi-wifi.txt
G_EXEC rm -Rf /{root,home/*}/.{bash_history,nano_history,wget-hsts,cache,local,config,gnupg,viminfo,dbus,gconf,nano,vim,zshrc,oh-my-zsh} /etc/*- /var/{cache/debconf,lib/dpkg}/*-old /var/lib/dhcp/{,.??,.[^.]}*
# Remove unique Roon IDs: https://community.roonlabs.com/t/roon-core-will-not-recognize-two-dietpi-allo-gui-roon-bridges-simultaneously/32563/18?u=dan_knight
# Remove unique Roon IDs: https://community.roonlabs.com/t/roon-core-will-not-recognize-two-dietpi-allo-gui-roon-bridges-simultaneously/32563/18
G_EXEC rm -f /mnt/dietpi_userdata/roon/{RoonBridge,RAATServer}/Settings/unique_id

# Re-create required log dirs
Expand Down
81 changes: 67 additions & 14 deletions .build/images/dietpi-installer
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,16 @@ Package: armbian-firmware* linux-*
Pin: origin apt.armbian.com
Pin-Priority: 500
_EOF_
if dpkg --compare-versions "$(dpkg-query -Wf '${Version}' base-files)" gt 20
then
G_DIETPI-NOTIFY 2 'Enforcing downgrade of Armbian'\''s base-files package to Debian'\''s'
cat << '_EOF_' > /etc/apt/preferences.d/dietpi-armbian-tmp
Package: base-files
Pin: release o=Debian
Pin-Priority: 1000
_EOF_
G_EXEC eval 'echo '\''APT::Get::Allow-Downgrades "1";'\'' > /etc/apt/apt.conf.d/dietpi-armbian'
fi
# Bootstrap Armbian repository
G_EXEC_RETRIES=2 G_EXEC eval 'curl -sSfL '\''https://apt.armbian.com/armbian.key'\'' | gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-armbian.gpg --yes'
# Remove obsolete combined keyring
Expand Down Expand Up @@ -1056,8 +1066,19 @@ _EOF_
G_EXEC rm package.deb
fi

# Odroid C1: https://dietpi.com/forum/t/odroid-c1-not-booting-after-kernel-upgrade/17818
if (( $G_HW_MODEL == 10 ))
then
G_DIETPI-NOTIFY 2 'Pinning Odroid C1 "current" and "edge" kernel packages to latest known functional version and in case enforcing automated downgrade'
cat << '_EOF_' > /etc/apt/preferences.d/00-dietpi-odroidc1
Package: linux-image-current-meson linux-dtb-current-meson linux-headers-current-meson linux-image-edge-meson linux-dtb-edge-meson linux-headers-edge-meson
Pin: version 23.02.2
Pin-Priority: 1000
_EOF_
G_EXEC eval 'echo '\''APT::Get::Allow-Downgrades "1";'\'' > /etc/apt/apt.conf.d/dietpi-armbian'

# NanoPi R2S/NEO3
if [[ $G_HW_MODEL =~ ^(55|56)$ ]]
elif [[ $G_HW_MODEL =~ ^(55|56)$ ]]
then
G_DIETPI-NOTIFY 2 'Blacklisting video related kernel modules'
cat << '_EOF_' > /etc/modprobe.d/dietpi-headless.conf
Expand All @@ -1069,7 +1090,7 @@ blacklist rockchip_vdec
_EOF_
fi
# Install initramfs-tools first to have an initramfs generated on kernel install, and configure it to use zstd if supported for better compression and faster decompression
[[ $kernel == 'rockchip64' || $kernel == 'rk35xx' || $kernel == 'meson64' || $kernel == 'sunxi64' || $kernel == 'sunxi' ]] && zstd=('zstd')
[[ $kernel == 'rockchip64' || $kernel == 'rk35xx' || $kernel == 'meson64' || $kernel == 'sunxi64' || $kernel == 'sunxi' || $kernel == 'rockchip' ]] && zstd=('zstd')
# - Download and pre-install a more recent armbian-firmware package from our server
#G_EXEC_OUTPUT=1 G_EXEC curl -fo package.deb 'https://dietpi.com/downloads/binaries/armbian-firmware.deb'
#G_EXEC_OUTPUT=1 G_EXEC dpkg -i package.deb
Expand Down Expand Up @@ -1097,8 +1118,15 @@ _EOF_
. /usr/lib/u-boot/platform_install.sh
# shellcheck disable=SC2154
write_uboot_platform "$DIR" "$BOOT_DEVICE"

# Odroid C1 cleanup: https://dietpi.com/forum/t/odroid-c1-not-booting-after-kernel-upgrade/17818
if (( $G_HW_MODEL == 10 ))
then
G_DIETPI-NOTIFY 2 'Setting Odroid C1 "current" and "edge" kernel packages on hold'
G_EXEC apt-mark hold linux-image-current-meson linux-dtb-current-meson linux-headers-current-meson linux-image-edge-meson linux-dtb-edge-meson linux-headers-edge-meson

# Radxa Zero: Enable USB OTG OOTB: https://github.com/MichaIng/DietPi/issues/5931
if (( $G_HW_MODEL == 74 ))
elif (( $G_HW_MODEL == 74 ))
then
G_AGI device-tree-compiler
[[ -d '/boot/overlay-user' ]] || G_EXEC mkdir /boot/overlay-user
Expand Down Expand Up @@ -1202,11 +1230,15 @@ _EOF_
elif (( $G_HW_MODEL == 81 ))
then
G_EXEC curl -sSfo package.deb 'https://dietpi.com/downloads/binaries/linux-image-visionfive2.deb'
[[ -f '/boot/extlinux/extlinux.conf' ]] && G_EXEC rm /boot/extlinux/extlinux.conf
dpkg-deb -I linux-image-visionfive2.deb conffiles | while read -r line
do
[[ -f $line ]] && G_EXEC rm "$line"
done
G_EXEC_OUTPUT=1 G_EXEC dpkg -i package.deb
G_EXEC rm package.deb
G_EXEC sed -i "s/root=[^[:blank:]]*/root=PARTUUID=$(findmnt -Ufnro PARTUUID -M /)/" /boot/extlinux/extlinux.conf
G_EXEC sed -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/extlinux/extlinux.conf
aPACKAGES_REQUIRED_INSTALL+=('libubootenv-tool')

# Sparky SBC
elif (( $G_HW_MODEL == 70 ))
Expand All @@ -1228,11 +1260,33 @@ _EOF_
# Apply Lighttpd as default webserver, since Apache does not run on Linux 3.10: https://dietpi.com/forum/t/allogui-not-working-apache-service-doesnt-start/15708
G_CONFIG_INJECT 'AUTO_SETUP_WEB_SERVER_INDEX=' 'AUTO_SETUP_WEB_SERVER_INDEX=-2' /boot/dietpi.txt

# Armbian grab currently installed packages
# Armbian
elif [[ $G_HW_MODEL != 75 && $(dpkg-query -Wf '${Package} ') == *'armbian'* ]]
then
# Prevent any unintended packages from being installed from Armbian's APT repository, like base-files: https://github.com/MichaIng/DietPi/issues/6227#issuecomment-1713688577
cat << '_EOF_' > /etc/apt/preferences.d/dietpi-armbian
Package: *
Pin: origin apt.armbian.com
Pin-Priority: -1

Package: armbian-firmware* linux-*
Pin: origin apt.armbian.com
Pin-Priority: 500
_EOF_
if dpkg --compare-versions "$(dpkg-query -Wf '${Version}' base-files)" gt 20
then
G_DIETPI-NOTIFY 2 'Enforcing downgrade of Armbian'\''s base-files package to Debian'\''s'
cat << '_EOF_' > /etc/apt/preferences.d/dietpi-armbian-tmp
Package: base-files
Pin: release o=Debian
Pin-Priority: 1000
_EOF_
G_EXEC eval 'echo '\''APT::Get::Allow-Downgrades "1";'\'' > /etc/apt/apt.conf.d/dietpi-armbian'
fi

systemctl stop armbian-*

# Keep currently installed kernel and bootloader packages
local apackages=(

'linux-image-'
Expand Down Expand Up @@ -1310,9 +1364,6 @@ _EOF_
unset -v apackages
fi

# RISC-V: Install Debian ports repository key
(( $G_HW_ARCH == 11 )) && aPACKAGES_REQUIRED_INSTALL+=('debian-ports-archive-keyring')

# WiFi and firmware packages: Usually no firmware should be necessary for VMs. If user manually passes though some USB device, user might need to install the firmware then.
if (( $G_HW_MODEL != 20 && $G_HW_MODEL != 75 ))
then
Expand Down Expand Up @@ -1383,6 +1434,10 @@ _EOF_

G_AGA

# Remove temporary APT configs
[[ -f '/etc/apt/preferences.d/dietpi-armbian-tmp' ]] && G_EXEC rm /etc/apt/preferences.d/dietpi-armbian-tmp
[[ -f '/etc/apt/apt.conf.d/dietpi-armbian' ]] && G_EXEC rm /etc/apt/apt.conf.d/dietpi-armbian

#------------------------------------------------------------------------------------------------
G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "[$SETUP_STEP] Applying DietPi tweaks and cleanup"; ((SETUP_STEP++))
#------------------------------------------------------------------------------------------------
Expand All @@ -1403,12 +1458,8 @@ _EOF_
G_DIETPI-NOTIFY 2 'Restoring default base files:'
# shellcheck disable=SC2114
rm -Rfv /etc/{motd,profile,update-motd.d,issue{,.net}} /root /home /media /var/mail
# Replace Armbian's base-files package with Debian's: https://github.com/MichaIng/DietPi/issues/6407
G_EXEC eval 'echo -e '\''Package: base-files\nPin: origin *\nPin-Priority: 1000'\'' > /etc/apt/preferences.d/99dietpi-base-files'
G_AGI --reinstall --allow-downgrades base-files # Restore /etc/{update-motd.d,issue{,.net}} /root /home, allow downgrades to replace Armbian's base-files package
G_EXEC rm /etc/apt/preferences.d/99dietpi-base-files
G_AGA
[[ -L '/var/lock' ]] || G_EXEC rm -R /var/lock # Armbian images currently ship with this as directory (bug), and postinst fails migrating it to symlink => /run/lock if that directory has content: https://github.com/MichaIng/DietPi/issues/6407
G_AGI --reinstall base-files # Restore /etc/{update-motd.d,issue{,.net}} /root /home
[[ -L '/var/lock' ]] || { [[ -d '/var/lock' ]] && G_EXEC rm -R /var/lock; G_EXEC ln -s /run/lock /var/lock; } # Armbian images currently ship with this as directory (bug), and postinst fails migrating it to symlink => /run/lock if that directory has content: https://github.com/MichaIng/DietPi/issues/6407
G_EXEC /var/lib/dpkg/info/base-files.postinst configure # Restore /root/.{profile,bashrc} /etc/{motd,profile} /media /var/mail

G_DIETPI-NOTIFY 2 'Deleting list of known users and groups, not required by DietPi'
Expand Down Expand Up @@ -1553,6 +1604,8 @@ _EOF_
G_EXEC rm -f /etc/{default,logrotate.d}/armbian*
[[ -f '/lib/firmware/bootsplash.armbian' ]] && G_EXEC rm /lib/firmware/bootsplash.armbian
[[ -L '/etc/systemd/system/sysinit.target.wants/bootsplash-ask-password-console.path' ]] && G_EXEC rm /etc/systemd/system/sysinit.target.wants/bootsplash-ask-password-console.path
[[ -f '/etc/udev/rules.d/70-rename-lan.rules' ]] && G_EXEC rm /etc/udev/rules.d/70-rename-lan.rules # NanoPi R2S/R2C: https://github.com/armbian/build/blob/main/config/boards/nanopi-r2s.csc, https://github.com/armbian/build/blob/main/config/boards/nanopi-r2c.csc
[[ -f '/etc/udev/rules.d/70-persistent-net.rules' ]] && G_EXEC rm /etc/udev/rules.d/70-persistent-net.rules # NanoPi R5S/R6S: https://github.com/armbian/build/blob/main/config/boards/nanopi-r5s.csc, https://github.com/armbian/build/blob/main/config/boards/nanopi-r6s.conf

# - OMV: https://github.com/MichaIng/DietPi/issues/2994
[[ -d '/etc/openmediavault' ]] && G_EXEC rm -R /etc/openmediavault
Expand Down
89 changes: 7 additions & 82 deletions .build/software/raspberrypi-sys-mods/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,7 @@ fi

G_EXEC mkdir -p raspberrypi-sys-mods/{DEBIAN,lib/udev/rules.d,usr/{lib,share/doc}/raspberrypi-sys-mods}

cat << '_EOF_' > raspberrypi-sys-mods/usr/share/doc/raspberrypi-sys-mods/copyright
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: raspberrypi-sys-mods
Source: https://github.com/RPi-Distro/raspberrypi-sys-mods

Files: *
Copyright: 2015 Raspberry Pi Foundation
License: BSD-3-Clause

License: BSD-3-Clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
_EOF_
G_EXEC curl -sSfo raspberrypi-sys-mods/usr/share/doc/raspberrypi-sys-mods/copyright 'https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/debian/copyright'

cat << '_EOF_' > raspberrypi-sys-mods/usr/lib/raspberrypi-sys-mods/i2cprobe
#!/bin/dash
Expand All @@ -66,53 +33,11 @@ modprobe "$MODALIAS" || modprobe "of:N${OF_NAME}T<NULL>C$OF_COMPATIBLE_0"
_EOF_
G_EXEC chmod +x raspberrypi-sys-mods/usr/lib/raspberrypi-sys-mods/i2cprobe

cat << '_EOF_' > raspberrypi-sys-mods/lib/udev/rules.d/15-i2c-modprobe.rules
SUBSYSTEM=="i2c|spi", ENV{MODALIAS}=="?*", ENV{OF_NAME}=="?*", ENV{OF_COMPATIBLE_0}=="?*", RUN+="/usr/lib/raspberrypi-sys-mods/i2cprobe"
_EOF_

cat << '_EOF_' > raspberrypi-sys-mods/lib/udev/rules.d/99-com.rules
SUBSYSTEM=="input", GROUP="input", MODE="0660"
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
SUBSYSTEM=="*gpiomem*", GROUP="gpio", MODE="0660"
SUBSYSTEM=="rpivid-*", GROUP="video", MODE="0660"
G_EXEC curl -sSfo raspberrypi-sys-mods/lib/udev/rules.d/15-i2c-modprobe.rules 'https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/lib/udev/rules.d/15-i2c-modprobe.rules'

KERNEL=="vcsm-cma", GROUP="video", MODE="0660"
SUBSYSTEM=="dma_heap", GROUP="video", MODE="0660"

SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660"
SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys/class/gpio && chmod -R g=u /sys/class/gpio'"
SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys%p && chmod -R g=u /sys%p'"

# PWM export results in a "change" action on the pwmchip device (not "add" of a new device), so match actions other than "remove".
SUBSYSTEM=="pwm", ACTION!="remove", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys%p && chmod -R g=u /sys%p'"

KERNEL=="ttyAMA[0-9]*|ttyS[0-9]*", PROGRAM="/bin/sh -c '\
ALIASES=/proc/device-tree/aliases; \
TTYNODE=$$(readlink /sys/class/tty/%k/device/of_node | sed 's/base/:/' | cut -d: -f2); \
if [ -e $$ALIASES/bluetooth ] && [ $$TTYNODE/bluetooth = $$(strings $$ALIASES/bluetooth) ]; then \
echo 1; \
elif [ -e $$ALIASES/console ]; then \
if [ $$TTYNODE = $$(strings $$ALIASES/console) ]; then \
echo 0;\
else \
exit 1; \
fi \
elif [ $$TTYNODE = $$(strings $$ALIASES/serial0) ]; then \
echo 0; \
elif [ $$TTYNODE = $$(strings $$ALIASES/serial1) ]; then \
echo 1; \
else \
exit 1; \
fi \
'", SYMLINK+="serial%c"

ACTION=="add", SUBSYSTEM=="vtconsole", KERNEL=="vtcon1", RUN+="/bin/sh -c '\
if echo RPi-Sense FB | cmp -s /sys/class/graphics/fb0/name; then \
echo 0 > /sys$devpath/bind; \
fi; \
'"
_EOF_
G_EXEC curl -sSfo raspberrypi-sys-mods/lib/udev/rules.d/99-com.rules 'https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules'
# The original rule uses the "strings" command from binutils, which we do not want to have pre-installed (it is huge!). So we use cat, which is safe for the node values read here.
G_EXEC sed -i 's/(strings/(cat/g' raspberrypi-sys-mods/lib/udev/rules.d/99-com.rules

cat << '_EOF_' > raspberrypi-sys-mods/DEBIAN/preinst
#!/bin/dash
Expand All @@ -126,7 +51,7 @@ find raspberrypi-sys-mods ! \( -path raspberrypi-sys-mods/DEBIAN -prune \) -type

cat << _EOF_ > raspberrypi-sys-mods/DEBIAN/control
Package: raspberrypi-sys-mods
Version: 2:20230510-dietpi1
Version: 2:20230510-dietpi2
Architecture: all
Maintainer: MichaIng <[email protected]>
Date: $(date -u '+%a, %d %b %Y %T %z')
Expand All @@ -142,7 +67,7 @@ _EOF_
G_CONFIG_INJECT 'Installed-Size: ' "Installed-Size: $(du -sk raspberrypi-sys-mods | mawk '{print $1}')" raspberrypi-sys-mods/DEBIAN/control

# Build DEB package
G_EXEC_OUTPUT=1 G_EXEC dpkg-deb -b raspberrypi-sys-mods
G_EXEC_OUTPUT=1 G_EXEC dpkg-deb -b -Zxz -z9 raspberrypi-sys-mods

# Cleanup
G_EXEC rm -R raspberrypi-sys-mods
Expand Down
Loading