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.24.0 #6737

Merged
merged 86 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
6bea5f9
Release v8.23 (#6693)
MichaIng Oct 21, 2023
c309978
v8.24
MichaIng Oct 22, 2023
e95a135
Live patch 0 v8.23 (#6701)
MichaIng Oct 22, 2023
fa805ea
Init v8.24
MichaIng Oct 22, 2023
6ac4aa1
v8.24
MichaIng Oct 22, 2023
04039f7
v8.24
MichaIng Oct 24, 2023
165352f
v8.24
MichaIng Oct 24, 2023
a5dd5a9
v8.24 backport
MichaIng Oct 24, 2023
44601d7
v8.24 (#6709)
MichaIng Oct 26, 2023
9a3e3fe
v8.24
MichaIng Oct 28, 2023
a406892
v8.24
MichaIng Oct 28, 2023
125d612
v8.24
MichaIng Oct 29, 2023
42e9087
v8.24
MichaIng Oct 29, 2023
c7d4355
v8.24
MichaIng Oct 29, 2023
a602e7c
v8.24
MichaIng Oct 29, 2023
4815577
v8.24
MichaIng Oct 29, 2023
44b9acc
v8.24
MichaIng Oct 29, 2023
c95607a
v8.24
MichaIng Oct 29, 2023
1919f30
v8.24
MichaIng Oct 29, 2023
7a74d40
v8.24
MichaIng Oct 29, 2023
6341dfb
v8.24
MichaIng Oct 29, 2023
181f531
v8.24
MichaIng Oct 29, 2023
5a67ac6
v8.24
MichaIng Oct 29, 2023
2692e7c
v8.24
MichaIng Oct 29, 2023
34f680c
v8.24
MichaIng Oct 29, 2023
baeb501
v8.24
MichaIng Oct 29, 2023
b392c5d
v8.24
MichaIng Oct 29, 2023
9d7a8de
v8.24
MichaIng Oct 29, 2023
dd4a5a9
v8.24
MichaIng Oct 29, 2023
0050e80
v8.24
MichaIng Oct 29, 2023
ea9818b
v8.24
MichaIng Oct 29, 2023
6acdf43
v8.24
MichaIng Oct 29, 2023
02afdd2
v8.24
MichaIng Oct 29, 2023
781c758
v8.24
MichaIng Oct 30, 2023
ade0d99
v8.24 backport
MichaIng Oct 30, 2023
d279b05
v8.24
MichaIng Oct 30, 2023
ec0953d
Merge branch 'master' into dev
MichaIng Oct 30, 2023
abba288
v8.24
MichaIng Oct 30, 2023
a6f891c
v8.24
MichaIng Oct 30, 2023
7fdd226
v8.24
MichaIng Oct 30, 2023
b416bf5
v8.24
MichaIng Oct 30, 2023
d7f4989
v8.24
MichaIng Oct 30, 2023
fbe2c3e
v8.24
MichaIng Oct 30, 2023
8b2b7c1
v8.24
MichaIng Oct 30, 2023
67a328d
v8.24
MichaIng Oct 30, 2023
3fc7157
v8.24
MichaIng Oct 30, 2023
a474b58
v8.24
MichaIng Oct 30, 2023
4a37e3d
v8.24
MichaIng Oct 31, 2023
d1ebbbb
v8.24
MichaIng Oct 31, 2023
bb39175
v8.24
MichaIng Oct 31, 2023
f03849e
v8.24
MichaIng Oct 31, 2023
48d2cd4
v8.24
MichaIng Oct 31, 2023
32ac26a
v8.24
MichaIng Oct 31, 2023
e6a611d
v8.24
MichaIng Oct 31, 2023
4183435
v8.24
MichaIng Oct 31, 2023
f9e9625
v8.24
MichaIng Nov 1, 2023
7c356e6
v8.24
MichaIng Nov 1, 2023
7532f05
v8.24
MichaIng Nov 1, 2023
b0b2b35
v8.24
MichaIng Nov 1, 2023
ae9ec23
v8.24
MichaIng Nov 1, 2023
33b34ca
v8.24
MichaIng Nov 1, 2023
ea0a47c
v8.24
MichaIng Nov 1, 2023
cda3125
v8.24
MichaIng Nov 1, 2023
bfff425
v8.24
MichaIng Nov 1, 2023
6a50d11
v8.24
MichaIng Nov 2, 2023
4248889
v8.24
MichaIng Nov 2, 2023
a749004
v8.24
MichaIng Nov 2, 2023
06bea90
v8.24
MichaIng Nov 2, 2023
7e7ce4f
v8.24
MichaIng Nov 2, 2023
c5d5340
v8.24
MichaIng Nov 3, 2023
bc8a552
v8.24
MichaIng Nov 5, 2023
b2da834
v8.24
MichaIng Nov 5, 2023
0769da8
v8.24
MichaIng Nov 5, 2023
9b3c7ea
v8.24
MichaIng Nov 5, 2023
1af571e
v8.24
MichaIng Nov 5, 2023
65108d3
v8.24 (#6732)
MichaIng Nov 5, 2023
5365581
v8.24
MichaIng Nov 7, 2023
4dc8529
v8.24
MichaIng Nov 8, 2023
93011e8
v8.24
MichaIng Nov 9, 2023
63b7040
v8.24
MichaIng Nov 9, 2023
05af808
v8.24
MichaIng Nov 9, 2023
50ae0e2
v8.24
MichaIng Nov 10, 2023
7fb5796
v8.24
MichaIng Nov 10, 2023
06529cf
v8.24
MichaIng Nov 11, 2023
1d9b8d9
v8.24
MichaIng Nov 11, 2023
df33142
v8.24
MichaIng Nov 11, 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
31 changes: 28 additions & 3 deletions .build/images/dietpi-build
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ case $HW_MODEL in
80) iname='OrangePi5' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=752;;
81) iname='VisionFive2' HW_ARCH=11 root_size=639;;
82) iname='OrangePi5Plus' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=752;;
83) iname='OrangePiZero3' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=752;;
83) iname='OrangePiZero3' HW_ARCH=3 partition_start=4 root_size=752;;
84) iname='Star64' HW_ARCH=11 root_size=639;;
85) iname='ROCK5A' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=752;;
86) iname='ASUSTB2' HW_ARCH=3 partition_start=16 root_size=752;;
Expand Down Expand Up @@ -415,7 +415,7 @@ G_EXEC umount rootfs/dev rootfs/run rootfs/var/cache/apt rootfs/var/lib/apt/list
cat << '_EOF_' > rootfs/etc/rc.local
#!/bin/dash
{
infocmp "$TERM" > /dev/null 2>&1 || TERM='dumb'
infocmp "$TERM" > /dev/null 2>&1 || { echo "[ WARN ] Unsupported TERM=\"$TERM\", switching to TERM=\"dumb\""; export TERM=dumb; }
echo '[ INFO ] Running DietPi-Installer...'
_EOF_

Expand Down Expand Up @@ -571,19 +571,41 @@ then

# Install Allo GUI via automated first run setup right here
G_CONFIG_INJECT 'AUTO_SETUP_AUTOMATED=' 'AUTO_SETUP_AUTOMATED=1' rootfs/boot/dietpi.txt
# - Workaround for skipped autologin in emulated Trixie/Sid containers: https://gitlab.com/qemu-project/qemu/-/issues/1962
if (( $DISTRO == 8 && $G_HW_ARCH != $HW_ARCH && ( $G_HW_ARCH > 9 || $G_HW_ARCH < $HW_ARCH ) ))
then
cat << '_EOF_' > rootfs/etc/systemd/system/dietpi-automation.service
[Unit]
Description=DietPi-Automation
After=dietpi-postboot.service

[Service]
Type=idle
StandardOutput=tty
ExecStart=/bin/dash -c 'infocmp "$TERM" > /dev/null 2>&1 || export TERM=dumb; exec /boot/dietpi/dietpi-login'
ExecStop=/sbin/poweroff

[Install]
WantedBy=multi-user.target
_EOF_
G_EXEC ln -s /etc/systemd/system/dietpi-automation.service rootfs/etc/systemd/system/multi-user.target.wants/
fi
G_CONFIG_INJECT 'AUTO_SETUP_INSTALL_SOFTWARE_ID=' 'AUTO_SETUP_INSTALL_SOFTWARE_ID=159' rootfs/boot/dietpi.txt
# Revert autostart option, in case Amiberry image was generated before
G_CONFIG_INJECT 'AUTO_SETUP_AUTOSTART_TARGET_INDEX=' 'AUTO_SETUP_AUTOSTART_TARGET_INDEX=0' rootfs/boot/dietpi.txt

# Force ARMv6 arch on Raspbian
(( $HW_ARCH == 1 )) && echo 'sed -i -e '\''/^G_HW_ARCH=/c\G_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' > rootfs/boot/Automation_Custom_PreScript.sh

# Temporary fix for failing NAA Daemon install on Trixie
(( $DISTRO == 8 )) && G_EXEC sed -i '\|www.signalyst.eu|s|bookworm/bullseye|trixie/bullseye|' rootfs/boot/dietpi/dietpi-software

# Skip filesystem expansion
G_EXEC rm rootfs/etc/systemd/system/local-fs.target.wants/dietpi-fs_partition_resize.service

# Workaround invalid TERM on login
# shellcheck disable=SC2016
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'
G_EXEC eval 'echo '\''infocmp "$TERM" > /dev/null 2>&1 || { echo "[ WARN ] 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 @@ -652,6 +674,9 @@ _EOF_
# Reset IPv4 network connectivity check setting
G_CONFIG_INJECT 'CONFIG_CHECK_CONNECTION_IP=' 'CONFIG_CHECK_CONNECTION_IP=9.9.9.9' rootfs/boot/dietpi.txt

# Revert workaround for skipped autologin in emulated Trixie/Sid containers: https://gitlab.com/qemu-project/qemu/-/issues/1962
(( $DISTRO == 8 )) && G_EXEC rm rootfs/etc/systemd/system/{multi-user.target.wants/,}dietpi-automation.service

[[ -f 'rootfs/success' ]] || { G_DIETPI-NOTIFY 1 'The container setup did not finish successfully, aborting...'; exit 1; }
G_EXEC rm rootfs/success
G_EXEC sync
Expand Down
67 changes: 56 additions & 11 deletions .build/images/dietpi-installer
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ _EOF_
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot
G_EXEC sed -i 's/arm64/arm/' /etc/initramfs/post-update.d/99-dietpi-uboot

elif [[ $G_HW_MODEL =~ ^(12|15|16|40|42|43|44|45|46|47|48|52|54|55|56|57|58|59|60|62|63|64|65|66|67|68|72|73|74|77|78|80|82|85|86)$ ]]
elif [[ $G_HW_MODEL =~ ^(12|15|16|40|42|43|44|45|46|47|48|52|54|55|56|57|58|59|60|62|63|64|65|66|67|68|72|73|74|77|78|80|82|83|85|86)$ ]]
then
armbian_repo=1
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/U-Boot/boot.cmd" /boot/boot.cmd
Expand Down Expand Up @@ -670,7 +670,7 @@ setenv rootuuid "true"' /boot/boot.cmd
G_EXEC sed -i -e 's/ttyAML0/ttyS2/' -e '/^extraargs=/s/$/ systemd.unified_cgroup_hierarchy=0/' /boot/dietpiEnv.txt

# Allwinner 64-bit
elif [[ $G_HW_MODEL =~ ^(40|44|45|57|65|67)$ ]]
elif [[ $G_HW_MODEL =~ ^(40|44|45|57|65|67|83)$ ]]
then
G_EXEC sed -Ei '/^setenv (kernel|fdt)_addr_r/d' /boot/boot.cmd
G_CONFIG_INJECT 'setenv scriptaddr ' 'setenv scriptaddr "0x45000000"' /boot/boot.cmd
Expand All @@ -683,6 +683,7 @@ setenv rootuuid "true"' /boot/boot.cmd
40|44) G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=sun50i-a64' /boot/dietpiEnv.txt;;
45) G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=sun50i-h6' /boot/dietpiEnv.txt;;
57|65|67) G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=sun50i-h5' /boot/dietpiEnv.txt;;
83) G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=sun50i-h616' /boot/dietpiEnv.txt; armbian_repo=0;;
*) :;;
esac
case $G_HW_MODEL in
Expand Down Expand Up @@ -793,14 +794,13 @@ setenv rootuuid "true"' /boot/boot.cmd
G_EXEC rm keyring.deb
fi

# Bookworm: Avoid conflict between RPi repo and Bookworm FFmpeg packages: https://github.com/MichaIng/DietPi/issues/6461
if (( $DISTRO_TARGET > 6 ))
if (( $DISTRO_TARGET > 7 ))
then
G_DIETPI-NOTIFY 2 'Enforcing Debian Bookworm FFmpeg packages over RPi repo ones'
G_DIETPI-NOTIFY 2 'Enforcing Debian Trixie FFmpeg packages over RPi repo ones'
cat << '_EOF_' > /etc/apt/preferences.d/dietpi-ffmpeg
Package: src:ffmpeg
Pin: version 7:5*
Pin-Priority: 1000
Pin: origin archive.raspberrypi.org
Pin-Priority: -1
_EOF_
fi
fi
Expand Down Expand Up @@ -1119,7 +1119,7 @@ _EOF_
[[ -f '/boot/.next' ]] && G_EXEC rm /boot/.next
[[ -f '/boot/armbianEnv.txt' ]] && G_EXEC rm /boot/armbianEnv.txt
[[ -f '/boot/uEnv.txt' ]] && G_EXEC rm /boot/uEnv.txt
# Compile U-Boot config
# Compile U-Boot script
[[ -f '/boot/boot.cmd' ]] && G_EXEC mkimage -C none -A "$arch" -T script -d /boot/boot.cmd /boot/boot.scr
# Flash U-Boot
# shellcheck disable=SC1091
Expand Down Expand Up @@ -1186,7 +1186,7 @@ _EOF_
then
# ARMv6/7: Add raspi-copies-and-fills
local a32bit=()
[[ $G_HW_ARCH == 3 ]] || a32bit=('raspi-copies-and-fills')
(( $G_HW_ARCH == 3 )) || a32bit=('raspi-copies-and-fills')
# Install our own raspberrypi-sys-mods
G_EXEC curl -sSfO 'https://dietpi.com/downloads/binaries/raspberrypi-sys-mods.deb'
G_AGI raspberrypi-bootloader raspberrypi-kernel libraspberrypi0 libraspberrypi-bin ./raspberrypi-sys-mods.deb raspberrypi-archive-keyring "${a32bit[@]}"
Expand Down Expand Up @@ -1248,6 +1248,43 @@ _EOF_
G_EXEC sed -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/extlinux/extlinux.conf
aPACKAGES_REQUIRED_INSTALL+=('libubootenv-tool')

# Orange Pi Zero 3
elif (( $G_HW_MODEL == 83 ))
then
# Install firmware and initramfs
G_EXEC curl -fo package1.deb 'https://dietpi.com/downloads/binaries/orangepi-firmware.deb'
G_AGI initramfs-tools u-boot-tools ./package1.deb zstd
[[ ${zstd[0]} ]] && G_CONFIG_INJECT 'COMPRESS=' 'COMPRESS=zstd' /etc/initramfs-tools/initramfs.conf

# Install kernel and U-Boot packages
G_EXEC_OUTPUT=1 G_EXEC curl -fo package1.deb 'https://dietpi.com/downloads/binaries/linux-image-next-sun50iw9.deb'
G_EXEC_OUTPUT=1 G_EXEC curl -fo package2.deb 'https://dietpi.com/downloads/binaries/linux-dtb-next-sun50iw9.deb'
G_EXEC_OUTPUT=1 G_EXEC curl -fo package3.deb 'https://dietpi.com/downloads/binaries/linux-u-boot-orangepizero3-next.deb'
G_EXEC_OUTPUT=1 G_EXEC dpkg -i package1.deb package2.deb package3.deb
G_EXEC rm package1.deb package2.deb package3.deb

# Flash U-Boot
# shellcheck disable=SC1091
. /usr/lib/u-boot/platform_install.sh
# shellcheck disable=SC2154
write_uboot_platform "$DIR" "$BOOT_DEVICE"

# Compile U-Boot script
G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr

# Remove obsolete combined keyring
[[ -f '/etc/apt/trusted.gpg' ]] && G_EXEC rm /etc/apt/trusted.gpg
[[ -f '/etc/apt/trusted.gpg~' ]] && G_EXEC rm '/etc/apt/trusted.gpg~'

# Remove obsolete components from Armbian list and connect via HTTPS
G_EXEC rm -Rf /etc/apt/sources.list.d/{,.??,.[^.]}*

# Cleanup
[[ -f '/boot/orangepiEnv.txt' ]] && G_EXEC rm /boot/orangepiEnv.txt

# Load WiFi and Bluetooth modules explicitly, as they do not load automatically, until DietPi v8.24 does it via dietpi-set_hardware
G_EXEC eval 'echo -e '\''sprdwl_ng\nsprdbt_tty'\'' > /etc/modules-load.d/dietpi-enable_wifi.conf'

# Sparky SBC
elif (( $G_HW_MODEL == 70 ))
then
Expand Down Expand Up @@ -1389,6 +1426,10 @@ _EOF_
if dpkg-query -s 'armbian-firmware' &> /dev/null
then
aPACKAGES_REQUIRED_INSTALL+=('armbian-firmware')

elif dpkg-query -s 'orangepi-firmware' &> /dev/null
then
aPACKAGES_REQUIRED_INSTALL+=('orangepi-firmware')
else
aPACKAGES_REQUIRED_INSTALL+=('firmware-linux-free') # Free misc
aPACKAGES_REQUIRED_INSTALL+=('firmware-misc-nonfree') # Non-free misc incl. Ralink and MediaTek WiFi/BT
Expand Down Expand Up @@ -1497,6 +1538,7 @@ _EOF_
G_DIETPI-NOTIFY 2 'Removing misc files/folders/services, not required by DietPi'

[[ -f '/boot/boot.bmp' ]] && G_EXEC rm /boot/boot.bmp
[[ -f '/boot/logo.bmp' ]] && G_EXEC rm /boot/logo.bmp
[[ -d '/selinux' ]] && G_EXEC rm -R /selinux
[[ -d '/var/cache/apparmor' ]] && G_EXEC rm -R /var/cache/apparmor
[[ -d '/var/lib/udisks2' ]] && G_EXEC rm -R /var/lib/udisks2
Expand Down Expand Up @@ -1652,6 +1694,9 @@ _EOF_
# - Radxa
[[ -e '/etc/systemd/system/systemd-networkd-wait-online.service' || -L '/etc/systemd/system/systemd-networkd-wait-online.service' ]] && G_EXEC rm /etc/systemd/system/systemd-networkd-wait-online.service

# - Orange Pi
[[ -f '/boot/orangepi_first_run.txt.template' ]] && G_EXEC rm /boot/orangepi_first_run.txt.template

#-----------------------------------------------------------------------------------
# https://www.debian.org/doc/debian-policy/ch-opersys.html#site-specific-programs
G_DIETPI-NOTIFY 2 'Setting modern /usr/local permissions'
Expand Down Expand Up @@ -1884,8 +1929,8 @@ _EOF_'
then
/boot/dietpi/func/dietpi-set_hardware serialconsole enable ttyS2

# PINE A64, Pinebook, PINE H64, NenoPi NEO Plus2, ZeroPi, NanoPi NEO, NanoPi M1, NanoPi NEO Air, NenoPi NEO2, NanoPi M1 Plus, NanoPi K1 Plus, ROCK Pi S, VisionFive 2, Star64
elif [[ $G_HW_MODEL =~ ^(40|44|45|57|59|60|63|64|65|66|67|73|81|84)$ ]]
# PINE A64, Pinebook, PINE H64, NenoPi NEO Plus2, ZeroPi, NanoPi NEO, NanoPi M1, NanoPi NEO Air, NenoPi NEO2, NanoPi M1 Plus, NanoPi K1 Plus, ROCK Pi S, VisionFive 2, Orange Pi Zero 3, Star64
elif [[ $G_HW_MODEL =~ ^(40|44|45|57|59|60|63|64|65|66|67|73|81|83|84)$ ]]
then
/boot/dietpi/func/dietpi-set_hardware serialconsole enable ttyS0

Expand Down
8 changes: 7 additions & 1 deletion .build/software/Amiberry/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ adeps=('libdrm2' 'libgl1-mesa-dri' 'libgbm1' 'libegl1' 'libudev1' 'libxml2' 'lib

G_AGUP
G_AGDUG "${adeps_build[@]}"
for i in "${adeps[@]}"
do
dpkg-query -s "$i" &> /dev/null && continue
G_DIETPI-NOTIFY 1 "Expected dependency package was not installed: $i"
exit 1
done

# Build libSDL2
v_sdl=$(curl -sSf 'https://api.github.com/repos/libsdl-org/SDL/releases/latest' | mawk -F\" '/^ "name"/{print $4}')
Expand Down Expand Up @@ -177,7 +183,7 @@ do
done
DEPS_APT_VERSIONED=${DEPS_APT_VERSIONED%,}
# shellcheck disable=SC2001
grep -q '^ID=raspbian' /etc/os-release && DEPS_APT_VERSIONED=$(sed 's/+rp[it][0-9]\+[^)]*)/)/g' <<< "$DEPS_APT_VERSIONED") || DEPS_APT_VERSIONED=$(sed 's/+b[0-9]\+)/)/g' <<< "$DEPS_APT_VERSIONED")
[[ $G_HW_ARCH_NAME == 'armv6l' ]] && DEPS_APT_VERSIONED=$(sed 's/+rp[it][0-9]\+[^)]*)/)/g' <<< "$DEPS_APT_VERSIONED") || DEPS_APT_VERSIONED=$(sed 's/+b[0-9]\+)/)/g' <<< "$DEPS_APT_VERSIONED")

# - Obtain version suffix
G_EXEC curl -sSfo package.deb "https://dietpi.com/downloads/binaries/$G_DISTRO_NAME/amiberry_$PLATFORM.deb"
Expand Down
91 changes: 60 additions & 31 deletions .build/software/Amiberry/container_build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
##########################################
# Load DietPi-Globals
##########################################
Error_Exit(){ G_DIETPI-NOTIFY 1 "$1, aborting ..."; exit 1; }
if [[ -f '/boot/dietpi/func/dietpi-globals' ]]
then
. /boot/dietpi/func/dietpi-globals
else
curl -sSf "https://raw.githubusercontent.com/${G_GITOWNER:=MichaIng}/DietPi/${G_GITBRANCH:=master}/dietpi/func/dietpi-globals" -o /tmp/dietpi-globals || exit 1
curl -sSf "https://raw.githubusercontent.com/${G_GITOWNER:=MichaIng}/DietPi/${G_GITBRANCH:=master}/dietpi/func/dietpi-globals" -o /tmp/dietpi-globals || Error_Exit 'Failed to download DietPi-Globals'
# shellcheck disable=SC1091
. /tmp/dietpi-globals
G_EXEC_NOHALT=1 G_EXEC rm /tmp/dietpi-globals
Expand All @@ -20,7 +21,7 @@ case $G_HW_ARCH_NAME in
'aarch64') export G_HW_ARCH=3;;
'x86_64') export G_HW_ARCH=10;;
'riscv64') export G_HW_ARCH=11;;
*) G_DIETPI-NOTIFY 1 "Unsupported host system architecture \"$G_HW_ARCH_NAME\" detected, aborting..."; exit 1;;
*) Error_Exit "Unsupported host system architecture \"$G_HW_ARCH_NAME\" detected";;
esac
readonly G_PROGRAM_NAME='DietPi-Amiberry_container_setup'
G_CHECK_ROOT_USER
Expand All @@ -39,38 +40,38 @@ do
case $1 in
'-d') shift; DISTRO=$1;;
'-p') shift; PLATFORM=$1;;
*) G_DIETPI-NOTIFY 1 "Invalid input \"$1\", aborting..."; exit 1;;
*) Error_Exit "Invalid input \"$1\"";;
esac
shift
done
[[ $DISTRO =~ ^('buster'|'bullseye'|'bookworm'|'trixie')$ ]] || { G_DIETPI-NOTIFY 1 "Invalid distro \"$DISTRO\" passed, aborting..."; exit 1; }
[[ $DISTRO =~ ^('buster'|'bullseye'|'bookworm'|'trixie')$ ]] || Error_Exit "Invalid distro \"$DISTRO\" passed"
case $PLATFORM in
'rpi'[1-4]) image="DietPi_Container-ARMv6-${DISTRO^}" arch=1;;
'c1'|'xu4'|'RK3288'|'sun8i'|'s812') image="DietPi_Container-ARMv7-${DISTRO^}" arch=2;;
'rpi'[34]'-64-dmx'|'AMLSM1'|'n2'|'a64'|'rk3588') image="DietPi_Container-ARMv8-${DISTRO^}" arch=3;;
'x86-64') image="DietPi_Container-x86_64-${DISTRO^}" arch=10;;
*) G_DIETPI-NOTIFY 1 "Invalid platform \"$PLATFORM\" passed, aborting..."; exit 1;;
'rpi1') image="ARMv6-${DISTRO^}" arch=1;;
'rpi'[234]|'c1'|'xu4'|'RK3288'|'sun8i'|'s812') image="ARMv7-${DISTRO^}" arch=2;;
'rpi'[34]'-64-dmx'|'AMLSM1'|'n2'|'a64'|'rk3588') image="ARMv8-${DISTRO^}" arch=3;;
'x86-64') image="x86_64-${DISTRO^}" arch=10;;
*) Error_Exit "Invalid platform \"$PLATFORM\" passed";;
esac
image="DietPi_Container-$image.img"

##########################################
# Dependencies
##########################################
apackages=('7zip' 'parted' 'fdisk' 'systemd-container')
apackages=('xz-utils' 'parted' 'fdisk' 'systemd-container')
(( $G_HW_ARCH == $arch || ( $G_HW_ARCH < 10 && $G_HW_ARCH > $arch ) )) || apackages+=('qemu-user-static' 'binfmt-support')
G_AG_CHECK_INSTALL_PREREQ "${apackages[@]}"

##########################################
# Prepare container
##########################################
# Download
G_EXEC curl -sSfO "https://dietpi.com/downloads/images/$image.7z"
G_EXEC 7zz x "$image.7z"
G_EXEC rm "$image.7z" hash.txt README.md
G_EXEC truncate -s 2G "$image.img"
G_EXEC curl -sSfO "https://dietpi.com/downloads/images/$image.xz"
G_EXEC xz -d "$image.xz"
G_EXEC truncate -s 2G "$image"

# Loop device
# Mount as loop device
FP_LOOP=$(losetup -f)
G_EXEC losetup "$FP_LOOP" "$image.img"
G_EXEC losetup "$FP_LOOP" "$image"
G_EXEC partprobe "$FP_LOOP"
G_EXEC partx -u "$FP_LOOP"
G_EXEC_OUTPUT=1 G_EXEC e2fsck -fp "${FP_LOOP}p1"
Expand All @@ -82,31 +83,59 @@ G_EXEC_OUTPUT=1 G_EXEC e2fsck -fp "${FP_LOOP}p1"
G_EXEC mkdir rootfs
G_EXEC mount "${FP_LOOP}p1" rootfs

# Enforce ARMv6 arch on Raspbian
(( $arch > 1 )) || echo 'sed -i -e '\''/^G_HW_ARCH=/c\G_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' > rootfs/boot/Automation_Custom_PreScript.sh || Error_Exit 'Failed to generate Automation_Custom_PreScript.sh'

# Enable automated setup
G_CONFIG_INJECT 'AUTO_SETUP_AUTOMATED=' 'AUTO_SETUP_AUTOMATED=1' rootfs/boot/dietpi.txt
# - Workaround for skipped autologin in emulated Trixie/Sid containers: https://gitlab.com/qemu-project/qemu/-/issues/1962
if [[ $DISTRO == 'trixie' ]] && (( $G_HW_ARCH != $arch && ( $G_HW_ARCH > 9 || $G_HW_ARCH < $arch ) ))
then
cat << '_EOF_' > rootfs/etc/systemd/system/dietpi-automation.service
[Unit]
Description=DietPi-Automation
After=dietpi-postboot.service

# Avoid DietPi-Survey uploads to not mess with the statistics
G_EXEC rm rootfs/root/.ssh/known_hosts
[Service]
Type=idle
StandardOutput=tty
ExecStart=/bin/dash -c 'infocmp "$TERM" > /dev/null 2>&1 || { echo "[ WARN ] Unsupported TERM=\"$TERM\", switching to TERM=\"dumb\""; export TERM=dumb; }; exec /boot/dietpi/dietpi-login'
ExecStop=/sbin/poweroff

[Install]
WantedBy=multi-user.target
_EOF_
G_EXEC ln -s /etc/systemd/system/dietpi-automation.service rootfs/etc/systemd/system/multi-user.target.wants/
fi

# 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 "[ WARN ] 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.
# 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

# - RPi 64-bit: Add RPi repo, ARMv6 container images contain it already
[[ $PLATFORM != 'rpi'[34]'-64-dmx' ]] || cat << _EOF_ > rootfs/boot/Automation_Custom_Script.sh || exit 1
#!/bin/dash
echo '[ INFO ] Setting up RPi APT repository...'
echo 'deb https://archive.raspberrypi.org/debian/ ${DISTRO/bookworm/bullseye} main' > /etc/apt/sources.list.d/raspi.list
curl -sSf 'https://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-archive-keyring/raspberrypi-archive-keyring_2021.1.1+rpt1_all.deb' -o /tmp/keyring.deb
dpkg -i /tmp/keyring.deb
rm -v /tmp/keyring.deb
# Avoid DietPi-Survey uploads to not mess with the statistics
G_EXEC rm rootfs/root/.ssh/known_hosts

# RPi 64-bit: Add RPi repo, ARMv6 container images contain it already
if [[ $PLATFORM == 'rpi'[234]* ]]
then
G_EXEC eval "echo 'deb https://archive.raspberrypi.org/debian/ ${DISTRO/trixie/bookworm} main' > rootfs/etc/apt/sources.list.d/raspi.list"
G_EXEC curl -sSf 'https://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-archive-keyring/raspberrypi-archive-keyring_2021.1.1+rpt1_all.deb' -o keyring.deb
G_EXEC dpkg --root=rootfs -i keyring.deb
G_EXEC rm keyring.deb
# Enforce Debian Trixie FFmpeg packages over RPi repo ones
[[ $DISTRO != 'trixie' ]] || cat << '_EOF_' > rootfs/etc/apt/preferences.d/dietpi-ffmpeg || exit 1
Package: src:ffmpeg
Pin: origin archive.raspberrypi.org
Pin-Priority: -1
_EOF_
fi

cat << _EOF_ >> rootfs/boot/Automation_Custom_Script.sh || exit 1
echo '[ INFO ] Running Amiberry build script...'
# Automated build
cat << _EOF_ >> rootfs/boot/Automation_Custom_Script.sh || Error_Exit 'Failed to generate Automation_Custom_Script.sh'
echo '[ INFO ] Running Amiberry build script ...'
bash -c "\$(curl -sSf 'https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/software/Amiberry/build.bash')" -- '$PLATFORM'
mv -v '/tmp/amiberry_$PLATFORM.deb' /
poweroff
Expand All @@ -116,5 +145,5 @@ _EOF_
# Boot container
##########################################
systemd-nspawn -bD rootfs
[[ -f rootfs/amiberry_$PLATFORM.deb ]] || exit 1
[[ -f rootfs/amiberry_$PLATFORM.deb ]] || Error_Exit "Failed to build package: amiberry_$PLATFORM.deb"
}
Loading