Skip to content

Commit

Permalink
v9.7
Browse files Browse the repository at this point in the history
- DietPi-Installer | Suppport Git branch names with forwards flashes
- DietPi-Patches | Install kernel and bootloader scripts and configs for legacy image migrations
  • Loading branch information
MichaIng committed Aug 15, 2024
1 parent 728a345 commit 8267b87
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 23 deletions.
43 changes: 22 additions & 21 deletions .build/images/dietpi-installer
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,11 @@ _EOF_
#------------------------------------------------------------------------------------------------

G_EXEC_DESC='Downloading source code' G_EXEC curl -sSfLO "https://github.com/$G_GITOWNER/DietPi/archive/$G_GITBRANCH.tar.gz"
[[ -d DietPi-$G_GITBRANCH ]] && G_EXEC_DESC='Removing old source code' G_EXEC rm -R "DietPi-$G_GITBRANCH"
G_EXEC_DESC='Unpacking source code' G_EXEC tar xf "$G_GITBRANCH.tar.gz"
G_EXEC_DESC='Removing unused files' G_EXEC rm -f "$G_GITBRANCH.tar.gz" "DietPi-$G_GITBRANCH/dietpi/"{pre-patch_file,patch_file,server_version-6}
G_EXEC_DESC='Hardening source code mode' G_EXEC chmod -R g-w "DietPi-$G_GITBRANCH"
local dir="DietPi-${G_GITBRANCH//\//-}" # GitHub translates forward slashes into dashes
[[ -d $dir ]] && G_EXEC_DESC='Removing old source code' G_EXEC rm -R "$dir"
G_EXEC_DESC='Unpacking source code' G_EXEC tar xf "${G_GITBRANCH##*/}.tar.gz" # Support for Git branch names with forward slashes
G_EXEC_DESC='Removing unused files' G_EXEC rm -f "${G_GITBRANCH##*/}.tar.gz" "$dir/"{pre-patch_file,patch_file,server_version-6}
G_EXEC_DESC='Hardening update archive mode' G_EXEC chmod -R g-w "$dir"

[[ -d '/boot' ]] || G_EXEC mkdir /boot

Expand All @@ -605,9 +606,9 @@ _EOF_
then
G_EXEC ln -sf firmware/cmdline.txt /boot/cmdline.txt
G_EXEC ln -sf firmware/config.txt /boot/config.txt
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/RPi/config.txt" /boot/firmware/
G_EXEC mv "$dir/.build/images/RPi/config.txt" /boot/firmware/
else
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/RPi/config.txt" /boot/
G_EXEC mv "$dir/.build/images/RPi/config.txt" /boot/
fi
echo "root=PARTUUID=$(findmnt -Ufnro PARTUUID -M /) rootfstype=$(findmnt -Ufnro FSTYPE -M /) rootwait net.ifnames=0 logo.nologo console=serial0,115200 console=tty1" > /boot/cmdline.txt
# Boot in 64-bit mode if this is a 64-bit image
Expand All @@ -618,26 +619,26 @@ _EOF_
armbian_packages=1
local model='OdroidC1'
(( $G_HW_MODEL == 11 )) && model='OdroidXU4'
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/$model/boot.ini" /boot/boot.ini
G_EXEC mv "$dir/.build/images/$model/boot.ini" /boot/boot.ini
G_EXEC sed --follow-symlinks -i "s/root=[^[:blank:]]*/root=UUID=$(findmnt -Ufnro UUID -M /)/" /boot/boot.ini
G_EXEC sed --follow-symlinks -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/boot.ini
G_EXEC mkdir -p /etc/kernel/post{inst,rm}.d /etc/initramfs/post-update.d
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/U-Boot/dietpi-initramfs_cleanup" /etc/kernel/postinst.d/dietpi-initramfs_cleanup
G_EXEC mv "$dir/.build/images/U-Boot/dietpi-initramfs_cleanup" /etc/kernel/postinst.d/dietpi-initramfs_cleanup
G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot
G_EXEC mv "$dir/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot
G_EXEC sed --follow-symlinks -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|76|77|78|79|80|82|83|85|86|87|88|89|90)$ ]]
then
armbian_packages=1
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/U-Boot/boot.cmd" /boot/boot.cmd
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/U-Boot/dietpiEnv.txt" /boot/dietpiEnv.txt
G_EXEC mv "$dir/.build/images/U-Boot/boot.cmd" /boot/boot.cmd
G_EXEC mv "$dir/.build/images/U-Boot/dietpiEnv.txt" /boot/dietpiEnv.txt
G_CONFIG_INJECT 'rootdev=' "rootdev=UUID=$(findmnt -Ufnro UUID -M /)" /boot/dietpiEnv.txt
G_CONFIG_INJECT 'rootfstype=' "rootfstype=$(findmnt -Ufnro FSTYPE -M /)" /boot/dietpiEnv.txt
G_EXEC mkdir -p /etc/kernel/post{inst,rm}.d /etc/initramfs/post-update.d
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/U-Boot/dietpi-initramfs_cleanup" /etc/kernel/postinst.d/dietpi-initramfs_cleanup
G_EXEC mv "$dir/.build/images/U-Boot/dietpi-initramfs_cleanup" /etc/kernel/postinst.d/dietpi-initramfs_cleanup
G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot
G_EXEC mv "$dir/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot
# Odroid C2: Fix USB device detection: https://github.com/MichaIng/DietPi/issues/5963
if (( $G_HW_MODEL == 12 ))
then
Expand Down Expand Up @@ -787,7 +788,7 @@ setenv rootuuid "true"' /boot/boot.cmd
# NanoPi M3/T3/Fire3 (64-bit)
elif (( $G_HW_MODEL == 62 ))
then
G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/NanoPiM3/boot.cmd" /boot/boot.cmd
G_EXEC mv "$dir/.build/images/NanoPiM3/boot.cmd" /boot/boot.cmd
G_EXEC sed --follow-symlinks -i '/overlay/d' /boot/dietpiEnv.txt
G_EXEC sed --follow-symlinks -i 's/ttyAML0/ttySAC0/' /boot/dietpiEnv.txt
fi
Expand All @@ -796,20 +797,20 @@ setenv rootuuid "true"' /boot/boot.cmd
# shellcheck disable=SC2016
[[ -f '/etc/initramfs/post-update.d/99-dietpi-uboot' && $(findmnt -t vfat -M /boot) ]] && G_EXEC sed --follow-symlinks -i '/^ln -s/c\mv -v "/boot/uInitrd-$1" /boot/uInitrd' /etc/initramfs/post-update.d/99-dietpi-uboot # FAT does not support symlinks

G_EXEC mv "DietPi-$G_GITBRANCH/dietpi.txt" /boot/
G_EXEC mv "DietPi-$G_GITBRANCH/README.md" /boot/dietpi-README.md
G_EXEC mv "DietPi-$G_GITBRANCH/LICENSE" /boot/dietpi-LICENSE.txt
G_EXEC mv "$dir/dietpi.txt" /boot/
G_EXEC mv "$dir/README.md" /boot/dietpi-README.md
G_EXEC mv "$dir/LICENSE" /boot/dietpi-LICENSE.txt

# Reading version string for later use
# shellcheck source=.update/version source=/boot/dietpi/.version
. "DietPi-$G_GITBRANCH/.update/version"
. "$dir/.update/version"
G_DIETPI_VERSION_CORE=$G_REMOTE_VERSION_CORE
G_DIETPI_VERSION_SUB=$G_REMOTE_VERSION_SUB
G_DIETPI_VERSION_RC=$G_REMOTE_VERSION_RC

G_EXEC_DESC='Copy DietPi scripts to /boot/dietpi' G_EXEC cp -a "DietPi-$G_GITBRANCH/dietpi" /boot/
G_EXEC_DESC='Copy DietPi system files in place' G_EXEC cp -a "DietPi-$G_GITBRANCH/rootfs/." /
G_EXEC_DESC='Clean download location' G_EXEC rm -R "DietPi-$G_GITBRANCH"
G_EXEC_DESC='Copy DietPi scripts to /boot/dietpi' G_EXEC cp -a "$dir/dietpi" /boot/
G_EXEC_DESC='Copy DietPi system files in place' G_EXEC cp -a "$dir/rootfs/." /
G_EXEC_DESC='Clean download location' G_EXEC rm -R "$dir"

G_DIETPI-NOTIFY 2 'Storing DietPi version info:'
G_CONFIG_INJECT 'DEV_GITBRANCH=' "DEV_GITBRANCH=$G_GITBRANCH" /boot/dietpi.txt
Expand Down
48 changes: 46 additions & 2 deletions .update/patches
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,26 @@ Patch_9_7()
\nHowever, while we are not aware of any left issues, it is still good to have a backup in place, and we do not enforce the upgrade. You can do it any time later.
\nDo you want to migrate to the new Linux 6.1 kernel now?'
then
:
# Packages
G_AGI armbian-firmware initramfs-tools u-boot-tools zstd
G_AGI linux-{image,dtb}-current-rockchip64 "linux-u-boot-$model-current"
# Install boot scripts and configs
local dir="DietPi-${G_GITBRANCH//\//-}" # GitHub translates forward slashes into dashes
G_EXEC mv "$dir/.build/images/U-Boot/boot.cmd" /boot/boot.cmd
G_EXEC mv "$dir/.build/images/U-Boot/dietpiEnv.txt" /boot/dietpiEnv.txt
G_CONFIG_INJECT 'rootdev=' "rootdev=UUID=$(findmnt -Ufnro UUID -M /)" /boot/dietpiEnv.txt
G_CONFIG_INJECT 'rootfstype=' "rootfstype=$(findmnt -Ufnro FSTYPE -M /)" /boot/dietpiEnv.txt
G_EXEC mkdir -p /etc/kernel/post{inst,rm}.d /etc/initramfs/post-update.d
G_EXEC mv "$dir/.build/images/U-Boot/dietpi-initramfs_cleanup" /etc/kernel/postinst.d/dietpi-initramfs_cleanup
G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup
G_EXEC mv "$dir/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot
G_EXEC sed --follow-symlinks -Ei '/^setenv (kernel|fdt)_addr_r/d' /boot/boot.cmd
G_CONFIG_INJECT 'setenv scriptaddr ' 'setenv scriptaddr "0x9000000"' /boot/boot.cmd
G_CONFIG_INJECT 'overlay_path=' 'overlay_path=rockchip' /boot/dietpiEnv.txt
# Overlay prefix
G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=rockchip' /boot/dietpiEnv.txt
# Console args
G_EXEC sed --follow-symlinks -i 's/ttyAML0,115200/ttyS2,1500000/' /boot/dietpiEnv.txt
fi

elif [[ $G_HW_MODEL == 79 ]] && dpkg-query -s 'firmware-nanopi6' &> /dev/null
Expand All @@ -1814,7 +1833,32 @@ Patch_9_7()
\nHowever, while we are not aware of any left issues, it is still good to have a backup in place, and we do not enforce the upgrade. You can do it any time later.
\nDo you want to migrate to the new Linux 6.6 kernel now?'
then
:
# Packages
G_AGI armbian-firmware initramfs-tools u-boot-tools zstd
G_AGI linux-{image,dtb}-vendor-rk35xx "linux-u-boot-$model-vendor"
# Install boot scripts and configs
local dir="DietPi-${G_GITBRANCH//\//-}" # GitHub translates forward slashes into dashes
G_EXEC mv "$dir/.build/images/U-Boot/boot.cmd" /boot/boot.cmd
G_EXEC mv "$dir/.build/images/U-Boot/dietpiEnv.txt" /boot/dietpiEnv.txt
G_CONFIG_INJECT 'rootdev=' "rootdev=UUID=$(findmnt -Ufnro UUID -M /)" /boot/dietpiEnv.txt
G_CONFIG_INJECT 'rootfstype=' "rootfstype=$(findmnt -Ufnro FSTYPE -M /)" /boot/dietpiEnv.txt
G_EXEC mkdir -p /etc/kernel/post{inst,rm}.d /etc/initramfs/post-update.d
G_EXEC mv "$dir/.build/images/U-Boot/dietpi-initramfs_cleanup" /etc/kernel/postinst.d/dietpi-initramfs_cleanup
G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup
G_EXEC mv "$dir/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot
G_EXEC sed --follow-symlinks -Ei '/^setenv (kernel|fdt)_addr_r/d' /boot/boot.cmd
G_CONFIG_INJECT 'setenv scriptaddr ' 'setenv scriptaddr "0x9000000"' /boot/boot.cmd
G_CONFIG_INJECT 'overlay_path=' 'overlay_path=rockchip' /boot/dietpiEnv.txt
# Device tree
case $model in
'nanopi-r6s') G_CONFIG_INJECT 'fdtfile=' 'fdtfile=rockchip/rk3588s-nanopi-r6s.dtb' /boot/dietpiEnv.txt;;
'nanopi-r6c') G_CONFIG_INJECT 'fdtfile=' 'fdtfile=rockchip/rk3588s-nanopi-r6c.dtb' /boot/dietpiEnv.txt;;
*) :;;
esac
# Overlay prefix
G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=rk3588' /boot/dietpiEnv.txt
# Console args
G_EXEC sed --follow-symlinks -i 's/ttyAML0,115200/ttyFIQ0,1500000/' /boot/dietpiEnv.txt
fi
fi

Expand Down

0 comments on commit 8267b87

Please sign in to comment.