diff --git a/buildroot-external/Config.in b/buildroot-external/Config.in index f8c647cf..47defb35 100644 --- a/buildroot-external/Config.in +++ b/buildroot-external/Config.in @@ -1,4 +1,5 @@ menu "Mycroft A.I. Personal Assistant" + source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/firstboot-service/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/python-mycroft/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/mycroft-service/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/mycroft-splash/Config.in" diff --git a/buildroot-external/configs/mycroftos_rpi3_defconfig b/buildroot-external/configs/mycroftos_rpi3_defconfig index 1b2b2c27..e376cffe 100644 --- a/buildroot-external/configs/mycroftos_rpi3_defconfig +++ b/buildroot-external/configs/mycroftos_rpi3_defconfig @@ -187,6 +187,7 @@ BR2_PACKAGE_HOST_PYTHON_CYTHON=y BR2_PACKAGE_HOST_PYTHON_LXML=y BR2_PACKAGE_HOST_PYTHON_SIX=y BR2_PACKAGE_HOST_PYTHON_XLRD=y +BR2_PACKAGE_FIRSTBOOT_SERVICE=y BR2_PACKAGE_PYTHON_MYCROFT=y BR2_PACKAGE_MYCROFT_SERVICE=y BR2_PACKAGE_MYCROFT_SPLASH=y diff --git a/buildroot-external/package/firstboot-service/Config.in b/buildroot-external/package/firstboot-service/Config.in new file mode 100644 index 00000000..23cd1748 --- /dev/null +++ b/buildroot-external/package/firstboot-service/Config.in @@ -0,0 +1,8 @@ +config BR2_PACKAGE_FIRSTBOOT_SERVICE + bool "firstboot-service" + help + A systemd service that only runs on first boot + which can be used to run certain scripts that + prepare the rootfs. For now being used to auto + expand the filesystem over the full size of the + SD card. diff --git a/buildroot-external/package/firstboot-service/firstboot b/buildroot-external/package/firstboot-service/firstboot new file mode 100755 index 00000000..bb9b3eb8 --- /dev/null +++ b/buildroot-external/package/firstboot-service/firstboot @@ -0,0 +1,4 @@ +#!/bin/bash +# +/usr/sbin/resizeSD && +rm /etc/firstboot diff --git a/buildroot-external/package/firstboot-service/firstboot-service.mk b/buildroot-external/package/firstboot-service/firstboot-service.mk new file mode 100644 index 00000000..f6f3b635 --- /dev/null +++ b/buildroot-external/package/firstboot-service/firstboot-service.mk @@ -0,0 +1,24 @@ +################################################################################ +# +# firstboot-service +# +################################################################################ + +FIRSTBOOT_SERVICE_VERSION = 0.1.0 +FIRSTBOOT_SERVICE_SITE = $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/firstboot-service +FIRSTBOOT_SERVICE_SITE_METHOD = local +FIRSTBOOT_SERVICE_LICENSE = Apache License 2.0 +FIRSTBOOT_SERVICE_LICENSE_FILES = LICENSE + +define FIRSTBOOT_SERVICE_INSTALL_TARGET_CMDS + $(INSTALL) -m 0755 $(@D)/resizeSD $(TARGET_DIR)/usr/sbin/ + $(INSTALL) -m 0755 $(@D)/firstboot $(TARGET_DIR)/usr/sbin/ + $(INSTALL) -D -m 644 $(@D)/firstboot.service \ + $(TARGET_DIR)/usr/lib/systemd/system/firstboot.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/sysinit.target.wants + ln -fs ../../../../usr/lib/systemd/system/firstboot.service \ + $(TARGET_DIR)/etc/systemd/system/sysinit.target.wants/firstboot.service + touch $(TARGET_DIR)/etc/firstboot +endef + +$(eval $(generic-package)) diff --git a/buildroot-external/package/firstboot-service/firstboot.service b/buildroot-external/package/firstboot-service/firstboot.service new file mode 100644 index 00000000..4f140799 --- /dev/null +++ b/buildroot-external/package/firstboot-service/firstboot.service @@ -0,0 +1,16 @@ +[Unit] +Description=First Boot run script +DefaultDependencies=no +Conflicts=shutdown.target +After=systemd-remount-fs.service +Before=sysinit.target shutdown.target +ConditionPathIsReadWrite=/etc +ConditionFirstBoot=yes + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/sbin/resizeSD + +[Install] +WantedBy=sysinit.target diff --git a/buildroot-external/package/firstboot-service/resizeSD b/buildroot-external/package/firstboot-service/resizeSD new file mode 100755 index 00000000..4818c6b1 --- /dev/null +++ b/buildroot-external/package/firstboot-service/resizeSD @@ -0,0 +1,9 @@ +#!/bin/bash +# +printf "Resize data partition ..." +parted /dev/mmcblk0 unit % resizepart 2 100% && +partprobe /dev/mmcblk0 && +sync && +resize2fs /dev/mmcblk0p2 && +echo "[OK]" +