From 9e00becfc522c70125eca92fecf3638772781355 Mon Sep 17 00:00:00 2001 From: hzy Date: Sun, 9 Oct 2022 21:16:01 +0800 Subject: [PATCH] Adapt refactored armbian --- .github/workflows/ci.yml | 3 +- 3774.patch | 123 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 3774.patch diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b27850e4d684..29104fb8bd81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,7 +152,8 @@ jobs: - name: "Apply patch #3774 and #4077" run: | - curl -L -O "https://github.com/armbian/build/pull/{3774,4077}.patch" + curl -L -O "https://raw.githubusercontent.com/hzyitc/armbian-onecloud/readme/3774.patch" + curl -L -O "https://github.com/armbian/build/pull/4077.patch" for file in *.patch; do patch --batch -p1 -N <"$file" done diff --git a/3774.patch b/3774.patch new file mode 100644 index 000000000000..5f9ed4fbbedc --- /dev/null +++ b/3774.patch @@ -0,0 +1,123 @@ +modify from https://github.com/armbian/build/pull/3774/files + +Firstrun 2 + +--- + lib/functions/image/rootfs-to-image.sh | 4 ++++ + lib/functions/main/rootfs-image.sh | 3 +++ + .../systemd/system/armbian-firstrun-config.service | 6 ++++-- + .../lib/systemd/system/armbian-firstrun.service | 5 +++-- + packages/bsp/common/usr/lib/armbian/armbian-firstrun | 12 +++--------- + 5 files changed, 17 insertions(+), 13 deletions(-) + +diff --git a/lib/functions/image/rootfs-to-image.sh b/lib/functions/image/rootfs-to-image.sh +index b592b2fe6..6f1374b51 100644 +--- a/lib/functions/image/rootfs-to-image.sh ++++ b/lib/functions/image/rootfs-to-image.sh +@@ -71,6 +71,10 @@ PRE_UPDATE_INITRAMFS + # fix wrong / permissions + chmod 755 $MOUNT + ++ # cleanup image according to systemd.io/BUILDING_IMAGES/ ++ echo -e "uninitialized\n" > ${MOUNT}/etc/machine-id ++ rm ${MOUNT}/var/lib/systemd/random-seed ${MOUNT}/var/lib/dbus/machine-id ++ + call_extension_method "pre_umount_final_image" "config_pre_umount_final_image" << 'PRE_UMOUNT_FINAL_IMAGE' + *allow config to hack into the image before the unmount* + Called before unmounting both `/root` and `/boot`. +diff --git a/lib/functions/main/rootfs-image.sh b/lib/functions/main/rootfs-image.sh +index 9847350ce..7a957f183 100644 +--- a/lib/functions/main/rootfs-image.sh ++++ b/lib/functions/main/rootfs-image.sh +@@ -81,6 +81,9 @@ PRE_INSTALL_DISTRIBUTION_SPECIFIC + # install from apt.armbian.com + [[ $EXTERNAL_NEW == prebuilt ]] && chroot_installpackages "yes" + ++ # remove existing ssh keys ++ rm -f ${SDCARD}/etc/ssh/ssh_host_* ++ + # stage: user customization script + # NOTE: installing too many packages may fill tmpfs mount + customize_image +diff --git a/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service b/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service +index 20943ec42..08e701d96 100644 +--- a/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service ++++ b/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service +@@ -3,13 +3,15 @@ + + [Unit] + Description=Armbian first run optional user configuration +-Wants=network-online.target ++Wants=network-online.target first-boot-complete.target + After=network.target network-online.target ++Before=first-boot-complete.target + ConditionPathExists=/boot/armbian_first_run.txt + ConditionPathExists=/root/.not_logged_in_yet ++ConditionFirstBoot=yes + + [Service] +-Type=idle ++Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/armbian/armbian-firstrun-config + TimeoutStartSec=2min +diff --git a/packages/bsp/common/lib/systemd/system/armbian-firstrun.service b/packages/bsp/common/lib/systemd/system/armbian-firstrun.service +index 64a390950..a22ef42e3 100644 +--- a/packages/bsp/common/lib/systemd/system/armbian-firstrun.service ++++ b/packages/bsp/common/lib/systemd/system/armbian-firstrun.service +@@ -4,10 +4,11 @@ + + [Unit] + Description=Armbian first run tasks +-Before=getty.target system-getty.slice ++Before=getty.target system-getty.slice first-boot-complete.target ssh.service ++Wants=first-boot-complete.target + + [Service] +-Type=simple ++Type=oneshot + RemainAfterExit=yes + ExecStart=/usr/lib/armbian/armbian-firstrun start + TimeoutStartSec=2min +diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstrun b/packages/bsp/common/usr/lib/armbian/armbian-firstrun +index 32f3e88c7..8fa123328 100755 +--- a/packages/bsp/common/usr/lib/armbian/armbian-firstrun ++++ b/packages/bsp/common/usr/lib/armbian/armbian-firstrun +@@ -53,10 +53,8 @@ case "$1" in + sed '1s/^/IMAGE_UUID=/' /proc/sys/kernel/random/uuid >> /etc/armbian-image-release + + # SSH Keys creation +- rm -f /etc/ssh/ssh_host* + read entropy_before /dev/null 2>&1 +- service sshd restart ++ ssh-keygen -A >/dev/null 2>&1 + read entropy_after >${Log} + +@@ -107,12 +105,9 @@ case "$1" in + + mvebu64|mt7623) + # configure/enable/start systemd-networkd +- systemctl start systemd-networkd.service +- systemctl start systemd-resolved.service +- systemctl enable systemd-networkd.service +- systemctl enable systemd-resolved.service + ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf +- systemctl restart systemd-networkd ++ systemctl enable --now systemd-networkd.service ++ systemctl enable --now systemd-resolved.service + ;; + x86|arm64) + [[ -n "$(dmesg | grep "No NVIDIA GPU found")" ]] && sudo apt-get -y -qq purge nvidia-dkms-510 nvidia-driver-510 nvidia-settings nvidia-common >> /dev/null +@@ -126,7 +121,6 @@ case "$1" in + [[ $BRANCH == dev && $LINUXFAMILY == rockchip ]] && set_fixed_mac + [[ $LINUXFAMILY == meson ]] && set_fixed_mac + [[ $LINUXFAMILY == meson64 ]] && set_fixed_mac +- systemctl disable armbian-firstrun + exit 0 + ;; + +-- +2.34.1 +