From 7ff17d949993fc050a693dbaaf6ffc1ddd7cc1fd Mon Sep 17 00:00:00 2001 From: Hangfan Li Date: Fri, 5 Sep 2025 10:43:56 +0800 Subject: [PATCH] initial support --- _service | 12 ++++++++++++ oerv-firstboot.service | 13 +++++++++++++ oerv-firstboot.sh | 10 ++++++++++ oerv-firstboot.spec | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 _service create mode 100644 oerv-firstboot.service create mode 100755 oerv-firstboot.sh create mode 100644 oerv-firstboot.spec diff --git a/_service b/_service new file mode 100644 index 0000000..c3bd40d --- /dev/null +++ b/_service @@ -0,0 +1,12 @@ + + + git + https://git.oerv.ac.cn/OERV-BSP-RPM/oerv-firstboot.git + master + disable + _none_ + * + + *.spec + + diff --git a/oerv-firstboot.service b/oerv-firstboot.service new file mode 100644 index 0000000..bf39493 --- /dev/null +++ b/oerv-firstboot.service @@ -0,0 +1,13 @@ +[Unit] +Before=systemd-user-sessions.service +ConditionPathExists=/etc/systemd/system/multi-user.target.wants/oerv-firstboot.service +Requires=-.mount + +[Service] +Type=oneshot +ExecStart=/usr/sbin/oerv-firstboot.sh +ExecStartPost=/usr/bin/rm /etc/systemd/system/multi-user.target.wants/oerv-firstboot.service +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/oerv-firstboot.sh b/oerv-firstboot.sh new file mode 100755 index 0000000..e8e6fd2 --- /dev/null +++ b/oerv-firstboot.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +echo "OERV first-time booting helper." +ROOT_PART="$(findmnt -no SOURCE /)" +ROOT_PARTNUM="$(lsblk -pr -no partn "${ROOT_PART}")" +ROOT_DISK="$(lsblk -p -no pkname "${ROOT_PART}")" +sgdisk -e "${ROOT_DISK}" +echo "Yes" | parted ---pretend-input-tty "${ROOT_DISK}" resizepart "${ROOT_PARTNUM}" 100% +partprobe +resize2fs "\${ROOT_PART}" diff --git a/oerv-firstboot.spec b/oerv-firstboot.spec new file mode 100644 index 0000000..b373dee --- /dev/null +++ b/oerv-firstboot.spec @@ -0,0 +1,34 @@ +Name: oerv-firstboot +Version: 1.0.0 +Release: 0%{?dist} +Summary: OERV first boot service + +License: GPLv2 +URL: https://git.oerv.ac.cn/OERV-BSP/oerv-firstboot +BuildArch: noarch +Source0: oerv-firstboot.tar + +Requires: coreutils + +%description + Helper scripts for first boot. + Expands rootfs to whole disk. + +%prep +%setup -n %{name} + +%build + +%install +install -Dm 755 oerv-firstboot.sh %{buildroot}/%{_sbindir}/oerv-firstboot.sh +install -Dm 644 oerv-firstboot.service %{buildroot}/etc/systemd/system/oerv-firstboot.service +ln -s "/etc/systemd/system/oerv-firstboot.service" "%{buildroot}/etc/systemd/system/multi-user.target.wants/oerv-firstboot.service" + +%files +%{_sbindir}/oerv-firstboot.sh +%{buildroot}/etc/systemd/system/oerv-firstboot.service +%{buildroot}/etc/systemd/system/multi-user.target.wants/oerv-firstboot.service + +%changelog +* Fri Sep 05 2024 Hangfan Li +- Initilal RPM release