Skip to content

Commit

Permalink
Release v9.1 (#6921)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaIng authored Feb 19, 2024
2 parents 6a4b6e0 + 17d8531 commit 7372523
Show file tree
Hide file tree
Showing 32 changed files with 558 additions and 443 deletions.
78 changes: 41 additions & 37 deletions .build/images/dietpi-build
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ EDITION=
SUFFIX=
ADD_DOS_PART=1
SIGN_PASS=
RPI_NEW=0
while (( $# ))
do
case $1 in
Expand All @@ -63,6 +64,7 @@ do
'-s') shift; SUFFIX=$1;;
'--no-dos-part') ADD_DOS_PART=0;;
'--sign') shift; SIGN_PASS=$1;;
'--rpi-new') RPI_NEW=1;;
*) G_DIETPI-NOTIFY 1 "Invalid input \"$1\", aborting..."; exit 1;;
esac
shift
Expand All @@ -77,6 +79,10 @@ boot_fstype='fat32'
CLONING_TOOL='dd'
case $HW_MODEL in
0) iname='RPi' HW_ARCH=${HW_ARCH:-1} boot_size=128 root_size=895;;
1) iname='RPi1' HW_ARCH=1 boot_size=128 root_size=895;;
2) iname='RPi2' HW_ARCH=2 boot_size=128 root_size=895;;
4) iname='RPi234' HW_ARCH=3 boot_size=128 root_size=895;;
5) iname='RPi5' HW_ARCH=3 boot_size=128 root_size=895;;
10) iname='OdroidC1' HW_ARCH=2 partition_start=4 boot_size=128 root_size=700 boot_fstype='fat16';;
11) iname='OdroidXU4' HW_ARCH=2 partition_start=4 root_size=764;;
12) iname='OdroidC2' HW_ARCH=3 partition_start=4 root_size=892;;
Expand Down Expand Up @@ -116,14 +122,18 @@ case $HW_MODEL in
'68.2') iname='NanoPCT4' HW_ARCH=3 partition_start=16 root_size=880;;
'68.3') iname='NanoPiNEO4' HW_ARCH=3 partition_start=16 root_size=880;;
70) iname='SparkySBC' HW_ARCH=2 partition_start=8 boot_size=48 root_size=712 boot_fstype='fat16';;
72) iname='ROCKPi4' HW_ARCH=3 partition_start=16 root_size=880;;
'72.1') iname='ROCKPi4' HW_ARCH=3 partition_start=16 root_size=880;;
'72.2') iname='ROCK4SE' HW_ARCH=3 partition_start=16 root_size=880;;
73) iname='ROCKPiS' HW_ARCH=3 partition_start=16 root_size=880;;
74) iname='RadxaZero' HW_ARCH=3 partition_start=4 root_size=892;;
75) iname='Container' HW_ARCH=${HW_ARCH:-10} root_size=447;;
76) iname='NanoPiR5S' HW_ARCH=3 root_size=752;; # Special case: Skips image file, partitioning and filesystem generation, but runs debootstrap only!
'76.1') iname='NanoPiR5S' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=1008;;
'76.2') iname='NanoPiR5C' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=1008;;
77) iname='ROCK3A' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=880;;
78) iname='ROCK5B' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=880;;
79) iname='NanoPi6' HW_ARCH=3 root_size=752;; # Special case: Skips image file, partitioning and filesystem generation, but runs debootstrap only!
'79.1') iname='NanoPiR6S' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=880;;
'79.2') iname='NanoPiR6C' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=880;;
'79.3') iname='NanoPCT6' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=880;;
80) iname='OrangePi5' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=880;;
81) iname='VisionFive2' HW_ARCH=11 root_size=639;;
82) iname='OrangePi5Plus' HW_ARCH=3 PTTYPE='gpt' partition_start=16 root_size=880;;
Expand Down Expand Up @@ -161,7 +171,7 @@ case $DISTRO in
6) distro='bullseye' exclude=',gcc-8-base,gcc-9-base';;
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'
[[ $DISTRO == 7 ]] && distro='bookworm' || distro='trixie' exclude+=',gcc-12-base,gcc-13-base'
[[ $HW_ARCH == 11 ]] && distro='sid' # RISC-V architecture is available on Sid only
# Raise root size where required
case $HW_MODEL in
Expand All @@ -179,6 +189,16 @@ case $PTTYPE in
*) G_DIETPI-NOTIFY 1 "Invalid partition table type \"$PTTYPE\" passed, aborting..."; exit 1;;
esac

if (( $RPI_NEW ))
then
(( $HW_MODEL < 10 && $DISTRO > 6 )) || { G_DIETPI-NOTIFY 1 "Invalid flag \"--rpi-new\" passed for hardware model \"$HW_MODEL\" or distro \"$DISTRO\" (${distro^}), aborting..."; exit 1; }

elif (( $HW_MODEL && $HW_MODEL < 10 ))
then
G_DIETPI-NOTIFY 1 "Invalid hardware model \"$HW_MODEL\" passed without flag \"--rpi-new\", aborting..."
exit 1
fi

# Do not add trailing FAT partitions for VM, container and (Clonezilla) installer images, and if there is a boot FAT partition already
[[ $HW_MODEL == 20 || $HW_MODEL == 75 || $ITYPE == 'Installer' ]] && ADD_DOS_PART=0
[[ $boot_size -gt 0 && $boot_fstype == 'fat'* ]] && ADD_DOS_PART=0
Expand Down Expand Up @@ -242,21 +262,6 @@ G_EXIT_CUSTOM(){
[[ -f $OUTPUT_IMG_NAME.img ]] && G_EXEC rm "$OUTPUT_IMG_NAME.img"
}

# NanoPi 5/6: Base image download
if [[ $HW_MODEL == 7[69] ]]
then
case $HW_MODEL in
76) series=5;;
79) series=6;;
*) :;;
esac
G_EXEC curl -sSfO "https://dietpi.com/downloads/nanopi$series.img.xz"
G_EXEC xz -d "nanopi$series.img.xz"
G_EXEC truncate -s "$(( 140 + $root_size ))M" "nanopi$series.img"
G_EXEC_OUTPUT=1 G_EXEC sgdisk -e "nanopi$series.img"
G_EXEC_OUTPUT=1 G_EXEC eval "sfdisk -fN8 'nanopi$series.img' <<< ',+'"
G_EXEC mv "nanopi$series.img" "$OUTPUT_IMG_NAME.img"
else
# Create image file
G_EXEC fallocate -l "$((partition_start+efi_size+boot_size+root_size))M" "$OUTPUT_IMG_NAME.img"

Expand Down Expand Up @@ -294,7 +299,6 @@ else
# Set boot flag
G_EXEC parted -s "$OUTPUT_IMG_NAME.img" set 1 boot on
fi
fi

# Create loop device
FP_LOOP=$(losetup -f)
Expand Down Expand Up @@ -322,19 +326,8 @@ cluster_size()

# Create and mount filesystems and fstab
G_EXEC mkdir rootfs
# - NanoPi 5/6 with base image
if [[ $HW_MODEL == 7[69] ]]
then
FP_ROOT_DEV=8
G_EXEC_OUTPUT=1 G_EXEC "${afsck[@]}" "${FP_LOOP}p8"
G_EXEC_OUTPUT=1 G_EXEC "${aresize[@]}" "${FP_LOOP}p8"
G_EXEC mount "${FP_LOOP}p8" rootfs
G_EXEC mkdir rootfs/etc
cat << _EOF_ > rootfs/etc/fstab
PARTUUID=$(lsblk -no PARTUUID "${FP_LOOP}p8") / $FSTYPE noatime,lazytime 0 1
_EOF_
# + EFI partition
elif (( $efi_size ))
if (( $efi_size ))
then
FP_ROOT_DEV=2
G_EXEC mkfs.fat -F 32 -S 512 -s "$(cluster_size "$efi_size")" "${FP_LOOP}p1"
Expand Down Expand Up @@ -367,12 +360,14 @@ then
fi
G_EXEC "mkfs.$FSTYPE" "${afs_opts[@]}" "${FP_LOOP}p2"
G_EXEC mount "${FP_LOOP}p2" rootfs
G_EXEC mkdir rootfs/boot
G_EXEC mount "${FP_LOOP}p1" rootfs/boot
fp_boot='boot'
(( $RPI_NEW )) && fp_boot+='/firmware'
G_EXEC mkdir -p "rootfs/$fp_boot"
G_EXEC mount "${FP_LOOP}p1" "rootfs/$fp_boot"
G_EXEC mkdir rootfs/etc
cat << _EOF_ > rootfs/etc/fstab
PARTUUID=$(lsblk -no PARTUUID "${FP_LOOP}p2") / $FSTYPE noatime,lazytime 0 1
PARTUUID=$(lsblk -no PARTUUID "${FP_LOOP}p1") /boot $boot_fstype noatime,lazytime 0 2
PARTUUID=$(lsblk -no PARTUUID "${FP_LOOP}p1") /$fp_boot $boot_fstype noatime,lazytime 0 2
_EOF_
# - single partition
else
Expand Down Expand Up @@ -470,6 +465,7 @@ G_EXEC losetup -d "$FP_LOOP"
export FP_ROOT_DEV CLONING_TOOL OUTPUT_IMG_NAME MOUNT_IT='Off' SKIP_ARCHIVE SKIP_FIRSTBOOT_RESIZE=1
IMAGER_ARGS=("$OUTPUT_IMG_NAME.img")
(( $ADD_DOS_PART )) && IMAGER_ARGS+=('--add-dos-part')
(( $RPI_NEW )) && IMAGER_ARGS+=('--configs-to-boot')
[[ $SIGN_PASS ]] && IMAGER_ARGS+=('--sign' "$SIGN_PASS")
if [[ ! $EDITION || $EDITION == 'all' ]]
then
Expand Down Expand Up @@ -501,7 +497,11 @@ then

# Mount filesystems
G_EXEC mkdir rootfs
if (( $boot_size ))
if (( $RPI_NEW ))
then
G_EXEC mount "${FP_LOOP}p2" rootfs

elif (( $boot_size ))
then
G_EXEC mount "${FP_LOOP}p2" rootfs
G_EXEC mount "${FP_LOOP}p1" rootfs/boot
Expand Down Expand Up @@ -559,7 +559,11 @@ then

# Mount filesystems
G_EXEC mkdir rootfs
if (( $boot_size ))
if (( $RPI_NEW ))
then
G_EXEC mount "${FP_LOOP}p2" rootfs

elif (( $boot_size ))
then
G_EXEC mount "${FP_LOOP}p2" rootfs
G_EXEC mount "${FP_LOOP}p1" rootfs/boot
Expand Down
19 changes: 18 additions & 1 deletion .build/images/dietpi-imager
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@
[[ $SHRINK_ONLY == 1 ]] || SHRINK_ONLY=0
[[ $SKIP_ARCHIVE == 1 ]] || SKIP_ARCHIVE=0
ADD_DOS_PART=0
CONFIGS_TO_BOOT=0
SIGN_PASS=
while (( $# ))
do
case $1 in
'--add-dos-part') ADD_DOS_PART=1;;
'--configs-to-boot') CONFIGS_TO_BOOT=1;;
'--sign') shift; SIGN_PASS=$1;;
*)
if [[ -b $1 ]]
Expand Down Expand Up @@ -515,8 +517,23 @@
[[ $PART_TABLE_TYPE == 'gpt' ]] && ((IMAGE_SIZE+=34)) || ((IMAGE_SIZE++))
((IMAGE_SIZE*=512)) # 512 byte sectors => bytes

# RPi: Move configs to boot FAT partition to allow easier edit from Windows/macOS
if (( $CONFIGS_TO_BOOT ))
then
local fat_mountpoint=$(mktemp -d)
local root_mountpoint=$(mktemp -d)
G_EXEC mount "${FP_ROOT_DEV::-1}1" "$fat_mountpoint"
G_EXEC mount "$FP_ROOT_DEV" "$root_mountpoint"
G_DIETPI-NOTIFY 2 'Copying dietpi.txt and other config files to the DIETPISETUP partition'
for f in 'dietpi.txt' 'dietpi-wifi.txt' 'dietpiEnv.txt' 'unattended_pivpn.conf' 'Automation_Custom_PreScript.sh' 'Automation_Custom_Script.sh'
do
[[ -f $root_mountpoint/boot/$f ]] && G_EXEC cp "$root_mountpoint/boot/$f" "$fat_mountpoint/"
done
G_EXEC umount "$root_mountpoint" "$fat_mountpoint"
G_EXEC rmdir "$root_mountpoint" "$fat_mountpoint"

# Add trailing FAT partition to simplify first run setup if requested
if (( $ADD_DOS_PART ))
elif (( $ADD_DOS_PART ))
then
G_DIETPI-NOTIFY 2 'Adding a 1 MiB FAT partition to simplify first run setup'
((IMAGE_SIZE+=1048576))
Expand Down
Loading

0 comments on commit 7372523

Please sign in to comment.