From b3530d1ce1d9724ba1845a351c86dc28fec39439 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Wed, 6 May 2020 00:00:28 +0200 Subject: [PATCH] Allow easy move data partition (#651) * Allow easy move data partition * Cleanup handling systemd * Improve handling * fix pipeline * pipeline * fix shell handling * fix scripts * Add bin folder * fix lint * Fix service handling * Fix loading * hide output * Fix handling --- azure-pipelines-ci.yml | 4 ++ ...k-meson-g12a-fix-gp0-and-hifi-ranges.patch | 39 +++++++++++ .../bluetooth-bcm43xx/bluetooth-bcm43xx.mk | 1 - .../bluetooth-rtl8723/bluetooth-rtl8723.mk | 1 - ...tworkManager-system\\x2dconnections.mount" | 1 - .../hassos-bind.target.wants/etc-docker.mount | 1 - .../etc-dropbear.mount | 1 - .../etc-hostname.mount | 1 - .../hassos-bind.target.wants/etc-hosts.mount | 1 - .../etc-modules\\x2dload.d.mount" | 1 - .../etc-systemd-timesyncd.conf.mount | 1 - .../etc-udev-rules.d.mount | 1 - .../hassos-user-rules-udev-trigger.service | 1 - .../root-.docker.mount | 1 - .../hassos-bind.target.wants/root-.ssh.mount | 1 - .../var-lib-NetworkManager.mount | 1 - .../var-lib-bluetooth.mount | 1 - .../var-lib-docker.mount | 1 - .../var-lib-systemd.mount | 1 - .../var-log-journal.mount | 1 - .../hassos-hardware.target.wants/.empty | 0 .../zram-swap.service | 1 - .../hassos-zram.target.wants/zram-tmp.service | 1 - .../hassos-zram.target.wants/zram-var.service | 1 - .../hassos-expand.service | 1 - .../hassos-overlay.service | 1 - .../local-fs.target.wants/mnt-boot.mount | 1 - .../local-fs.target.wants/mnt-data.mount | 1 - .../local-fs.target.wants/mnt-overlay.mount | 1 - .../busybox-acpid.service | 1 - .../hassos-apparmor.service | 1 - .../hassos-bind.target | 1 - .../hassos-config.service | 1 - .../hassos-hardware.target | 1 - .../hassos-persists.service | 1 - .../hassos-supervisor.service | 1 - .../hassos-zram.target | 1 - .../multi-user.target.wants/rauc.service | 1 - .../system/swap.target.wants/dev-zram0.swap | 1 - .../rootfs-overlay/usr/bin/datactl | 31 +++++++++ .../usr/lib/systemd/system/hassos-bind.target | 3 + .../lib/systemd/system/hassos-data.service | 17 +++++ .../lib/systemd/system/hassos-expand.service | 1 - .../lib/systemd/system/hassos-hardware.target | 3 + .../usr/lib/systemd/system/hassos-zram.target | 3 + .../rootfs-overlay/usr/libexec/hassos-data | 68 +++++++++++++++++++ .../rootfs-overlay/usr/libexec/hassos-expand | 13 +++- .../usr/libexec/hassos-persists | 8 +-- buildroot-external/scripts/post-build.sh | 3 + 49 files changed, 185 insertions(+), 44 deletions(-) create mode 100644 buildroot-external/board/hardkernel/patches/linux/0001-FROMLIST-clk-meson-g12a-fix-gp0-and-hifi-ranges.patch delete mode 120000 "buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-NetworkManager-system\\x2dconnections.mount" delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-docker.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-dropbear.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-hostname.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-hosts.mount delete mode 120000 "buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-modules\\x2dload.d.mount" delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-systemd-timesyncd.conf.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-udev-rules.d.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/hassos-user-rules-udev-trigger.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/root-.docker.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/root-.ssh.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-NetworkManager.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-bluetooth.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-docker.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-systemd.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-log-journal.mount delete mode 100644 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-hardware.target.wants/.empty delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-swap.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-tmp.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-var.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/hassos-expand.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/hassos-overlay.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-boot.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-data.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-overlay.mount delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/busybox-acpid.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-apparmor.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-bind.target delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-config.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-hardware.target delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-persists.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-supervisor.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-zram.target delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/rauc.service delete mode 120000 buildroot-external/rootfs-overlay/etc/systemd/system/swap.target.wants/dev-zram0.swap create mode 100755 buildroot-external/rootfs-overlay/usr/bin/datactl create mode 100644 buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-data.service create mode 100755 buildroot-external/rootfs-overlay/usr/libexec/hassos-data diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml index 6b9c1e0d1..a86b2b133 100644 --- a/azure-pipelines-ci.yml +++ b/azure-pipelines-ci.yml @@ -38,11 +38,15 @@ jobs: sudo docker pull koalaman/shellcheck:$(versionShellCheck) displayName: 'Install ShellCheck' - script: | + set -e + + # Check build script sudo docker run --rm -i \ -v $(pwd):/mnt:ro koalaman/shellcheck:$(versionShellCheck) \ scripts/*.sh \ buildroot-external/scripts/*.sh \ buildroot-external/board/**/*.sh \ + buildroot-external/rootfs-overlay/usr/bin/* \ buildroot-external/rootfs-overlay/usr/sbin/* \ buildroot-external/rootfs-overlay/usr/libexec/* \ buildroot-external/rootfs-overlay/usr/lib/rauc/* diff --git a/buildroot-external/board/hardkernel/patches/linux/0001-FROMLIST-clk-meson-g12a-fix-gp0-and-hifi-ranges.patch b/buildroot-external/board/hardkernel/patches/linux/0001-FROMLIST-clk-meson-g12a-fix-gp0-and-hifi-ranges.patch new file mode 100644 index 000000000..9ab235927 --- /dev/null +++ b/buildroot-external/board/hardkernel/patches/linux/0001-FROMLIST-clk-meson-g12a-fix-gp0-and-hifi-ranges.patch @@ -0,0 +1,39 @@ +From 81b290367d59103d1f041709c56a3de1c360e102 Mon Sep 17 00:00:00 2001 +From: Jerome Brunet +Date: Mon, 13 May 2019 14:45:31 +0200 +Subject: [PATCH] FROMLIST: clk: meson: g12a: fix gp0 and hifi ranges + +While some SoC samples are able to lock with a PLL factor of 55, others +samples can't. ATM, a minimum of 60 appears to work on all the samples +I have tried. + +Even with 60, it sometimes takes a long time for the PLL to eventually +lock. The documentation says that the minimum rate of these PLLs DCO +should be 3GHz, a factor of 125. Let's use that to be on the safe side. + +With factor range changed, the PLL seems to lock quickly (enough) so far. +It is still unclear if the range was the only reason for the delay. + +Fixes: 085a4ea93d54 ("clk: meson: g12a: add peripheral clock controller") +Signed-off-by: Jerome Brunet +Signed-off-by: Neil Armstrong +--- + drivers/clk/meson/g12a.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/clk/meson/g12a.c b/drivers/clk/meson/g12a.c +index b3af61cc6fb9..66cf791bfc8c 100644 +--- a/drivers/clk/meson/g12a.c ++++ b/drivers/clk/meson/g12a.c +@@ -1591,7 +1591,7 @@ static struct clk_regmap g12b_cpub_clk_trace = { + }; + + static const struct pll_mult_range g12a_gp0_pll_mult_range = { +- .min = 55, ++ .min = 125, + .max = 255, + }; + +-- +2.17.1 + diff --git a/buildroot-external/package/bluetooth-bcm43xx/bluetooth-bcm43xx.mk b/buildroot-external/package/bluetooth-bcm43xx/bluetooth-bcm43xx.mk index df5437648..684bf8560 100644 --- a/buildroot-external/package/bluetooth-bcm43xx/bluetooth-bcm43xx.mk +++ b/buildroot-external/package/bluetooth-bcm43xx/bluetooth-bcm43xx.mk @@ -24,7 +24,6 @@ define BLUETOOTH_BCM43XX_INSTALL_TARGET_CMDS $(INSTALL) -d $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants $(INSTALL) -m 0644 $(@D)/bluetooth-bcm43xx.service $(TARGET_DIR)/usr/lib/systemd/system/ $(INSTALL) -m 0644 $(@D)/bthelper@.service $(TARGET_DIR)/usr/lib/systemd/system/ - ln -fs /usr/lib/systemd/system/bluetooth-bcm43xx.service $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants/ $(INSTALL) -d $(TARGET_DIR)/usr/bin $(INSTALL) -m 0755 $(@D)/btuart $(TARGET_DIR)/usr/bin/ diff --git a/buildroot-external/package/bluetooth-rtl8723/bluetooth-rtl8723.mk b/buildroot-external/package/bluetooth-rtl8723/bluetooth-rtl8723.mk index 10fecae45..c3e3ebebf 100644 --- a/buildroot-external/package/bluetooth-rtl8723/bluetooth-rtl8723.mk +++ b/buildroot-external/package/bluetooth-rtl8723/bluetooth-rtl8723.mk @@ -21,7 +21,6 @@ define BLUETOOTH_RTL8723_INSTALL_TARGET_CMDS $(INSTALL) -d $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants $(INSTALL) -m 0755 $(@D)/bluetooth-rtl8723 $(TARGET_DIR)/usr/sbin/ $(INSTALL) -m 0644 $(@D)/bluetooth-rtl8723.service $(TARGET_DIR)/usr/lib/systemd/system/ - ln -fs /usr/lib/systemd/system/bluetooth-rtl8723.service $(TARGET_DIR)/etc/systemd/system/hassos-hardware.target.wants/ $(INSTALL) -d $(TARGET_DIR)/lib/firmware/rtlbt $(INSTALL) -m 0644 $(@D)/rtl8723b_* $(TARGET_DIR)/lib/firmware/rtlbt/ diff --git "a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-NetworkManager-system\\x2dconnections.mount" "b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-NetworkManager-system\\x2dconnections.mount" deleted file mode 120000 index 440f4a731..000000000 --- "a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-NetworkManager-system\\x2dconnections.mount" +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/etc-NetworkManager-system\x2dconnections.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-docker.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-docker.mount deleted file mode 120000 index 232985c3e..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-docker.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/etc-docker.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-dropbear.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-dropbear.mount deleted file mode 120000 index 4a225123b..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-dropbear.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/etc-dropbear.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-hostname.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-hostname.mount deleted file mode 120000 index 173cae388..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-hostname.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/etc-hostname.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-hosts.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-hosts.mount deleted file mode 120000 index d22d22eb3..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-hosts.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/etc-hosts.mount \ No newline at end of file diff --git "a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-modules\\x2dload.d.mount" "b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-modules\\x2dload.d.mount" deleted file mode 120000 index 11e4628b3..000000000 --- "a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-modules\\x2dload.d.mount" +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/etc-modules\x2dload.d.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-systemd-timesyncd.conf.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-systemd-timesyncd.conf.mount deleted file mode 120000 index 29053b7fc..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-systemd-timesyncd.conf.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/etc-systemd-timesyncd.conf.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-udev-rules.d.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-udev-rules.d.mount deleted file mode 120000 index c148f8000..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/etc-udev-rules.d.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/etc-udev-rules.d.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/hassos-user-rules-udev-trigger.service b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/hassos-user-rules-udev-trigger.service deleted file mode 120000 index b41d47acb..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/hassos-user-rules-udev-trigger.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-user-rules-udev-trigger.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/root-.docker.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/root-.docker.mount deleted file mode 120000 index 89b8e7c7e..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/root-.docker.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/root-.docker.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/root-.ssh.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/root-.ssh.mount deleted file mode 120000 index 84b3685f2..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/root-.ssh.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/root-.ssh.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-NetworkManager.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-NetworkManager.mount deleted file mode 120000 index eea387e8c..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-NetworkManager.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/var-lib-NetworkManager.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-bluetooth.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-bluetooth.mount deleted file mode 120000 index d16b3e1f6..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-bluetooth.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/var-lib-bluetooth.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-docker.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-docker.mount deleted file mode 120000 index 467de4f6f..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-docker.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/var-lib-docker.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-systemd.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-systemd.mount deleted file mode 120000 index 4a7127d20..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-lib-systemd.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/var-lib-systemd.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-log-journal.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-log-journal.mount deleted file mode 120000 index efc836fc0..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-bind.target.wants/var-log-journal.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/var-log-journal.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-hardware.target.wants/.empty b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-hardware.target.wants/.empty deleted file mode 100644 index e69de29bb..000000000 diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-swap.service b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-swap.service deleted file mode 120000 index e01102d0f..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-swap.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/zram-swap.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-tmp.service b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-tmp.service deleted file mode 120000 index fa475eac5..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-tmp.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/zram-tmp.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-var.service b/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-var.service deleted file mode 120000 index 9d0314340..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/hassos-zram.target.wants/zram-var.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/zram-var.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/hassos-expand.service b/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/hassos-expand.service deleted file mode 120000 index efdd01fe4..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/hassos-expand.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-expand.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/hassos-overlay.service b/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/hassos-overlay.service deleted file mode 120000 index 577ec4382..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/hassos-overlay.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-overlay.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-boot.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-boot.mount deleted file mode 120000 index 909c6e93d..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-boot.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/mnt-boot.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-data.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-data.mount deleted file mode 120000 index 62a16cffe..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-data.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/mnt-data.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-overlay.mount b/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-overlay.mount deleted file mode 120000 index f3df5f297..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/local-fs.target.wants/mnt-overlay.mount +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/mnt-overlay.mount \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/busybox-acpid.service b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/busybox-acpid.service deleted file mode 120000 index 58ebeea6d..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/busybox-acpid.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/busybox-acpid.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-apparmor.service b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-apparmor.service deleted file mode 120000 index 3caec078f..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-apparmor.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-apparmor.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-bind.target b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-bind.target deleted file mode 120000 index afb44860c..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-bind.target +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-bind.target \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-config.service b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-config.service deleted file mode 120000 index 24c0f09e3..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-config.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-config.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-hardware.target b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-hardware.target deleted file mode 120000 index e14d96357..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-hardware.target +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-hardware.target \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-persists.service b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-persists.service deleted file mode 120000 index fae7b5b9c..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-persists.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-persists.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-supervisor.service b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-supervisor.service deleted file mode 120000 index 17b423d69..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-supervisor.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-supervisor.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-zram.target b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-zram.target deleted file mode 120000 index decfca7a2..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/hassos-zram.target +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/hassos-zram.target \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/rauc.service b/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/rauc.service deleted file mode 120000 index c7ea83e7a..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/multi-user.target.wants/rauc.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/rauc.service \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/etc/systemd/system/swap.target.wants/dev-zram0.swap b/buildroot-external/rootfs-overlay/etc/systemd/system/swap.target.wants/dev-zram0.swap deleted file mode 120000 index 80109b60f..000000000 --- a/buildroot-external/rootfs-overlay/etc/systemd/system/swap.target.wants/dev-zram0.swap +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/system/dev-zram0.swap \ No newline at end of file diff --git a/buildroot-external/rootfs-overlay/usr/bin/datactl b/buildroot-external/rootfs-overlay/usr/bin/datactl new file mode 100755 index 000000000..adc024685 --- /dev/null +++ b/buildroot-external/rootfs-overlay/usr/bin/datactl @@ -0,0 +1,31 @@ +#!/bin/sh +# ============================================================================== +# HassOS data partition handling +# ============================================================================== +set -e + +OPTION_FILE=/mnt/overlay/data.opt +DATA_DEVICE_CHILD="$(findfs LABEL="hassos-data")" +DATA_DEVICE_ROOT="/dev/$(lsblk -no pkname "${DATA_DEVICE_CHILD}")" + +# Move command +if [ "${1}" = "move" ] && [ -e "${2}" ]; then + DEVICE="${2}" + + # Check device + if ! lsblk "${DEVICE}" | grep disk > /dev/null 2>&1; then + echo "[ERROR] Is not disk!" + exit 1 + elif [ "${DEVICE}" = "${DATA_DEVICE_ROOT}" ]; then + echo "[ERROR] Can't be the same disk!" + exit 1 + fi + + # Flag device + echo "WARNING: ${DEVICE} will be reset on next restart!" + echo "Press a key to move forward" + read -r + + echo "${DEVICE}" > ${OPTION_FILE} +fi + diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-bind.target b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-bind.target index 4d0e40302..7d030b79d 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-bind.target +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-bind.target @@ -2,3 +2,6 @@ Description=HassOS overlay targets Documentation=man:systemd.target(5) Before=sysinit.target + +[Install] +WantedBy=multi-user.target diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-data.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-data.service new file mode 100644 index 000000000..2b1978ddf --- /dev/null +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-data.service @@ -0,0 +1,17 @@ +[Unit] +Description=HassOS data partition +DefaultDependencies=no +RefuseManualStart=true +RefuseManualStop=true +Requires=mnt-overlay.mount dev-disk-by\x2dlabel-hassos\x2ddata.device +Wants=hassos-expand.service +After=mnt-overlay.mount dev-disk-by\x2dlabel-hassos\x2ddata.device +Before=hassos-expand.service +ConditionPathExists=/mnt/overlay/data.opt + +[Service] +Type=oneshot +ExecStart=/usr/libexec/hassos-data + +[Install] +WantedBy=local-fs.target diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service index afa6a1eff..a847f9f9a 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service @@ -10,7 +10,6 @@ After=dev-disk-by\x2dlabel-hassos\x2ddata.device [Service] Type=oneshot ExecStart=/usr/libexec/hassos-expand -RemainAfterExit=true [Install] WantedBy=local-fs.target diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-hardware.target b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-hardware.target index 44001027e..931db9009 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-hardware.target +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-hardware.target @@ -1,3 +1,6 @@ [Unit] Description=HassOS hardware targets Documentation=man:systemd.target(5) + +[Install] +WantedBy=multi-user.target diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-zram.target b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-zram.target index f94232646..4279629ae 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-zram.target +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-zram.target @@ -1,3 +1,6 @@ [Unit] Description=HassOS zram targets Documentation=man:systemd.target(5) + +[Install] +WantedBy=multi-user.target diff --git a/buildroot-external/rootfs-overlay/usr/libexec/hassos-data b/buildroot-external/rootfs-overlay/usr/libexec/hassos-data new file mode 100755 index 000000000..20a0f9bb2 --- /dev/null +++ b/buildroot-external/rootfs-overlay/usr/libexec/hassos-data @@ -0,0 +1,68 @@ +#!/bin/sh +# shellcheck disable=SC2039 +# ============================================================================== +# HassOS data partition handler +# ============================================================================== +set -e + +OPTION_FILE=/mnt/overlay/data.opt + +# New data partition exits +if ! [ -e "${OPTION_FILE}" ]; then + echo "[INFO] No data option found" + exit 0 +else + NEW_DEVICE_ROOT="$(cat ${OPTION_FILE})" + rm ${OPTION_FILE} +fi + +# Get device information +OLD_DEVICE_CHILD="$(findfs LABEL="hassos-data")" +OLD_DEVICE_ROOT="/dev/$(lsblk -no pkname "${OLD_DEVICE_CHILD}")" +OLD_PART_NUM="${OLD_DEVICE_CHILD: -1}" + +# Create new partition +echo "[INFO] Create new hassos-data partition" +sgdisk -o "${NEW_DEVICE_ROOT}" +sgdisk \ + -n "0:0:0" \ + -c "0:hassos-data" \ + -t "0:0FC63DAF-8483-4772-8E79-3D69D8477DE4" \ + -u "0:a52a4597-fa3a-4851-aefd-2fbe9f849079" \ + "${NEW_DEVICE_ROOT}" +sgdisk -v "${NEW_DEVICE_ROOT}" +partx -u "${NEW_DEVICE_ROOT}" + +NEW_DEVICE_CHILD="$(fdisk -l "${NEW_DEVICE_ROOT}" | grep '^/dev' | cut -d' ' -f1 | head -n 1)" + +echo "[INFO] Move hassos-data from ${OLD_DEVICE_CHILD} to ${NEW_DEVICE_CHILD}" +if ! dd if="${OLD_DEVICE_CHILD}" of="${NEW_DEVICE_CHILD}" status=none; then + echo "[ERROR] Data copy fails!" + + # Reset new data partition + sgdisk -o "${NEW_DEVICE_ROOT}" + partx -u "${NEW_DEVICE_ROOT}" + exit 1 +fi + +echo "[INFO] Remove old hassos-data partition ${OLD_PART_NUM} / ${OLD_DEVICE_ROOT}" +if sfdisk -dq "${OLD_DEVICE_ROOT}" | grep -q 'label: gpt'; then + sgdisk -d "${OLD_PART_NUM}" "${OLD_DEVICE_ROOT}" + sgdisk -v "${OLD_DEVICE_ROOT}" + +else + sfdisk --delete "${OLD_PART_NUM}" "${OLD_DEVICE_ROOT}" --force + sfdisk -V "${OLD_DEVICE_ROOT}" +fi + +echo "[INFO] fix filesystem & layout" + +# Fix filesystem +e2fsck -y "${NEW_DEVICE_CHILD}" +resize2fs -f "${NEW_DEVICE_CHILD}" + +# Fix partition layout +partx -d "${OLD_DEVICE_CHILD}" +partx -u "${NEW_DEVICE_ROOT}" + +echo "[INFO] Finish hassos data movement" diff --git a/buildroot-external/rootfs-overlay/usr/libexec/hassos-expand b/buildroot-external/rootfs-overlay/usr/libexec/hassos-expand index 64554e18b..6cbe7d0c7 100755 --- a/buildroot-external/rootfs-overlay/usr/libexec/hassos-expand +++ b/buildroot-external/rootfs-overlay/usr/libexec/hassos-expand @@ -1,5 +1,8 @@ #!/bin/sh # shellcheck disable=SC2039 +# ============================================================================== +# HassOS partition expander +# ============================================================================== set -e DEVICE_CHILD="$(findfs LABEL="hassos-data")" @@ -13,11 +16,15 @@ if [ -z "${UNUSED}" ] || [ "${UNUSED}" -le "2048" ]; then exit 0 fi +echo "[INFO] Update hassos-data partition ${PART_NUM}" if sfdisk -dq "${DEVICE_ROOT}" | grep -q 'label: gpt'; then - # Resize & Reload partition - echo "[INFO] Update hassos-data partition ${PART_NUM}" sgdisk -e "${DEVICE_ROOT}" - sgdisk -d "${PART_NUM}" -n "${PART_NUM}:0:0" -c "${PART_NUM}:hassos-data" -t "${PART_NUM}:0FC63DAF-8483-4772-8E79-3D69D8477DE4" -u "${PART_NUM}:a52a4597-fa3a-4851-aefd-2fbe9f849079" "${DEVICE_ROOT}" + sgdisk -d "${PART_NUM}" \ + -n "${PART_NUM}:0:0" \ + -c "${PART_NUM}:hassos-data" \ + -t "${PART_NUM}:0FC63DAF-8483-4772-8E79-3D69D8477DE4" \ + -u "${PART_NUM}:a52a4597-fa3a-4851-aefd-2fbe9f849079" \ + "${DEVICE_ROOT}" sgdisk -v "${DEVICE_ROOT}" else echo ", +" | sfdisk -N "${PART_NUM}" "${DEVICE_ROOT}" --force diff --git a/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists b/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists index 3b71b09ba..305cdc95e 100755 --- a/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists +++ b/buildroot-external/rootfs-overlay/usr/libexec/hassos-persists @@ -9,10 +9,10 @@ if [ -e /usr/sbin/fw_setenv ]; then # machine-id if [ "$(fw_printenv -n MACHINE_ID)" != "${MACHINE_ID}" ]; then - echo "[info] set machine-id to ${MACHINE_ID}" + echo "[INFO] set machine-id to ${MACHINE_ID}" fw_setenv MACHINE_ID "${MACHINE_ID}" else - echo "[info] machine-id is okay" + echo "[INFO] machine-id is okay" fi ### @@ -21,10 +21,10 @@ else # machine-id if [ "$(barebox-state -g state.machine_id -i /etc/barebox-state.dtb)" != "${MACHINE_ID}" ]; then - echo "[info] set machine-id to ${MACHINE_ID}" + echo "[INFO] set machine-id to ${MACHINE_ID}" barebox-state -s "state.machine_id=${MACHINE_ID}" -i /etc/barebox-state.dtb else - echo "[info] machine-id is okay" + echo "[INFO] machine-id is okay" fi fi diff --git a/buildroot-external/scripts/post-build.sh b/buildroot-external/scripts/post-build.sh index 8b8c82490..029b41d24 100755 --- a/buildroot-external/scripts/post-build.sh +++ b/buildroot-external/scripts/post-build.sh @@ -45,3 +45,6 @@ install_hassos_cli write_rauc_config install_rauc_certs install_bootloader_config + +# Fix overlay presets +"${HOST_DIR}/bin/systemctl" --root="${TARGET_DIR}" preset-all