diff mbox series

[v2,06/13] package/skeleton-init-openrc: addsupport to remount rootfs as rw

Message ID 20190512195550.24457-6-michal.lyszczek@bofc.pl
State Superseded
Headers show
Series [v2,01/13] package/openrc: new package (v0.41.2) | expand

Commit Message

Michał Łyszczek May 12, 2019, 7:55 p.m. UTC
Adds support to openrc skeleton to monitor
BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW and remount rootfs as rw when
options is set.

Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>

---
Changes v1 -> v2
  None
---
 .../skeleton-init-openrc/skeleton-init-sysv.mk    | 15 +++++++++++++++
 package/skeleton-init-openrc/skeleton/etc/fstab   |  1 +
 2 files changed, 16 insertions(+)

Comments

Thomas Petazzoni May 18, 2019, 9:22 p.m. UTC | #1
Hello,

On Sun, 12 May 2019 21:55:43 +0200
Michał Łyszczek <michal.lyszczek@bofc.pl> wrote:

> diff --git a/package/skeleton-init-openrc/skeleton-init-sysv.mk b/package/skeleton-init-openrc/skeleton-init-sysv.mk
> index 5ee2192093..bbe80071ae 100644
> --- a/package/skeleton-init-openrc/skeleton-init-sysv.mk
> +++ b/package/skeleton-init-openrc/skeleton-init-sysv.mk
> @@ -15,8 +15,23 @@ SKELETON_INIT_OPENRC_DEPENDENCIES = skeleton-init-common
>  
>  SKELETON_INIT_OPENRC_PROVIDES = skeleton
>  
> +ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
> +# Comment /dev/root entry in fstab. When openrc does not find fstab entry for
> +# "/", it will try to remount "/" as "rw".
> +define SKELETON_INIT_OPENRC_ROOT_RO_OR_RW
> +	$(SED) '/^ *\/dev\/root.*$$/s~^~#~' $(TARGET_DIR)/etc/fstab
> +endef
> +else
> +# Uncomment /dev/root entry in fstab which has "ro" option so openrc notices
> +# it and doesn't remount root to rw.
> +define SKELETON_INIT_OPENRC_ROOT_RO_OR_RW
> +	$(SED) '/^# *\/dev\/root.*$$/s~^#\+~~' $(TARGET_DIR)/etc/fstab
> +endef
> +endif # BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW

Why are you handling the ro/rw rootfs topic from skeleton-init-sysv.mk,
but the getty topic is handled from openrc.mk (in PATCH 04/13). It
doesn't seem very consistent.

Thomas
Michał Łyszczek May 19, 2019, 8:32 a.m. UTC | #2
Hello Thomas
On 2019-05-18 23:22:40, Thomas Petazzoni wrote:
> Hello,
> 
> On Sun, 12 May 2019 21:55:43 +0200
> Michał Łyszczek <michal.lyszczek@bofc.pl> wrote:
> 
> > diff --git a/package/skeleton-init-openrc/skeleton-init-sysv.mk b/package/skeleton-init-openrc/skeleton-init-sysv.mk
> > index 5ee2192093..bbe80071ae 100644
> > --- a/package/skeleton-init-openrc/skeleton-init-sysv.mk
> > +++ b/package/skeleton-init-openrc/skeleton-init-sysv.mk
> > @@ -15,8 +15,23 @@ SKELETON_INIT_OPENRC_DEPENDENCIES = skeleton-init-common
> >  
> >  SKELETON_INIT_OPENRC_PROVIDES = skeleton
> >  
> > +ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
> > +# Comment /dev/root entry in fstab. When openrc does not find fstab entry for
> > +# "/", it will try to remount "/" as "rw".
> > +define SKELETON_INIT_OPENRC_ROOT_RO_OR_RW
> > +	$(SED) '/^ *\/dev\/root.*$$/s~^~#~' $(TARGET_DIR)/etc/fstab
> > +endef
> > +else
> > +# Uncomment /dev/root entry in fstab which has "ro" option so openrc notices
> > +# it and doesn't remount root to rw.
> > +define SKELETON_INIT_OPENRC_ROOT_RO_OR_RW
> > +	$(SED) '/^# *\/dev\/root.*$$/s~^#\+~~' $(TARGET_DIR)/etc/fstab
> > +endef
> > +endif # BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
> 
> Why are you handling the ro/rw rootfs topic from skeleton-init-sysv.mk,
> but the getty topic is handled from openrc.mk (in PATCH 04/13). It
> doesn't seem very consistent.

I just followed already established rules here (based on systemd package).
BR2_TARGET_GENERIC_GETTY is in systemd.mk, and
BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is in skeleton-init-systemd.mk
Michał Łyszczek July 23, 2019, 10:50 a.m. UTC | #3
Hello Thomas
On 2019-05-19 10:32:27, michal.lyszczek@bofc.pl wrote:
> Hello Thomas
> On 2019-05-18 23:22:40, Thomas Petazzoni wrote:
> > Hello,
> > 
> > On Sun, 12 May 2019 21:55:43 +0200
> > Michał Łyszczek <michal.lyszczek@bofc.pl> wrote:
> > 
> > > diff --git a/package/skeleton-init-openrc/skeleton-init-sysv.mk b/package/skeleton-init-openrc/skeleton-init-sysv.mk
> > > index 5ee2192093..bbe80071ae 100644
> > > --- a/package/skeleton-init-openrc/skeleton-init-sysv.mk
> > > +++ b/package/skeleton-init-openrc/skeleton-init-sysv.mk
> > > @@ -15,8 +15,23 @@ SKELETON_INIT_OPENRC_DEPENDENCIES = skeleton-init-common
> > >  
> > >  SKELETON_INIT_OPENRC_PROVIDES = skeleton
> > >  
> > > +ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
> > > +# Comment /dev/root entry in fstab. When openrc does not find fstab entry for
> > > +# "/", it will try to remount "/" as "rw".
> > > +define SKELETON_INIT_OPENRC_ROOT_RO_OR_RW
> > > +	$(SED) '/^ *\/dev\/root.*$$/s~^~#~' $(TARGET_DIR)/etc/fstab
> > > +endef
> > > +else
> > > +# Uncomment /dev/root entry in fstab which has "ro" option so openrc notices
> > > +# it and doesn't remount root to rw.
> > > +define SKELETON_INIT_OPENRC_ROOT_RO_OR_RW
> > > +	$(SED) '/^# *\/dev\/root.*$$/s~^#\+~~' $(TARGET_DIR)/etc/fstab
> > > +endef
> > > +endif # BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
> > 
> > Why are you handling the ro/rw rootfs topic from skeleton-init-sysv.mk,
> > but the getty topic is handled from openrc.mk (in PATCH 04/13). It
> > doesn't seem very consistent.
> 
> I just followed already established rules here (based on systemd package).
> BR2_TARGET_GENERIC_GETTY is in systemd.mk, and
> BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is in skeleton-init-systemd.mk

It's been some time and openrc has been only partialy merged. Any thoughts
about my last comment? Do you want me to move ro/rw handling to openrc.mk
or leave it as it is (to be consistent with systemd.mk)?
diff mbox series

Patch

diff --git a/package/skeleton-init-openrc/skeleton-init-sysv.mk b/package/skeleton-init-openrc/skeleton-init-sysv.mk
index 5ee2192093..bbe80071ae 100644
--- a/package/skeleton-init-openrc/skeleton-init-sysv.mk
+++ b/package/skeleton-init-openrc/skeleton-init-sysv.mk
@@ -15,8 +15,23 @@  SKELETON_INIT_OPENRC_DEPENDENCIES = skeleton-init-common
 
 SKELETON_INIT_OPENRC_PROVIDES = skeleton
 
+ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
+# Comment /dev/root entry in fstab. When openrc does not find fstab entry for
+# "/", it will try to remount "/" as "rw".
+define SKELETON_INIT_OPENRC_ROOT_RO_OR_RW
+	$(SED) '/^ *\/dev\/root.*$$/s~^~#~' $(TARGET_DIR)/etc/fstab
+endef
+else
+# Uncomment /dev/root entry in fstab which has "ro" option so openrc notices
+# it and doesn't remount root to rw.
+define SKELETON_INIT_OPENRC_ROOT_RO_OR_RW
+	$(SED) '/^# *\/dev\/root.*$$/s~^#\+~~' $(TARGET_DIR)/etc/fstab
+endef
+endif # BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
+
 define SKELETON_INIT_OPENRC_INSTALL_TARGET_CMDS
 	$(call SYSTEM_RSYNC,$(SKELETON_INIT_OPENRC_PKGDIR)/skeleton,$(TARGET_DIR))
+	$(SKELETON_INIT_OPENRC_ROOT_RO_OR_RW)
 endef
 
 $(eval $(generic-package))
diff --git a/package/skeleton-init-openrc/skeleton/etc/fstab b/package/skeleton-init-openrc/skeleton/etc/fstab
index 3ec96cf634..21cf49ba5a 100644
--- a/package/skeleton-init-openrc/skeleton/etc/fstab
+++ b/package/skeleton-init-openrc/skeleton/etc/fstab
@@ -1,3 +1,4 @@ 
 # <file system>	<mount pt>	<type>	<options>	<dump>	<pass>
+/dev/root	/		ext2	ro,noauto	0	0
 tmpfs		/tmp		tmpfs	mode=1777	0	0
 tmpfs		/run		tmpfs	mode=0755,nosuid,nodev	0	0