Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
drahen authored Sep 11, 2023
2 parents a7aa355 + 3bf1053 commit 9f48d16
Show file tree
Hide file tree
Showing 14 changed files with 301 additions and 88 deletions.
44 changes: 40 additions & 4 deletions .build/images/dietpi-build
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ GITBRANCH='master'
GITOWNER='MichaIng'
EDITION=
SUFFIX=
ADD_DOS_PART=1
while (( $# ))
do
case $1 in
Expand All @@ -59,6 +60,7 @@ do
'-o') shift; GITOWNER=$1;;
'-e') shift; EDITION=$1;;
'-s') shift; SUFFIX=$1;;
'--no-dos-part') ADD_DOS_PART=0;;
*) G_DIETPI-NOTIFY 1 "Invalid input \"$1\", aborting..."; exit 1;;
esac
shift
Expand Down Expand Up @@ -170,6 +172,10 @@ case $PTTYPE in
*) G_DIETPI-NOTIFY 1 "Invalid partition table type \"$PTTYPE\" passed, aborting..."; exit 1;;
esac

# 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

fsname='' apackages=() afs_opts=() afsck=() aresize=()
case $FSTYPE in
'ext4') apackages+=('e2fsprogs') afs_opts=('-e' 'remount-ro') afsck=('e2fsck' '-fyD') aresize=('resize2fs');;
Expand Down Expand Up @@ -419,6 +425,7 @@ _EOF_

cat << _EOF_ >> rootfs/etc/rc.local
export GITOWNER='$GITOWNER' GITBRANCH='$GITBRANCH' HW_MODEL='$HW_MODEL' IMAGE_CREATOR=0 PREIMAGE_INFO=0 WIFI_REQUIRED=1 DISTRO_TARGET=$DISTRO
echo '[ INFO ] Running DietPi-Installer for $G_GITOWNER/$G_GITBRANCH'
bash -c "\$(curl -sSf 'https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/dietpi-installer')" || poweroff
_EOF_

Expand Down Expand Up @@ -464,20 +471,36 @@ G_EXEC losetup -d "$FP_LOOP"
# Do not pack and upload raw VM image if not explicitly requested
[[ $VMTYPE && ! $VMTYPE =~ ^(raw|all)$ ]] && SKIP_ARCHIVE=1 || SKIP_ARCHIVE=0
export FP_ROOT_DEV CLONING_TOOL OUTPUT_IMG_NAME MOUNT_IT='Off' SKIP_ARCHIVE SKIP_FIRSTBOOT_RESIZE=1
[[ $EDITION && $EDITION != 'all' ]] || bash -c "$(curl -sSf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/dietpi-imager")" 'DietPi-Imager' "$OUTPUT_IMG_NAME.img" || exit 1
IMAGER_ARGS=("$OUTPUT_IMG_NAME.img")
(( $ADD_DOS_PART )) && IMAGER_ARGS+=('--add-dos-part')
if [[ ! $EDITION || $EDITION == 'all' ]]
then
G_DIETPI-NOTIFY 2 "Running DietPi-Imager for $G_GITOWNER/$G_GITBRANCH"
bash -c "$(curl -sSf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/dietpi-imager")" 'DietPi-Imager' "${IMAGER_ARGS[@]}" || exit 1
fi

# Amiberry edition: Install automatically on first boot, enable autostart option and onboard audio on RPi
if [[ $EDITION == 'Amiberry' || ( $EDITION == 'all' && $HW_MODEL == 0 ) ]]
then
G_EXEC mv "$OUTPUT_IMG_NAME.img" "${OUTPUT_IMG_NAME}_Amiberry.img"
OUTPUT_IMG_NAME="${OUTPUT_IMG_NAME}_Amiberry"
IMAGER_ARGS[0]="$OUTPUT_IMG_NAME.img"

# Create loop device
FP_LOOP=$(losetup -f)
G_EXEC losetup "$FP_LOOP" "$OUTPUT_IMG_NAME.img"
G_EXEC partprobe "$FP_LOOP"
G_EXEC partx -u "$FP_LOOP"

# Remove added DOS partition, it will be re-added by DietPi-Imager
if (( $ADD_DOS_PART )) && [[ $(lsblk -nrbo FSTYPE,LABEL "$FP_LOOP" | tail -1) == 'vfat DIETPISETUP' ]]
then
SETUP_PART=$(sfdisk -lqo DEVICE "$FP_LOOP" | tail -1)
G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread --no-tell-kernel --delete "$FP_LOOP" "${SETUP_PART: -1}"
G_EXEC partprobe "$FP_LOOP"
G_EXEC partx -u "$FP_LOOP"
fi

# Mount filesystems
G_EXEC mkdir rootfs
if (( $boot_size ))
Expand All @@ -502,22 +525,34 @@ then
G_EXEC rmdir rootfs
G_EXEC losetup -d "$FP_LOOP"

bash -c "$(curl -sSf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/dietpi-imager")" 'DietPi-Imager' "$OUTPUT_IMG_NAME.img" || exit 1
G_DIETPI-NOTIFY 2 "Running DietPi-Imager for $G_GITOWNER/$G_GITBRANCH"
bash -c "$(curl -sSf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/dietpi-imager")" 'DietPi-Imager' "${IMAGER_ARGS[@]}" || exit 1
fi

# AlloGUI edition: Pre-install Allo GUI with all managed audiophile software
if [[ $EDITION == 'AlloGUI' || ( $EDITION == 'all' && $HW_MODEL =~ ^(0|70)$ ) ]]
then
G_EXEC mv "$OUTPUT_IMG_NAME.img" "${OUTPUT_IMG_NAME%_Amiberry}_AlloGUI.img"
OUTPUT_IMG_NAME="${OUTPUT_IMG_NAME%_Amiberry}_AlloGUI"
IMAGER_ARGS[0]="$OUTPUT_IMG_NAME.img"

# Raise image size to 2.5 GiB and create loop device
G_EXEC truncate -s '2560M' "$OUTPUT_IMG_NAME.img"
FP_LOOP=$(losetup -f)
G_EXEC losetup "$FP_LOOP" "$OUTPUT_IMG_NAME.img"
G_EXEC partprobe "$FP_LOOP"
G_EXEC partx -u "$FP_LOOP"
# Raise partition and filesystem size as well, since resize2fs within the image returns "Nothing to do!"

# Remove added DOS partition, it will be re-added by DietPi-Imager
if (( $ADD_DOS_PART )) && [[ $(lsblk -nrbo FSTYPE,LABEL "$FP_LOOP" | tail -1) == 'vfat DIETPISETUP' ]]
then
SETUP_PART=$(sfdisk -lqo DEVICE "$FP_LOOP" | tail -1)
G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread --no-tell-kernel --delete "$FP_LOOP" "${SETUP_PART: -1}"
G_EXEC partprobe "$FP_LOOP"
G_EXEC partx -u "$FP_LOOP"
fi

# Raise partition and filesystem sizes as well, since partprobe cannot inform the host kernel about the changed size from within the container
G_EXEC_OUTPUT=1 G_EXEC eval "sfdisk -fN2 '$FP_LOOP' <<< ',+'"
G_EXEC partprobe "$FP_LOOP"
G_EXEC partx -u "$FP_LOOP"
Expand Down Expand Up @@ -625,7 +660,8 @@ _EOF_
G_EXEC rmdir rootfs
G_EXEC losetup -d "$FP_LOOP"

bash -c "$(curl -sSf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/dietpi-imager")" 'DietPi-Imager' "$OUTPUT_IMG_NAME.img" || exit 1
G_DIETPI-NOTIFY 2 "Running DietPi-Imager for $G_GITOWNER/$G_GITBRANCH"
bash -c "$(curl -sSf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/dietpi-imager")" 'DietPi-Imager' "${IMAGER_ARGS[@]}" || exit 1
fi

[[ $VMTYPE && $VMTYPE != 'raw' ]] || exit 0
Expand Down
93 changes: 75 additions & 18 deletions .build/images/dietpi-imager
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,44 @@
exit 1
}

# Inputs
##########################################
# Process inputs
##########################################
SOURCE_TYPE='Drive'
FP_SOURCE_IMG=
if [[ -b $1 ]]
then
FP_SOURCE=$1

elif [[ -f $1 ]]
then
SOURCE_TYPE='Image'
FP_SOURCE_IMG=$1

elif [[ $1 ]]
then
Error_Exit "Input source $1 does not exist, aborting..."
fi
PART_TABLE_TYPE=
#FP_ROOT_DEV=
ROOT_FS_TYPE=
#CLONING_TOOL=
OUTPUT_IMG_EXT='img'
#OUTPUT_IMG_NAME=
[[ $MOUNT_IT == 'On' ]] || MOUNT_IT='Off'
[[ $SKIP_FIRSTBOOT_RESIZE == 1 ]] || SKIP_FIRSTBOOT_RESIZE=0
[[ $SHRINK_ONLY == 1 ]] || SHRINK_ONLY=0
[[ $SKIP_ARCHIVE == 1 ]] || SKIP_ARCHIVE=0
[[ $SKIP_FIRSTBOOT_RESIZE == 1 ]] || SKIP_FIRSTBOOT_RESIZE=0
ADD_DOS_PART=0
while (( $# ))
do
case $1 in
'--add-dos-part') ADD_DOS_PART=1;;
*)
if [[ -b $1 ]]
then
FP_SOURCE=$1

elif [[ -f $1 ]]
then
SOURCE_TYPE='Image'
FP_SOURCE_IMG=$1

elif [[ $1 ]]
then
Error_Exit "Input source $1 does not exist, aborting..."
fi
;;
esac
shift
done

Unmount_tmp()
{
Expand Down Expand Up @@ -494,12 +506,57 @@
G_EXEC partx -u "$FP_SOURCE"
fi

# Derive target image size from last partition end + 1 sector
IMAGE_SIZE=$(( ( $(sfdisk -qlo End "$FP_SOURCE" | tail -1) + 1 ) * 512 )) # 512 byte sectors => bytes

# Add trailing FAT partition to simplify first run setup if requested
# - WARNING: this assumes that the partitions in the table are in order (which we do in other places as well)
if (( $ADD_DOS_PART ))
then
G_DIETPI-NOTIFY 2 'Adding a 1 MiB FAT partition to simplify first run setup'
# Increase source image size if required
[[ $SOURCE_TYPE == 'Image' ]] && (( $(stat -c '%s' "$FP_SOURCE_IMG") < $IMAGE_SIZE + 1048576 )) && G_EXEC truncate -s "$(( $IMAGE_SIZE + 1048576 ))" "$FP_SOURCE_IMG" && G_EXEC losetup -c "$FP_SOURCE"
# Add new DOS partition
local type='EBD0A0A2-B9E5-4433-87C0-68B6B72699C7' # https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
[[ $PART_TABLE_TYPE == 'dos' ]] && type='c'
G_EXEC eval "sfdisk -a '$FP_SOURCE' <<< 'start=$IMAGE_SIZE,size=2048,type=$type'" # size in sectors
G_EXEC partprobe "$FP_SOURCE"
G_EXEC partx -u "$FP_SOURCE"
# create a FAT filesystem and add config files to it
local new_dos_part=$(sfdisk -l "$FP_SOURCE" | mawk "/ $IMAGE_SIZE /{print \$1;exit}")
G_EXE_OUTPUT=1 G_EXEC mkfs.fat -F 16 -n DIETPISETUP "$new_dos_part"
local fat_mountpoint=$(mktemp -d)
local root_mountpoint=$(mktemp -d)
G_EXEC mount "$new_dos_part" "$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
cat << '_EOF_' > "$fat_mountpoint/Readme-DietPi-Config.txt"
DietPi pre-boot configuration
You can edit the files in this folder to setup some configuration options
or even a completely automated install. Please check the documentation and
dietpi.txt for details: https://dietpi.com/docs/install/
This folder also supports the following additional files. Please ensure that
they have UNIX style LF line endings:
- unattended_pivpn.conf
- Automation_Custom_PreScript.sh
- Automation_Custom_Script.sh
_EOF_
G_EXEC umount "$root_mountpoint" "$fat_mountpoint"
G_EXEC rmdir "$root_mountpoint" "$fat_mountpoint"
((IMAGE_SIZE+=1048576))
fi

# Exit now if source shall be shrunk only
(( $SHRINK_ONLY )) && exit 0

# Finished: Derive final image size from last partition end + 1 sector
IMAGE_SIZE=$(( ( $(sfdisk -qlo End "$FP_SOURCE" | tail -1) + 1 ) * 512 )) # 512 byte sectors => bytes
[[ $PART_TABLE_TYPE == 'gpt' ]] && IMAGE_SIZE=$(( $IMAGE_SIZE + 33*512 )) # Add 33 (34 overall) sectors for GPT backup partition table
# Add 33 (34 overall) sectors for GPT backup partition table
[[ $PART_TABLE_TYPE == 'gpt' ]] && IMAGE_SIZE=$(( $IMAGE_SIZE + 33*512 ))

# Image file source and dd target
if [[ $FP_SOURCE_IMG && $CLONING_TOOL == 'dd' ]]
Expand Down
43 changes: 21 additions & 22 deletions .build/images/dietpi-installer
Original file line number Diff line number Diff line change
Expand Up @@ -990,13 +990,13 @@ _EOF_
40) model='pine64' kernel='sunxi64';;
42) model='rockpro64' kernel='rockchip64';;
43) model='rock64' kernel='rockchip64';;
44) model='pinebook-a64' kernel='sunxi64' dietpi_com=1;;
44) model='pinebook-a64' kernel='sunxi64';;
45) model='pineh64-b' kernel='sunxi64';;
46) model='pinebook-pro' kernel='rockchip64' dietpi_com=1;;
46) model='pinebook-pro' kernel='rockchip64';;
47) model='nanopi-r4s' kernel='rockchip64';;
48) model='nanopi-r1' kernel='sunxi' arch='arm';;
52) model='tinkerboard' kernel='rockchip' arch='arm';;
54) model='nanopik2-s905' dietpi_com=1;;
54) model='nanopik2-s905';;
55) model='nanopi-r2s' kernel='rockchip64';;
56) model='nanopineo3' kernel='rockchip64';;
57) model='nanopineoplus2' kernel='sunxi64';;
Expand All @@ -1007,10 +1007,9 @@ _EOF_
case $HW_VARIANT in
2) model='nanopifire3';;
*) model='nanopim3';;
esac
dietpi_com=1;;
esac;;
63) model='nanopim1' kernel='sunxi' arch='arm' dietpi_com=1;;
64) model='nanopiair' kernel='sunxi' arch='arm' dietpi_com=1;;
64) model='nanopiair' kernel='sunxi' arch='arm';;
65) kernel='sunxi64'
case $HW_VARIANT in
2) model='nanopineo2black';;
Expand All @@ -1021,20 +1020,20 @@ _EOF_
68) kernel='rockchip64'
case $HW_VARIANT in
1) model='nanopim4';;
3) model='nanopineo4' dietpi_com=1;;
3) model='nanopineo4';;
*) model='nanopct4';;
esac;;
72) model='rockpi-4b' kernel='rockchip64';;
73) model='rockpi-s' kernel='rockchip64' dietpi_com=1;;
73) model='rockpi-s' kernel='rockchip64';;
74) model='radxa-zero';;
77) model='rock-3a' kernel='rk35xx' branch='edge';;
78) model='rock-5b' kernel='rk35xx' branch='legacy';;
80) model='orangepi5' kernel='rk35xx' branch='legacy';;
82) model='orangepi5-plus' kernel='rk35xx' branch='legacy';;
*) :;;
esac
# Download and pre-install U-Boot hosted on dietpi.com where it has not been ported (and probably never will) to the Armbian Bookworm repo or where it provides a too old version
if (( $dietpi_com && $G_DISTRO > 6 || $G_HW_MODEL == 62 || $G_HW_MODEL == 72 || $G_HW_MODEL == 80 || $G_HW_MODEL == 82 ))
# Download and pre-install U-Boot hosted on dietpi.com where it has not been ported to the Armbian Bookworm repo or has been removed completely
if (( $dietpi_com && $G_DISTRO > 6 || $G_HW_MODEL == 62 ))
then
G_EXEC curl -sSfo package.deb "https://dietpi.com/downloads/binaries/linux-u-boot-$model-$branch.deb"
G_EXEC_OUTPUT=1 G_EXEC dpkg -i package.deb
Expand All @@ -1056,19 +1055,19 @@ _EOF_
# 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')
# - 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
G_EXEC rm package.deb
#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
#G_EXEC rm package.deb
G_AGI initramfs-tools u-boot-tools armbian-firmware "${zstd[@]}"
[[ ${zstd[0]} ]] && G_CONFIG_INJECT 'COMPRESS=' 'COMPRESS=zstd' /etc/initramfs-tools/initramfs.conf
# Download and pre-install kernel hosted on dietpi.com where the Armbian APT repo provides a too old version
if [[ $G_HW_MODEL =~ ^(78|80|82)$ || ( $kernel == 'rockchip64' && $branch == 'current' ) ]]
then
G_EXEC_OUTPUT=1 G_EXEC curl -fo package1.deb "https://dietpi.com/downloads/binaries/linux-image-$branch-$kernel.deb"
G_EXEC_OUTPUT=1 G_EXEC curl -fo package2.deb "https://dietpi.com/downloads/binaries/linux-dtb-$branch-$kernel.deb"
G_EXEC_OUTPUT=1 G_EXEC dpkg -i package1.deb package2.deb
G_EXEC rm package1.deb package2.deb
fi
#if [[ $G_HW_MODEL =~ ^(78|80|82)$ || ( $kernel == 'rockchip64' && $branch == 'current' ) ]]
#then
# G_EXEC_OUTPUT=1 G_EXEC curl -fo package1.deb "https://dietpi.com/downloads/binaries/linux-image-$branch-$kernel.deb"
# G_EXEC_OUTPUT=1 G_EXEC curl -fo package2.deb "https://dietpi.com/downloads/binaries/linux-dtb-$branch-$kernel.deb"
# G_EXEC_OUTPUT=1 G_EXEC dpkg -i package1.deb package2.deb
# G_EXEC rm package1.deb package2.deb
#fi
G_AGI linux-{image,dtb}-"$branch-$kernel" "linux-u-boot-$model-$branch"
# Cleanup
[[ $G_HW_MODEL != 10 && -f '/boot/uImage' ]] && G_EXEC rm /boot/uImage
Expand Down Expand Up @@ -1962,8 +1961,8 @@ _EOF_
G_DIETPI-NOTIFY 2 'Enabling NanoPi R4S Ethernet LEDs'
G_EXEC eval 'echo '\''ledtrig-netdev'\'' > /etc/modules-load.d/dietpi-eth-leds.conf'
cat << '_EOF_' > /etc/udev/rules.d/dietpi-eth-leds.rules
SUBSYSTEM=="leds", KERNEL=="lan_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s up dev eth0", RUN+="/bin/ip l s down dev eth0"
SUBSYSTEM=="leds", KERNEL=="wan_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth1", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s up dev eth1", RUN+="/bin/ip l s down dev eth1"
SUBSYSTEM=="leds", KERNEL=="green:lan", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s up dev eth0", RUN+="/bin/ip l s down dev eth0"
SUBSYSTEM=="leds", KERNEL=="green:wan", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth1", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s up dev eth1", RUN+="/bin/ip l s down dev eth1"
_EOF_
# NanoPi R2S
elif (( $G_HW_MODEL == 55 ))
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- name: Setup tmpfs
run: sudo mount -t tmpfs -o "noatime,lazytime,uid=$(id -u)" tmpfs "$GITHUB_WORKSPACE"
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup DietPi-Globals
run: |
sudo mkdir -p /boot/dietpi/func
Expand Down
5 changes: 4 additions & 1 deletion .meta/dietpi-survey_report
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,16 @@ shopt -s extglob
aSOFTWARE_NAME8_20[211]='Homebridge'

aSOFTWARE_NAME8_21=()
aSOFTWARE_NAME8_22=()
for i in "${!aSOFTWARE_NAME8_20[@]}"
do
aSOFTWARE_NAME8_21[i]=${aSOFTWARE_NAME8_20[i]}
aSOFTWARE_NAME8_22[i]=${aSOFTWARE_NAME8_21[i]}
done
aSOFTWARE_NAME8_22[141]='ADS-B Feeder'

# Pre-create software counter array so that we can see also software (available in newest version) with 0 installs
for i in "${aSOFTWARE_NAME8_21[@]}"
for i in "${aSOFTWARE_NAME8_22[@]}"
do
aSOFTWARE[$i]=0
done
Expand Down
Loading

0 comments on commit 9f48d16

Please sign in to comment.