Skip to contentSkip to conversation

system: properly handle systemd as init system (branch yem/systemd-skeleton)

PATCH Superseded Yann E. MORIN 4 participants 73 messages Jun 22, 2016 – Jul 17, 2016 VFS

lore
Share & tools
lore
#0 lore raw

v2 cover system: properly handle systemd as init system (branch yem/systemd-skeleton)

Hello All!

This series is a proposal to fix our handling of systemd as an init system.

Our default skeleton is not well suited for systemd:

- we have /var/log a symlink to /tmp/log, but the way systemd starts hides the journals:
- start systemd-journald, stores journals in /tmp/log/ (because of the redirection above)
- mounts a tmpfs over /tmp, thus hidding the journals.

- on a read-only rootfs, systemd expects /var to be read-write, which we do not provide.

All of this sounds trivial, but fixing it is definitely not.

The overall idea is that we need different skeletons, one for each of the init systems (and as can be seen later, there is in fact none for systeemd).

Also, the organisation of the rootfs is different between the different init systems, with different mount points in some cases.

First comes a long and rather boring sub-series aimed at preparing for the various skeletons, with patches 1-11 some cleanups and re-factoring of the system sub-menu, plus limiting our tweaks in the custom skeleton.

Then comes more in-depth preparatory works in the core infra: allow packages to explicitly declare target-finalize hooks, or avoid the dependency on the skeleton.

Third, we split the current skeleton into various parts: one skeleton for the sysv-like init systems (busybox, sysv-init), one skeleton for sysv-like network management (because shared between sysv and systemd-without-networkd) and a third to handle the custom skeleton.

Finally, we introduce the skeleton for systemd, add missing pieces it really needs (timezones) and make it work flawlessly on a read-only rootfs.

Please have a look at the various commit logs for more in-depth explanations for the vairious pieces.

With this series, I was able to build and run without issues those combinations:

init system rootfs DHCP? target
----------------------------------------------------
busybox ext4 no rpi0
busybox ext4 eth0 rpi1-B
busybox squashfs no rpi0
busybox squashfs eth0 rpi1-B

  * systemd-minimal     ext4        no      rpi0
    systemd-minimal     ext4        eth0    rpi1-B
    systemd-minimal     squashfs    no      rpi0
    systemd-minimal     squashfs    eth0    rpi1-B
 ** systemd-full        ext4        no      rpi0
    systemd-full        ext4        eth0    rpi1-B
    systemd-full        squashfs    no      rpi0
    systemd-full        squashfs    eth0    rpi1-B

* systemd-minimal: only what gets selected automatically when systemd is used as init system, with all other options unset

** systemd-full: all systemd options enabled

To be noted for future work:

- systemd-230 (which we currently have) has dropped support for legacy

    libs, patch should be trivial;

- systemd-230 also ditched systemd-bootchartd, which is now a separate package; until recently it did not compile against systemd-230; its repository was recently updated to supposedly fix this issue, but I did not have time to test;

- I also had a look at all the pending patches on the list; I'll handle them after this series has been completed (i.e. applied after any necessary rework). I don;t want to carry a series with tens and tens of patches... ;-)

Changes v1 -> v2:
- enhance the commit logs

Regards,
Yann E. MORIN.

The following changes since commit aed1ac36ecfc834618a0210e70bfbbff68c02e51

strace: fix build with kernel headers before v3.11 (2016-06-22 17:01:07 +0200)

are available in the git repository at:

https://git.buildroot.org/~ymorin/git/buildroot

for you to fetch changes up to f1c505051eef3830d3cea769967f7218bd70e7c9

system: allow DHCP interface with systemd-networkd (2016-06-22 19:29:15 +0200)

----------------------------------------------------------------
Yann E. MORIN (24):
package/skeleton: remove useless .empty file
system: sysvinit only selects busybox-show-others if busybox is enabled package/skeleton: respect variables namespace system/skeleton: update etc/mtab with a more sensible link
system: systemd only really supports a R/W rootfs package/systemd: disabling tty1 getty is a post-install hook
system: provide no default for custom skeleton path
system: move the rootfs skeleton choice
system: do not handle network settings for custom skeleton package/perl: use dummy hostname
system: do not set hostname and issue for custom skeleton core/pkg-generic: add variable to skip skeleton dependency package/skeleton: add macro to rsync skeleton directory core/pkg-generic: allow packages to declare target-finalize hooks
packages: use the <PKG>_TARGET_FINALIZE_HOOKS package/skeleton: split into sysv and custom skeleton package/skeleton: make it a virtual package package/skeleton-sysv: split into skeleton-common
system: split skeleton
package/skeleton-systemd: new package
system/systemd: needs timezone
fs: add pre- and post-command hooks
system: make systemd work on a read-only rootfs
system: allow DHCP interface with systemd-networkd

 docs/manual/adding-packages-hooks.txt              |   7 +
 fs/common.mk                                       |   4 +
 package/Config.in                                  |   4 +
 package/google-breakpad/google-breakpad.mk         |   6 +-
 package/libglib2/libglib2.mk                       |   6 +-
 package/libgtk3/libgtk3.mk                         |   4 +-
 package/luarocks/luarocks.mk                       |   3 +-
 package/perl/perl.mk                               |   6 +-
 package/pkg-generic.mk                             |  13 +-
 package/python/python.mk                           |  10 +-
 package/python3/python3.mk                         |  10 +-
 package/skeleton-common/Config.in                  |   2 +
 package/skeleton-common/skeleton-common.mk         |  99 ++++++++++
 package/skeleton-custom/Config.in                  |   6 +
 package/skeleton-custom/skeleton-custom.mk         | 114 +++++++++++
 package/skeleton-systemd/Config.in                 |   7 +
 package/skeleton-systemd/skeleton-systemd.mk       | 107 +++++++++++
 package/skeleton-sysv/Config.in                    |   7 +
 package/skeleton-sysv/skeleton-sysv.mk             |  79 ++++++++
 package/skeleton/Config.in                         |  11 ++
 package/skeleton/skeleton.mk                       | 213 +++------------------
 package/systemd/systemd.mk                         |  12 +-
 system/Config.in                                   |  78 ++++----
 .../etc/network/if-down.d}/.empty                  |   0
 .../etc/network/if-post-down.d}/.empty             |   0
 .../etc/network/if-pre-up.d/wait_iface             |   0
 .../etc/network/if-up.d}/.empty                    |   0
 system/{skeleton => skeleton-sysv}/dev/log         |   0
 .../if-down.d => skeleton-sysv/dev/pts}/.empty     |   0
 system/{skeleton => skeleton-sysv}/dev/shm/.empty  |   0
 system/{skeleton => skeleton-sysv}/etc/fstab       |   0
 system/{skeleton => skeleton-sysv}/etc/resolv.conf |   0
 system/{skeleton => skeleton-sysv}/var/cache       |   0
 system/{skeleton => skeleton-sysv}/var/lib/misc    |   0
 system/{skeleton => skeleton-sysv}/var/lock        |   0
 system/{skeleton => skeleton-sysv}/var/log         |   0
 system/{skeleton => skeleton-sysv}/var/run         |   0
 system/{skeleton => skeleton-sysv}/var/spool       |   0
 system/{skeleton => skeleton-sysv}/var/tmp         |   0
 system/skeleton/dev/{pts => }/.empty               |   0
 system/skeleton/etc/mtab                           |   2 +-
 41 files changed, 550 insertions(+), 260 deletions(-)
 create mode 100644 package/skeleton-common/Config.in
 create mode 100644 package/skeleton-common/skeleton-common.mk
 create mode 100644 package/skeleton-custom/Config.in
 create mode 100644 package/skeleton-custom/skeleton-custom.mk
 create mode 100644 package/skeleton-systemd/Config.in
 create mode 100644 package/skeleton-systemd/skeleton-systemd.mk
 create mode 100644 package/skeleton-sysv/Config.in
 create mode 100644 package/skeleton-sysv/skeleton-sysv.mk
 rename system/{skeleton/etc/network/if-up.d => skeleton-net/etc/network/if-down.d}/.empty (100%)
 rename system/{skeleton/etc/network/if-pre-up.d => skeleton-net/etc/network/if-post-down.d}/.empty (100%)
 rename system/{skeleton => skeleton-net}/etc/network/if-pre-up.d/wait_iface (100%)
 rename system/{skeleton/etc/network/if-post-down.d => skeleton-net/etc/network/if-up.d}/.empty (100%)
 rename system/{skeleton => skeleton-sysv}/dev/log (100%)
 rename system/{skeleton/etc/network/if-down.d => skeleton-sysv/dev/pts}/.empty (100%)
 rename system/{skeleton => skeleton-sysv}/dev/shm/.empty (100%)
 rename system/{skeleton => skeleton-sysv}/etc/fstab (100%)
 rename system/{skeleton => skeleton-sysv}/etc/resolv.conf (100%)
 rename system/{skeleton => skeleton-sysv}/var/cache (100%)
 rename system/{skeleton => skeleton-sysv}/var/lib/misc (100%)
 rename system/{skeleton => skeleton-sysv}/var/lock (100%)
 rename system/{skeleton => skeleton-sysv}/var/log (100%)
 rename system/{skeleton => skeleton-sysv}/var/run (100%)
 rename system/{skeleton => skeleton-sysv}/var/spool (100%)
 rename system/{skeleton => skeleton-sysv}/var/tmp (100%)
 rename system/skeleton/dev/{pts => }/.empty (100%)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v2 1/24 package/skeleton: remove useless .empty file

We now have a real file in that directory, so we do not need a .empty placeholder.

---
 system/skeleton/etc/network/if-pre-up.d/.empty | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 system/skeleton/etc/network/if-pre-up.d/.empty
system/skeleton/etc/network/if-pre-up.d/.empty deleted +0 -0
deleted file mode 100644
index e69de29..0000000
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/24 package/skeleton: remove useless .empty file

Quoted 4 lines · Yann E. MORIN

We now have a real file in that directory, so we do not need a .empty placeholder.

Regards,
Arnout

Quoted 9 lines
---
 system/skeleton/etc/network/if-pre-up.d/.empty | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 system/skeleton/etc/network/if-pre-up.d/.empty
system/skeleton/etc/network/if-pre-up.d/.empty deleted +0 -0
deleted file mode 100644
index e69de29..0000000
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

PATCH v2 1/24 package/skeleton: remove useless .empty file

In reply to Yann E. MORIN

Hello,

Quoted 8 lines · Yann E. MORIN

We now have a real file in that directory, so we do not need a .empty placeholder.

---
 system/skeleton/etc/network/if-pre-up.d/.empty | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 system/skeleton/etc/network/if-pre-up.d/.empty

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH v2 2/24 system: sysvinit only selects busybox-show-others if busybox is enabled

In reply to Yann E. MORIN

BR2_PACKAGE_BUSYBOX_SHOW_OTHERS is a bit special. When Busybox is enabled, it is a Busybox option. When Busybox is not enabled, it is a stand-alone option, forcibly enabled.

So we can safely 'select' it without ensuring (via a 'depends on' or another 'select') that Busybox is enabled.

However, the name of this option does not express the fact that it is safe to select it without checking Busybox, which can lead to a bit of time-consuming head-scratching.

To avoid future puzzlement from an unsuspecting observer, consider this to be a Busybox option, and only select it when Busybox is enabled.

Cc Thomas Petazzoni <[email protected]>
Cc Peter Korsgaard <[email protected]>

---
Changes v1 -> v2:
- only select if busybox is enabled (Thomas)

---
Hopefully, this will avoid people to go hunting like I did, and loose a few precious minutes of hair-pulling... ;-]

---
 system/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/Config.in +1 -1
index 9441467..2d20230 100644
@@ -74,7 +74,7 @@ config BR2_INIT_BUSYBOX
 
 config BR2_INIT_SYSV
 	bool "systemV"
-	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # sysvinit
+	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS if BR2_PACKAGE_BUSYBOX # sysvinit
 	select BR2_PACKAGE_INITSCRIPTS
 	select BR2_PACKAGE_SYSVINIT
 
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 2/24 system: sysvinit only selects busybox-show-others if busybox is enabled

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 11 lines

BR2_PACKAGE_BUSYBOX_SHOW_OTHERS is a bit special. When Busybox is enabled, it is a Busybox option. When Busybox is not enabled, it is a stand-alone option, forcibly enabled.

So we can safely 'select' it without ensuring (via a 'depends on' or another 'select') that Busybox is enabled.

However, the name of this option does not express the fact that it is safe to select it without checking Busybox, which can lead to a bit of time-consuming head-scratching.

Quoted 6 lines

To avoid future puzzlement from an unsuspecting observer, consider this to be a Busybox option, and only select it when Busybox is enabled.

Cc Thomas Petazzoni <[email protected]>
Cc Peter Korsgaard <[email protected]>

Not related to your patch but should we do the same change for tovid and systemd packages which select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS ?

Best regards,
Romain

Quoted 26 lines

---
Changes v1 -> v2:
- only select if busybox is enabled (Thomas)

---
Hopefully, this will avoid people to go hunting like I did, and loose a few precious minutes of hair-pulling... ;-]

---
 system/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/Config.in +1 -1
index 9441467..2d20230 100644
@@ -74,7 +74,7 @@ config BR2_INIT_BUSYBOX
 
 config BR2_INIT_SYSV
 	bool "systemV"
-	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # sysvinit
+	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS if BR2_PACKAGE_BUSYBOX # sysvinit
 	select BR2_PACKAGE_INITSCRIPTS
 	select BR2_PACKAGE_SYSVINIT
 
#6 lore raw

PATCH v2 2/24 system: sysvinit only selects busybox-show-others if busybox is enabled

Romain, All,

On 2016-07-03 09:53 +0200, Romain Naour spake thusly:

Quoted 15 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 14 lines

BR2_PACKAGE_BUSYBOX_SHOW_OTHERS is a bit special. When Busybox is enabled, it is a Busybox option. When Busybox is not enabled, it is a stand-alone option, forcibly enabled.

So we can safely 'select' it without ensuring (via a 'depends on' or another 'select') that Busybox is enabled.

However, the name of this option does not express the fact that it is safe to select it without checking Busybox, which can lead to a bit of time-consuming head-scratching.

To avoid future puzzlement from an unsuspecting observer, consider this to be a Busybox option, and only select it when Busybox is enabled.

Quoted 8 lines
Quoted 3 lines
Cc Thomas Petazzoni <[email protected]>
Cc Peter Korsgaard <[email protected]>

Not related to your patch but should we do the same change for tovid and systemd packages which select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS ?

Indeed, but in retrospect, I think I should drop this patch altogether...

This option is really special, so I think a better solution would probably to add a big fat comment above that option that basically states that:

# This option is not an option of Busybox, it canbe selected even # if Busybox is not enabled.

I'll do that in a follow-up series.

Thanks for the review! ;-)

Regards,
Yann E. MORIN.

Quoted 30 lines

Best regards,
Romain

Quoted 26 lines

---
Changes v1 -> v2:
- only select if busybox is enabled (Thomas)

---
Hopefully, this will avoid people to go hunting like I did, and loose a few precious minutes of hair-pulling... ;-]

---
 system/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/Config.in +1 -1
index 9441467..2d20230 100644
@@ -74,7 +74,7 @@ config BR2_INIT_BUSYBOX
 
 config BR2_INIT_SYSV
 	bool "systemV"
-	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # sysvinit
+	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS if BR2_PACKAGE_BUSYBOX # sysvinit
 	select BR2_PACKAGE_INITSCRIPTS
 	select BR2_PACKAGE_SYSVINIT
 
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

PATCH v2 2/24 system: sysvinit only selects busybox-show-others if busybox is enabled

Hello,

Quoted 2 lines · Yann E. MORIN

Indeed, but in retrospect, I think I should drop this patch altogether...

Following this, I've marked this patch as Rejected. It's indeed simpler to just select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS, even if technically when Busybox is disabled, this symbol is always set to 'y'.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#8 lore raw

PATCH v2 3/24 package/skeleton: respect variables namespace

In reply to Yann E. MORIN

In makefiles, variables have global scope. We traditionally ensure that we get no name clashing by prefixing all variables with the package name.

Currently, this is not the case in the skeleton package, for historical reasons (code snippets copied over from the common Makefiles). We currently have a mix of naming for the variables:
- some are indeed prefixed with SKELETON_
- some are prefixed with SYSTEM_
- some are prefixed with both
- some are not prefixed

Clean up these discrepancies, and prefix all variables with just SKELETON_ and drop the SYSTEM_ prefix.

Also include SET_ in all variables that do set something (getty) for consistency across all the variables.

---
 package/skeleton/skeleton.mk | 60 ++++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 30 deletions(-)
package/skeleton/skeleton.mk +30 -30
index 4e3cdc6..3852448 100644
@@ -121,24 +121,24 @@ SKELETON_TARGET_GENERIC_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TE
 SKELETON_TARGET_GENERIC_GETTY_OPTIONS = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_OPTIONS))
 
 ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME),)
-define SYSTEM_HOSTNAME
+define SKELETON_SET_HOSTNAME
 	mkdir -p $(TARGET_DIR)/etc
 	echo "$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
 	$(SED) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
 		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
 endef
-TARGET_FINALIZE_HOOKS += SYSTEM_HOSTNAME
+TARGET_FINALIZE_HOOKS += SKELETON_SET_HOSTNAME
 endif
 
 ifneq ($(SKELETON_TARGET_GENERIC_ISSUE),)
-define SYSTEM_ISSUE
+define SKELETON_SET_ISSUE
 	mkdir -p $(TARGET_DIR)/etc
 	echo "$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue
 endef
-TARGET_FINALIZE_HOOKS += SYSTEM_ISSUE
+TARGET_FINALIZE_HOOKS += SKELETON_SET_ISSUE
 endif
 
-define SET_NETWORK_LOCALHOST
+define SKELETON_SET_NETWORK_LOCALHOST
 	( \
 		echo "# interface file auto-generated by buildroot"; \
 		echo ;                                               \
@@ -147,14 +147,14 @@ define SET_NETWORK_LOCALHOST
 	) > $(TARGET_DIR)/etc/network/interfaces
 endef
 
-NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP))
+SKELETON_NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP))
 
-ifneq ($(NETWORK_DHCP_IFACE),)
-define SET_NETWORK_DHCP
+ifneq ($(SKELETON_NETWORK_DHCP_IFACE),)
+define SKELETON_SET_NETWORK_DHCP
 	( \
 		echo ;                                               \
-		echo "auto $(NETWORK_DHCP_IFACE)";                   \
-		echo "iface $(NETWORK_DHCP_IFACE) inet dhcp";        \
+		echo "auto $(SKELETON_NETWORK_DHCP_IFACE)";                   \
+		echo "iface $(SKELETON_NETWORK_DHCP_IFACE) inet dhcp";        \
 		echo "	pre-up /etc/network/nfs_check";              \
 		echo "	wait-delay 15";                              \
 	) >> $(TARGET_DIR)/etc/network/interfaces
@@ -163,13 +163,13 @@ define SET_NETWORK_DHCP
 endef
 endif
 
-define SET_NETWORK
+define SKELETON_SET_NETWORK
 	mkdir -p $(TARGET_DIR)/etc/network/
-	$(SET_NETWORK_LOCALHOST)
-	$(SET_NETWORK_DHCP)
+	$(SKELETON_SET_NETWORK_LOCALHOST)
+	$(SKELETON_SET_NETWORK_DHCP)
 endef
 
-TARGET_FINALIZE_HOOKS += SET_NETWORK
+TARGET_FINALIZE_HOOKS += SKELETON_SET_NETWORK
 
 # The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
 # default skeleton.
@@ -177,66 +177,66 @@ ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
 
 ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
 ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
-SYSTEM_ROOT_PASSWORD =
+SKELETON_ROOT_PASSWORD =
 else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)),)
-SYSTEM_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
+SKELETON_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
 else
 SKELETON_DEPENDENCIES += host-mkpasswd
 # This variable will only be evaluated in the finalize stage, so we can
 # be sure that host-mkpasswd will have already been built by that time.
-SYSTEM_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
+SKELETON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
 endif
 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
-SYSTEM_ROOT_PASSWORD = "*"
+SKELETON_ROOT_PASSWORD = "*"
 endif
 
-define SKELETON_SYSTEM_SET_ROOT_PASSWD
-	$(SED) s,^root:[^:]*:,root:$(SYSTEM_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
+define SKELETON_SET_ROOT_PASSWD
+	$(SED) s,^root:[^:]*:,root:$(SKELETON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
 endef
-TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_SET_ROOT_PASSWD
+TARGET_FINALIZE_HOOKS += SKELETON_SET_ROOT_PASSWD
 
 ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
-define SKELETON_SYSTEM_BIN_SH
+define SKELETON_BIN_SH
 	rm -f $(TARGET_DIR)/bin/sh
 endef
 else
-define SKELETON_SYSTEM_BIN_SH
+define SKELETON_BIN_SH
 	ln -sf $(SKELETON_TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
 endef
 endif
-TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_BIN_SH
+TARGET_FINALIZE_HOOKS += SKELETON_BIN_SH
 
 ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
 ifeq ($(BR2_INIT_SYSV),y)
 # In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
 # skip the "tty" part and keep only the remaining.
-define SKELETON_SYSTEM_GETTY
+define SKELETON_SET_GETTY
 	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(shell echo $(SKELETON_TARGET_GENERIC_GETTY_PORT) | tail -c+4)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
 		$(TARGET_DIR)/etc/inittab
 endef
 else ifeq ($(BR2_INIT_BUSYBOX),y)
 # Add getty to busybox inittab
-define SKELETON_SYSTEM_GETTY
+define SKELETON_SET_GETTY
 	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(SKELETON_TARGET_GENERIC_GETTY_PORT)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
 		$(TARGET_DIR)/etc/inittab
 endef
 endif
-TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_GETTY
+TARGET_FINALIZE_HOOKS += SKELETON_SET_GETTY
 endif
 
 ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y)
 ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
 # Find commented line, if any, and remove leading '#'s
-define SKELETON_SYSTEM_REMOUNT_RW
+define SKELETON_REMOUNT_RW
 	$(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
 endef
 else
 # Find uncommented line, if any, and add a leading '#'
-define SKELETON_SYSTEM_REMOUNT_RW
+define SKELETON_REMOUNT_RW
 	$(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
 endef
 endif
-TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_REMOUNT_RW
+TARGET_FINALIZE_HOOKS += SKELETON_REMOUNT_RW
 endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
Signature · 1 line
2.7.4
#9 lore raw

PATCH v2 3/24 package/skeleton: respect variables namespace

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 12 lines

In makefiles, variables have global scope. We traditionally ensure that we get no name clashing by prefixing all variables with the package name.

Currently, this is not the case in the skeleton package, for historical reasons (code snippets copied over from the common Makefiles). We currently have a mix of naming for the variables:
- some are indeed prefixed with SKELETON_
- some are prefixed with SYSTEM_
- some are prefixed with both
- some are not prefixed

Quoted 7 lines

Clean up these discrepancies, and prefix all variables with just SKELETON_ and drop the SYSTEM_ prefix.

Also include SET_ in all variables that do set something (getty) for consistency across all the variables.

Best regards,
Romain

Quoted 160 lines
---
 package/skeleton/skeleton.mk | 60 ++++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 30 deletions(-)
package/skeleton/skeleton.mk +30 -30
index 4e3cdc6..3852448 100644
@@ -121,24 +121,24 @@ SKELETON_TARGET_GENERIC_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TE
 SKELETON_TARGET_GENERIC_GETTY_OPTIONS = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_OPTIONS))
 
 ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME),)
-define SYSTEM_HOSTNAME
+define SKELETON_SET_HOSTNAME
 	mkdir -p $(TARGET_DIR)/etc
 	echo "$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
 	$(SED) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
 		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
 endef
-TARGET_FINALIZE_HOOKS += SYSTEM_HOSTNAME
+TARGET_FINALIZE_HOOKS += SKELETON_SET_HOSTNAME
 endif
 
 ifneq ($(SKELETON_TARGET_GENERIC_ISSUE),)
-define SYSTEM_ISSUE
+define SKELETON_SET_ISSUE
 	mkdir -p $(TARGET_DIR)/etc
 	echo "$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue
 endef
-TARGET_FINALIZE_HOOKS += SYSTEM_ISSUE
+TARGET_FINALIZE_HOOKS += SKELETON_SET_ISSUE
 endif
 
-define SET_NETWORK_LOCALHOST
+define SKELETON_SET_NETWORK_LOCALHOST
 	( \
 		echo "# interface file auto-generated by buildroot"; \
 		echo ;                                               \
@@ -147,14 +147,14 @@ define SET_NETWORK_LOCALHOST
 	) > $(TARGET_DIR)/etc/network/interfaces
 endef
 
-NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP))
+SKELETON_NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP))
 
-ifneq ($(NETWORK_DHCP_IFACE),)
-define SET_NETWORK_DHCP
+ifneq ($(SKELETON_NETWORK_DHCP_IFACE),)
+define SKELETON_SET_NETWORK_DHCP
 	( \
 		echo ;                                               \
-		echo "auto $(NETWORK_DHCP_IFACE)";                   \
-		echo "iface $(NETWORK_DHCP_IFACE) inet dhcp";        \
+		echo "auto $(SKELETON_NETWORK_DHCP_IFACE)";                   \
+		echo "iface $(SKELETON_NETWORK_DHCP_IFACE) inet dhcp";        \
 		echo "	pre-up /etc/network/nfs_check";              \
 		echo "	wait-delay 15";                              \
 	) >> $(TARGET_DIR)/etc/network/interfaces
@@ -163,13 +163,13 @@ define SET_NETWORK_DHCP
 endef
 endif
 
-define SET_NETWORK
+define SKELETON_SET_NETWORK
 	mkdir -p $(TARGET_DIR)/etc/network/
-	$(SET_NETWORK_LOCALHOST)
-	$(SET_NETWORK_DHCP)
+	$(SKELETON_SET_NETWORK_LOCALHOST)
+	$(SKELETON_SET_NETWORK_DHCP)
 endef
 
-TARGET_FINALIZE_HOOKS += SET_NETWORK
+TARGET_FINALIZE_HOOKS += SKELETON_SET_NETWORK
 
 # The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
 # default skeleton.
@@ -177,66 +177,66 @@ ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
 
 ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
 ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
-SYSTEM_ROOT_PASSWORD =
+SKELETON_ROOT_PASSWORD =
 else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)),)
-SYSTEM_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
+SKELETON_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
 else
 SKELETON_DEPENDENCIES += host-mkpasswd
 # This variable will only be evaluated in the finalize stage, so we can
 # be sure that host-mkpasswd will have already been built by that time.
-SYSTEM_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
+SKELETON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
 endif
 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
-SYSTEM_ROOT_PASSWORD = "*"
+SKELETON_ROOT_PASSWORD = "*"
 endif
 
-define SKELETON_SYSTEM_SET_ROOT_PASSWD
-	$(SED) s,^root:[^:]*:,root:$(SYSTEM_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
+define SKELETON_SET_ROOT_PASSWD
+	$(SED) s,^root:[^:]*:,root:$(SKELETON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
 endef
-TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_SET_ROOT_PASSWD
+TARGET_FINALIZE_HOOKS += SKELETON_SET_ROOT_PASSWD
 
 ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
-define SKELETON_SYSTEM_BIN_SH
+define SKELETON_BIN_SH
 	rm -f $(TARGET_DIR)/bin/sh
 endef
 else
-define SKELETON_SYSTEM_BIN_SH
+define SKELETON_BIN_SH
 	ln -sf $(SKELETON_TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
 endef
 endif
-TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_BIN_SH
+TARGET_FINALIZE_HOOKS += SKELETON_BIN_SH
 
 ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
 ifeq ($(BR2_INIT_SYSV),y)
 # In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
 # skip the "tty" part and keep only the remaining.
-define SKELETON_SYSTEM_GETTY
+define SKELETON_SET_GETTY
 	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(shell echo $(SKELETON_TARGET_GENERIC_GETTY_PORT) | tail -c+4)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
 		$(TARGET_DIR)/etc/inittab
 endef
 else ifeq ($(BR2_INIT_BUSYBOX),y)
 # Add getty to busybox inittab
-define SKELETON_SYSTEM_GETTY
+define SKELETON_SET_GETTY
 	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(SKELETON_TARGET_GENERIC_GETTY_PORT)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
 		$(TARGET_DIR)/etc/inittab
 endef
 endif
-TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_GETTY
+TARGET_FINALIZE_HOOKS += SKELETON_SET_GETTY
 endif
 
 ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y)
 ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
 # Find commented line, if any, and remove leading '#'s
-define SKELETON_SYSTEM_REMOUNT_RW
+define SKELETON_REMOUNT_RW
 	$(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
 endef
 else
 # Find uncommented line, if any, and add a leading '#'
-define SKELETON_SYSTEM_REMOUNT_RW
+define SKELETON_REMOUNT_RW
 	$(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
 endef
 endif
-TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_REMOUNT_RW
+TARGET_FINALIZE_HOOKS += SKELETON_REMOUNT_RW
 endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
#10 lore raw

PATCH v2 3/24 package/skeleton: respect variables namespace

In reply to Yann E. MORIN

Hello,

Quoted 15 lines · Yann E. MORIN

In makefiles, variables have global scope. We traditionally ensure that we get no name clashing by prefixing all variables with the package name.

Currently, this is not the case in the skeleton package, for historical reasons (code snippets copied over from the common Makefiles). We currently have a mix of naming for the variables:
- some are indeed prefixed with SKELETON_
- some are prefixed with SYSTEM_
- some are prefixed with both
- some are not prefixed

Clean up these discrepancies, and prefix all variables with just SKELETON_ and drop the SYSTEM_ prefix.

Quoted 7 lines

Also include SET_ in all variables that do set something (getty) for consistency across all the variables.

---
 package/skeleton/skeleton.mk | 60 ++++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#11 lore raw

PATCH v2 4/24 system/skeleton: update etc/mtab with a more sensible link

In reply to Yann E. MORIN

Currently, our /etc/mtab points to /proc/mounts. This was all neat so far, and was good for a sysv-like init system.

However, the way today is to point it at /proc/self/mounts, the per-process mount tab.

Additionnally, that's what systemd expects. If /etc/mtab is not a symlink to ../proc/self/mounts and the rootfs is readonly, systemd would whine loudly (and a service unit would be marked failed).

Since it works well for sysv-like init systems too, just use that.

---
 system/skeleton/etc/mtab | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/skeleton/etc/mtab +1 -1
index 4c0a094..5c4677a 120000
@@ -1 +1 @@
-/proc/mounts
\ No newline at end of file
+../proc/self/mounts
\ No newline at end of file
Signature · 1 line
2.7.4
#12 lore raw

PATCH v2 4/24 system/skeleton: update etc/mtab with a more sensible link

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 11 lines

Currently, our /etc/mtab points to /proc/mounts. This was all neat so far, and was good for a sysv-like init system.

However, the way today is to point it at /proc/self/mounts, the per-process mount tab.

Additionnally, that's what systemd expects. If /etc/mtab is not a symlink to ../proc/self/mounts and the rootfs is readonly, systemd would whine loudly (and a service unit would be marked failed).

Since it works well for sysv-like init systems too, just use that.

Best regards,
Romain

Quoted 16 lines
---
 system/skeleton/etc/mtab | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/skeleton/etc/mtab +1 -1
index 4c0a094..5c4677a 120000
@@ -1 +1 @@
-/proc/mounts
\ No newline at end of file
+../proc/self/mounts
\ No newline at end of file
#13 lore raw

PATCH v2 4/24 system/skeleton: update etc/mtab with a more sensible link

In reply to Yann E. MORIN
Quoted 6 lines · Yann E. MORIN

Currently, our /etc/mtab points to /proc/mounts. This was all neat so far, and was good for a sysv-like init system.

However, the way today is to point it at /proc/self/mounts, the per-process mount tab.

Quoted 7 lines

Additionnally, that's what systemd expects. If /etc/mtab is not a symlink to ../proc/self/mounts and the rootfs is readonly, systemd would whine loudly (and a service unit would be marked failed).

Since it works well for sysv-like init systems too, just use that.

I was worried a bit that /proc/self/mounts would need a relatively recent
kernel, but it already existed in 2.6.18 and probably earlier, so that's OK.

Then I worried about the relative instead of absolute symlink (I prefer an
absolute symlink for something like this), but is seems systemd really wants the relative link, so OK.

Regards,
Arnout

Quoted 14 lines
---
 system/skeleton/etc/mtab | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/skeleton/etc/mtab +1 -1
index 4c0a094..5c4677a 120000
@@ -1 +1 @@
-/proc/mounts
\ No newline at end of file
+../proc/self/mounts
\ No newline at end of file
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#14 lore raw

PATCH v2 4/24 system/skeleton: update etc/mtab with a more sensible link

In reply to Yann E. MORIN

Hello,

Quoted 10 lines · Yann E. MORIN

Currently, our /etc/mtab points to /proc/mounts. This was all neat so far, and was good for a sysv-like init system.

However, the way today is to point it at /proc/self/mounts, the per-process mount tab.

Additionnally, that's what systemd expects. If /etc/mtab is not a symlink to ../proc/self/mounts and the rootfs is readonly, systemd would whine loudly (and a service unit would be marked failed).

Quoted 6 lines

Since it works well for sysv-like init systems too, just use that.

---
 system/skeleton/etc/mtab | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#15 lore raw

PATCH v2 5/24 system: systemd only really supports a R/W rootfs

In reply to Yann E. MORIN

Supporting a R/O rootfs needs a bit more love to be fully operational. This will come in later patches...

---
 system/Config.in | 1 +
 1 file changed, 1 insertion(+)
system/Config.in +1 -0
index 2d20230..4f9f270 100644
@@ -94,6 +94,7 @@ config BR2_INIT_SYSTEMD
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
+	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 
 comment "systemd needs (e)glibc toolchain, headers >= 3.10"
 	depends on !(BR2_TOOLCHAIN_USES_GLIBC \
Signature · 1 line
2.7.4
#16 lore raw

PATCH v2 5/24 system: systemd only really supports a R/W rootfs

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 4 lines

Supporting a R/O rootfs needs a bit more love to be fully operational. This will come in later patches...

Best regards,
Romain

Quoted 17 lines
---
 system/Config.in | 1 +
 1 file changed, 1 insertion(+)
system/Config.in +1 -0
index 2d20230..4f9f270 100644
@@ -94,6 +94,7 @@ config BR2_INIT_SYSTEMD
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
+	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 
 comment "systemd needs (e)glibc toolchain, headers >= 3.10"
 	depends on !(BR2_TOOLCHAIN_USES_GLIBC \
#17 lore raw

PATCH v2 5/24 system: systemd only really supports a R/W rootfs

In reply to Yann E. MORIN

Hello,

Quoted 7 lines · Yann E. MORIN

Supporting a R/O rootfs needs a bit more love to be fully operational. This will come in later patches...

---
 system/Config.in | 1 +
 1 file changed, 1 insertion(+)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#18 lore raw

PATCH v2 6/24 package/systemd: disabling tty1 getty is a post-install hook

In reply to Yann E. MORIN

Currently, we disable the getty on tty1 as a "init" step. It looks better like it is a post-install hook.

---
 package/systemd/systemd.mk | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
package/systemd/systemd.mk +6 -6
index c0503ae..7e8fc0b 100644
@@ -211,10 +211,15 @@ define SYSTEMD_INSTALL_MACHINEID_HOOK
 	touch $(TARGET_DIR)/etc/machine-id
 endef
 
+define SYSTEMD_DISABLE_SERVICE_TTY1_HOOK
+	rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty at tty1.service
+endef
+
 SYSTEMD_POST_INSTALL_TARGET_HOOKS += \
 	SYSTEMD_INSTALL_INIT_HOOK \
 	SYSTEMD_INSTALL_MACHINEID_HOOK \
-	SYSTEMD_INSTALL_RESOLVCONF_HOOK
+	SYSTEMD_INSTALL_RESOLVCONF_HOOK \
+	SYSTEMD_DISABLE_SERVICE_TTY1_HOOK
 
 define SYSTEMD_USERS
 	systemd-journal -1 systemd-journal -1 * /var/log/journal - - Journal
@@ -228,10 +233,6 @@ define SYSTEMD_USERS
 	- - input -1 * - - - Input device group
 endef
 
-define SYSTEMD_DISABLE_SERVICE_TTY1
-	rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty at tty1.service
-endef
-
 ifneq ($(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)),)
 # systemd needs getty.service for VTs and serial-getty.service for serial ttys
 # also patch the file to use the correct baud-rate, the default baudrate is 115200 so look for that
@@ -252,7 +253,6 @@ endef
 endif
 
 define SYSTEMD_INSTALL_INIT_SYSTEMD
-	$(SYSTEMD_DISABLE_SERVICE_TTY1)
 	$(SYSTEMD_INSTALL_SERVICE_TTY)
 	$(SYSTEMD_INSTALL_SERVICE_NETWORK)
 	$(SYSTEMD_INSTALL_SERVICE_TIMESYNC)
Signature · 1 line
2.7.4
#19 lore raw

PATCH v2 6/24 package/systemd: disabling tty1 getty is a post-install hook

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 16 lines

Currently, we disable the getty on tty1 as a "init" step. It looks better like it is a post-install hook.

---
 package/systemd/systemd.mk | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
package/systemd/systemd.mk +0 -0
index c0503ae..7e8fc0b 100644
@@ -211,10 +211,15 @@ define SYSTEMD_INSTALL_MACHINEID_HOOK
 	touch $(TARGET_DIR)/etc/machine-id
 endef
 

package/systemd/systemd.mk define SYSTEMD_INSTALL_MACHINEID_HOOK · line 222

Quoted 10 lines
package/systemd/systemd.mk +6 -1
+define SYSTEMD_DISABLE_SERVICE_TTY1_HOOK
+	rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty at tty1.service
+endef
+
 SYSTEMD_POST_INSTALL_TARGET_HOOKS += \
 	SYSTEMD_INSTALL_INIT_HOOK \
 	SYSTEMD_INSTALL_MACHINEID_HOOK \
-	SYSTEMD_INSTALL_RESOLVCONF_HOOK
+	SYSTEMD_INSTALL_RESOLVCONF_HOOK \
+	SYSTEMD_DISABLE_SERVICE_TTY1_HOOK

It would be great to keep alphabetical order :)

Otherwise:

Best regards,
Romain

Quoted 23 lines
package/systemd/systemd.mk +0 -5
 define SYSTEMD_USERS
 	systemd-journal -1 systemd-journal -1 * /var/log/journal - - Journal
@@ -228,10 +233,6 @@ define SYSTEMD_USERS
 	- - input -1 * - - - Input device group
 endef
 
-define SYSTEMD_DISABLE_SERVICE_TTY1
-	rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty at tty1.service
-endef
-
 ifneq ($(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)),)
 # systemd needs getty.service for VTs and serial-getty.service for serial ttys
 # also patch the file to use the correct baud-rate, the default baudrate is 115200 so look for that
@@ -252,7 +253,6 @@ endef
 endif
 
 define SYSTEMD_INSTALL_INIT_SYSTEMD
-	$(SYSTEMD_DISABLE_SERVICE_TTY1)
 	$(SYSTEMD_INSTALL_SERVICE_TTY)
 	$(SYSTEMD_INSTALL_SERVICE_NETWORK)
 	$(SYSTEMD_INSTALL_SERVICE_TIMESYNC)
#20 lore raw

PATCH v2 6/24 package/systemd: disabling tty1 getty is a post-install hook

Romain, All,

On 2016-07-03 10:37 +0200, Romain Naour spake thusly:

Quoted 17 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 16 lines

Currently, we disable the getty on tty1 as a "init" step. It looks better like it is a post-install hook.

---
 package/systemd/systemd.mk | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
package/systemd/systemd.mk +0 -0
index c0503ae..7e8fc0b 100644
@@ -211,10 +211,15 @@ define SYSTEMD_INSTALL_MACHINEID_HOOK
 	touch $(TARGET_DIR)/etc/machine-id
 endef
 
Quoted 12 lines

package/systemd/systemd.mk define SYSTEMD_INSTALL_MACHINEID_HOOK · line 222

Quoted 10 lines
package/systemd/systemd.mk +6 -1
+define SYSTEMD_DISABLE_SERVICE_TTY1_HOOK
+	rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty at tty1.service
+endef
+
 SYSTEMD_POST_INSTALL_TARGET_HOOKS += \
 	SYSTEMD_INSTALL_INIT_HOOK \
 	SYSTEMD_INSTALL_MACHINEID_HOOK \
-	SYSTEMD_INSTALL_RESOLVCONF_HOOK
+	SYSTEMD_INSTALL_RESOLVCONF_HOOK \
+	SYSTEMD_DISABLE_SERVICE_TTY1_HOOK

It would be great to keep alphabetical order :)

Well, 'SERVICE' comes after 'RESOLVCONF', no?

OK, 'DISABLE' comes before 'INSTALL'... ;-)

I can switch, yes.

Quoted 2 lines

Otherwise:

OK, thanks! :-)

Regards,
Yann E. MORIN.

Quoted 28 lines

Best regards,
Romain

Quoted 23 lines
package/systemd/systemd.mk +0 -5
 define SYSTEMD_USERS
 	systemd-journal -1 systemd-journal -1 * /var/log/journal - - Journal
@@ -228,10 +233,6 @@ define SYSTEMD_USERS
 	- - input -1 * - - - Input device group
 endef
 
-define SYSTEMD_DISABLE_SERVICE_TTY1
-	rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty at tty1.service
-endef
-
 ifneq ($(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)),)
 # systemd needs getty.service for VTs and serial-getty.service for serial ttys
 # also patch the file to use the correct baud-rate, the default baudrate is 115200 so look for that
@@ -252,7 +253,6 @@ endef
 endif
 
 define SYSTEMD_INSTALL_INIT_SYSTEMD
-	$(SYSTEMD_DISABLE_SERVICE_TTY1)
 	$(SYSTEMD_INSTALL_SERVICE_TTY)
 	$(SYSTEMD_INSTALL_SERVICE_NETWORK)
 	$(SYSTEMD_INSTALL_SERVICE_TIMESYNC)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#21 lore raw

PATCH v2 6/24 package/systemd: disabling tty1 getty is a post-install hook

In reply to Yann E. MORIN

Hello,

Quoted 25 lines · Yann E. MORIN
package/systemd/systemd.mk +6 -5
+define SYSTEMD_DISABLE_SERVICE_TTY1_HOOK
+	rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty at tty1.service
+endef
+
 SYSTEMD_POST_INSTALL_TARGET_HOOKS += \
 	SYSTEMD_INSTALL_INIT_HOOK \
 	SYSTEMD_INSTALL_MACHINEID_HOOK \
-	SYSTEMD_INSTALL_RESOLVCONF_HOOK
+	SYSTEMD_INSTALL_RESOLVCONF_HOOK \
+	SYSTEMD_DISABLE_SERVICE_TTY1_HOOK
 
 define SYSTEMD_USERS
 	systemd-journal -1 systemd-journal -1 * /var/log/journal - - Journal
@@ -228,10 +233,6 @@ define SYSTEMD_USERS
 	- - input -1 * - - - Input device group
 endef
 
-define SYSTEMD_DISABLE_SERVICE_TTY1
-	rm -f $(TARGET_DIR)/etc/systemd/system/getty.target.wants/getty at tty1.service
-endef
-
 ifneq ($(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT)),)
 # systemd needs getty.service for VTs and serial-getty.service for serial ttys
 # also patch the file to use the correct baud-rate, the default baudrate is 115200 so look for that

package/systemd/systemd.mk endef · line 258

Quoted 7 lines
package/systemd/systemd.mk +0 -1
@@ -252,7 +253,6 @@ endef
 endif
 
 define SYSTEMD_INSTALL_INIT_SYSTEMD
-	$(SYSTEMD_DISABLE_SERVICE_TTY1)
 	$(SYSTEMD_INSTALL_SERVICE_TTY)
 	$(SYSTEMD_INSTALL_SERVICE_NETWORK)
 	$(SYSTEMD_INSTALL_SERVICE_TIMESYNC)

Doing this change doesn't work if BR2_TARGET_GENERIC_GETTY_PORT is "tty1". In this case, you will create getty at tty1.service symlink during <pkg>_INIT_SYSTEMD, and then you will remove it in your post-install target hook. And you end up with no getty@<foo>.service symbolic link.

So, I've marked this patch as Rejected in patchwork.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#22 lore raw

PATCH v2 7/24 system: provide no default for custom skeleton path

In reply to Yann E. MORIN

Being custom means that our default one is not suitable to start with.

So there is no reson to offer it as the default path.

Add a separating empty line, for good measure, too.

---
 system/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/Config.in +1 -1
index 4f9f270..04b886b 100644
@@ -179,9 +179,9 @@ config BR2_ROOTFS_SKELETON_CUSTOM
 endchoice
 
 if BR2_ROOTFS_SKELETON_CUSTOM
+
 config BR2_ROOTFS_SKELETON_CUSTOM_PATH
 	string "custom target skeleton path"
-	default "system/skeleton"
 	help
 	  Path to custom target skeleton.
 
Signature · 1 line
2.7.4
#23 lore raw

PATCH v2 7/24 system: provide no default for custom skeleton path

Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 16 lines

Being custom means that our default one is not suitable to start with.

So there is no reson to offer it as the default path.

Add a separating empty line, for good measure, too.

---
 system/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/Config.in +0 -0
index 4f9f270..04b886b 100644

system/Config.in config BR2_ROOTFS_SKELETON_CUSTOM · line 184

Quoted 7 lines
system/Config.in +1 -1
@@ -179,9 +179,9 @@ config BR2_ROOTFS_SKELETON_CUSTOM
 endchoice
 
 if BR2_ROOTFS_SKELETON_CUSTOM
+
 config BR2_ROOTFS_SKELETON_CUSTOM_PATH
 	string "custom target skeleton path"
-	default "system/skeleton"

Then, I think we should add a check in skeleton.mk if BR2_ROOTFS_SKELETON_CUSTOM_PATH is not empty and print an explicit error message.

Best regards,
Romain

Quoted 4 lines
system/Config.in +0 -0
 	help
 	  Path to custom target skeleton.
 
#24 lore raw

PATCH v2 7/24 system: provide no default for custom skeleton path

Quoted 21 lines · Romain Naour

Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 18 lines

Being custom means that our default one is not suitable to start with.

So there is no reson to offer it as the default path.

Add a separating empty line, for good measure, too.

---
 system/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/Config.in +0 -0
index 4f9f270..04b886b 100644
@@ -179,9 +179,9 @@ config BR2_ROOTFS_SKELETON_CUSTOM
 endchoice
 
Quoted 8 lines

system/Config.in config BR2_ROOTFS_SKELETON_CUSTOM · line 184

Quoted 5 lines
system/Config.in +1 -1
 if BR2_ROOTFS_SKELETON_CUSTOM
+
 config BR2_ROOTFS_SKELETON_CUSTOM_PATH
 	string "custom target skeleton path"
-	default "system/skeleton"

Then, I think we should add a check in skeleton.mk if BR2_ROOTFS_SKELETON_CUSTOM_PATH is not empty and print an explicit error message.

+1 to that. I checked, we don't have it at the moment.

Regards,
Arnout

Quoted 15 lines

Best regards,
Romain

system/Config.in config BR2_ROOTFS_SKELETON_CUSTOM · line 187

Quoted 4 lines
system/Config.in +0 -0
 	help
 	  Path to custom target skeleton.
 

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#25 lore raw

PATCH v2 7/24 system: provide no default for custom skeleton path

In reply to Romain Naour

Romain, All,

On 2016-07-03 10:42 +0200, Romain Naour spake thusly:

Quoted 19 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 18 lines

Being custom means that our default one is not suitable to start with.

So there is no reson to offer it as the default path.

Add a separating empty line, for good measure, too.

---
 system/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
system/Config.in +0 -0
index 4f9f270..04b886b 100644
@@ -179,9 +179,9 @@ config BR2_ROOTFS_SKELETON_CUSTOM
 endchoice
 
Quoted 8 lines

system/Config.in config BR2_ROOTFS_SKELETON_CUSTOM · line 184

Quoted 5 lines
system/Config.in +1 -1
 if BR2_ROOTFS_SKELETON_CUSTOM
+
 config BR2_ROOTFS_SKELETON_CUSTOM_PATH
 	string "custom target skeleton path"
-	default "system/skeleton"

Then, I think we should add a check in skeleton.mk if BR2_ROOTFS_SKELETON_CUSTOM_PATH is not empty and print an explicit error message.

ACK.

Regards,
Yann E. MORIN.

Quoted 9 lines

Best regards,
Romain

Quoted 4 lines
system/Config.in +0 -0
 	help
 	  Path to custom target skeleton.
 
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#26 lore raw

PATCH v2 7/24 system: provide no default for custom skeleton path

In reply to Yann E. MORIN

Hello,

Quoted 7 lines · Yann E. MORIN

Being custom means that our default one is not suitable to start with.

So there is no reson to offer it as the default path.

Add a separating empty line, for good measure, too.

Looks good, but I'll wait for a respin with the check that the path is not empty.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#27 lore raw

PATCH v2 8/24 system: move the rootfs skeleton choice

In reply to Yann E. MORIN

In the following commits, we'll be switching more options to be conditional on the default or custom skeleton.

So, it makes sense that those options come after the choice of a skeleton.

---
 system/Config.in | 56 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
system/Config.in +28 -28
index 04b886b..662443b 100644
@@ -1,5 +1,33 @@
 menu "System configuration"
 
+choice
+	prompt "Root FS skeleton"
+
+config BR2_ROOTFS_SKELETON_DEFAULT
+	bool "default target skeleton"
+	help
+	  Use default target skeleton
+
+config BR2_ROOTFS_SKELETON_CUSTOM
+	bool "custom target skeleton"
+	help
+	  Use custom target skeleton.
+
+endchoice
+
+if BR2_ROOTFS_SKELETON_CUSTOM
+
+config BR2_ROOTFS_SKELETON_CUSTOM_PATH
+	string "custom target skeleton path"
+	help
+	  Path to custom target skeleton.
+
+# dummy config so merged /usr workarounds can also be activated for
+# custom rootfs skeleton
+config BR2_ROOTFS_MERGED_USR
+
+endif
+
 config BR2_TARGET_GENERIC_HOSTNAME
 	string "System hostname"
 	default "buildroot"
@@ -163,34 +191,6 @@ config BR2_ROOTFS_STATIC_DEVICE_TABLE
 	  See package/makedevs/README for details on the usage and
 	  syntax of these files.
 
-choice
-	prompt "Root FS skeleton"
-
-config BR2_ROOTFS_SKELETON_DEFAULT
-	bool "default target skeleton"
-	help
-	  Use default target skeleton
-
-config BR2_ROOTFS_SKELETON_CUSTOM
-	bool "custom target skeleton"
-	help
-	  Use custom target skeleton.
-
-endchoice
-
-if BR2_ROOTFS_SKELETON_CUSTOM
-
-config BR2_ROOTFS_SKELETON_CUSTOM_PATH
-	string "custom target skeleton path"
-	help
-	  Path to custom target skeleton.
-
-# dummy config so merged /usr workarounds can also be activated for
-# custom rootfs skeleton
-config BR2_ROOTFS_MERGED_USR
-
-endif
-
 if BR2_ROOTFS_SKELETON_DEFAULT
 
 config BR2_ROOTFS_MERGED_USR
Signature · 1 line
2.7.4
#28 lore raw

PATCH v2 8/24 system: move the rootfs skeleton choice

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 7 lines

In the following commits, we'll be switching more options to be conditional on the default or custom skeleton.

So, it makes sense that those options come after the choice of a skeleton.

Best regards,
Romain

Quoted 78 lines
---
 system/Config.in | 56 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
system/Config.in +28 -28
index 04b886b..662443b 100644
@@ -1,5 +1,33 @@
 menu "System configuration"
 
+choice
+	prompt "Root FS skeleton"
+
+config BR2_ROOTFS_SKELETON_DEFAULT
+	bool "default target skeleton"
+	help
+	  Use default target skeleton
+
+config BR2_ROOTFS_SKELETON_CUSTOM
+	bool "custom target skeleton"
+	help
+	  Use custom target skeleton.
+
+endchoice
+
+if BR2_ROOTFS_SKELETON_CUSTOM
+
+config BR2_ROOTFS_SKELETON_CUSTOM_PATH
+	string "custom target skeleton path"
+	help
+	  Path to custom target skeleton.
+
+# dummy config so merged /usr workarounds can also be activated for
+# custom rootfs skeleton
+config BR2_ROOTFS_MERGED_USR
+
+endif
+
 config BR2_TARGET_GENERIC_HOSTNAME
 	string "System hostname"
 	default "buildroot"
@@ -163,34 +191,6 @@ config BR2_ROOTFS_STATIC_DEVICE_TABLE
 	  See package/makedevs/README for details on the usage and
 	  syntax of these files.
 
-choice
-	prompt "Root FS skeleton"
-
-config BR2_ROOTFS_SKELETON_DEFAULT
-	bool "default target skeleton"
-	help
-	  Use default target skeleton
-
-config BR2_ROOTFS_SKELETON_CUSTOM
-	bool "custom target skeleton"
-	help
-	  Use custom target skeleton.
-
-endchoice
-
-if BR2_ROOTFS_SKELETON_CUSTOM
-
-config BR2_ROOTFS_SKELETON_CUSTOM_PATH
-	string "custom target skeleton path"
-	help
-	  Path to custom target skeleton.
-
-# dummy config so merged /usr workarounds can also be activated for
-# custom rootfs skeleton
-config BR2_ROOTFS_MERGED_USR
-
-endif
-
 if BR2_ROOTFS_SKELETON_DEFAULT
 
 config BR2_ROOTFS_MERGED_USR
#29 lore raw

PATCH v2 9/24 system: do not handle network settings for custom skeleton

In reply to Yann E. MORIN

We expect the custom skeleton to be fully filled with the necessary files, now. There is definitely no reason we should handle network settings in there. A user using a custom skeleton should be fully responsible for providing a functional skeleton.

---
 package/skeleton/skeleton.mk | 8 ++++----
 system/Config.in             | 5 ++---
 2 files changed, 6 insertions(+), 7 deletions(-)
package/skeleton/skeleton.mk +4 -4
index 3852448..144b759 100644
@@ -138,6 +138,10 @@ endef
 TARGET_FINALIZE_HOOKS += SKELETON_SET_ISSUE
 endif
 
+# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
+# default skeleton.
+ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
+
 define SKELETON_SET_NETWORK_LOCALHOST
 	( \
 		echo "# interface file auto-generated by buildroot"; \
@@ -171,10 +175,6 @@ endef
 
 TARGET_FINALIZE_HOOKS += SKELETON_SET_NETWORK
 
-# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
-# default skeleton.
-ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
-
 ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
 ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
 SKELETON_ROOT_PASSWORD =
system/Config.in +2 -3
index 662443b..c02f394 100644
@@ -352,9 +352,6 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 	  read-only.
 	  If unsure, say Y.
 
-endif # BR2_ROOTFS_SKELETON_DEFAULT
-
-
 config BR2_SYSTEM_DHCP
 	string "Network interface to configure through DHCP"
 	default ""
@@ -374,6 +371,8 @@ comment "automatic network configuration via DHCP is not compatible with network
 comment "automatic network configuration via DHCP needs ifupdown or busybox"
 	depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN)
 
+endif # BR2_ROOTFS_SKELETON_DEFAULT
+
 config BR2_TARGET_TZ_INFO
 	bool "Install timezone info"
 	# No timezone for musl; only for uClibc or (e)glibc.
Signature · 1 line
2.7.4
#30 lore raw

PATCH v2 9/24 system: do not handle network settings for custom skeleton

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 6 lines

We expect the custom skeleton to be fully filled with the necessary files, now. There is definitely no reason we should handle network settings in there. A user using a custom skeleton should be fully responsible for providing a functional skeleton.

Best regards,
Romain

Quoted 55 lines
---
 package/skeleton/skeleton.mk | 8 ++++----
 system/Config.in             | 5 ++---
 2 files changed, 6 insertions(+), 7 deletions(-)
package/skeleton/skeleton.mk +4 -4
index 3852448..144b759 100644
@@ -138,6 +138,10 @@ endef
 TARGET_FINALIZE_HOOKS += SKELETON_SET_ISSUE
 endif
 
+# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
+# default skeleton.
+ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
+
 define SKELETON_SET_NETWORK_LOCALHOST
 	( \
 		echo "# interface file auto-generated by buildroot"; \
@@ -171,10 +175,6 @@ endef
 
 TARGET_FINALIZE_HOOKS += SKELETON_SET_NETWORK
 
-# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
-# default skeleton.
-ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
-
 ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
 ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
 SKELETON_ROOT_PASSWORD =
system/Config.in +2 -3
index 662443b..c02f394 100644
@@ -352,9 +352,6 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 	  read-only.
 	  If unsure, say Y.
 
-endif # BR2_ROOTFS_SKELETON_DEFAULT
-
-
 config BR2_SYSTEM_DHCP
 	string "Network interface to configure through DHCP"
 	default ""
@@ -374,6 +371,8 @@ comment "automatic network configuration via DHCP is not compatible with network
 comment "automatic network configuration via DHCP needs ifupdown or busybox"
 	depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN)
 
+endif # BR2_ROOTFS_SKELETON_DEFAULT
+
 config BR2_TARGET_TZ_INFO
 	bool "Install timezone info"
 	# No timezone for musl; only for uClibc or (e)glibc.
#31 lore raw

PATCH v2 10/24 package/perl: use dummy hostname

In reply to Yann E. MORIN

The hostname does not look like it serves any useful purpose, except maybe to set set perladmin email.

Which is undoubtfully useless on the target.

A followup commit will make the hostname depend on the default skeleton, so it won't always be available. We can not rely on it to be set.

Besides, even today it is not guaranteed to be set; a user may well leave it empty.

Use a dummy hostname.

---
 package/perl/perl.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/perl/perl.mk +1 -1
index 11b10ff..29af7a4 100644
@@ -54,7 +54,7 @@ PERL_CONF_OPTS = \
 	-Dccflags="$(TARGET_CFLAGS)" \
 	-Dldflags="$(TARGET_LDFLAGS) -lm" \
 	-Dmydomain="" \
-	-Dmyhostname="$(BR2_TARGET_GENERIC_HOSTNAME)" \
+	-Dmyhostname="noname" \
 	-Dmyuname="Buildroot $(BR2_VERSION_FULL)" \
 	-Dosname=linux \
 	-Dosvers=$(LINUX_VERSION) \
Signature · 1 line
2.7.4
#32 lore raw

PATCH v2 10/24 package/perl: use dummy hostname

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 8 lines

The hostname does not look like it serves any useful purpose, except maybe to set set perladmin email.

Which is undoubtfully useless on the target.

A followup commit will make the hostname depend on the default skeleton, so it won't always be available. We can not rely on it to be set.

Quoted 6 lines

Besides, even today it is not guaranteed to be set; a user may well leave it empty.

Use a dummy hostname.

Best regards,
Romain

Quoted 18 lines
---
 package/perl/perl.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/perl/perl.mk +1 -1
index 11b10ff..29af7a4 100644
@@ -54,7 +54,7 @@ PERL_CONF_OPTS = \
 	-Dccflags="$(TARGET_CFLAGS)" \
 	-Dldflags="$(TARGET_LDFLAGS) -lm" \
 	-Dmydomain="" \
-	-Dmyhostname="$(BR2_TARGET_GENERIC_HOSTNAME)" \
+	-Dmyhostname="noname" \
 	-Dmyuname="Buildroot $(BR2_VERSION_FULL)" \
 	-Dosname=linux \
 	-Dosvers=$(LINUX_VERSION) \
#33 lore raw

PATCH v2 10/24 package/perl: use dummy hostname

In reply to Yann E. MORIN

Hello,

Quoted 11 lines · Yann E. MORIN

The hostname does not look like it serves any useful purpose, except maybe to set set perladmin email.

Which is undoubtfully useless on the target.

A followup commit will make the hostname depend on the default skeleton, so it won't always be available. We can not rely on it to be set.

Besides, even today it is not guaranteed to be set; a user may well leave it empty.

Quoted 6 lines

Use a dummy hostname.

---
 package/perl/perl.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#34 lore raw

PATCH v2 11/24 system: do not set hostname and issue for custom skeleton

In reply to Yann E. MORIN

We expect the custom skeleton to be fully filled with the necessary files, now. There is definitely no reason we should handle setting the hostname and the issue file in there. A user using a custom skeleton should be fully responsible for providing a functional skeleton.

---
Note: beside the skeleton, the only other user of the hostname was the perl package, and it was just previously changed not to use it anymore.

---
 package/skeleton/skeleton.mk | 8 ++++----
 system/Config.in             | 4 ++++
 2 files changed, 8 insertions(+), 4 deletions(-)
package/skeleton/skeleton.mk +4 -4
index 144b759..e67a477 100644
@@ -110,6 +110,10 @@ define SKELETON_INSTALL_STAGING_CMDS
 	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
 endef
 
+# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
+# default skeleton.
+ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
+
 SKELETON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 SKELETON_TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
 SKELETON_TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
@@ -138,10 +142,6 @@ endef
 TARGET_FINALIZE_HOOKS += SKELETON_SET_ISSUE
 endif
 
-# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
-# default skeleton.
-ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
-
 define SKELETON_SET_NETWORK_LOCALHOST
 	( \
 		echo "# interface file auto-generated by buildroot"; \
system/Config.in +4 -0
index c02f394..3a38bd4 100644
@@ -28,6 +28,8 @@ config BR2_ROOTFS_MERGED_USR
 
 endif
 
+if BR2_ROOTFS_SKELETON_DEFAULT
+
 config BR2_TARGET_GENERIC_HOSTNAME
 	string "System hostname"
 	default "buildroot"
@@ -46,6 +48,8 @@ config BR2_TARGET_GENERIC_ISSUE
 	  Leave empty to not create /etc/issue, or to keep the
 	  one from a custom skeleton.
 
+endif
+
 choice
 	bool "Passwords encoding"
 	default BR2_TARGET_GENERIC_PASSWD_MD5
Signature · 1 line
2.7.4
#35 lore raw

PATCH v2 11/24 system: do not set hostname and issue for custom skeleton

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 6 lines

We expect the custom skeleton to be fully filled with the necessary files, now. There is definitely no reason we should handle setting the hostname and the issue file in there. A user using a custom skeleton should be fully responsible for providing a functional skeleton.

Best regards,
Romain

Quoted 58 lines

---
Note: beside the skeleton, the only other user of the hostname was the perl package, and it was just previously changed not to use it anymore.

---
 package/skeleton/skeleton.mk | 8 ++++----
 system/Config.in             | 4 ++++
 2 files changed, 8 insertions(+), 4 deletions(-)
package/skeleton/skeleton.mk +4 -4
index 144b759..e67a477 100644
@@ -110,6 +110,10 @@ define SKELETON_INSTALL_STAGING_CMDS
 	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
 endef
 
+# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
+# default skeleton.
+ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
+
 SKELETON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 SKELETON_TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
 SKELETON_TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
@@ -138,10 +142,6 @@ endef
 TARGET_FINALIZE_HOOKS += SKELETON_SET_ISSUE
 endif
 
-# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
-# default skeleton.
-ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
-
 define SKELETON_SET_NETWORK_LOCALHOST
 	( \
 		echo "# interface file auto-generated by buildroot"; \
system/Config.in +4 -0
index c02f394..3a38bd4 100644
@@ -28,6 +28,8 @@ config BR2_ROOTFS_MERGED_USR
 
 endif
 
+if BR2_ROOTFS_SKELETON_DEFAULT
+
 config BR2_TARGET_GENERIC_HOSTNAME
 	string "System hostname"
 	default "buildroot"
@@ -46,6 +48,8 @@ config BR2_TARGET_GENERIC_ISSUE
 	  Leave empty to not create /etc/issue, or to keep the
 	  one from a custom skeleton.
 
+endif
+
 choice
 	bool "Passwords encoding"
 	default BR2_TARGET_GENERIC_PASSWD_MD5
#36 lore raw

PATCH v2 12/24 core/pkg-generic: add variable to skip skeleton dependency

In reply to Yann E. MORIN

We currently skip the skeleton dependency by checking if the current package is the skeleton.

We are going to introduce more skeleton-related packages, so we need a way to exclude the skeleton dependency for those, or we'd get a circular dependency, for the same reason we need to skip the toolchain dependency.

Instead of checking for all the skeleton-providing packages in the core infra, add a new package options so that packages can express they do not need the dependency on the skeleton, like we have an option to avoid the depednency on the toolchain. The only packages that will use that option are probably the skeletons, so we need not document this variable, like we did not document the option to exclude the dependency on the toolchain.

---
 package/pkg-generic.mk       | 7 +++++--
 package/skeleton/skeleton.mk | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)
package/pkg-generic.mk +5 -2
index 374d9d5..3281374 100644
@@ -486,15 +486,18 @@ $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)
 
 # When a target package is a toolchain dependency set this variable to
 # 'NO' so the 'toolchain' dependency is not added to prevent a circular
-# dependency
+# dependency.
+# Similarly for the skeleton.
 $(2)_ADD_TOOLCHAIN_DEPENDENCY	?= YES
+$(2)_ADD_SKELETON_DEPENDENCY	?= YES
+
 
 ifeq ($(4),host)
 $(2)_DEPENDENCIES ?= $$(filter-out host-skeleton host-toolchain $(1),\
 	$$(patsubst host-host-%,host-%,$$(addprefix host-,$$($(3)_DEPENDENCIES))))
 endif
 ifeq ($(4),target)
-ifneq ($(1),skeleton)
+ifeq ($$($(2)_ADD_SKELETON_DEPENDENCY),YES)
 $(2)_DEPENDENCIES += skeleton
 endif
 ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY),YES)
package/skeleton/skeleton.mk +1 -0
index e67a477..072d217 100644
@@ -12,6 +12,7 @@ SKELETON_SOURCE =
 # Hence, skeleton would depends on the toolchain and the toolchain would depend
 # on skeleton.
 SKELETON_ADD_TOOLCHAIN_DEPENDENCY = NO
+SKELETON_ADD_SKELETON_DEPENDENCY = NO
 
 # The skeleton also handles the merged /usr case in the sysroot
 SKELETON_INSTALL_STAGING = YES
Signature · 1 line
2.7.4
#37 lore raw

PATCH v2 12/24 core/pkg-generic: add variable to skip skeleton dependency

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 16 lines

We currently skip the skeleton dependency by checking if the current package is the skeleton.

We are going to introduce more skeleton-related packages, so we need a way to exclude the skeleton dependency for those, or we'd get a circular dependency, for the same reason we need to skip the toolchain dependency.

Instead of checking for all the skeleton-providing packages in the core infra, add a new package options so that packages can express they do not need the dependency on the skeleton, like we have an option to avoid the depednency on the toolchain. The only packages that will use that option are probably the skeletons, so we need not document this variable, like we did not document the option to exclude the dependency on the toolchain.

Quoted 1 line

Best regards,
Romain

Quoted 43 lines
---
 package/pkg-generic.mk       | 7 +++++--
 package/skeleton/skeleton.mk | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)
package/pkg-generic.mk +5 -2
index 374d9d5..3281374 100644
@@ -486,15 +486,18 @@ $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)
 
 # When a target package is a toolchain dependency set this variable to
 # 'NO' so the 'toolchain' dependency is not added to prevent a circular
-# dependency
+# dependency.
+# Similarly for the skeleton.
 $(2)_ADD_TOOLCHAIN_DEPENDENCY	?= YES
+$(2)_ADD_SKELETON_DEPENDENCY	?= YES
+
 
 ifeq ($(4),host)
 $(2)_DEPENDENCIES ?= $$(filter-out host-skeleton host-toolchain $(1),\
 	$$(patsubst host-host-%,host-%,$$(addprefix host-,$$($(3)_DEPENDENCIES))))
 endif
 ifeq ($(4),target)
-ifneq ($(1),skeleton)
+ifeq ($$($(2)_ADD_SKELETON_DEPENDENCY),YES)
 $(2)_DEPENDENCIES += skeleton
 endif
 ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY),YES)
package/skeleton/skeleton.mk +1 -0
index e67a477..072d217 100644
@@ -12,6 +12,7 @@ SKELETON_SOURCE =
 # Hence, skeleton would depends on the toolchain and the toolchain would depend
 # on skeleton.
 SKELETON_ADD_TOOLCHAIN_DEPENDENCY = NO
+SKELETON_ADD_SKELETON_DEPENDENCY = NO
 
 # The skeleton also handles the merged /usr case in the sysroot
 SKELETON_INSTALL_STAGING = YES
#38 lore raw

PATCH v2 13/24 package/skeleton: add macro to rsync skeleton directory

In reply to Yann E. MORIN

The rsync command is currently called from a single location. In follow-up patches, it will be called from various places now.

It will be easier to update and fix this command if it is defined in a single location, rather than if duplicated in many places.

Define a macro that skeleton packages can call to install their skeleton directories. Since at least one occurence of it will want to install in staging, the macro must accept a destination path, rather than hard-code target as the destination.

---
 package/skeleton/skeleton.mk | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
package/skeleton/skeleton.mk +9 -3
index 072d217..e3ae694 100644
@@ -62,6 +62,14 @@ SKELETON_PATH = system/skeleton
 
 endif # ! custom skeleton
 
+# This function rsyncs the skeleton directory in $(1) to the destination
+# in $(2), which should be either $(TARTGET_DIR) or $(STAGING_DIR)
+define SKELETON_RSYNC
+	rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
+		--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
+		$(1)/ $(2)/
+endef
+
 # This function handles the merged or non-merged /usr cases
 ifeq ($(BR2_ROOTFS_MERGED_USR),y)
 define SKELETON_USR_SYMLINKS_OR_DIRS
@@ -86,9 +94,7 @@ SKELETON_LIB_SYMLINK = lib32
 endif
 
 define SKELETON_INSTALL_TARGET_CMDS
-	rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
-		--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
-		$(SKELETON_PATH)/ $(TARGET_DIR)/
+	$(call SKELETON_RSYNC,$(SKELETON_PATH),$(TARGET_DIR))
 	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
 	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
 	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
Signature · 1 line
2.7.4
#39 lore raw

PATCH v2 13/24 package/skeleton: add macro to rsync skeleton directory

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 6 lines

The rsync command is currently called from a single location. In follow-up patches, it will be called from various places now.

It will be easier to update and fix this command if it is defined in a single location, rather than if duplicated in many places.

Quoted 6 lines

Define a macro that skeleton packages can call to install their skeleton directories. Since at least one occurence of it will want to install in staging, the macro must accept a destination path, rather than hard-code target as the destination.

Best regards,
Romain

Quoted 35 lines
---
 package/skeleton/skeleton.mk | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
package/skeleton/skeleton.mk +9 -3
index 072d217..e3ae694 100644
@@ -62,6 +62,14 @@ SKELETON_PATH = system/skeleton
 
 endif # ! custom skeleton
 
+# This function rsyncs the skeleton directory in $(1) to the destination
+# in $(2), which should be either $(TARTGET_DIR) or $(STAGING_DIR)
+define SKELETON_RSYNC
+	rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
+		--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
+		$(1)/ $(2)/
+endef
+
 # This function handles the merged or non-merged /usr cases
 ifeq ($(BR2_ROOTFS_MERGED_USR),y)
 define SKELETON_USR_SYMLINKS_OR_DIRS
@@ -86,9 +94,7 @@ SKELETON_LIB_SYMLINK = lib32
 endif
 
 define SKELETON_INSTALL_TARGET_CMDS
-	rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
-		--chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
-		$(SKELETON_PATH)/ $(TARGET_DIR)/
+	$(call SKELETON_RSYNC,$(SKELETON_PATH),$(TARGET_DIR))
 	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
 	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
 	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
#40 lore raw

PATCH v2 14/24 core/pkg-generic: allow packages to declare target-finalize hooks

In reply to Yann E. MORIN

Currently, our skeleton declares target-finalize hooks, and does so unconditionally.

That's fine since we have a single skeleton package, and thus the hooks it declares need not be conditional.

However, we're going to be adding more skeleton packages, one for the custom skeleton, one for the sysv-like init systems and, eventually, one for the systemd init system.

In that case, we will not want the sysv-like target-finalize hooks to be applied when the init system is systemd. And the other way around, of course. And so on for each type of skeleton...

The only solution we have so far is to enclose all target-finalize hooks declarations between an ifeq-block to check that the package is enabled. This is cumbersome to do, even more so when the hooks are themselves conditional.

Add support in the core infra for packages to register such hooks, like is done to register users, device tables and whatnots.

---
 docs/manual/adding-packages-hooks.txt | 7 +++++++
 package/pkg-generic.mk                | 2 ++
 2 files changed, 9 insertions(+)
docs/manual/adding-packages-hooks.txt +7 -0
index 5b5bf6a..d25092a 100644
@@ -77,3 +77,10 @@ others, use the following variables:
 
 * +$(SRCDIR)+: the path to the overridden source directory
 * +$(@D)+: the path to the build directory
+
+==== Target-finalize hook
+
+Packages may also register hooks in +LIBFOO_TARGET_FINALIZE_HOOKS+.
+These hooks are run after all packages are built, but before the
+filesystem images are generated. They are seldom used, and your
+package probably do not need them.
package/pkg-generic.mk +2 -0
index 3281374..4415342 100644
@@ -558,6 +558,7 @@ $(2)_PRE_INSTALL_IMAGES_HOOKS   ?=
 $(2)_POST_INSTALL_IMAGES_HOOKS  ?=
 $(2)_PRE_LEGAL_INFO_HOOKS       ?=
 $(2)_POST_LEGAL_INFO_HOOKS      ?=
+$(2)_TARGET_FINALIZE_HOOKS      ?=
 
 # human-friendly targets and target sequencing
 $(1):			$(1)-install
@@ -858,6 +859,7 @@ endif
 ifneq ($$($(2)_USERS),)
 PACKAGES_USERS += $$($(2)_USERS)$$(sep)
 endif
+TARGET_FINALIZE_HOOKS += $$($(2)_TARGET_FINALIZE_HOOKS)
 
 ifeq ($$($(2)_SITE_METHOD),svn)
 DL_TOOLS_DEPENDENCIES += svn
Signature · 1 line
2.7.4
#41 lore raw

PATCH v2 14/24 core/pkg-generic: allow packages to declare target-finalize hooks

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 19 lines

Currently, our skeleton declares target-finalize hooks, and does so unconditionally.

That's fine since we have a single skeleton package, and thus the hooks it declares need not be conditional.

However, we're going to be adding more skeleton packages, one for the custom skeleton, one for the sysv-like init systems and, eventually, one for the systemd init system.

In that case, we will not want the sysv-like target-finalize hooks to be applied when the init system is systemd. And the other way around, of course. And so on for each type of skeleton...

The only solution we have so far is to enclose all target-finalize hooks declarations between an ifeq-block to check that the package is enabled. This is cumbersome to do, even more so when the hooks are themselves conditional.

Quoted 4 lines

Add support in the core infra for packages to register such hooks, like is done to register users, device tables and whatnots.

Best regards,
Romain

Quoted 41 lines
---
 docs/manual/adding-packages-hooks.txt | 7 +++++++
 package/pkg-generic.mk                | 2 ++
 2 files changed, 9 insertions(+)
docs/manual/adding-packages-hooks.txt +7 -0
index 5b5bf6a..d25092a 100644
@@ -77,3 +77,10 @@ others, use the following variables:
 
 * +$(SRCDIR)+: the path to the overridden source directory
 * +$(@D)+: the path to the build directory
+
+==== Target-finalize hook
+
+Packages may also register hooks in +LIBFOO_TARGET_FINALIZE_HOOKS+.
+These hooks are run after all packages are built, but before the
+filesystem images are generated. They are seldom used, and your
+package probably do not need them.
package/pkg-generic.mk +2 -0
index 3281374..4415342 100644
@@ -558,6 +558,7 @@ $(2)_PRE_INSTALL_IMAGES_HOOKS   ?=
 $(2)_POST_INSTALL_IMAGES_HOOKS  ?=
 $(2)_PRE_LEGAL_INFO_HOOKS       ?=
 $(2)_POST_LEGAL_INFO_HOOKS      ?=
+$(2)_TARGET_FINALIZE_HOOKS      ?=
 
 # human-friendly targets and target sequencing
 $(1):			$(1)-install
@@ -858,6 +859,7 @@ endif
 ifneq ($$($(2)_USERS),)
 PACKAGES_USERS += $$($(2)_USERS)$$(sep)
 endif
+TARGET_FINALIZE_HOOKS += $$($(2)_TARGET_FINALIZE_HOOKS)
 
 ifeq ($$($(2)_SITE_METHOD),svn)
 DL_TOOLS_DEPENDENCIES += svn
#42 lore raw

PATCH v2 14/24 core/pkg-generic: allow packages to declare target-finalize hooks

In reply to Yann E. MORIN

Hello,

Quoted 19 lines · Yann E. MORIN

Currently, our skeleton declares target-finalize hooks, and does so unconditionally.

That's fine since we have a single skeleton package, and thus the hooks it declares need not be conditional.

However, we're going to be adding more skeleton packages, one for the custom skeleton, one for the sysv-like init systems and, eventually, one for the systemd init system.

In that case, we will not want the sysv-like target-finalize hooks to be applied when the init system is systemd. And the other way around, of course. And so on for each type of skeleton...

The only solution we have so far is to enclose all target-finalize hooks declarations between an ifeq-block to check that the package is enabled. This is cumbersome to do, even more so when the hooks are themselves conditional.

Quoted 8 lines

Add support in the core infra for packages to register such hooks, like is done to register users, device tables and whatnots.

---
 docs/manual/adding-packages-hooks.txt | 7 +++++++
 package/pkg-generic.mk                | 2 ++
 2 files changed, 9 insertions(+)

I've applied after rewriting the commit log. Indeed, I am not yet sure we will have multiple skeleton packages, so the commit log from that perspective may not be correct. However, the functionality itself is useful on its own, for other packages, which is why I've applied it.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#43 lore raw

PATCH v2 15/24 packages: use the <PKG>_TARGET_FINALIZE_HOOKS

In reply to Yann E. MORIN

Register package-specific target-finalize hooks with the newly-introduced <PKG>_TARGET_FINALIZE_HOOKS.

This incidentally fixes luarocks, which was registering target-finalize hooks even when it was not enabled.

To be noted, the skeleton package is not converted, because it is not optional, we always have it; so its hooks would always be registered anyway. Besides, the followup patches would render this conversion moot anyway, since those hooks would be spread across the various skeleton packages.

---
 package/google-breakpad/google-breakpad.mk |  6 ++----
 package/libglib2/libglib2.mk               |  6 ++----
 package/libgtk3/libgtk3.mk                 |  4 +---
 package/luarocks/luarocks.mk               |  3 +--
 package/perl/perl.mk                       |  4 +---
 package/python/python.mk                   | 10 ++++------
 package/python3/python3.mk                 | 10 ++++------
 7 files changed, 15 insertions(+), 28 deletions(-)
package/google-breakpad/google-breakpad.mk +2 -4
index 1bbe4da..7a88c76 100644
@@ -13,15 +13,13 @@ GOOGLE_BREAKPAD_INSTALL_TARGET = NO
 GOOGLE_BREAKPAD_INSTALL_STAGING = YES
 GOOGLE_BREAKPAD_LICENSE = BSD-3c
 GOOGLE_BREAKPAD_LICENSE_FILES = LICENSE
-
-ifeq ($(BR2_PACKAGE_GOOGLE_BREAKPAD),y)
 GOOGLE_BREAKPAD_DEPENDENCIES = host-google-breakpad
+
 define GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
 	$(EXTRA_ENV) package/google-breakpad/gen-syms.sh $(STAGING_DIR) \
 		$(TARGET_DIR) $(call qstrip,$(BR2_GOOGLE_BREAKPAD_INCLUDE_FILES))
 endef
-TARGET_FINALIZE_HOOKS += GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
-endif
+GOOGLE_BREAKPAD_TARGET_FINALIZE_HOOKS += GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/libglib2/libglib2.mk +2 -4
index b479bae..e2bff6d 100644
@@ -160,10 +160,8 @@ define LIBGLIB2_COMPILE_SCHEMAS
 		--targetdir=$(TARGET_DIR)/usr/share/glib-2.0/schemas
 endef
 
-ifeq ($(BR2_PACKAGE_LIBGLIB2),y)
-TARGET_FINALIZE_HOOKS += LIBGLIB2_REMOVE_TARGET_SCHEMAS
-TARGET_FINALIZE_HOOKS += LIBGLIB2_COMPILE_SCHEMAS
-endif
+LIBGLIB2_TARGET_FINALIZE_HOOKS += LIBGLIB2_REMOVE_TARGET_SCHEMAS
+LIBGLIB2_TARGET_FINALIZE_HOOKS += LIBGLIB2_COMPILE_SCHEMAS
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/libgtk3/libgtk3.mk +1 -3
index f447e7a..08d172f 100644
@@ -182,13 +182,11 @@ endef
 
 # Create icon-theme.cache for each of the icon directories/themes
 # It's not strictly necessary but speeds up lookups
-ifeq ($(BR2_PACKAGE_LIBGTK3),y)
 define LIBGTK3_UPDATE_ICON_CACHE
 	find $(TARGET_DIR)/usr/share/icons -maxdepth 1 -mindepth 1 -type d \
 		-exec $(HOST_DIR)/usr/bin/gtk-update-icon-cache {} \;
 endef
-TARGET_FINALIZE_HOOKS += LIBGTK3_UPDATE_ICON_CACHE
-endif
+LIBGTK3_TARGET_FINALIZE_HOOKS += LIBGTK3_UPDATE_ICON_CACHE
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/luarocks/luarocks.mk +1 -2
index 656b832..eddd435 100644
@@ -60,5 +60,4 @@ define LUAROCKS_FINALIZE_TARGET
 	rm -rf $(TARGET_DIR)/usr/lib/luarocks
 endef
 
-TARGET_FINALIZE_HOOKS += LUAROCKS_FINALIZE_TARGET
-
+LUAROCKS_TARGET_FINALIZE_HOOKS += LUAROCKS_FINALIZE_TARGET
package/perl/perl.mk +1 -3
index 29af7a4..ca70123 100644
@@ -114,7 +114,6 @@ endef
 $(eval $(generic-package))
 $(eval $(host-generic-package))
 
-ifeq ($(BR2_PACKAGE_PERL),y)
 define PERL_FINALIZE_TARGET
 	rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/pod
 	rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/$(PERL_ARCHNAME)/CORE
@@ -122,5 +121,4 @@ define PERL_FINALIZE_TARGET
 	find $(TARGET_DIR)/usr/lib/perl5/ -name '*.bs' -print0 | xargs -0 rm -f
 	find $(TARGET_DIR)/usr/lib/perl5/ -name '.packlist' -print0 | xargs -0 rm -f
 endef
-TARGET_FINALIZE_HOOKS += PERL_FINALIZE_TARGET
-endif
+PERL_TARGET_FINALIZE_HOOKS += PERL_FINALIZE_TARGET
package/python/python.mk +4 -6
index 913dc2c..5e13bf3 100644
@@ -226,7 +226,7 @@ define PYTHON_CREATE_PYC_FILES
 endef
 
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY)$(BR2_PACKAGE_PYTHON_PY_PYC),y)
-TARGET_FINALIZE_HOOKS += PYTHON_CREATE_PYC_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_CREATE_PYC_FILES
 endif
 
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
@@ -234,7 +234,7 @@ define PYTHON_REMOVE_PY_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.py' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
 endif
 
 # Normally, *.pyc files should not have been compiled, but just in
@@ -244,14 +244,12 @@ define PYTHON_REMOVE_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
 endif
 
 # In all cases, we don't want to keep the optimized .pyo files
-ifeq ($(BR2_PACKAGE_PYTHON),y)
 define PYTHON_REMOVE_PYO_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyo' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYO_FILES
-endif
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYO_FILES
package/python3/python3.mk +4 -6
index 8459b11..dc776fe 100644
@@ -217,7 +217,7 @@ define PYTHON3_CREATE_PYC_FILES
 endef
 
 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY)$(BR2_PACKAGE_PYTHON3_PY_PYC),y)
-TARGET_FINALIZE_HOOKS += PYTHON3_CREATE_PYC_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_CREATE_PYC_FILES
 endif
 
 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
@@ -225,7 +225,7 @@ define PYTHON3_REMOVE_PY_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PY_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PY_FILES
 endif
 
 # Normally, *.pyc files should not have been compiled, but just in
@@ -235,16 +235,14 @@ define PYTHON3_REMOVE_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PYC_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PYC_FILES
 endif
 
 # In all cases, we don't want to keep the optimized .opt-1.pyc and
 # .opt-2.pyc files, since they can't work without their non-optimized
 # variant.
-ifeq ($(BR2_PACKAGE_PYTHON3),y)
 define PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.opt-1.pyc' -print0 -o -name '*.opt-2.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
-endif
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
Signature · 1 line
2.7.4
#44 lore raw

PATCH v2 15/24 packages: use the <PKG>_TARGET_FINALIZE_HOOKS

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 11 lines

Register package-specific target-finalize hooks with the newly-introduced <PKG>_TARGET_FINALIZE_HOOKS.

This incidentally fixes luarocks, which was registering target-finalize hooks even when it was not enabled.

To be noted, the skeleton package is not converted, because it is not optional, we always have it; so its hooks would always be registered anyway. Besides, the followup patches would render this conversion moot anyway, since those hooks would be spread across the various skeleton packages.

Have you considered the two TARGET_FINALIZE_HOOKS from the toolchain package ?

Quoted 2 lines

Otherwise:

Best regards,
Romain

Quoted 179 lines
---
 package/google-breakpad/google-breakpad.mk |  6 ++----
 package/libglib2/libglib2.mk               |  6 ++----
 package/libgtk3/libgtk3.mk                 |  4 +---
 package/luarocks/luarocks.mk               |  3 +--
 package/perl/perl.mk                       |  4 +---
 package/python/python.mk                   | 10 ++++------
 package/python3/python3.mk                 | 10 ++++------
 7 files changed, 15 insertions(+), 28 deletions(-)
package/google-breakpad/google-breakpad.mk +2 -4
index 1bbe4da..7a88c76 100644
@@ -13,15 +13,13 @@ GOOGLE_BREAKPAD_INSTALL_TARGET = NO
 GOOGLE_BREAKPAD_INSTALL_STAGING = YES
 GOOGLE_BREAKPAD_LICENSE = BSD-3c
 GOOGLE_BREAKPAD_LICENSE_FILES = LICENSE
-
-ifeq ($(BR2_PACKAGE_GOOGLE_BREAKPAD),y)
 GOOGLE_BREAKPAD_DEPENDENCIES = host-google-breakpad
+
 define GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
 	$(EXTRA_ENV) package/google-breakpad/gen-syms.sh $(STAGING_DIR) \
 		$(TARGET_DIR) $(call qstrip,$(BR2_GOOGLE_BREAKPAD_INCLUDE_FILES))
 endef
-TARGET_FINALIZE_HOOKS += GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
-endif
+GOOGLE_BREAKPAD_TARGET_FINALIZE_HOOKS += GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/libglib2/libglib2.mk +2 -4
index b479bae..e2bff6d 100644
@@ -160,10 +160,8 @@ define LIBGLIB2_COMPILE_SCHEMAS
 		--targetdir=$(TARGET_DIR)/usr/share/glib-2.0/schemas
 endef
 
-ifeq ($(BR2_PACKAGE_LIBGLIB2),y)
-TARGET_FINALIZE_HOOKS += LIBGLIB2_REMOVE_TARGET_SCHEMAS
-TARGET_FINALIZE_HOOKS += LIBGLIB2_COMPILE_SCHEMAS
-endif
+LIBGLIB2_TARGET_FINALIZE_HOOKS += LIBGLIB2_REMOVE_TARGET_SCHEMAS
+LIBGLIB2_TARGET_FINALIZE_HOOKS += LIBGLIB2_COMPILE_SCHEMAS
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/libgtk3/libgtk3.mk +1 -3
index f447e7a..08d172f 100644
@@ -182,13 +182,11 @@ endef
 
 # Create icon-theme.cache for each of the icon directories/themes
 # It's not strictly necessary but speeds up lookups
-ifeq ($(BR2_PACKAGE_LIBGTK3),y)
 define LIBGTK3_UPDATE_ICON_CACHE
 	find $(TARGET_DIR)/usr/share/icons -maxdepth 1 -mindepth 1 -type d \
 		-exec $(HOST_DIR)/usr/bin/gtk-update-icon-cache {} \;
 endef
-TARGET_FINALIZE_HOOKS += LIBGTK3_UPDATE_ICON_CACHE
-endif
+LIBGTK3_TARGET_FINALIZE_HOOKS += LIBGTK3_UPDATE_ICON_CACHE
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/luarocks/luarocks.mk +1 -2
index 656b832..eddd435 100644
@@ -60,5 +60,4 @@ define LUAROCKS_FINALIZE_TARGET
 	rm -rf $(TARGET_DIR)/usr/lib/luarocks
 endef
 
-TARGET_FINALIZE_HOOKS += LUAROCKS_FINALIZE_TARGET
-
+LUAROCKS_TARGET_FINALIZE_HOOKS += LUAROCKS_FINALIZE_TARGET
package/perl/perl.mk +1 -3
index 29af7a4..ca70123 100644
@@ -114,7 +114,6 @@ endef
 $(eval $(generic-package))
 $(eval $(host-generic-package))
 
-ifeq ($(BR2_PACKAGE_PERL),y)
 define PERL_FINALIZE_TARGET
 	rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/pod
 	rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/$(PERL_ARCHNAME)/CORE
@@ -122,5 +121,4 @@ define PERL_FINALIZE_TARGET
 	find $(TARGET_DIR)/usr/lib/perl5/ -name '*.bs' -print0 | xargs -0 rm -f
 	find $(TARGET_DIR)/usr/lib/perl5/ -name '.packlist' -print0 | xargs -0 rm -f
 endef
-TARGET_FINALIZE_HOOKS += PERL_FINALIZE_TARGET
-endif
+PERL_TARGET_FINALIZE_HOOKS += PERL_FINALIZE_TARGET
package/python/python.mk +4 -6
index 913dc2c..5e13bf3 100644
@@ -226,7 +226,7 @@ define PYTHON_CREATE_PYC_FILES
 endef
 
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY)$(BR2_PACKAGE_PYTHON_PY_PYC),y)
-TARGET_FINALIZE_HOOKS += PYTHON_CREATE_PYC_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_CREATE_PYC_FILES
 endif
 
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
@@ -234,7 +234,7 @@ define PYTHON_REMOVE_PY_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.py' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
 endif
 
 # Normally, *.pyc files should not have been compiled, but just in
@@ -244,14 +244,12 @@ define PYTHON_REMOVE_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
 endif
 
 # In all cases, we don't want to keep the optimized .pyo files
-ifeq ($(BR2_PACKAGE_PYTHON),y)
 define PYTHON_REMOVE_PYO_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyo' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYO_FILES
-endif
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYO_FILES
package/python3/python3.mk +4 -6
index 8459b11..dc776fe 100644
@@ -217,7 +217,7 @@ define PYTHON3_CREATE_PYC_FILES
 endef
 
 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY)$(BR2_PACKAGE_PYTHON3_PY_PYC),y)
-TARGET_FINALIZE_HOOKS += PYTHON3_CREATE_PYC_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_CREATE_PYC_FILES
 endif
 
 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
@@ -225,7 +225,7 @@ define PYTHON3_REMOVE_PY_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PY_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PY_FILES
 endif
 
 # Normally, *.pyc files should not have been compiled, but just in
@@ -235,16 +235,14 @@ define PYTHON3_REMOVE_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PYC_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PYC_FILES
 endif
 
 # In all cases, we don't want to keep the optimized .opt-1.pyc and
 # .opt-2.pyc files, since they can't work without their non-optimized
 # variant.
-ifeq ($(BR2_PACKAGE_PYTHON3),y)
 define PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.opt-1.pyc' -print0 -o -name '*.opt-2.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
-endif
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
#45 lore raw

PATCH v2 15/24 packages: use the <PKG>_TARGET_FINALIZE_HOOKS

Romain, All,

On 2016-07-03 12:02 +0200, Romain Naour spake thusly:

Quoted 7 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 6 lines

Register package-specific target-finalize hooks with the newly-introduced <PKG>_TARGET_FINALIZE_HOOKS.

This incidentally fixes luarocks, which was registering target-finalize hooks even when it was not enabled.

Quoted 7 lines
Quoted 5 lines

To be noted, the skeleton package is not converted, because it is not optional, we always have it; so its hooks would always be registered anyway. Besides, the followup patches would render this conversion moot anyway, since those hooks would be spread across the various skeleton packages.

Have you considered the two TARGET_FINALIZE_HOOKS from the toolchain package ?

Good idea! Done, now.

Quoted 5 lines
Quoted 2 lines

Otherwise:

Thanks! :-)

Regards,
Yann E. MORIN.

Quoted 184 lines

Best regards,
Romain

Quoted 179 lines
---
 package/google-breakpad/google-breakpad.mk |  6 ++----
 package/libglib2/libglib2.mk               |  6 ++----
 package/libgtk3/libgtk3.mk                 |  4 +---
 package/luarocks/luarocks.mk               |  3 +--
 package/perl/perl.mk                       |  4 +---
 package/python/python.mk                   | 10 ++++------
 package/python3/python3.mk                 | 10 ++++------
 7 files changed, 15 insertions(+), 28 deletions(-)
package/google-breakpad/google-breakpad.mk +2 -4
index 1bbe4da..7a88c76 100644
@@ -13,15 +13,13 @@ GOOGLE_BREAKPAD_INSTALL_TARGET = NO
 GOOGLE_BREAKPAD_INSTALL_STAGING = YES
 GOOGLE_BREAKPAD_LICENSE = BSD-3c
 GOOGLE_BREAKPAD_LICENSE_FILES = LICENSE
-
-ifeq ($(BR2_PACKAGE_GOOGLE_BREAKPAD),y)
 GOOGLE_BREAKPAD_DEPENDENCIES = host-google-breakpad
+
 define GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
 	$(EXTRA_ENV) package/google-breakpad/gen-syms.sh $(STAGING_DIR) \
 		$(TARGET_DIR) $(call qstrip,$(BR2_GOOGLE_BREAKPAD_INCLUDE_FILES))
 endef
-TARGET_FINALIZE_HOOKS += GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
-endif
+GOOGLE_BREAKPAD_TARGET_FINALIZE_HOOKS += GOOGLE_BREAKPAD_EXTRACT_SYMBOLS
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/libglib2/libglib2.mk +2 -4
index b479bae..e2bff6d 100644
@@ -160,10 +160,8 @@ define LIBGLIB2_COMPILE_SCHEMAS
 		--targetdir=$(TARGET_DIR)/usr/share/glib-2.0/schemas
 endef
 
-ifeq ($(BR2_PACKAGE_LIBGLIB2),y)
-TARGET_FINALIZE_HOOKS += LIBGLIB2_REMOVE_TARGET_SCHEMAS
-TARGET_FINALIZE_HOOKS += LIBGLIB2_COMPILE_SCHEMAS
-endif
+LIBGLIB2_TARGET_FINALIZE_HOOKS += LIBGLIB2_REMOVE_TARGET_SCHEMAS
+LIBGLIB2_TARGET_FINALIZE_HOOKS += LIBGLIB2_COMPILE_SCHEMAS
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/libgtk3/libgtk3.mk +1 -3
index f447e7a..08d172f 100644
@@ -182,13 +182,11 @@ endef
 
 # Create icon-theme.cache for each of the icon directories/themes
 # It's not strictly necessary but speeds up lookups
-ifeq ($(BR2_PACKAGE_LIBGTK3),y)
 define LIBGTK3_UPDATE_ICON_CACHE
 	find $(TARGET_DIR)/usr/share/icons -maxdepth 1 -mindepth 1 -type d \
 		-exec $(HOST_DIR)/usr/bin/gtk-update-icon-cache {} \;
 endef
-TARGET_FINALIZE_HOOKS += LIBGTK3_UPDATE_ICON_CACHE
-endif
+LIBGTK3_TARGET_FINALIZE_HOOKS += LIBGTK3_UPDATE_ICON_CACHE
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
package/luarocks/luarocks.mk +1 -2
index 656b832..eddd435 100644
@@ -60,5 +60,4 @@ define LUAROCKS_FINALIZE_TARGET
 	rm -rf $(TARGET_DIR)/usr/lib/luarocks
 endef
 
-TARGET_FINALIZE_HOOKS += LUAROCKS_FINALIZE_TARGET
-
+LUAROCKS_TARGET_FINALIZE_HOOKS += LUAROCKS_FINALIZE_TARGET
package/perl/perl.mk +1 -3
index 29af7a4..ca70123 100644
@@ -114,7 +114,6 @@ endef
 $(eval $(generic-package))
 $(eval $(host-generic-package))
 
-ifeq ($(BR2_PACKAGE_PERL),y)
 define PERL_FINALIZE_TARGET
 	rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/pod
 	rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/$(PERL_ARCHNAME)/CORE
@@ -122,5 +121,4 @@ define PERL_FINALIZE_TARGET
 	find $(TARGET_DIR)/usr/lib/perl5/ -name '*.bs' -print0 | xargs -0 rm -f
 	find $(TARGET_DIR)/usr/lib/perl5/ -name '.packlist' -print0 | xargs -0 rm -f
 endef
-TARGET_FINALIZE_HOOKS += PERL_FINALIZE_TARGET
-endif
+PERL_TARGET_FINALIZE_HOOKS += PERL_FINALIZE_TARGET
package/python/python.mk +4 -6
index 913dc2c..5e13bf3 100644
@@ -226,7 +226,7 @@ define PYTHON_CREATE_PYC_FILES
 endef
 
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY)$(BR2_PACKAGE_PYTHON_PY_PYC),y)
-TARGET_FINALIZE_HOOKS += PYTHON_CREATE_PYC_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_CREATE_PYC_FILES
 endif
 
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
@@ -234,7 +234,7 @@ define PYTHON_REMOVE_PY_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.py' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PY_FILES
 endif
 
 # Normally, *.pyc files should not have been compiled, but just in
@@ -244,14 +244,12 @@ define PYTHON_REMOVE_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYC_FILES
 endif
 
 # In all cases, we don't want to keep the optimized .pyo files
-ifeq ($(BR2_PACKAGE_PYTHON),y)
 define PYTHON_REMOVE_PYO_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR) -name '*.pyo' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYO_FILES
-endif
+PYTHON_TARGET_FINALIZE_HOOKS += PYTHON_REMOVE_PYO_FILES
package/python3/python3.mk +4 -6
index 8459b11..dc776fe 100644
@@ -217,7 +217,7 @@ define PYTHON3_CREATE_PYC_FILES
 endef
 
 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY)$(BR2_PACKAGE_PYTHON3_PY_PYC),y)
-TARGET_FINALIZE_HOOKS += PYTHON3_CREATE_PYC_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_CREATE_PYC_FILES
 endif
 
 ifeq ($(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
@@ -225,7 +225,7 @@ define PYTHON3_REMOVE_PY_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PY_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PY_FILES
 endif
 
 # Normally, *.pyc files should not have been compiled, but just in
@@ -235,16 +235,14 @@ define PYTHON3_REMOVE_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PYC_FILES
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_PYC_FILES
 endif
 
 # In all cases, we don't want to keep the optimized .opt-1.pyc and
 # .opt-2.pyc files, since they can't work without their non-optimized
 # variant.
-ifeq ($(BR2_PACKAGE_PYTHON3),y)
 define PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
 	find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.opt-1.pyc' -print0 -o -name '*.opt-2.pyc' -print0 | \
 		xargs -0 --no-run-if-empty rm -f
 endef
-TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
-endif
+PYTHON3_TARGET_FINALIZE_HOOKS += PYTHON3_REMOVE_OPTIMIZED_PYC_FILES
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#46 lore raw

PATCH v2 15/24 packages: use the <PKG>_TARGET_FINALIZE_HOOKS

In reply to Yann E. MORIN

Hello,

Quoted 13 lines · Yann E. MORIN

Register package-specific target-finalize hooks with the newly-introduced <PKG>_TARGET_FINALIZE_HOOKS.

This incidentally fixes luarocks, which was registering target-finalize hooks even when it was not enabled.

To be noted, the skeleton package is not converted, because it is not optional, we always have it; so its hooks would always be registered anyway. Besides, the followup patches would render this conversion moot anyway, since those hooks would be spread across the various skeleton packages.

Quoted 9 lines
---
 package/google-breakpad/google-breakpad.mk |  6 ++----
 package/libglib2/libglib2.mk               |  6 ++----
 package/libgtk3/libgtk3.mk                 |  4 +---
 package/luarocks/luarocks.mk               |  3 +--
 package/perl/perl.mk                       |  4 +---
 package/python/python.mk                   | 10 ++++------
 package/python3/python3.mk                 | 10 ++++------
 7 files changed, 15 insertions(+), 28 deletions(-)

Applied to master, thanks. Please send a followup patch changing the TARGET_FINALIZE_HOOKS in the toolchain package, as suggested by Romain.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#47 lore raw

PATCH v2 16/24 package/skeleton: split into sysv and custom skeleton

In reply to Yann E. MORIN

Currently, both the sysv-like and custom skeletons are managed in a single package.

However, for the custom skeleton, we basically do nothing, except for a few symlinks for the /lib directory aliases, and a few checks about merged /usr.

OTOH, for the default (sysv-like) skeleton, we do a lot more things, like tweaking the issue, the hostname, setting the root password and so on...

Furthermore, we're soon gonna have a skeleton for each kind of init system, be it sysv-based or systemd.

So, it makes sense to offload the custom skeleton management to its own package.

We change the way we check for the merged /usr readiness, from checking at make parse time, to a configure command. This has virtually zero impact, since the skeleton is the very first package to be "built", so its configure commands are the very first to be run. It however slightly cimplifies the .mk as we need not enclose the parse-time checks inside an ifeq-block to check if the package is enabled.

---
 package/Config.in                          |   2 +
 package/skeleton-custom/Config.in          |   2 +
 package/skeleton-custom/skeleton-custom.mk | 112 +++++++++++++++++++
 package/skeleton-sysv/Config.in            |   2 +
 package/skeleton-sysv/skeleton-sysv.mk     | 126 +++++++++++++++++++++
 package/skeleton/Config.in                 |   2 +
 package/skeleton/skeleton.mk               | 172 ++++-------------------------
 7 files changed, 265 insertions(+), 153 deletions(-)
 create mode 100644 package/skeleton-custom/Config.in
 create mode 100644 package/skeleton-custom/skeleton-custom.mk
 create mode 100644 package/skeleton-sysv/Config.in
 create mode 100644 package/skeleton-sysv/skeleton-sysv.mk
package/Config.in +2 -0
index a2a02a8..fd445f4 100644
@@ -2,6 +2,8 @@ menu "Target packages"
 
 	source "package/busybox/Config.in"
 	source "package/skeleton/Config.in"
+	source "package/skeleton-custom/Config.in"
+	source "package/skeleton-sysv/Config.in"
 
 menu "Audio and video applications"
 	source "package/alsa-utils/Config.in"
package/skeleton-custom/Config.in new file +2 -0
new file mode 100644
index 0000000..1f3c87c
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_SKELETON_CUSTOM
+	bool
package/skeleton-custom/skeleton-custom.mk new file +112 -0

112 lines not on this page · raw message

package/skeleton-sysv/Config.in new file +2 -0
new file mode 100644
index 0000000..8c2e7dd
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_SKELETON_SYSV
+	bool
package/skeleton-sysv/skeleton-sysv.mk new file +126 -0

126 lines not on this page · raw message

package/skeleton/Config.in +2 -0
index d25147b..6db0634 100644
@@ -1,5 +1,7 @@
 config BR2_PACKAGE_SKELETON
 	bool
 	default y
+	select BR2_PACKAGE_SKELETON_SYSV   if BR2_ROOTFS_SKELETON_DEFAULT
+	select BR2_PACKAGE_SKELETON_CUSTOM if BR2_ROOTFS_SKELETON_CUSTOM
 	help
 	  The basic skeleton for your rootfs.
package/skeleton/skeleton.mk +19 -153

213 lines not on this page · raw message

Signature · 1 line
2.7.4
#48 lore raw

PATCH v2 16/24 package/skeleton: split into sysv and custom skeleton

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 14 lines

Currently, both the sysv-like and custom skeletons are managed in a single package.

However, for the custom skeleton, we basically do nothing, except for a few symlinks for the /lib directory aliases, and a few checks about merged /usr.

OTOH, for the default (sysv-like) skeleton, we do a lot more things, like tweaking the issue, the hostname, setting the root password and so on...

Furthermore, we're soon gonna have a skeleton for each kind of init system, be it sysv-based or systemd.

Quoted 8 lines

So, it makes sense to offload the custom skeleton management to its own package.

We change the way we check for the merged /usr readiness, from checking at make parse time, to a configure command. This has virtually zero impact, since the skeleton is the very first package to be "built", so its configure commands are the very first to be run. It however slightly cimplifies the .mk as we need not enclose the parse-time checks inside

^
s/cimplifies/simplifies/

Quoted 188 lines

an ifeq-block to check if the package is enabled.

---
 package/Config.in                          |   2 +
 package/skeleton-custom/Config.in          |   2 +
 package/skeleton-custom/skeleton-custom.mk | 112 +++++++++++++++++++
 package/skeleton-sysv/Config.in            |   2 +
 package/skeleton-sysv/skeleton-sysv.mk     | 126 +++++++++++++++++++++
 package/skeleton/Config.in                 |   2 +
 package/skeleton/skeleton.mk               | 172 ++++-------------------------
 7 files changed, 265 insertions(+), 153 deletions(-)
 create mode 100644 package/skeleton-custom/Config.in
 create mode 100644 package/skeleton-custom/skeleton-custom.mk
 create mode 100644 package/skeleton-sysv/Config.in
 create mode 100644 package/skeleton-sysv/skeleton-sysv.mk
package/Config.in +2 -0
index a2a02a8..fd445f4 100644
@@ -2,6 +2,8 @@ menu "Target packages"
 
 	source "package/busybox/Config.in"
 	source "package/skeleton/Config.in"
+	source "package/skeleton-custom/Config.in"
+	source "package/skeleton-sysv/Config.in"
 
 menu "Audio and video applications"
 	source "package/alsa-utils/Config.in"
package/skeleton-custom/Config.in new file +2 -0
new file mode 100644
index 0000000..1f3c87c
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_SKELETON_CUSTOM
+	bool
package/skeleton-custom/skeleton-custom.mk new file +112 -0
new file mode 100644
index 0000000..8690af4
@@ -0,0 +1,112 @@
+################################################################################
+#
+# skeleton-custom
+#
+################################################################################
+
+SKELETON_CUSTOM_SOURCE =
+
+SKELETON_CUSTOM_ADD_TOOLCHAIN_DEPENDENCY = NO
+SKELETON_CUSTOM_ADD_SKELETON_DEPENDENCY = NO
+
+SKELETON_CUSTOM_INSTALL_STAGING = YES
+
+SKELETON_CUSTOM_PATH = $(call qstrip,$(BR2_ROOTFS_SKELETON_CUSTOM_PATH))
+
+# Extract the inode numbers for all of those directories. In case any is
+# a symlink, we want to get the inode of the pointed-to directory, so we
+# append '/.' to be sure we get the target directory. Since the symlinks
+# can be anyway (/bin -> /usr/bin or /usr/bin -> /bin), we do that for
+# all of them.
+#
+SKELETON_CUSTOM_LIB_INODE = $(shell stat -c '%i' $(SKELETON_CUSTOM_PATH)/lib/. 2>/dev/null)
+SKELETON_CUSTOM_BIN_INODE = $(shell stat -c '%i' $(SKELETON_CUSTOM_PATH)/bin/. 2>/dev/null)
+SKELETON_CUSTOM_SBIN_INODE = $(shell stat -c '%i' $(SKELETON_CUSTOM_PATH)/sbin/. 2>/dev/null)
+SKELETON_CUSTOM_USR_LIB_INODE = $(shell stat -c '%i' $(SKELETON_CUSTOM_PATH)/usr/lib/. 2>/dev/null)
+SKELETON_CUSTOM_USR_BIN_INODE = $(shell stat -c '%i' $(SKELETON_CUSTOM_PATH)/usr/bin/. 2>/dev/null)
+SKELETON_CUSTOM_USR_SBIN_INODE = $(shell stat -c '%i' $(SKELETON_CUSTOM_PATH)/usr/sbin/. 2>/dev/null)
+
+# Ensure that the custom skeleton has /lib, /bin and /sbin, and their
+# /usr counterparts
+define SKELETON_CUSTOM_MISSING_DIRS
+	if [ -z "$(SKELETON_CUSTOM_LIB_INODE)" ]; then \
+		missing+=" /lib"; \
+	fi; \
+	if [ -z "$(SKELETON_CUSTOM_USR_LIB_INODE)" ]; then \
+		missing+=" /usr/lib"; \
+	fi; \
+	if [ -z "$(SKELETON_CUSTOM_BIN_INODE)" ]; then \
+		missing+=" /bin"; \
+	fi; \
+	if [ -z "$(SKELETON_CUSTOM_USR_BIN_INODE)" ]; then \
+		missing+=" /usr/bin"; \
+	fi; \
+	if [ -z "$(SKELETON_CUSTOM_SBIN_INODE)" ]; then \
+		missing+=" /sbin"; \
+	fi; \
+	if [ -z "$(SKELETON_CUSTOM_USR_SBIN_INODE)" ]; then \
+		missing+=" /usr/sbin"; \
+	fi; \
+	if [ "$${missing" ]; then \
+		printf "The custom skeleton in %s is missing\n" "$(SKELETON_CUSTOM_PATH)"; \
+		printf "the following directories:\n"; \
+		printf "   %s\n" "$${missing}"; \
+		exit 1; \
+	fi
+endef
+
+# For a merged /usr, ensure that /lib, /bin and /sbin and their /usr
+# counterparts are appropriately setup symlinks ones to the others.
+ifeq ($(BR2_ROOTFS_MERGED_USR),y)
+
+define SKELETON_CUSTOM_MERGED_USR
+	if [ $(SKELETON_LIB_INODE) != $(SKELETON_USR_LIB_INODE) ]; then \
+		missing+=" /lib"; \
+	fi; \
+	if [ $(SKELETON_BIN_INODE) != $(SKELETON_USR_BIN_INODE) ]; then \
+		missing+=" /bin"; \
+	fi; \
+	if [ $(SKELETON_SBIN_INODE) != $(SKELETON_USR_SBIN_INODE) ]; then \
+		missing+=" /sbin"; \
+	fi;
+	if [ "$${missing}" ]; then
+		printf "The custom skeleton in %s is not\n" "$(SKELETON_CUSTOM_PATH)"; \
+		printf "using a merged /usr for the following directories:\n"; \
+		printf "   %s\n" "$${missing}"; \
+		exit 1; \
+	fi
+endef
+
+endif # merged /usr
+
+# We used to do the followinf checks in Makefile code, to catch the
+# errors as early as possible. But the skeleton is the very first
+# package to be installed, so we do the checks in its configure
+# commands; they are almost as early as if they were done in Makefile
+# code.
+define SKELETON_CUSTOM_CONFIGURE_CMDS
+	$(SKELETON_CUSTOM_MISSING_DIRS)
+	$(SKELETON_CUSTOM_MERGED_USR)
+endef
+
+# Provided by the 'skeleton' package:
+# - SKELETON_LIB_SYMLINK
+
+define SKELETON_CUSTOM_INSTALL_TARGET_CMDS
+	$(call SKELETON_RSYNC,$(SKELETON_CUSTOM_PATH),$(TARGET_DIR))
+	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
+	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
+endef
+
+# For the staging dir, we don't really care what we install, but we
+# need the /lib and /usr/lib apropriately setup.
+# Since we ensure, above, that they are correct in the skeleton, we
+# can simply copy it to staging.
+define SKELETON_CUSTOM_INSTALL_STAGING_CMDS
+	$(call SKELETON_RSYNC,$(SKELETON_CUSTOM_PATH),$(STAGING_DIR))
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
+	ln -snf lib $(STAGING_DIR)/$(SKELETON_LIB_SYMLINK)
+	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
+endef
+
+$(eval $(generic-package))
package/skeleton-sysv/Config.in new file +2 -0
new file mode 100644
index 0000000..8c2e7dd
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_SKELETON_SYSV
+	bool
package/skeleton-sysv/skeleton-sysv.mk new file +18 -0
new file mode 100644
index 0000000..0a2f51b
@@ -0,0 +1,126 @@
+################################################################################
+#
+# skeleton-sysv
+#
+################################################################################
+
+SKELETON_SYSV_SOURCE =
+
+SKELETON_SYSV_ADD_TOOLCHAIN_DEPENDENCY = NO
+SKELETON_SYSV_ADD_SKELETON_DEPENDENCY = NO
+
+SKELETON_SYSV_INSTALL_STAGING = YES
+
+# Provided by the 'skeleton' package:
+# - SKELETON_USR_SYMLINKS_OR_DIRS
+# - SKELETON_LIB_SYMLINK
+# - SKELETON_TARGET_GENERIC_HOSTNAME
+# - SKELETON_TARGET_GENERIC_ISSUE

package/skeleton-sysv/skeleton-sysv.mk line 28

Quoted 10 lines
package/skeleton-sysv/skeleton-sysv.mk new file +10 -0
+# - SKELETON_TARGET_ROOT_PASSWD
+# - SKELETON_TARGET_GENERIC_BIN_SH
+# - SKELETON_TARGET_GENERIC_GETTY_PORT
+# - SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
+# - SKELETON_TARGET_GENERIC_GETTY_TERM
+# - SKELETON_TARGET_GENERIC_GETTY_OPTIONS
+# - SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK
+# - SKELETON_SET_NETWORK_IFUPDOWN_DHCP
+
+define SKELETON_INSTALL_TARGET_CMDS

s/SKELETON_INSTALL_TARGET_CMDS/SKELETON_SYSV_INSTALL_TARGET_CMDS/

Quoted 324 lines
package/skeleton-sysv/skeleton-sysv.mk new file +98 -0
+	$(call SKELETON_RSYNC,system/skeleton,$(TARGET_DIR))
+	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
+	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
+	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
+	$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
+		$(TARGET_DIR_WARNING_FILE)
+endef
+
+# For the staging dir, we don't really care about /bin and /sbin.
+# But for consistency with the target dir, and to simplify the code,
+# we still handle them for the merged or non-merged /usr cases.
+# Since the toolchain is not yet available, the staging is not yet
+# populated, so we need to create the directories in /usr
+define SKELETON_SYSV_INSTALL_STAGING_CMDS
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/lib
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/bin
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/sbin
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
+	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(STAGING_DIR))
+	ln -snf lib $(STAGING_DIR)/$(SKELETON_LIB_SYMLINK)
+	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
+endef
+
+ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME),)
+define SKELETON_SYSV_SET_HOSTNAME
+	mkdir -p $(TARGET_DIR)/etc
+	echo "$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
+	$(SED) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
+		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
+endef
+SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_HOSTNAME
+endif
+
+ifneq ($(SKELETON_TARGET_GENERIC_ISSUE),)
+define SKELETON_SYSV_SET_ISSUE
+	mkdir -p $(TARGET_DIR)/etc
+	echo "$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue
+endef
+SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_ISSUE
+endif
+
+define SKELETON_SYSV_SET_NETWORK
+	mkdir -p $(TARGET_DIR)/etc/network/
+	$(SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK)
+	$(SKELETON_SET_NETWORK_IFUPDOWN_DHCP)
+endef
+SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_NETWORK
+
+define SKELETON_SYSV_SET_ROOT_PASSWD
+	$(SED) s,^root:[^:]*:,root:$(SKELETON_SYSV_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
+endef
+SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_ROOT_PASSWD
+
+ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
+define SKELETON_SYSV_BIN_SH
+	rm -f $(TARGET_DIR)/bin/sh
+endef
+else
+define SKELETON_SYSV_BIN_SH
+	ln -sf $(SKELETON_TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
+endef
+endif
+SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_BIN_SH
+
+ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
+ifeq ($(BR2_INIT_SYSV),y)
+# In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
+# skip the "tty" part and keep only the remaining.
+define SKELETON_SYSV_SET_GETTY
+	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(shell echo $(SKELETON_TARGET_GENERIC_GETTY_PORT) | tail -c+4)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
+		$(TARGET_DIR)/etc/inittab
+endef
+else ifeq ($(BR2_INIT_BUSYBOX),y)
+# Add getty to busybox inittab
+define SKELETON_SYSV_SET_GETTY
+	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(SKELETON_TARGET_GENERIC_GETTY_PORT)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
+		$(TARGET_DIR)/etc/inittab
+endef
+endif
+SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_GETTY
+endif
+
+ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y)
+ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
+# Find commented line, if any, and remove leading '#'s
+define SKELETON_SYSV_REMOUNT_RW
+	$(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
+endef
+else
+# Find uncommented line, if any, and add a leading '#'
+define SKELETON_SYSV_REMOUNT_RW
+	$(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
+endef
+endif
+SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_REMOUNT_RW
+endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
+
+$(eval $(generic-package))
package/skeleton/Config.in +2 -0
index d25147b..6db0634 100644
@@ -1,5 +1,7 @@
 config BR2_PACKAGE_SKELETON
 	bool
 	default y
+	select BR2_PACKAGE_SKELETON_SYSV   if BR2_ROOTFS_SKELETON_DEFAULT
+	select BR2_PACKAGE_SKELETON_CUSTOM if BR2_ROOTFS_SKELETON_CUSTOM
 	help
 	  The basic skeleton for your rootfs.
package/skeleton/skeleton.mk +19 -144
index e3ae694..bd787db 100644
@@ -7,6 +7,10 @@
 # source included in buildroot
 SKELETON_SOURCE =
 
+SKELETON_DEPENDENCIES = \
+	$(if $(BR2_PACKAGE_SKELETON_SYSV),skeleton-sysv) \
+	$(if $(BR2_PACKAGE_SKELETON_CUSTOM),skeleton-custom)
+
 # The skeleton can't depend on the toolchain, since all packages depends on the
 # skeleton and the toolchain is a target package, as is skeleton.
 # Hence, skeleton would depends on the toolchain and the toolchain would depend
@@ -14,53 +18,19 @@ SKELETON_SOURCE =
 SKELETON_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_ADD_SKELETON_DEPENDENCY = NO
 
-# The skeleton also handles the merged /usr case in the sysroot
-SKELETON_INSTALL_STAGING = YES
-
-ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM),y)
-
-SKELETON_PATH = $(call qstrip,$(BR2_ROOTFS_SKELETON_CUSTOM_PATH))
-
-ifeq ($(BR2_ROOTFS_MERGED_USR),y)
-
-# Ensure the user has prepared a merged /usr.
-#
-# Extract the inode numbers for all of those directories. In case any is
-# a symlink, we want to get the inode of the pointed-to directory, so we
-# append '/.' to be sure we get the target directory. Since the symlinks
-# can be anyway (/bin -> /usr/bin or /usr/bin -> /bin), we do that for
-# all of them.
-#
-SKELETON_LIB_INODE = $(shell stat -c '%i' $(SKELETON_PATH)/lib/.)
-SKELETON_BIN_INODE = $(shell stat -c '%i' $(SKELETON_PATH)/bin/.)
-SKELETON_SBIN_INODE = $(shell stat -c '%i' $(SKELETON_PATH)/sbin/.)
-SKELETON_USR_LIB_INODE = $(shell stat -c '%i' $(SKELETON_PATH)/usr/lib/.)
-SKELETON_USR_BIN_INODE = $(shell stat -c '%i' $(SKELETON_PATH)/usr/bin/.)
-SKELETON_USR_SBIN_INODE = $(shell stat -c '%i' $(SKELETON_PATH)/usr/sbin/.)
-
-ifneq ($(SKELETON_LIB_INODE),$(SKELETON_USR_LIB_INODE))
-SKELETON_CUSTOM_NOT_MERGED_USR += /lib
-endif
-ifneq ($(SKELETON_BIN_INODE),$(SKELETON_USR_BIN_INODE))
-SKELETON_CUSTOM_NOT_MERGED_USR += /bin
-endif
-ifneq ($(SKELETON_SBIN_INODE),$(SKELETON_USR_SBIN_INODE))
-SKELETON_CUSTOM_NOT_MERGED_USR += /sbin
-endif
-
-ifneq ($(SKELETON_CUSTOM_NOT_MERGED_USR),)
-$(error The custom skeleton in $(SKELETON_PATH) is not \
-	using a merged /usr for the following directories: \
-	$(SKELETON_CUSTOM_NOT_MERGED_USR))
-endif
-
-endif # merged /usr
-
-else # ! custom skeleton
-
-SKELETON_PATH = system/skeleton
-
-endif # ! custom skeleton
+# The following definitions are to be used by the specific skeletons:
+# - SKELETON_USR_SYMLINKS_OR_DIRS
+# - SKELETON_LIB_SYMLINK
+# - SKELETON_TARGET_GENERIC_HOSTNAME
+# - SKELETON_TARGET_GENERIC_ISSUE
+# - SKELETON_TARGET_ROOT_PASSWD
+# - SKELETON_TARGET_GENERIC_BIN_SH
+# - SKELETON_TARGET_GENERIC_GETTY_PORT
+# - SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
+# - SKELETON_TARGET_GENERIC_GETTY_TERM
+# - SKELETON_TARGET_GENERIC_GETTY_OPTIONS
+# - SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK
+# - SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 
 # This function rsyncs the skeleton directory in $(1) to the destination
 # in $(2), which should be either $(TARTGET_DIR) or $(STAGING_DIR)
@@ -93,34 +63,6 @@ else
 SKELETON_LIB_SYMLINK = lib32
 endif
 
-define SKELETON_INSTALL_TARGET_CMDS
-	$(call SKELETON_RSYNC,$(SKELETON_PATH),$(TARGET_DIR))
-	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
-	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
-	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
-	$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
-		$(TARGET_DIR_WARNING_FILE)
-endef
-
-# For the staging dir, we don't really care about /bin and /sbin.
-# But for consistency with the target dir, and to simplify the code,
-# we still handle them for the merged or non-merged /usr cases.
-# Since the toolchain is not yet available, the staging is not yet
-# populated, so we need to create the directories in /usr
-define SKELETON_INSTALL_STAGING_CMDS
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/lib
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/bin
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/sbin
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
-	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(STAGING_DIR))
-	ln -snf lib $(STAGING_DIR)/$(SKELETON_LIB_SYMLINK)
-	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
-endef
-
-# The TARGET_FINALIZE_HOOKS must be sourced only if the users choose to use the
-# default skeleton.
-ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y)
-
 SKELETON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
 SKELETON_TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
 SKELETON_TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
@@ -131,25 +73,8 @@ SKELETON_TARGET_GENERIC_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETT
 SKELETON_TARGET_GENERIC_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
 SKELETON_TARGET_GENERIC_GETTY_OPTIONS = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_OPTIONS))
 
-ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME),)
-define SKELETON_SET_HOSTNAME
-	mkdir -p $(TARGET_DIR)/etc
-	echo "$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
-	$(SED) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
-		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
-endef
-TARGET_FINALIZE_HOOKS += SKELETON_SET_HOSTNAME
-endif
 
-ifneq ($(SKELETON_TARGET_GENERIC_ISSUE),)
-define SKELETON_SET_ISSUE
-	mkdir -p $(TARGET_DIR)/etc
-	echo "$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue
-endef
-TARGET_FINALIZE_HOOKS += SKELETON_SET_ISSUE
-endif
-
-define SKELETON_SET_NETWORK_LOCALHOST
+define SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK
 	( \
 		echo "# interface file auto-generated by buildroot"; \
 		echo ;                                               \
@@ -161,7 +86,7 @@ endef
 SKELETON_NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SYSTEM_DHCP))
 
 ifneq ($(SKELETON_NETWORK_DHCP_IFACE),)
-define SKELETON_SET_NETWORK_DHCP
+define SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 	( \
 		echo ;                                               \
 		echo "auto $(SKELETON_NETWORK_DHCP_IFACE)";                   \
@@ -174,14 +99,6 @@ define SKELETON_SET_NETWORK_DHCP
 endef
 endif
 
-define SKELETON_SET_NETWORK
-	mkdir -p $(TARGET_DIR)/etc/network/
-	$(SKELETON_SET_NETWORK_LOCALHOST)
-	$(SKELETON_SET_NETWORK_DHCP)
-endef
-
-TARGET_FINALIZE_HOOKS += SKELETON_SET_NETWORK
-
 ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
 ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
 SKELETON_ROOT_PASSWORD =
@@ -197,55 +114,4 @@ else # !BR2_TARGET_ENABLE_ROOT_LOGIN
 SKELETON_ROOT_PASSWORD = "*"
 endif
 
-define SKELETON_SET_ROOT_PASSWD
-	$(SED) s,^root:[^:]*:,root:$(SKELETON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
-endef
-TARGET_FINALIZE_HOOKS += SKELETON_SET_ROOT_PASSWD
-
-ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
-define SKELETON_BIN_SH
-	rm -f $(TARGET_DIR)/bin/sh
-endef
-else
-define SKELETON_BIN_SH
-	ln -sf $(SKELETON_TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
-endef
-endif
-TARGET_FINALIZE_HOOKS += SKELETON_BIN_SH
-
-ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
-ifeq ($(BR2_INIT_SYSV),y)
-# In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
-# skip the "tty" part and keep only the remaining.
-define SKELETON_SET_GETTY
-	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(shell echo $(SKELETON_TARGET_GENERIC_GETTY_PORT) | tail -c+4)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
-		$(TARGET_DIR)/etc/inittab
-endef
-else ifeq ($(BR2_INIT_BUSYBOX),y)
-# Add getty to busybox inittab
-define SKELETON_SET_GETTY
-	$(SED) '/# GENERIC_SERIAL$$/s~^.*#~$(SKELETON_TARGET_GENERIC_GETTY_PORT)::respawn:/sbin/getty -L $(SKELETON_TARGET_GENERIC_GETTY_OPTIONS) $(SKELETON_TARGET_GENERIC_GETTY_PORT) $(SKELETON_TARGET_GENERIC_GETTY_BAUDRATE) $(SKELETON_TARGET_GENERIC_GETTY_TERM) #~' \
-		$(TARGET_DIR)/etc/inittab
-endef
-endif
-TARGET_FINALIZE_HOOKS += SKELETON_SET_GETTY
-endif
-
-ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y)
-ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
-# Find commented line, if any, and remove leading '#'s
-define SKELETON_REMOUNT_RW
-	$(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab
-endef
-else
-# Find uncommented line, if any, and add a leading '#'

package/skeleton/skeleton.mk else # !BR2_TARGET_ENABLE_ROOT_LOGIN · line 117

Quoted 10 lines
package/skeleton/skeleton.mk +0 -9
-define SKELETON_REMOUNT_RW
-	$(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab
-endef
-endif
-TARGET_FINALIZE_HOOKS += SKELETON_REMOUNT_RW
-endif # BR2_INIT_BUSYBOX || BR2_INIT_SYSV
-
-endif # BR2_ROOTFS_SKELETON_DEFAULT
-
 $(eval $(generic-package))

Have you considered to convert skeleton package to a virtual package with skeleton-sysv and skeleton-custom as providers ?

Best regards,
Romain

Quoted 1 line
#49 lore raw

PATCH v2 16/24 package/skeleton: split into sysv and custom skeleton

Romain, All,

On 2016-07-03 12:27 +0200, Romain Naour spake thusly:

Quoted 18 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 17 lines

Currently, both the sysv-like and custom skeletons are managed in a single package.

However, for the custom skeleton, we basically do nothing, except for a few symlinks for the /lib directory aliases, and a few checks about merged /usr.

OTOH, for the default (sysv-like) skeleton, we do a lot more things, like tweaking the issue, the hostname, setting the root password and so on...

Furthermore, we're soon gonna have a skeleton for each kind of init system, be it sysv-based or systemd.

So, it makes sense to offload the custom skeleton management to its own package.

Quoted 7 lines
Quoted 5 lines

We change the way we check for the merged /usr readiness, from checking at make parse time, to a configure command. This has virtually zero impact, since the skeleton is the very first package to be "built", so its configure commands are the very first to be run. It however slightly cimplifies the .mk as we need not enclose the parse-time checks inside

^
s/cimplifies/simplifies/

Fixed.

[--SNIP--]

Quoted 28 lines
Quoted 28 lines
package/skeleton-sysv/skeleton-sysv.mk new file +22 -0
new file mode 100644
index 0000000..0a2f51b
@@ -0,0 +1,126 @@
+################################################################################
+#
+# skeleton-sysv
+#
+################################################################################
+
+SKELETON_SYSV_SOURCE =
+
+SKELETON_SYSV_ADD_TOOLCHAIN_DEPENDENCY = NO
+SKELETON_SYSV_ADD_SKELETON_DEPENDENCY = NO
+
+SKELETON_SYSV_INSTALL_STAGING = YES
+
+# Provided by the 'skeleton' package:
+# - SKELETON_USR_SYMLINKS_OR_DIRS
+# - SKELETON_LIB_SYMLINK
+# - SKELETON_TARGET_GENERIC_HOSTNAME
+# - SKELETON_TARGET_GENERIC_ISSUE
+# - SKELETON_TARGET_ROOT_PASSWD
+# - SKELETON_TARGET_GENERIC_BIN_SH
+# - SKELETON_TARGET_GENERIC_GETTY_PORT
+# - SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
Quoted 8 lines

package/skeleton-sysv/skeleton-sysv.mk line 28

Quoted 6 lines
package/skeleton-sysv/skeleton-sysv.mk new file +6 -0
+# - SKELETON_TARGET_GENERIC_GETTY_TERM
+# - SKELETON_TARGET_GENERIC_GETTY_OPTIONS
+# - SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK
+# - SKELETON_SET_NETWORK_IFUPDOWN_DHCP
+
+define SKELETON_INSTALL_TARGET_CMDS

s/SKELETON_INSTALL_TARGET_CMDS/SKELETON_SYSV_INSTALL_TARGET_CMDS/

Good catch, fixed.

[--SNIP--]

Quoted 2 lines

Have you considered to convert skeleton package to a virtual package with skeleton-sysv and skeleton-custom as providers ?

Have you considered looking at the following patch? ;-) (I know you have!)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#50 lore raw

PATCH v2 17/24 package/skeleton: make it a virtual package

In reply to Yann E. MORIN

The skeleton package now only serves as an intermediate package to direct to the real skeleton implementaion.

This is exactly what a virtual package is. Make it so.

Note: when graphing the dependency chain, and contrary to other virtual packages, skeleton is de facto excluded from the dependencies of all packages, and is "attached" as a dependency of the "All" package instead, so as not to make the graph overly complicated and unreadable.

So, for it to appear on the graph, it needs to have a BR2_PACKAGE_SKELETON kconfig variable, so that it appears in the output of "make show-targets", like we do for the toolchain.

---
 package/skeleton-custom/Config.in          |  4 ++++
 package/skeleton-custom/skeleton-custom.mk |  2 ++
 package/skeleton-sysv/Config.in            |  4 ++++
 package/skeleton-sysv/skeleton-sysv.mk     |  2 ++
 package/skeleton/Config.in                 | 13 +++++++++++--
 package/skeleton/skeleton.mk               | 11 ++---------
 system/Config.in                           |  2 ++
 7 files changed, 27 insertions(+), 11 deletions(-)
package/skeleton-custom/Config.in +4 -0
index 1f3c87c..601c3b2 100644
@@ -1,2 +1,6 @@
 config BR2_PACKAGE_SKELETON_CUSTOM
 	bool
+	select BR2_PACKAGE_HAS_SKELETON
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	default "skeleton-custom" if BR2_PACKAGE_SKELETON_CUSTOM
package/skeleton-custom/skeleton-custom.mk +2 -0
index 8690af4..e251448 100644
@@ -6,6 +6,8 @@
 
 SKELETON_CUSTOM_SOURCE =
 
+SKELETON_CUSTOM_PROVIDES = skeleton
+
 SKELETON_CUSTOM_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_CUSTOM_ADD_SKELETON_DEPENDENCY = NO
 
package/skeleton-sysv/Config.in +4 -0
index 8c2e7dd..95c796f 100644
@@ -1,2 +1,6 @@
 config BR2_PACKAGE_SKELETON_SYSV
 	bool
+	select BR2_PACKAGE_HAS_SKELETON
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	default "skeleton-sysv" if BR2_PACKAGE_SKELETON_SYSV
package/skeleton-sysv/skeleton-sysv.mk +2 -0
index 0a2f51b..aa0b65c 100644
@@ -6,6 +6,8 @@
 
 SKELETON_SYSV_SOURCE =
 
+SKELETON_SYSV_PROVIDES = skeleton
+
 SKELETON_SYSV_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_SYSV_ADD_SKELETON_DEPENDENCY = NO
 
package/skeleton/Config.in +11 -2
index 6db0634..762196c 100644
@@ -1,7 +1,16 @@
+# Every packages depend on the 'skeleton' package, but noone selects its
+# symbol since it is an implicit dependency. So we just force that symbol
+# to always be 'y' so that it does appear in the dependency graph. Just
+# for that, no kidding.
 config BR2_PACKAGE_SKELETON
 	bool
 	default y
-	select BR2_PACKAGE_SKELETON_SYSV   if BR2_ROOTFS_SKELETON_DEFAULT
-	select BR2_PACKAGE_SKELETON_CUSTOM if BR2_ROOTFS_SKELETON_CUSTOM
 	help
 	  The basic skeleton for your rootfs.
+
+config BR2_PACKAGE_HAS_SKELETON
+	bool
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	string
+	depends on BR2_PACKAGE_SKELETON
package/skeleton/skeleton.mk +2 -9
index bd787db..b791650 100644
@@ -4,13 +4,6 @@
 #
 ################################################################################
 
-# source included in buildroot
-SKELETON_SOURCE =
-
-SKELETON_DEPENDENCIES = \
-	$(if $(BR2_PACKAGE_SKELETON_SYSV),skeleton-sysv) \
-	$(if $(BR2_PACKAGE_SKELETON_CUSTOM),skeleton-custom)
-
 # The skeleton can't depend on the toolchain, since all packages depends on the
 # skeleton and the toolchain is a target package, as is skeleton.
 # Hence, skeleton would depends on the toolchain and the toolchain would depend
@@ -18,6 +11,8 @@ SKELETON_DEPENDENCIES = \
 SKELETON_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_ADD_SKELETON_DEPENDENCY = NO
 
+$(eval $(virtual-package))
+
 # The following definitions are to be used by the specific skeletons:
 # - SKELETON_USR_SYMLINKS_OR_DIRS
 # - SKELETON_LIB_SYMLINK
@@ -113,5 +108,3 @@ endif
 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
 SKELETON_ROOT_PASSWORD = "*"
 endif
-
-$(eval $(generic-package))
system/Config.in +2 -0
index 3a38bd4..3792be2 100644
@@ -5,11 +5,13 @@ choice
 
 config BR2_ROOTFS_SKELETON_DEFAULT
 	bool "default target skeleton"
+	select BR2_PACKAGE_SKELETON_SYSV
 	help
 	  Use default target skeleton
 
 config BR2_ROOTFS_SKELETON_CUSTOM
 	bool "custom target skeleton"
+	select BR2_PACKAGE_SKELETON_CUSTOM
 	help
 	  Use custom target skeleton.
 
Signature · 1 line
2.7.4
#51 lore raw

PATCH v2 17/24 package/skeleton: make it a virtual package

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 2 lines

The skeleton package now only serves as an intermediate package to direct to the real skeleton implementaion.

                                ^

s/implementaion/implementation/

Quoted 2 lines

This is exactly what a virtual package is. Make it so.

Great, you already addressed my previous comment :)

Quoted 74 lines

Note: when graphing the dependency chain, and contrary to other virtual packages, skeleton is de facto excluded from the dependencies of all packages, and is "attached" as a dependency of the "All" package instead, so as not to make the graph overly complicated and unreadable.

So, for it to appear on the graph, it needs to have a BR2_PACKAGE_SKELETON kconfig variable, so that it appears in the output of "make show-targets", like we do for the toolchain.

---
 package/skeleton-custom/Config.in          |  4 ++++
 package/skeleton-custom/skeleton-custom.mk |  2 ++
 package/skeleton-sysv/Config.in            |  4 ++++
 package/skeleton-sysv/skeleton-sysv.mk     |  2 ++
 package/skeleton/Config.in                 | 13 +++++++++++--
 package/skeleton/skeleton.mk               | 11 ++---------
 system/Config.in                           |  2 ++
 7 files changed, 27 insertions(+), 11 deletions(-)
package/skeleton-custom/Config.in +4 -0
index 1f3c87c..601c3b2 100644
@@ -1,2 +1,6 @@
 config BR2_PACKAGE_SKELETON_CUSTOM
 	bool
+	select BR2_PACKAGE_HAS_SKELETON
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	default "skeleton-custom" if BR2_PACKAGE_SKELETON_CUSTOM
package/skeleton-custom/skeleton-custom.mk +2 -0
index 8690af4..e251448 100644
@@ -6,6 +6,8 @@
 
 SKELETON_CUSTOM_SOURCE =
 
+SKELETON_CUSTOM_PROVIDES = skeleton
+
 SKELETON_CUSTOM_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_CUSTOM_ADD_SKELETON_DEPENDENCY = NO
 
package/skeleton-sysv/Config.in +4 -0
index 8c2e7dd..95c796f 100644
@@ -1,2 +1,6 @@
 config BR2_PACKAGE_SKELETON_SYSV
 	bool
+	select BR2_PACKAGE_HAS_SKELETON
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	default "skeleton-sysv" if BR2_PACKAGE_SKELETON_SYSV
package/skeleton-sysv/skeleton-sysv.mk +2 -0
index 0a2f51b..aa0b65c 100644
@@ -6,6 +6,8 @@
 
 SKELETON_SYSV_SOURCE =
 
+SKELETON_SYSV_PROVIDES = skeleton
+
 SKELETON_SYSV_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_SYSV_ADD_SKELETON_DEPENDENCY = NO
 
package/skeleton/Config.in +0 -0
index 6db0634..762196c 100644

package/skeleton/Config.in line 1

Quoted 1 line
package/skeleton/Config.in +1 -0
@@ -1,7 +1,16 @@
+# Every packages depend on the 'skeleton' package, but noone selects its
                                                           ^

s/noone/none/

Quoted 7 lines
package/skeleton/Config.in +3 -1
+# symbol since it is an implicit dependency. So we just force that symbol
+# to always be 'y' so that it does appear in the dependency graph. Just
+# for that, no kidding.
 config BR2_PACKAGE_SKELETON
 	bool
 	default y
-	select BR2_PACKAGE_SKELETON_SYSV   if BR2_ROOTFS_SKELETON_DEFAULT

package/skeleton/Config.in line 16

Quoted 10 lines
package/skeleton/Config.in +7 -1
-	select BR2_PACKAGE_SKELETON_CUSTOM if BR2_ROOTFS_SKELETON_CUSTOM
 	help
 	  The basic skeleton for your rootfs.
+
+config BR2_PACKAGE_HAS_SKELETON
+	bool
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	string
+	depends on BR2_PACKAGE_SKELETON

Should it be depends on BR2_PACKAGE_HAS_SKELETON instead ?

Other that that, the patch looks ok.

Best regards,
Romain

Quoted 52 lines
package/skeleton/skeleton.mk +2 -9
index bd787db..b791650 100644
@@ -4,13 +4,6 @@
 #
 ################################################################################
 
-# source included in buildroot
-SKELETON_SOURCE =
-
-SKELETON_DEPENDENCIES = \
-	$(if $(BR2_PACKAGE_SKELETON_SYSV),skeleton-sysv) \
-	$(if $(BR2_PACKAGE_SKELETON_CUSTOM),skeleton-custom)
-
 # The skeleton can't depend on the toolchain, since all packages depends on the
 # skeleton and the toolchain is a target package, as is skeleton.
 # Hence, skeleton would depends on the toolchain and the toolchain would depend
@@ -18,6 +11,8 @@ SKELETON_DEPENDENCIES = \
 SKELETON_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_ADD_SKELETON_DEPENDENCY = NO
 
+$(eval $(virtual-package))
+
 # The following definitions are to be used by the specific skeletons:
 # - SKELETON_USR_SYMLINKS_OR_DIRS
 # - SKELETON_LIB_SYMLINK
@@ -113,5 +108,3 @@ endif
 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
 SKELETON_ROOT_PASSWORD = "*"
 endif
-
-$(eval $(generic-package))
system/Config.in +2 -0
index 3a38bd4..3792be2 100644
@@ -5,11 +5,13 @@ choice
 
 config BR2_ROOTFS_SKELETON_DEFAULT
 	bool "default target skeleton"
+	select BR2_PACKAGE_SKELETON_SYSV
 	help
 	  Use default target skeleton
 
 config BR2_ROOTFS_SKELETON_CUSTOM
 	bool "custom target skeleton"
+	select BR2_PACKAGE_SKELETON_CUSTOM
 	help
 	  Use custom target skeleton.
 
#52 lore raw

PATCH v2 17/24 package/skeleton: make it a virtual package

Romain, All,

On 2016-07-03 12:47 +0200, Romain Naour spake thusly:

Quoted 5 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 2 lines

The skeleton package now only serves as an intermediate package to direct to the real skeleton implementaion.

                                ^

s/implementaion/implementation/

Fixed.

Quoted 2 lines
Quoted 1 line

This is exactly what a virtual package is. Make it so.

Great, you already addressed my previous comment :)

Ehehe! ;-)

[--SNIP--]

Quoted 8 lines

package/skeleton/Config.in line 16

Quoted 6 lines
package/skeleton/Config.in +6 -0
+config BR2_PACKAGE_HAS_SKELETON
+	bool
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	string
+	depends on BR2_PACKAGE_SKELETON

Should it be depends on BR2_PACKAGE_HAS_SKELETON instead ?

Yep, good catch.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#53 lore raw

PATCH v2 18/24 package/skeleton-sysv: split into skeleton-common

In reply to Yann E. MORIN

Add skeleton-common, the base skeleton shared between the sysv/busybox and systemd skeletons (the latter to come in followup patches).

---
 package/Config.in                          |  1 +
 package/skeleton-common/Config.in          |  2 +
 package/skeleton-common/skeleton-common.mk | 99 ++++++++++++++++++++++++++++++
 package/skeleton-sysv/Config.in            |  1 +
 package/skeleton-sysv/skeleton-sysv.mk     | 60 +-----------------
 package/skeleton/skeleton.mk               | 25 +-------
 6 files changed, 106 insertions(+), 82 deletions(-)
 create mode 100644 package/skeleton-common/Config.in
 create mode 100644 package/skeleton-common/skeleton-common.mk
package/Config.in +1 -0
index fd445f4..9db6332 100644
@@ -2,6 +2,7 @@ menu "Target packages"
 
 	source "package/busybox/Config.in"
 	source "package/skeleton/Config.in"
+	source "package/skeleton-common/Config.in"
 	source "package/skeleton-custom/Config.in"
 	source "package/skeleton-sysv/Config.in"
 
package/skeleton-common/Config.in new file +2 -0
new file mode 100644
index 0000000..9abed42
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_SKELETON_COMMON
+	bool
package/skeleton-common/skeleton-common.mk new file +99 -0

99 lines not on this page · raw message

package/skeleton-sysv/Config.in +1 -0
index 95c796f..2f6dbd9 100644
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_SKELETON_SYSV
 	bool
 	select BR2_PACKAGE_HAS_SKELETON
+	select BR2_PACKAGE_SKELETON_COMMON
 
 config BR2_PACKAGE_PROVIDES_SKELETON
 	default "skeleton-sysv" if BR2_PACKAGE_SKELETON_SYSV
package/skeleton-sysv/skeleton-sysv.mk +2 -58

78 lines not on this page · raw message

package/skeleton/skeleton.mk +1 -24
index b791650..d93f939 100644
@@ -16,10 +16,6 @@ $(eval $(virtual-package))
 # The following definitions are to be used by the specific skeletons:
 # - SKELETON_USR_SYMLINKS_OR_DIRS
 # - SKELETON_LIB_SYMLINK
-# - SKELETON_TARGET_GENERIC_HOSTNAME
-# - SKELETON_TARGET_GENERIC_ISSUE
-# - SKELETON_TARGET_ROOT_PASSWD
-# - SKELETON_TARGET_GENERIC_BIN_SH
 # - SKELETON_TARGET_GENERIC_GETTY_PORT
 # - SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
 # - SKELETON_TARGET_GENERIC_GETTY_TERM
@@ -58,11 +54,7 @@ else
 SKELETON_LIB_SYMLINK = lib32
 endif
 
-SKELETON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
-SKELETON_TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
-SKELETON_TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
-SKELETON_TARGET_GENERIC_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
-SKELETON_TARGET_GENERIC_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
+# The various init systems have different ways of dealing with those:
 SKELETON_TARGET_GENERIC_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
 SKELETON_TARGET_GENERIC_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
 SKELETON_TARGET_GENERIC_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
@@ -93,18 +85,3 @@ define SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 		$(TARGET_DIR)/etc/network/nfs_check
 endef
 endif
-
-ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
-ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
-SKELETON_ROOT_PASSWORD =
-else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)),)
-SKELETON_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
-else
-SKELETON_DEPENDENCIES += host-mkpasswd
-# This variable will only be evaluated in the finalize stage, so we can
-# be sure that host-mkpasswd will have already been built by that time.
-SKELETON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
-endif
-else # !BR2_TARGET_ENABLE_ROOT_LOGIN
-SKELETON_ROOT_PASSWORD = "*"
-endif
Signature · 1 line
2.7.4
#54 lore raw

PATCH v2 18/24 package/skeleton-sysv: split into skeleton-common

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 59 lines

Add skeleton-common, the base skeleton shared between the sysv/busybox and systemd skeletons (the latter to come in followup patches).

---
 package/Config.in                          |  1 +
 package/skeleton-common/Config.in          |  2 +
 package/skeleton-common/skeleton-common.mk | 99 ++++++++++++++++++++++++++++++
 package/skeleton-sysv/Config.in            |  1 +
 package/skeleton-sysv/skeleton-sysv.mk     | 60 +-----------------
 package/skeleton/skeleton.mk               | 25 +-------
 6 files changed, 106 insertions(+), 82 deletions(-)
 create mode 100644 package/skeleton-common/Config.in
 create mode 100644 package/skeleton-common/skeleton-common.mk
package/Config.in +1 -0
index fd445f4..9db6332 100644
@@ -2,6 +2,7 @@ menu "Target packages"
 
 	source "package/busybox/Config.in"
 	source "package/skeleton/Config.in"
+	source "package/skeleton-common/Config.in"
 	source "package/skeleton-custom/Config.in"
 	source "package/skeleton-sysv/Config.in"
 
package/skeleton-common/Config.in new file +2 -0
new file mode 100644
index 0000000..9abed42
@@ -0,0 +1,2 @@
+config BR2_PACKAGE_SKELETON_COMMON
+	bool
package/skeleton-common/skeleton-common.mk new file +18 -0
new file mode 100644
index 0000000..544cce7
@@ -0,0 +1,99 @@
+################################################################################
+#
+# skeleton-common
+#
+################################################################################
+
+SKELETON_COMMON_SOURCE =
+
+SKELETON_COMMON_ADD_TOOLCHAIN_DEPENDENCY = NO
+SKELETON_COMMON_ADD_SKELETON_DEPENDENCY = NO
+
+SKELETON_COMMON_INSTALL_STAGING = YES
+
+SKELETON_COMMON_PATH = system/skeleton
+
+# Provided by the 'skeleton' package:
+# - SKELETON_USR_SYMLINKS_OR_DIRS
+# - SKELETON_LIB_SYMLINK

package/skeleton-common/skeleton-common.mk line 28

Quoted 10 lines
package/skeleton-common/skeleton-common.mk new file +10 -0
+
+SKELETON_COMMON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
+SKELETON_COMMON_TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
+SKELETON_COMMON_TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
+SKELETON_COMMON_TARGET_GENERIC_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
+SKELETON_COMMON_TARGET_GENERIC_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
+
+ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
+ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
+SKELETON_ROOT_PASSWORD =

SKELETON_ROOT_PASSWORD should be renamed to SKELETON_COMMON_ROOT_PASSWORD ?

package/skeleton-common/skeleton-common.mk line 32

Quoted 4 lines
package/skeleton-common/skeleton-common.mk new file +4 -0
+else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)),)
+SKELETON_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
+else
+SKELETON_DEPENDENCIES += host-mkpasswd

s/SKELETON_DEPENDENCIES/SKELETON_COMMON_DEPENDENCIES/ even if mkpasswd is used in a target finalize hook.

Best regards,
Romain

Quoted 212 lines
package/skeleton-common/skeleton-common.mk new file +67 -0
+# This variable will only be evaluated in the finalize stage, so we can
+# be sure that host-mkpasswd will have already been built by that time.
+SKELETON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
+endif
+else # !BR2_TARGET_ENABLE_ROOT_LOGIN
+SKELETON_ROOT_PASSWORD = "*"
+endif
+
+define SKELETON_COMMON_INSTALL_TARGET_CMDS
+	$(call SKELETON_RSYNC,$(SKELETON_COMMON_PATH),$(TARGET_DIR))
+	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
+	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
+	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
+	$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
+		$(TARGET_DIR_WARNING_FILE)
+endef
+
+# For the staging dir, we don't really care about /bin and /sbin.
+# But for consistency with the target dir, and to simplify the code,
+# we still handle them for the merged or non-merged /usr cases.
+# Since the toolchain is not yet available, the staging is not yet
+# populated, so we need to create the directories in /usr
+define SKELETON_COMMON_INSTALL_STAGING_CMDS
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/lib
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/bin
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/sbin
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
+	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(STAGING_DIR))
+	ln -snf lib $(STAGING_DIR)/$(SKELETON_LIB_SYMLINK)
+	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
+endef
+
+ifneq ($(SKELETON_COMMON_TARGET_GENERIC_HOSTNAME),)
+define SKELETON_COMMON_SET_HOSTNAME
+	mkdir -p $(TARGET_DIR)/etc
+	echo "$(SKELETON_COMMON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
+	$(SED) '$$a \127.0.1.1\t$(SKELETON_COMMON_TARGET_GENERIC_HOSTNAME)' \
+		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
+endef
+SKELETON_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_COMMON_SET_HOSTNAME
+endif
+
+ifneq ($(SKELETON_COMMON_TARGET_GENERIC_ISSUE),)
+define SKELETON_COMMON_SET_ISSUE
+	mkdir -p $(TARGET_DIR)/etc
+	echo "$(SKELETON_COMMON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue
+endef
+SKELETON_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_COMMON_SET_ISSUE
+endif
+
+define SKELETON_COMMON_SET_ROOT_PASSWD
+	$(SED) s,^root:[^:]*:,root:$(SKELETON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
+endef
+SKELETON_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_COMMON_SET_ROOT_PASSWD
+
+ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
+define SKELETON_COMMON_BIN_SH
+	rm -f $(TARGET_DIR)/bin/sh
+endef
+else
+define SKELETON_COMMON_BIN_SH
+	ln -sf $(SKELETON_COMMON_TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
+endef
+endif
+SKELETON_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_COMMON_BIN_SH
+
+$(eval $(generic-package))
package/skeleton-sysv/Config.in +1 -0
index 95c796f..2f6dbd9 100644
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_SKELETON_SYSV
 	bool
 	select BR2_PACKAGE_HAS_SKELETON
+	select BR2_PACKAGE_SKELETON_COMMON
 
 config BR2_PACKAGE_PROVIDES_SKELETON
 	default "skeleton-sysv" if BR2_PACKAGE_SKELETON_SYSV
package/skeleton-sysv/skeleton-sysv.mk +2 -58
index aa0b65c..6e15b15 100644
@@ -8,6 +8,8 @@ SKELETON_SYSV_SOURCE =
 
 SKELETON_SYSV_PROVIDES = skeleton
 
+SKELETON_SYSV_DEPENDENCIES = skeleton-common
+
 SKELETON_SYSV_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_SYSV_ADD_SKELETON_DEPENDENCY = NO
 
@@ -27,48 +29,6 @@ SKELETON_SYSV_INSTALL_STAGING = YES
 # - SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK
 # - SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 
-define SKELETON_INSTALL_TARGET_CMDS
-	$(call SKELETON_RSYNC,system/skeleton,$(TARGET_DIR))
-	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
-	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
-	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
-	$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
-		$(TARGET_DIR_WARNING_FILE)
-endef
-
-# For the staging dir, we don't really care about /bin and /sbin.
-# But for consistency with the target dir, and to simplify the code,
-# we still handle them for the merged or non-merged /usr cases.
-# Since the toolchain is not yet available, the staging is not yet
-# populated, so we need to create the directories in /usr
-define SKELETON_SYSV_INSTALL_STAGING_CMDS
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/lib
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/bin
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/sbin
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
-	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(STAGING_DIR))
-	ln -snf lib $(STAGING_DIR)/$(SKELETON_LIB_SYMLINK)
-	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
-endef
-
-ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME),)
-define SKELETON_SYSV_SET_HOSTNAME
-	mkdir -p $(TARGET_DIR)/etc
-	echo "$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
-	$(SED) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
-		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
-endef
-SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_HOSTNAME
-endif
-
-ifneq ($(SKELETON_TARGET_GENERIC_ISSUE),)
-define SKELETON_SYSV_SET_ISSUE
-	mkdir -p $(TARGET_DIR)/etc
-	echo "$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue
-endef
-SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_ISSUE
-endif
-
 define SKELETON_SYSV_SET_NETWORK
 	mkdir -p $(TARGET_DIR)/etc/network/
 	$(SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK)
@@ -76,22 +36,6 @@ define SKELETON_SYSV_SET_NETWORK
 endef
 SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_NETWORK
 
-define SKELETON_SYSV_SET_ROOT_PASSWD
-	$(SED) s,^root:[^:]*:,root:$(SKELETON_SYSV_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
-endef
-SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_ROOT_PASSWD
-
-ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
-define SKELETON_SYSV_BIN_SH
-	rm -f $(TARGET_DIR)/bin/sh
-endef
-else
-define SKELETON_SYSV_BIN_SH
-	ln -sf $(SKELETON_TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
-endef
-endif
-SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_BIN_SH
-
 ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
 ifeq ($(BR2_INIT_SYSV),y)
 # In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
package/skeleton/skeleton.mk +1 -24
index b791650..d93f939 100644
@@ -16,10 +16,6 @@ $(eval $(virtual-package))
 # The following definitions are to be used by the specific skeletons:
 # - SKELETON_USR_SYMLINKS_OR_DIRS
 # - SKELETON_LIB_SYMLINK
-# - SKELETON_TARGET_GENERIC_HOSTNAME
-# - SKELETON_TARGET_GENERIC_ISSUE
-# - SKELETON_TARGET_ROOT_PASSWD
-# - SKELETON_TARGET_GENERIC_BIN_SH
 # - SKELETON_TARGET_GENERIC_GETTY_PORT
 # - SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
 # - SKELETON_TARGET_GENERIC_GETTY_TERM
@@ -58,11 +54,7 @@ else
 SKELETON_LIB_SYMLINK = lib32
 endif
 
-SKELETON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
-SKELETON_TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
-SKELETON_TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
-SKELETON_TARGET_GENERIC_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
-SKELETON_TARGET_GENERIC_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
+# The various init systems have different ways of dealing with those:
 SKELETON_TARGET_GENERIC_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
 SKELETON_TARGET_GENERIC_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
 SKELETON_TARGET_GENERIC_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
@@ -93,18 +85,3 @@ define SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 		$(TARGET_DIR)/etc/network/nfs_check
 endef
 endif
-
-ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
-ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
-SKELETON_ROOT_PASSWORD =
-else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)),)
-SKELETON_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
-else
-SKELETON_DEPENDENCIES += host-mkpasswd
-# This variable will only be evaluated in the finalize stage, so we can
-# be sure that host-mkpasswd will have already been built by that time.
-SKELETON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
-endif
-else # !BR2_TARGET_ENABLE_ROOT_LOGIN
-SKELETON_ROOT_PASSWORD = "*"
-endif
#55 lore raw

PATCH v2 18/24 package/skeleton-sysv: split into skeleton-common

Romain, All,

On 2016-07-03 13:05 +0200, Romain Naour spake thusly:

Quoted 6 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 5 lines

Add skeleton-common, the base skeleton shared between the sysv/busybox and systemd skeletons (the latter to come in followup patches).

---

[--SNIP--]

Quoted 28 lines
Quoted 28 lines
package/skeleton-common/skeleton-common.mk new file +22 -0
new file mode 100644
index 0000000..544cce7
@@ -0,0 +1,99 @@
+################################################################################
+#
+# skeleton-common
+#
+################################################################################
+
+SKELETON_COMMON_SOURCE =
+
+SKELETON_COMMON_ADD_TOOLCHAIN_DEPENDENCY = NO
+SKELETON_COMMON_ADD_SKELETON_DEPENDENCY = NO
+
+SKELETON_COMMON_INSTALL_STAGING = YES
+
+SKELETON_COMMON_PATH = system/skeleton
+
+# Provided by the 'skeleton' package:
+# - SKELETON_USR_SYMLINKS_OR_DIRS
+# - SKELETON_LIB_SYMLINK
+
+SKELETON_COMMON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
+SKELETON_COMMON_TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
+SKELETON_COMMON_TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
Quoted 8 lines

package/skeleton-common/skeleton-common.mk line 28

Quoted 6 lines
package/skeleton-common/skeleton-common.mk new file +6 -0
+SKELETON_COMMON_TARGET_GENERIC_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
+SKELETON_COMMON_TARGET_GENERIC_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
+
+ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
+ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
+SKELETON_ROOT_PASSWORD =

SKELETON_ROOT_PASSWORD should be renamed to SKELETON_COMMON_ROOT_PASSWORD ?

Done.

Quoted 7 lines

package/skeleton-common/skeleton-common.mk line 32

Quoted 4 lines
package/skeleton-common/skeleton-common.mk new file +4 -0
+else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)),)
+SKELETON_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
+else
+SKELETON_DEPENDENCIES += host-mkpasswd

s/SKELETON_DEPENDENCIES/SKELETON_COMMON_DEPENDENCIES/ even if mkpasswd is used in a target finalize hook.

Done.

Thanks! :-)

Regards,
Yann E. MORIN.

Quoted 216 lines

Best regards,
Romain

Quoted 212 lines
package/skeleton-common/skeleton-common.mk new file +67 -0
+# This variable will only be evaluated in the finalize stage, so we can
+# be sure that host-mkpasswd will have already been built by that time.
+SKELETON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
+endif
+else # !BR2_TARGET_ENABLE_ROOT_LOGIN
+SKELETON_ROOT_PASSWORD = "*"
+endif
+
+define SKELETON_COMMON_INSTALL_TARGET_CMDS
+	$(call SKELETON_RSYNC,$(SKELETON_COMMON_PATH),$(TARGET_DIR))
+	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
+	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
+	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
+	$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
+		$(TARGET_DIR_WARNING_FILE)
+endef
+
+# For the staging dir, we don't really care about /bin and /sbin.
+# But for consistency with the target dir, and to simplify the code,
+# we still handle them for the merged or non-merged /usr cases.
+# Since the toolchain is not yet available, the staging is not yet
+# populated, so we need to create the directories in /usr
+define SKELETON_COMMON_INSTALL_STAGING_CMDS
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/lib
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/bin
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/sbin
+	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
+	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(STAGING_DIR))
+	ln -snf lib $(STAGING_DIR)/$(SKELETON_LIB_SYMLINK)
+	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
+endef
+
+ifneq ($(SKELETON_COMMON_TARGET_GENERIC_HOSTNAME),)
+define SKELETON_COMMON_SET_HOSTNAME
+	mkdir -p $(TARGET_DIR)/etc
+	echo "$(SKELETON_COMMON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
+	$(SED) '$$a \127.0.1.1\t$(SKELETON_COMMON_TARGET_GENERIC_HOSTNAME)' \
+		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
+endef
+SKELETON_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_COMMON_SET_HOSTNAME
+endif
+
+ifneq ($(SKELETON_COMMON_TARGET_GENERIC_ISSUE),)
+define SKELETON_COMMON_SET_ISSUE
+	mkdir -p $(TARGET_DIR)/etc
+	echo "$(SKELETON_COMMON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue
+endef
+SKELETON_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_COMMON_SET_ISSUE
+endif
+
+define SKELETON_COMMON_SET_ROOT_PASSWD
+	$(SED) s,^root:[^:]*:,root:$(SKELETON_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
+endef
+SKELETON_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_COMMON_SET_ROOT_PASSWD
+
+ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
+define SKELETON_COMMON_BIN_SH
+	rm -f $(TARGET_DIR)/bin/sh
+endef
+else
+define SKELETON_COMMON_BIN_SH
+	ln -sf $(SKELETON_COMMON_TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
+endef
+endif
+SKELETON_COMMON_TARGET_FINALIZE_HOOKS += SKELETON_COMMON_BIN_SH
+
+$(eval $(generic-package))
package/skeleton-sysv/Config.in +1 -0
index 95c796f..2f6dbd9 100644
@@ -1,6 +1,7 @@
 config BR2_PACKAGE_SKELETON_SYSV
 	bool
 	select BR2_PACKAGE_HAS_SKELETON
+	select BR2_PACKAGE_SKELETON_COMMON
 
 config BR2_PACKAGE_PROVIDES_SKELETON
 	default "skeleton-sysv" if BR2_PACKAGE_SKELETON_SYSV
package/skeleton-sysv/skeleton-sysv.mk +2 -58
index aa0b65c..6e15b15 100644
@@ -8,6 +8,8 @@ SKELETON_SYSV_SOURCE =
 
 SKELETON_SYSV_PROVIDES = skeleton
 
+SKELETON_SYSV_DEPENDENCIES = skeleton-common
+
 SKELETON_SYSV_ADD_TOOLCHAIN_DEPENDENCY = NO
 SKELETON_SYSV_ADD_SKELETON_DEPENDENCY = NO
 
@@ -27,48 +29,6 @@ SKELETON_SYSV_INSTALL_STAGING = YES
 # - SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK
 # - SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 
-define SKELETON_INSTALL_TARGET_CMDS
-	$(call SKELETON_RSYNC,system/skeleton,$(TARGET_DIR))
-	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(TARGET_DIR))
-	ln -snf lib $(TARGET_DIR)/$(SKELETON_LIB_SYMLINK)
-	ln -snf lib $(TARGET_DIR)/usr/$(SKELETON_LIB_SYMLINK)
-	$(INSTALL) -m 0644 support/misc/target-dir-warning.txt \
-		$(TARGET_DIR_WARNING_FILE)
-endef
-
-# For the staging dir, we don't really care about /bin and /sbin.
-# But for consistency with the target dir, and to simplify the code,
-# we still handle them for the merged or non-merged /usr cases.
-# Since the toolchain is not yet available, the staging is not yet
-# populated, so we need to create the directories in /usr
-define SKELETON_SYSV_INSTALL_STAGING_CMDS
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/lib
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/bin
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/sbin
-	$(INSTALL) -d -m 0755 $(STAGING_DIR)/usr/include
-	$(call SKELETON_USR_SYMLINKS_OR_DIRS,$(STAGING_DIR))
-	ln -snf lib $(STAGING_DIR)/$(SKELETON_LIB_SYMLINK)
-	ln -snf lib $(STAGING_DIR)/usr/$(SKELETON_LIB_SYMLINK)
-endef
-
-ifneq ($(SKELETON_TARGET_GENERIC_HOSTNAME),)
-define SKELETON_SYSV_SET_HOSTNAME
-	mkdir -p $(TARGET_DIR)/etc
-	echo "$(SKELETON_TARGET_GENERIC_HOSTNAME)" > $(TARGET_DIR)/etc/hostname
-	$(SED) '$$a \127.0.1.1\t$(SKELETON_TARGET_GENERIC_HOSTNAME)' \
-		-e '/^127.0.1.1/d' $(TARGET_DIR)/etc/hosts
-endef
-SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_HOSTNAME
-endif
-
-ifneq ($(SKELETON_TARGET_GENERIC_ISSUE),)
-define SKELETON_SYSV_SET_ISSUE
-	mkdir -p $(TARGET_DIR)/etc
-	echo "$(SKELETON_TARGET_GENERIC_ISSUE)" > $(TARGET_DIR)/etc/issue
-endef
-SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_ISSUE
-endif
-
 define SKELETON_SYSV_SET_NETWORK
 	mkdir -p $(TARGET_DIR)/etc/network/
 	$(SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK)
@@ -76,22 +36,6 @@ define SKELETON_SYSV_SET_NETWORK
 endef
 SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_NETWORK
 
-define SKELETON_SYSV_SET_ROOT_PASSWD
-	$(SED) s,^root:[^:]*:,root:$(SKELETON_SYSV_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
-endef
-SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_SET_ROOT_PASSWD
-
-ifeq ($(BR2_SYSTEM_BIN_SH_NONE),y)
-define SKELETON_SYSV_BIN_SH
-	rm -f $(TARGET_DIR)/bin/sh
-endef
-else
-define SKELETON_SYSV_BIN_SH
-	ln -sf $(SKELETON_TARGET_GENERIC_BIN_SH) $(TARGET_DIR)/bin/sh
-endef
-endif
-SKELETON_SYSV_TARGET_FINALIZE_HOOKS += SKELETON_SYSV_BIN_SH
-
 ifeq ($(BR2_TARGET_GENERIC_GETTY),y)
 ifeq ($(BR2_INIT_SYSV),y)
 # In sysvinit inittab, the "id" must not be longer than 4 bytes, so we
package/skeleton/skeleton.mk +1 -24
index b791650..d93f939 100644
@@ -16,10 +16,6 @@ $(eval $(virtual-package))
 # The following definitions are to be used by the specific skeletons:
 # - SKELETON_USR_SYMLINKS_OR_DIRS
 # - SKELETON_LIB_SYMLINK
-# - SKELETON_TARGET_GENERIC_HOSTNAME
-# - SKELETON_TARGET_GENERIC_ISSUE
-# - SKELETON_TARGET_ROOT_PASSWD
-# - SKELETON_TARGET_GENERIC_BIN_SH
 # - SKELETON_TARGET_GENERIC_GETTY_PORT
 # - SKELETON_TARGET_GENERIC_GETTY_BAUDRATE
 # - SKELETON_TARGET_GENERIC_GETTY_TERM
@@ -58,11 +54,7 @@ else
 SKELETON_LIB_SYMLINK = lib32
 endif
 
-SKELETON_TARGET_GENERIC_HOSTNAME = $(call qstrip,$(BR2_TARGET_GENERIC_HOSTNAME))
-SKELETON_TARGET_GENERIC_ISSUE = $(call qstrip,$(BR2_TARGET_GENERIC_ISSUE))
-SKELETON_TARGET_GENERIC_ROOT_PASSWD = $(call qstrip,$(BR2_TARGET_GENERIC_ROOT_PASSWD))
-SKELETON_TARGET_GENERIC_PASSWD_METHOD = $(call qstrip,$(BR2_TARGET_GENERIC_PASSWD_METHOD))
-SKELETON_TARGET_GENERIC_BIN_SH = $(call qstrip,$(BR2_SYSTEM_BIN_SH))
+# The various init systems have different ways of dealing with those:
 SKELETON_TARGET_GENERIC_GETTY_PORT = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_PORT))
 SKELETON_TARGET_GENERIC_GETTY_BAUDRATE = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_BAUDRATE))
 SKELETON_TARGET_GENERIC_GETTY_TERM = $(call qstrip,$(BR2_TARGET_GENERIC_GETTY_TERM))
@@ -93,18 +85,3 @@ define SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 		$(TARGET_DIR)/etc/network/nfs_check
 endef
 endif
-
-ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
-ifeq ($(SKELETON_TARGET_GENERIC_ROOT_PASSWD),)
-SKELETON_ROOT_PASSWORD =
-else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)),)
-SKELETON_ROOT_PASSWORD = '$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)'
-else
-SKELETON_DEPENDENCIES += host-mkpasswd
-# This variable will only be evaluated in the finalize stage, so we can
-# be sure that host-mkpasswd will have already been built by that time.
-SKELETON_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(SKELETON_TARGET_GENERIC_PASSWD_METHOD)" "$(SKELETON_TARGET_GENERIC_ROOT_PASSWD)"`"
-endif
-else # !BR2_TARGET_ENABLE_ROOT_LOGIN
-SKELETON_ROOT_PASSWORD = "*"
-endif
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#56 lore raw

PATCH v2 19/24 system: split skeleton

In reply to Yann E. MORIN

Move the sysv-related parts to separate skeletons.

The network-related parts of the skeleton will also be useable by the systemd skeleton (but only when systemd-networkd is not enabled), so we also split that out into its own skeleton.

---
 package/skeleton-sysv/skeleton-sysv.mk                             | 7 +++++++
 .../network/if-up.d => skeleton-net/etc/network/if-down.d}/.empty  | 0
 .../{skeleton => skeleton-net}/etc/network/if-post-down.d/.empty   | 0
 .../{skeleton => skeleton-net}/etc/network/if-pre-up.d/wait_iface  | 0
 .../network/if-down.d => skeleton-net/etc/network/if-up.d}/.empty  | 0
 system/{skeleton => skeleton-sysv}/dev/log                         | 0
 system/{skeleton/dev/shm => skeleton-sysv/dev/pts}/.empty          | 0
 system/{skeleton/dev/pts => skeleton-sysv/dev/shm}/.empty          | 0
 system/{skeleton => skeleton-sysv}/etc/fstab                       | 0
 system/{skeleton => skeleton-sysv}/etc/resolv.conf                 | 0
 system/{skeleton => skeleton-sysv}/var/cache                       | 0
 system/{skeleton => skeleton-sysv}/var/lib/misc                    | 0
 system/{skeleton => skeleton-sysv}/var/lock                        | 0
 system/{skeleton => skeleton-sysv}/var/log                         | 0
 system/{skeleton => skeleton-sysv}/var/run                         | 0
 system/{skeleton => skeleton-sysv}/var/spool                       | 0
 system/{skeleton => skeleton-sysv}/var/tmp                         | 0
 system/skeleton/dev/.empty                                         | 0
 18 files changed, 7 insertions(+)
 rename system/{skeleton/etc/network/if-up.d => skeleton-net/etc/network/if-down.d}/.empty (100%)
 rename system/{skeleton => skeleton-net}/etc/network/if-post-down.d/.empty (100%)
 rename system/{skeleton => skeleton-net}/etc/network/if-pre-up.d/wait_iface (100%)
 rename system/{skeleton/etc/network/if-down.d => skeleton-net/etc/network/if-up.d}/.empty (100%)
 rename system/{skeleton => skeleton-sysv}/dev/log (100%)
 rename system/{skeleton/dev/shm => skeleton-sysv/dev/pts}/.empty (100%)
 rename system/{skeleton/dev/pts => skeleton-sysv/dev/shm}/.empty (100%)
 rename system/{skeleton => skeleton-sysv}/etc/fstab (100%)
 rename system/{skeleton => skeleton-sysv}/etc/resolv.conf (100%)
 rename system/{skeleton => skeleton-sysv}/var/cache (100%)
 rename system/{skeleton => skeleton-sysv}/var/lib/misc (100%)
 rename system/{skeleton => skeleton-sysv}/var/lock (100%)
 rename system/{skeleton => skeleton-sysv}/var/log (100%)
 rename system/{skeleton => skeleton-sysv}/var/run (100%)
 rename system/{skeleton => skeleton-sysv}/var/spool (100%)
 rename system/{skeleton => skeleton-sysv}/var/tmp (100%)
 create mode 100644 system/skeleton/dev/.empty
package/skeleton-sysv/skeleton-sysv.mk +7 -0
index 6e15b15..ee9e670 100644
@@ -29,6 +29,13 @@ SKELETON_SYSV_INSTALL_STAGING = YES
 # - SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK
 # - SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 
+# Even without a configured DHCP interface, we still need the network part
+# of the skeleton, because it is used to configure the loopback interface.
+define SKELETON_SYSV_INSTALL_TARGET_CMDS
+	$(call SKELETON_RSYNC,system/skeleton-sysv,$(TARGET_DIR))
+	$(call SKELETON_RSYNC,system/skeleton-net,$(TARGET_DIR))
+endef
+
 define SKELETON_SYSV_SET_NETWORK
 	mkdir -p $(TARGET_DIR)/etc/network/
 	$(SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK)
system/skeleton-net/etc/network/if-down.d/.empty renamed from system/skeleton/etc/network/if-up.d/.empty +0 -0
similarity index 100%
rename from system/skeleton/etc/network/if-up.d/.empty
rename to system/skeleton-net/etc/network/if-down.d/.empty
system/skeleton-net/etc/network/if-post-down.d/.empty renamed from system/skeleton/etc/network/if-post-down.d/.empty +0 -0
similarity index 100%
rename from system/skeleton/etc/network/if-post-down.d/.empty
rename to system/skeleton-net/etc/network/if-post-down.d/.empty
system/skeleton-net/etc/network/if-pre-up.d/wait_iface renamed from system/skeleton/etc/network/if-pre-up.d/wait_iface +0 -0
similarity index 100%
rename from system/skeleton/etc/network/if-pre-up.d/wait_iface
rename to system/skeleton-net/etc/network/if-pre-up.d/wait_iface
system/skeleton-net/etc/network/if-up.d/.empty renamed from system/skeleton/etc/network/if-down.d/.empty +0 -0
similarity index 100%
rename from system/skeleton/etc/network/if-down.d/.empty
rename to system/skeleton-net/etc/network/if-up.d/.empty
system/skeleton-sysv/dev/log renamed from system/skeleton/dev/log +0 -0
similarity index 100%
rename from system/skeleton/dev/log
rename to system/skeleton-sysv/dev/log
system/skeleton-sysv/dev/pts/.empty renamed from system/skeleton/dev/shm/.empty +0 -0
similarity index 100%
rename from system/skeleton/dev/shm/.empty
rename to system/skeleton-sysv/dev/pts/.empty
system/skeleton-sysv/dev/shm/.empty renamed from system/skeleton/dev/pts/.empty +0 -0
similarity index 100%
rename from system/skeleton/dev/pts/.empty
rename to system/skeleton-sysv/dev/shm/.empty
system/skeleton-sysv/etc/fstab renamed from system/skeleton/etc/fstab +0 -0
similarity index 100%
rename from system/skeleton/etc/fstab
rename to system/skeleton-sysv/etc/fstab
system/skeleton-sysv/etc/resolv.conf renamed from system/skeleton/etc/resolv.conf +0 -0
similarity index 100%
rename from system/skeleton/etc/resolv.conf
rename to system/skeleton-sysv/etc/resolv.conf
system/skeleton-sysv/var/cache renamed from system/skeleton/var/cache +0 -0
similarity index 100%
rename from system/skeleton/var/cache
rename to system/skeleton-sysv/var/cache
system/skeleton-sysv/var/lib/misc renamed from system/skeleton/var/lib/misc +0 -0
similarity index 100%
rename from system/skeleton/var/lib/misc
rename to system/skeleton-sysv/var/lib/misc
system/skeleton-sysv/var/lock renamed from system/skeleton/var/lock +0 -0
similarity index 100%
rename from system/skeleton/var/lock
rename to system/skeleton-sysv/var/lock
system/skeleton-sysv/var/log renamed from system/skeleton/var/log +0 -0
similarity index 100%
rename from system/skeleton/var/log
rename to system/skeleton-sysv/var/log
system/skeleton-sysv/var/run renamed from system/skeleton/var/run +0 -0
similarity index 100%
rename from system/skeleton/var/run
rename to system/skeleton-sysv/var/run
system/skeleton-sysv/var/spool renamed from system/skeleton/var/spool +0 -0
similarity index 100%
rename from system/skeleton/var/spool
rename to system/skeleton-sysv/var/spool
system/skeleton-sysv/var/tmp renamed from system/skeleton/var/tmp +0 -0
similarity index 100%
rename from system/skeleton/var/tmp
rename to system/skeleton-sysv/var/tmp
system/skeleton/dev/.empty new file +0 -0
new file mode 100644
index 0000000..e69de29
Signature · 1 line
2.7.4
#57 lore raw

PATCH v2 19/24 system: split skeleton

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 7 lines

Move the sysv-related parts to separate skeletons.

The network-related parts of the skeleton will also be useable by the systemd skeleton (but only when systemd-networkd is not enabled), so we also split that out into its own skeleton.

Best regards,
Romain

Quoted 124 lines
---
 package/skeleton-sysv/skeleton-sysv.mk                             | 7 +++++++
 .../network/if-up.d => skeleton-net/etc/network/if-down.d}/.empty  | 0
 .../{skeleton => skeleton-net}/etc/network/if-post-down.d/.empty   | 0
 .../{skeleton => skeleton-net}/etc/network/if-pre-up.d/wait_iface  | 0
 .../network/if-down.d => skeleton-net/etc/network/if-up.d}/.empty  | 0
 system/{skeleton => skeleton-sysv}/dev/log                         | 0
 system/{skeleton/dev/shm => skeleton-sysv/dev/pts}/.empty          | 0
 system/{skeleton/dev/pts => skeleton-sysv/dev/shm}/.empty          | 0
 system/{skeleton => skeleton-sysv}/etc/fstab                       | 0
 system/{skeleton => skeleton-sysv}/etc/resolv.conf                 | 0
 system/{skeleton => skeleton-sysv}/var/cache                       | 0
 system/{skeleton => skeleton-sysv}/var/lib/misc                    | 0
 system/{skeleton => skeleton-sysv}/var/lock                        | 0
 system/{skeleton => skeleton-sysv}/var/log                         | 0
 system/{skeleton => skeleton-sysv}/var/run                         | 0
 system/{skeleton => skeleton-sysv}/var/spool                       | 0
 system/{skeleton => skeleton-sysv}/var/tmp                         | 0
 system/skeleton/dev/.empty                                         | 0
 18 files changed, 7 insertions(+)
 rename system/{skeleton/etc/network/if-up.d => skeleton-net/etc/network/if-down.d}/.empty (100%)
 rename system/{skeleton => skeleton-net}/etc/network/if-post-down.d/.empty (100%)
 rename system/{skeleton => skeleton-net}/etc/network/if-pre-up.d/wait_iface (100%)
 rename system/{skeleton/etc/network/if-down.d => skeleton-net/etc/network/if-up.d}/.empty (100%)
 rename system/{skeleton => skeleton-sysv}/dev/log (100%)
 rename system/{skeleton/dev/shm => skeleton-sysv/dev/pts}/.empty (100%)
 rename system/{skeleton/dev/pts => skeleton-sysv/dev/shm}/.empty (100%)
 rename system/{skeleton => skeleton-sysv}/etc/fstab (100%)
 rename system/{skeleton => skeleton-sysv}/etc/resolv.conf (100%)
 rename system/{skeleton => skeleton-sysv}/var/cache (100%)
 rename system/{skeleton => skeleton-sysv}/var/lib/misc (100%)
 rename system/{skeleton => skeleton-sysv}/var/lock (100%)
 rename system/{skeleton => skeleton-sysv}/var/log (100%)
 rename system/{skeleton => skeleton-sysv}/var/run (100%)
 rename system/{skeleton => skeleton-sysv}/var/spool (100%)
 rename system/{skeleton => skeleton-sysv}/var/tmp (100%)
 create mode 100644 system/skeleton/dev/.empty
package/skeleton-sysv/skeleton-sysv.mk +7 -0
index 6e15b15..ee9e670 100644
@@ -29,6 +29,13 @@ SKELETON_SYSV_INSTALL_STAGING = YES
 # - SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK
 # - SKELETON_SET_NETWORK_IFUPDOWN_DHCP
 
+# Even without a configured DHCP interface, we still need the network part
+# of the skeleton, because it is used to configure the loopback interface.
+define SKELETON_SYSV_INSTALL_TARGET_CMDS
+	$(call SKELETON_RSYNC,system/skeleton-sysv,$(TARGET_DIR))
+	$(call SKELETON_RSYNC,system/skeleton-net,$(TARGET_DIR))
+endef
+
 define SKELETON_SYSV_SET_NETWORK
 	mkdir -p $(TARGET_DIR)/etc/network/
 	$(SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK)
system/skeleton-net/etc/network/if-down.d/.empty renamed from system/skeleton/etc/network/if-up.d/.empty +0 -0
similarity index 100%
rename from system/skeleton/etc/network/if-up.d/.empty
rename to system/skeleton-net/etc/network/if-down.d/.empty
system/skeleton-net/etc/network/if-post-down.d/.empty renamed from system/skeleton/etc/network/if-post-down.d/.empty +0 -0
similarity index 100%
rename from system/skeleton/etc/network/if-post-down.d/.empty
rename to system/skeleton-net/etc/network/if-post-down.d/.empty
system/skeleton-net/etc/network/if-pre-up.d/wait_iface renamed from system/skeleton/etc/network/if-pre-up.d/wait_iface +0 -0
similarity index 100%
rename from system/skeleton/etc/network/if-pre-up.d/wait_iface
rename to system/skeleton-net/etc/network/if-pre-up.d/wait_iface
system/skeleton-net/etc/network/if-up.d/.empty renamed from system/skeleton/etc/network/if-down.d/.empty +0 -0
similarity index 100%
rename from system/skeleton/etc/network/if-down.d/.empty
rename to system/skeleton-net/etc/network/if-up.d/.empty
system/skeleton-sysv/dev/log renamed from system/skeleton/dev/log +0 -0
similarity index 100%
rename from system/skeleton/dev/log
rename to system/skeleton-sysv/dev/log
system/skeleton-sysv/dev/pts/.empty renamed from system/skeleton/dev/shm/.empty +0 -0
similarity index 100%
rename from system/skeleton/dev/shm/.empty
rename to system/skeleton-sysv/dev/pts/.empty
system/skeleton-sysv/dev/shm/.empty renamed from system/skeleton/dev/pts/.empty +0 -0
similarity index 100%
rename from system/skeleton/dev/pts/.empty
rename to system/skeleton-sysv/dev/shm/.empty
system/skeleton-sysv/etc/fstab renamed from system/skeleton/etc/fstab +0 -0
similarity index 100%
rename from system/skeleton/etc/fstab
rename to system/skeleton-sysv/etc/fstab
system/skeleton-sysv/etc/resolv.conf renamed from system/skeleton/etc/resolv.conf +0 -0
similarity index 100%
rename from system/skeleton/etc/resolv.conf
rename to system/skeleton-sysv/etc/resolv.conf
system/skeleton-sysv/var/cache renamed from system/skeleton/var/cache +0 -0
similarity index 100%
rename from system/skeleton/var/cache
rename to system/skeleton-sysv/var/cache
system/skeleton-sysv/var/lib/misc renamed from system/skeleton/var/lib/misc +0 -0
similarity index 100%
rename from system/skeleton/var/lib/misc
rename to system/skeleton-sysv/var/lib/misc
system/skeleton-sysv/var/lock renamed from system/skeleton/var/lock +0 -0
similarity index 100%
rename from system/skeleton/var/lock
rename to system/skeleton-sysv/var/lock
system/skeleton-sysv/var/log renamed from system/skeleton/var/log +0 -0
similarity index 100%
rename from system/skeleton/var/log
rename to system/skeleton-sysv/var/log
system/skeleton-sysv/var/run renamed from system/skeleton/var/run +0 -0
similarity index 100%
rename from system/skeleton/var/run
rename to system/skeleton-sysv/var/run
system/skeleton-sysv/var/spool renamed from system/skeleton/var/spool +0 -0
similarity index 100%
rename from system/skeleton/var/spool
rename to system/skeleton-sysv/var/spool
system/skeleton-sysv/var/tmp renamed from system/skeleton/var/tmp +0 -0
similarity index 100%
rename from system/skeleton/var/tmp
rename to system/skeleton-sysv/var/tmp
system/skeleton/dev/.empty new file +0 -0
new file mode 100644
index 0000000..e69de29
#58 lore raw

PATCH v2 20/24 package/skeleton-systemd: new package

In reply to Yann E. MORIN

Given the very few things to create in the skeleton, there is no real need in having a pre-populated skeleton that we rsync. We can very well just create the directory structure with simple mkdir commands.

---
 package/Config.in                            |  1 +
 package/skeleton-systemd/Config.in           |  7 +++++
 package/skeleton-systemd/skeleton-systemd.mk | 43 ++++++++++++++++++++++++++++
 system/Config.in                             |  3 +-
 4 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 package/skeleton-systemd/Config.in
 create mode 100644 package/skeleton-systemd/skeleton-systemd.mk
package/Config.in +1 -0
index 9db6332..17356fe 100644
@@ -4,6 +4,7 @@ menu "Target packages"
 	source "package/skeleton/Config.in"
 	source "package/skeleton-common/Config.in"
 	source "package/skeleton-custom/Config.in"
+	source "package/skeleton-systemd/Config.in"
 	source "package/skeleton-sysv/Config.in"
 
 menu "Audio and video applications"
package/skeleton-systemd/Config.in new file +7 -0
new file mode 100644
index 0000000..c507264
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_SKELETON_SYSTEMD
+	bool
+	select BR2_PACKAGE_HAS_SKELETON
+	select BR2_PACKAGE_SKELETON_COMMON
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	default "skeleton-systemd" if BR2_PACKAGE_SKELETON_SYSTEMD
package/skeleton-systemd/skeleton-systemd.mk new file +43 -0

43 lines not on this page · raw message

system/Config.in +2 -1
index 3792be2..17ce832 100644
@@ -5,7 +5,8 @@ choice
 
 config BR2_ROOTFS_SKELETON_DEFAULT
 	bool "default target skeleton"
-	select BR2_PACKAGE_SKELETON_SYSV
+	select BR2_PACKAGE_SKELETON_SYSV    if !BR2_INIT_SYSTEMD
+	select BR2_PACKAGE_SKELETON_SYSTEMD if BR2_INIT_SYSTEMD
 	help
 	  Use default target skeleton
 
Signature · 1 line
2.7.4
#59 lore raw

PATCH v2 20/24 package/skeleton-systemd: new package

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 5 lines

Given the very few things to create in the skeleton, there is no real need in having a pre-populated skeleton that we rsync. We can very well just create the directory structure with simple mkdir commands.

Best regards,
Romain

Quoted 98 lines
---
 package/Config.in                            |  1 +
 package/skeleton-systemd/Config.in           |  7 +++++
 package/skeleton-systemd/skeleton-systemd.mk | 43 ++++++++++++++++++++++++++++
 system/Config.in                             |  3 +-
 4 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 package/skeleton-systemd/Config.in
 create mode 100644 package/skeleton-systemd/skeleton-systemd.mk
package/Config.in +1 -0
index 9db6332..17356fe 100644
@@ -4,6 +4,7 @@ menu "Target packages"
 	source "package/skeleton/Config.in"
 	source "package/skeleton-common/Config.in"
 	source "package/skeleton-custom/Config.in"
+	source "package/skeleton-systemd/Config.in"
 	source "package/skeleton-sysv/Config.in"
 
 menu "Audio and video applications"
package/skeleton-systemd/Config.in new file +7 -0
new file mode 100644
index 0000000..c507264
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_SKELETON_SYSTEMD
+	bool
+	select BR2_PACKAGE_HAS_SKELETON
+	select BR2_PACKAGE_SKELETON_COMMON
+
+config BR2_PACKAGE_PROVIDES_SKELETON
+	default "skeleton-systemd" if BR2_PACKAGE_SKELETON_SYSTEMD
package/skeleton-systemd/skeleton-systemd.mk new file +43 -0
new file mode 100644
index 0000000..e781ce9
@@ -0,0 +1,43 @@
+################################################################################
+#
+# skeleton-systemd
+#
+################################################################################
+
+SKELETON_SYSTEMD_SOURCE =
+
+SKELETON_SYSTEMD_PROVIDES = skeleton
+
+SKELETON_SYSTEMD_DEPENDENCIES = skeleton-common
+
+SKELETON_SYSTEMD_ADD_TOOLCHAIN_DEPENDENCY = NO
+SKELETON_SYSTEMD_ADD_SKELETON_DEPENDENCY = NO
+
+# In case we're not using systemd-networkd, use the sysv-like network infra;
+# otherwise, the necessary bits are installed by the systemd package.
+ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),)
+
+define SKELETON_SYSTEMD_RSYNC_NETWORK
+	 $(call SKELETON_RSYNC,system/skeleton-net,$(TARGET_DIR))
+endef
+
+define SKELETON_SYSTEMD_SET_NETWORK
+	ln -fs ../tmp/resolv.conf $(TARGET_DIR)/etc/resolv.conf
+	mkdir -p $(TARGET_DIR)/etc/network/
+	$(SKELETON_SET_NETWORK_IFUPDOWN_LOOPBACK)
+	$(SKELETON_SET_NETWORK_IFUPDOWN_DHCP)
+endef
+SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK
+
+endif # BR2_PACKAGE_SYSTEMD_NETWORKD not set
+
+define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
+	mkdir -p $(TARGET_DIR)/etc
+	mkdir -p $(TARGET_DIR)/home
+	mkdir -p $(TARGET_DIR)/srv
+	mkdir -p $(TARGET_DIR)/var
+	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	$(SKELETON_SYSTEMD_RSYNC_NETWORK)
+endef
+
+$(eval $(generic-package))
system/Config.in +2 -1
index 3792be2..17ce832 100644
@@ -5,7 +5,8 @@ choice
 
 config BR2_ROOTFS_SKELETON_DEFAULT
 	bool "default target skeleton"
-	select BR2_PACKAGE_SKELETON_SYSV
+	select BR2_PACKAGE_SKELETON_SYSV    if !BR2_INIT_SYSTEMD
+	select BR2_PACKAGE_SKELETON_SYSTEMD if BR2_INIT_SYSTEMD
 	help
 	  Use default target skeleton
 
#60 lore raw

PATCH v2 21/24 system/systemd: needs timezone

In reply to Yann E. MORIN

systemd does not like being booted without any timezone info (especially on a R/O filesystem), so we forcibly enable that. If there is no default timezone set, we fallback to UTC (which is basically what no TZ means anyway).

---
 package/skeleton-systemd/skeleton-systemd.mk | 7 +++++++
 system/Config.in                             | 1 +
 2 files changed, 8 insertions(+)
package/skeleton-systemd/skeleton-systemd.mk +7 -0
index e781ce9..b45bbde 100644
@@ -31,12 +31,19 @@ SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK
 
 endif # BR2_PACKAGE_SYSTEMD_NETWORKD not set
 
+SKELETON_SYSTEM_LOCALTIME = $(call qstrip,$(BR2_TARGET_LOCALTIME))
+ifeq ($(SKELETON_SYSTEM_LOCALTIME),)
+SKELETON_SYSTEM_LOCALTIME = Etc/UTC
+endif
+
 define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/etc
 	mkdir -p $(TARGET_DIR)/home
 	mkdir -p $(TARGET_DIR)/srv
 	mkdir -p $(TARGET_DIR)/var
 	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	ln -sf ../usr/share/zoneinfo/$(SKELETON_SYSTEMD_LOCALTIME) \
+		$(TARGET_DIR)/etc/localtime
 	$(SKELETON_SYSTEMD_RSYNC_NETWORK)
 endef
 
system/Config.in +1 -0
index 17ce832..07af2e0 100644
@@ -130,6 +130,7 @@ config BR2_INIT_SYSTEMD
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
 	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
+	select BR2_TARGET_TZ_INFO
 
 comment "systemd needs (e)glibc toolchain, headers >= 3.10"
 	depends on !(BR2_TOOLCHAIN_USES_GLIBC \
Signature · 1 line
2.7.4
#61 lore raw

PATCH v2 21/24 system/systemd: needs timezone

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 16 lines

systemd does not like being booted without any timezone info (especially on a R/O filesystem), so we forcibly enable that. If there is no default timezone set, we fallback to UTC (which is basically what no TZ means anyway).

---
 package/skeleton-systemd/skeleton-systemd.mk | 7 +++++++
 system/Config.in                             | 1 +
 2 files changed, 8 insertions(+)
package/skeleton-systemd/skeleton-systemd.mk +0 -0
index e781ce9..b45bbde 100644

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 34

Quoted 4 lines
package/skeleton-systemd/skeleton-systemd.mk +1 -0
@@ -31,12 +31,19 @@ SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK
 
 endif # BR2_PACKAGE_SYSTEMD_NETWORKD not set
 
+SKELETON_SYSTEM_LOCALTIME = $(call qstrip,$(BR2_TARGET_LOCALTIME))
                 ^

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 35

Quoted 1 line
package/skeleton-systemd/skeleton-systemd.mk +1 -0
+ifeq ($(SKELETON_SYSTEM_LOCALTIME),)
                         ^

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 36

Quoted 1 line
package/skeleton-systemd/skeleton-systemd.mk +1 -0
+SKELETON_SYSTEM_LOCALTIME = Etc/UTC
                 ^

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 38

Quoted 2 lines
package/skeleton-systemd/skeleton-systemd.mk +2 -0
+endif
+

s/SKELETON_SYSTEM_LOCALTIME/SKELETON_SYSTEMD_LOCALTIME/

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 45

Quoted 7 lines
package/skeleton-systemd/skeleton-systemd.mk +1 -0
 define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/etc
 	mkdir -p $(TARGET_DIR)/home
 	mkdir -p $(TARGET_DIR)/srv
 	mkdir -p $(TARGET_DIR)/var
 	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	ln -sf ../usr/share/zoneinfo/$(SKELETON_SYSTEMD_LOCALTIME) \

This one is ok :)

Best regards,
Romain

Quoted 17 lines
package/skeleton-systemd/skeleton-systemd.mk +1 -0
+		$(TARGET_DIR)/etc/localtime
 	$(SKELETON_SYSTEMD_RSYNC_NETWORK)
 endef
 
system/Config.in +1 -0
index 17ce832..07af2e0 100644
@@ -130,6 +130,7 @@ config BR2_INIT_SYSTEMD
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
 	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
+	select BR2_TARGET_TZ_INFO
 
 comment "systemd needs (e)glibc toolchain, headers >= 3.10"
 	depends on !(BR2_TOOLCHAIN_USES_GLIBC \
#62 lore raw

PATCH v2 21/24 system/systemd: needs timezone

Romain, All,

On 2016-07-03 13:41 +0200, Romain Naour spake thusly:

Quoted 22 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 16 lines

systemd does not like being booted without any timezone info (especially on a R/O filesystem), so we forcibly enable that. If there is no default timezone set, we fallback to UTC (which is basically what no TZ means anyway).

---
 package/skeleton-systemd/skeleton-systemd.mk | 7 +++++++
 system/Config.in                             | 1 +
 2 files changed, 8 insertions(+)
package/skeleton-systemd/skeleton-systemd.mk +0 -0
index e781ce9..b45bbde 100644

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 34

Quoted 4 lines
package/skeleton-systemd/skeleton-systemd.mk +1 -0
@@ -31,12 +31,19 @@ SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK
 
 endif # BR2_PACKAGE_SYSTEMD_NETWORKD not set
 
+SKELETON_SYSTEM_LOCALTIME = $(call qstrip,$(BR2_TARGET_LOCALTIME))
                 ^
Quoted 8 lines

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 35

Quoted 1 line
package/skeleton-systemd/skeleton-systemd.mk +1 -0
+ifeq ($(SKELETON_SYSTEM_LOCALTIME),)
                         ^

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 36

Quoted 1 line
package/skeleton-systemd/skeleton-systemd.mk +1 -0
+SKELETON_SYSTEM_LOCALTIME = Etc/UTC
                 ^

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 38

Quoted 2 lines
package/skeleton-systemd/skeleton-systemd.mk +2 -0
+endif
+

s/SKELETON_SYSTEM_LOCALTIME/SKELETON_SYSTEMD_LOCALTIME/

Fixed.

Regards,
Yann E. MORIN.

Quoted 32 lines

package/skeleton-systemd/skeleton-systemd.mk SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK · line 45

Quoted 7 lines
package/skeleton-systemd/skeleton-systemd.mk +1 -0
 define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/etc
 	mkdir -p $(TARGET_DIR)/home
 	mkdir -p $(TARGET_DIR)/srv
 	mkdir -p $(TARGET_DIR)/var
 	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	ln -sf ../usr/share/zoneinfo/$(SKELETON_SYSTEMD_LOCALTIME) \

This one is ok :)

Best regards,
Romain

Quoted 17 lines
package/skeleton-systemd/skeleton-systemd.mk +1 -0
+		$(TARGET_DIR)/etc/localtime
 	$(SKELETON_SYSTEMD_RSYNC_NETWORK)
 endef
 
system/Config.in +1 -0
index 17ce832..07af2e0 100644
@@ -130,6 +130,7 @@ config BR2_INIT_SYSTEMD
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
 	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
+	select BR2_TARGET_TZ_INFO
 
 comment "systemd needs (e)glibc toolchain, headers >= 3.10"
 	depends on !(BR2_TOOLCHAIN_USES_GLIBC \
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#63 lore raw

PATCH v2 22/24 fs: add pre- and post-command hooks

In reply to Yann E. MORIN

In some cases, the directory structure we want in the filesystem is not exactly what we have in target/

For example, when systemd is used on a read-only rootfs, /var must be a tmpfs. However, we may have packages that install stuff in there, and set important rights (via the permission-table). So, at build time, we need /var to be a symlink to the remanent location (/usr/share/factory) while at runtime we need /var to be a directory.

One option would have seen to be do have /var as a real directory even during build time, and in a target-finalize hook, move everything out of there and into the "factory" location. However, that's not possible because it's too early: some packages may want to set ownership and/or acces rights on directories or files in /var, and this is only done in the fakeroot script, which is called only later during the assembling of the filesystem images.

Also, there would have been no way to undo the tweak (i.e. we need to restore the /var symlink so that subsequent builds continue to work) if it were done as a target-finalize hook.

The only solution is to allow packages to register pre- and post-hooks that are called right before and right after the rootfs commands are executed.

Those hooks are not documented on-purpose; they are probably going to be used only by systemd.

---
 fs/common.mk           | 4 ++++
 package/pkg-generic.mk | 4 ++++
 2 files changed, 8 insertions(+)
fs/common.mk +4 -0
index b7202c3..8feb172 100644
@@ -92,7 +92,11 @@ endif
 	$$(call PRINTF,$$(PACKAGES_PERMISSIONS_TABLE)) >> $$(FULL_DEVICE_TABLE)
 	echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
 endif
+	$$(foreach hook,$$(FS_INIT_PRE_CMD_HOOKS),\
+		$$(call PRINTF,$$($$(hook))) >>$$(FAKEROOT_SCRIPT))
 	$$(call PRINTF,$$(ROOTFS_$(2)_CMD)) >> $$(FAKEROOT_SCRIPT)
+	$$(foreach hook,$$(FS_INIT_POST_CMD_HOOKS),\
+		$$(call PRINTF,$$($$(hook))) >>$$(FAKEROOT_SCRIPT))
 	chmod a+x $$(FAKEROOT_SCRIPT)
 	PATH=$$(BR_PATH) $$(HOST_DIR)/usr/bin/fakeroot -- $$(FAKEROOT_SCRIPT)
 	$$(INSTALL) -m 0644 support/misc/target-dir-warning.txt $$(TARGET_DIR_WARNING_FILE)
package/pkg-generic.mk +4 -0
index 4415342..2f80392 100644
@@ -559,6 +559,8 @@ $(2)_POST_INSTALL_IMAGES_HOOKS  ?=
 $(2)_PRE_LEGAL_INFO_HOOKS       ?=
 $(2)_POST_LEGAL_INFO_HOOKS      ?=
 $(2)_TARGET_FINALIZE_HOOKS      ?=
+$(2)_FS_PRE_CMD_HOOKS           ?=
+$(2)_FS_POST_CMD_HOOKS          ?=
 
 # human-friendly targets and target sequencing
 $(1):			$(1)-install
@@ -860,6 +862,8 @@ ifneq ($$($(2)_USERS),)
 PACKAGES_USERS += $$($(2)_USERS)$$(sep)
 endif
 TARGET_FINALIZE_HOOKS += $$($(2)_TARGET_FINALIZE_HOOKS)
+FS_INIT_PRE_CMD_HOOKS += $$($(2)_FS_PRE_CMD_HOOKS)
+FS_INIT_POST_CMD_HOOKS += $$($(2)_FS_POST_CMD_HOOKS)
 
 ifeq ($$($(2)_SITE_METHOD),svn)
 DL_TOOLS_DEPENDENCIES += svn
Signature · 1 line
2.7.4
#64 lore raw

PATCH v2 22/24 fs: add pre- and post-command hooks

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 39 lines

In some cases, the directory structure we want in the filesystem is not exactly what we have in target/

For example, when systemd is used on a read-only rootfs, /var must be a tmpfs. However, we may have packages that install stuff in there, and set important rights (via the permission-table). So, at build time, we need /var to be a symlink to the remanent location (/usr/share/factory) while at runtime we need /var to be a directory.

One option would have seen to be do have /var as a real directory even during build time, and in a target-finalize hook, move everything out of there and into the "factory" location. However, that's not possible because it's too early: some packages may want to set ownership and/or acces rights on directories or files in /var, and this is only done in the fakeroot script, which is called only later during the assembling of the filesystem images.

Also, there would have been no way to undo the tweak (i.e. we need to restore the /var symlink so that subsequent builds continue to work) if it were done as a target-finalize hook.

The only solution is to allow packages to register pre- and post-hooks that are called right before and right after the rootfs commands are executed.

Those hooks are not documented on-purpose; they are probably going to be used only by systemd.

---
 fs/common.mk           | 4 ++++
 package/pkg-generic.mk | 4 ++++
 2 files changed, 8 insertions(+)
fs/common.mk +0 -0
index b7202c3..8feb172 100644

fs/common.mk endif · line 96

Quoted 5 lines
fs/common.mk +2 -0
@@ -92,7 +92,11 @@ endif
 	$$(call PRINTF,$$(PACKAGES_PERMISSIONS_TABLE)) >> $$(FULL_DEVICE_TABLE)
 	echo "$$(HOST_DIR)/usr/bin/makedevs -d $$(FULL_DEVICE_TABLE) $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
 endif
+	$$(foreach hook,$$(FS_INIT_PRE_CMD_HOOKS),\
+		$$(call PRINTF,$$($$(hook))) >>$$(FAKEROOT_SCRIPT))
                                               ^

fs/common.mk endif · line 99

Quoted 3 lines
fs/common.mk +2 -0
 	$$(call PRINTF,$$(ROOTFS_$(2)_CMD)) >> $$(FAKEROOT_SCRIPT)
+	$$(foreach hook,$$(FS_INIT_POST_CMD_HOOKS),\
+		$$(call PRINTF,$$($$(hook))) >>$$(FAKEROOT_SCRIPT))
                                               ^

We need a space between >> and $$

With that fixed:

Best regards,
Romain

Quoted 26 lines
fs/common.mk +0 -0
 	chmod a+x $$(FAKEROOT_SCRIPT)
 	PATH=$$(BR_PATH) $$(HOST_DIR)/usr/bin/fakeroot -- $$(FAKEROOT_SCRIPT)
 	$$(INSTALL) -m 0644 support/misc/target-dir-warning.txt $$(TARGET_DIR_WARNING_FILE)
package/pkg-generic.mk +4 -0
index 4415342..2f80392 100644
@@ -559,6 +559,8 @@ $(2)_POST_INSTALL_IMAGES_HOOKS  ?=
 $(2)_PRE_LEGAL_INFO_HOOKS       ?=
 $(2)_POST_LEGAL_INFO_HOOKS      ?=
 $(2)_TARGET_FINALIZE_HOOKS      ?=
+$(2)_FS_PRE_CMD_HOOKS           ?=
+$(2)_FS_POST_CMD_HOOKS          ?=
 
 # human-friendly targets and target sequencing
 $(1):			$(1)-install
@@ -860,6 +862,8 @@ ifneq ($$($(2)_USERS),)
 PACKAGES_USERS += $$($(2)_USERS)$$(sep)
 endif
 TARGET_FINALIZE_HOOKS += $$($(2)_TARGET_FINALIZE_HOOKS)
+FS_INIT_PRE_CMD_HOOKS += $$($(2)_FS_PRE_CMD_HOOKS)
+FS_INIT_POST_CMD_HOOKS += $$($(2)_FS_POST_CMD_HOOKS)
 
 ifeq ($$($(2)_SITE_METHOD),svn)
 DL_TOOLS_DEPENDENCIES += svn
#65 lore raw

PATCH v2 23/24 system: make systemd work on a read-only rootfs

In reply to Yann E. MORIN

When the rootfs is readonly, systemd will expect /var to be writable. Because we do not really have a R/W filesystem to mount on /var, we make it a tmpfs, and use the systemd-tmpfiles feautre to populate it with "factory" defaults.

We obtain those factory defaults by redirecting /var to that location at build time, usign a symlink /var -> /usr/share/factory which is the location in which systemd-tmpfiles will look for when instructed to "recursively copy" a directory.

With a line like:

C /var/something - - - -

it will look for /usr/share/factory/something and copy it (recursively if it is a directory) to /var/something, but only if it does not already exist there.

We also mark this copy with the exclamation mark, as it is only safe to copy on boot, not when changing targets.

To be noted: the real format for such lines are:

C /var/something - - - - /from/where/to/copy/something

But if the source is not given, then it is implicitly taken from /usr/share/factory (which in our case is as-good a location as whatever else, so we use it, and thus we need not specify the source of the copy).

Note that we treat symlinks a little bit specially, by creating symlinks to the factory defaults rather than copying them.

Finally, /var at build time is a symlink, but at runtime, it must be a directory (so we can mount the tmpfs over there). We can't change that as a target-finalize hook, because:

- some packages may want to set ownership and/or acces rights on files or directoris in /var, and that only happens while assemblig the filesystem images; changing /var from a symlink to a (then empty) directory would break this;

- /var would be a directory on sub-sequent builds (until the next

    "make clean").

Instead, we use the newly-introduce pre- and post-rootfs command hooks, to turn /var into a directory before assembling the image, and back to a symlink after assembling the image.

---
Note: I haven't seen any symlinks installed in the factory so far, but I haven't build a lot of packages yet... So, I'm not sure what to do with the symlinks, especially when a package install relative symlinks...

---
 package/skeleton-systemd/skeleton-systemd.mk | 51 ++++++++++++++++++++++++++--
 system/Config.in                             |  1 -
 2 files changed, 49 insertions(+), 3 deletions(-)
package/skeleton-systemd/skeleton-systemd.mk +49 -2
index b45bbde..c7c2e26 100644
@@ -36,12 +36,59 @@ ifeq ($(SKELETON_SYSTEM_LOCALTIME),)
 SKELETON_SYSTEM_LOCALTIME = Etc/UTC
 endif
 
+ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
+
+define SKELETON_SYSTEMD_ROOT_RW
+	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	mkdir -p $(TARGET_DIR)/var
+endef
+
+else
+
+# On a R/O rootfs, /var is a tmpfs filesystem. So, at build time, we
+# redirect /var to the "factory settings" location. Just before the
+# filesystem gets created, the /var symlink will be replaced with
+# a real (but empty) directory, and the "factory files" will be copied
+# back there by the tmpfiles.d mechanism.
+define SKELETON_SYSTEMD_ROOT_RO
+	mkdir -p $(TARGET_DIR)/etc/systemd/tmpfiles.d
+	mkdir -p $(TARGET_DIR)/usr/share/factory
+	ln -s usr/share/factory $(TARGET_DIR)/var
+	echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab
+	echo "tmpfs /var tmpfs mode=1777 0 0" >>$(TARGET_DIR)/etc/fstab
+endef
+
+define SKELETON_SYSTEMD_VAR_PRE_FS
+	rm -f $(TARGET_DIR)/var
+	mkdir $(TARGET_DIR)/var
+	for i in $(TARGET_DIR)/usr/share/factory/*; do \
+		j="$${i##*/}"; \
+		if [ -L "$${i}" ]; then \
+			printf "L+! /var/%s - - - - %s\n" \
+				"$${j}" "../usr/share/factory/$${j}" \
+			|| exit 1; \
+		else \
+			printf "C! /var/%s - - - -\n" "$${j}" \
+			|| exit 1; \
+		fi; \
+	done >$(TARGET_DIR)/etc/systemd/tmpfiles.d/var-factory.conf
+endef
+SKELETON_SYSTEMD_FS_PRE_CMD_HOOKS += SKELETON_SYSTEMD_VAR_PRE_FS
+
+define SKELETON_SYSTEMD_VAR_POST_FS
+	rm -rf $(TARGET_DIR)/var
+	ln -s usr/share/factory $(TARGET_DIR)/var
+endef
+SKELETON_SYSTEMD_FS_POST_CMD_HOOKS += SKELETON_SYSTEMD_VAR_POST_FS
+
+endif
+
 define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/etc
 	mkdir -p $(TARGET_DIR)/home
 	mkdir -p $(TARGET_DIR)/srv
-	mkdir -p $(TARGET_DIR)/var
-	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	$(SKELETON_SYSTEMD_ROOT_RO)
+	$(SKELETON_SYSTEMD_ROOT_RW)
 	ln -sf ../usr/share/zoneinfo/$(SKELETON_SYSTEMD_LOCALTIME) \
 		$(TARGET_DIR)/etc/localtime
 	$(SKELETON_SYSTEMD_RSYNC_NETWORK)
system/Config.in +0 -1
index 07af2e0..32d6542 100644
@@ -129,7 +129,6 @@ config BR2_INIT_SYSTEMD
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
-	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 	select BR2_TARGET_TZ_INFO
 
 comment "systemd needs (e)glibc toolchain, headers >= 3.10"
Signature · 1 line
2.7.4
#66 lore raw

PATCH v2 23/24 system: make systemd work on a read-only rootfs

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 3 lines

When the rootfs is readonly, systemd will expect /var to be writable. Because we do not really have a R/W filesystem to mount on /var, we make it a tmpfs, and use the systemd-tmpfiles feautre to populate it with

                                            ^

s/feautre/feature/

Quoted 4 lines

"factory" defaults.

We obtain those factory defaults by redirecting /var to that location at build time, usign a symlink /var -> /usr/share/factory which is the

               ^

s/usign/using/

Quoted 23 lines

location in which systemd-tmpfiles will look for when instructed to "recursively copy" a directory.

With a line like:

C /var/something - - - -

it will look for /usr/share/factory/something and copy it (recursively if it is a directory) to /var/something, but only if it does not already exist there.

We also mark this copy with the exclamation mark, as it is only safe to copy on boot, not when changing targets.

To be noted: the real format for such lines are:

C /var/something - - - - /from/where/to/copy/something

But if the source is not given, then it is implicitly taken from /usr/share/factory (which in our case is as-good a location as whatever else, so we use it, and thus we need not specify the source of the copy).

Quoted 8 lines

Note that we treat symlinks a little bit specially, by creating symlinks to the factory defaults rather than copying them.

Finally, /var at build time is a symlink, but at runtime, it must be a directory (so we can mount the tmpfs over there). We can't change that as a target-finalize hook, because:

- some packages may want to set ownership and/or acces rights on files

                                                         ^

s/acces/access/

Quoted 1 line

or directoris in /var, and that only happens while assemblig the

^ ^
s/directoris/directories/
s/assemblig/assembling/

Quoted 12 lines

filesystem images; changing /var from a symlink to a (then empty) directory would break this;

- /var would be a directory on sub-sequent builds (until the next

    "make clean").

Instead, we use the newly-introduce pre- and post-rootfs command hooks, to turn /var into a directory before assembling the image, and back to a symlink after assembling the image.

Other than small typos highlighted by my mail client ;-)

Best regards,
Romain

Quoted 88 lines

---
Note: I haven't seen any symlinks installed in the factory so far, but I haven't build a lot of packages yet... So, I'm not sure what to do with the symlinks, especially when a package install relative symlinks...

---
 package/skeleton-systemd/skeleton-systemd.mk | 51 ++++++++++++++++++++++++++--
 system/Config.in                             |  1 -
 2 files changed, 49 insertions(+), 3 deletions(-)
package/skeleton-systemd/skeleton-systemd.mk +49 -2
index b45bbde..c7c2e26 100644
@@ -36,12 +36,59 @@ ifeq ($(SKELETON_SYSTEM_LOCALTIME),)
 SKELETON_SYSTEM_LOCALTIME = Etc/UTC
 endif
 
+ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
+
+define SKELETON_SYSTEMD_ROOT_RW
+	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	mkdir -p $(TARGET_DIR)/var
+endef
+
+else
+
+# On a R/O rootfs, /var is a tmpfs filesystem. So, at build time, we
+# redirect /var to the "factory settings" location. Just before the
+# filesystem gets created, the /var symlink will be replaced with
+# a real (but empty) directory, and the "factory files" will be copied
+# back there by the tmpfiles.d mechanism.
+define SKELETON_SYSTEMD_ROOT_RO
+	mkdir -p $(TARGET_DIR)/etc/systemd/tmpfiles.d
+	mkdir -p $(TARGET_DIR)/usr/share/factory
+	ln -s usr/share/factory $(TARGET_DIR)/var
+	echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab
+	echo "tmpfs /var tmpfs mode=1777 0 0" >>$(TARGET_DIR)/etc/fstab
+endef
+
+define SKELETON_SYSTEMD_VAR_PRE_FS
+	rm -f $(TARGET_DIR)/var
+	mkdir $(TARGET_DIR)/var
+	for i in $(TARGET_DIR)/usr/share/factory/*; do \
+		j="$${i##*/}"; \
+		if [ -L "$${i}" ]; then \
+			printf "L+! /var/%s - - - - %s\n" \
+				"$${j}" "../usr/share/factory/$${j}" \
+			|| exit 1; \
+		else \
+			printf "C! /var/%s - - - -\n" "$${j}" \
+			|| exit 1; \
+		fi; \
+	done >$(TARGET_DIR)/etc/systemd/tmpfiles.d/var-factory.conf
+endef
+SKELETON_SYSTEMD_FS_PRE_CMD_HOOKS += SKELETON_SYSTEMD_VAR_PRE_FS
+
+define SKELETON_SYSTEMD_VAR_POST_FS
+	rm -rf $(TARGET_DIR)/var
+	ln -s usr/share/factory $(TARGET_DIR)/var
+endef
+SKELETON_SYSTEMD_FS_POST_CMD_HOOKS += SKELETON_SYSTEMD_VAR_POST_FS
+
+endif
+
 define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/etc
 	mkdir -p $(TARGET_DIR)/home
 	mkdir -p $(TARGET_DIR)/srv
-	mkdir -p $(TARGET_DIR)/var
-	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	$(SKELETON_SYSTEMD_ROOT_RO)
+	$(SKELETON_SYSTEMD_ROOT_RW)
 	ln -sf ../usr/share/zoneinfo/$(SKELETON_SYSTEMD_LOCALTIME) \
 		$(TARGET_DIR)/etc/localtime
 	$(SKELETON_SYSTEMD_RSYNC_NETWORK)
system/Config.in +0 -1
index 07af2e0..32d6542 100644
@@ -129,7 +129,6 @@ config BR2_INIT_SYSTEMD
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
-	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 	select BR2_TARGET_TZ_INFO
 
 comment "systemd needs (e)glibc toolchain, headers >= 3.10"
#67 lore raw

PATCH v2 23/24 system: make systemd work on a read-only rootfs

Romain, All,

On 2016-07-03 14:54 +0200, Romain Naour spake thusly:

Quoted 5 lines

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 3 lines

When the rootfs is readonly, systemd will expect /var to be writable. Because we do not really have a R/W filesystem to mount on /var, we make it a tmpfs, and use the systemd-tmpfiles feautre to populate it with

s/feautre/feature/

[--SNIP--]

Quoted 1 line

Other than small typos highlighted by my mail client ;-)

Typoes fixed, thanks!

Regards,
Yann E. MORIN.

Quoted 95 lines

Best regards,
Romain

Quoted 88 lines

---
Note: I haven't seen any symlinks installed in the factory so far, but I haven't build a lot of packages yet... So, I'm not sure what to do with the symlinks, especially when a package install relative symlinks...

---
 package/skeleton-systemd/skeleton-systemd.mk | 51 ++++++++++++++++++++++++++--
 system/Config.in                             |  1 -
 2 files changed, 49 insertions(+), 3 deletions(-)
package/skeleton-systemd/skeleton-systemd.mk +49 -2
index b45bbde..c7c2e26 100644
@@ -36,12 +36,59 @@ ifeq ($(SKELETON_SYSTEM_LOCALTIME),)
 SKELETON_SYSTEM_LOCALTIME = Etc/UTC
 endif
 
+ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
+
+define SKELETON_SYSTEMD_ROOT_RW
+	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	mkdir -p $(TARGET_DIR)/var
+endef
+
+else
+
+# On a R/O rootfs, /var is a tmpfs filesystem. So, at build time, we
+# redirect /var to the "factory settings" location. Just before the
+# filesystem gets created, the /var symlink will be replaced with
+# a real (but empty) directory, and the "factory files" will be copied
+# back there by the tmpfiles.d mechanism.
+define SKELETON_SYSTEMD_ROOT_RO
+	mkdir -p $(TARGET_DIR)/etc/systemd/tmpfiles.d
+	mkdir -p $(TARGET_DIR)/usr/share/factory
+	ln -s usr/share/factory $(TARGET_DIR)/var
+	echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab
+	echo "tmpfs /var tmpfs mode=1777 0 0" >>$(TARGET_DIR)/etc/fstab
+endef
+
+define SKELETON_SYSTEMD_VAR_PRE_FS
+	rm -f $(TARGET_DIR)/var
+	mkdir $(TARGET_DIR)/var
+	for i in $(TARGET_DIR)/usr/share/factory/*; do \
+		j="$${i##*/}"; \
+		if [ -L "$${i}" ]; then \
+			printf "L+! /var/%s - - - - %s\n" \
+				"$${j}" "../usr/share/factory/$${j}" \
+			|| exit 1; \
+		else \
+			printf "C! /var/%s - - - -\n" "$${j}" \
+			|| exit 1; \
+		fi; \
+	done >$(TARGET_DIR)/etc/systemd/tmpfiles.d/var-factory.conf
+endef
+SKELETON_SYSTEMD_FS_PRE_CMD_HOOKS += SKELETON_SYSTEMD_VAR_PRE_FS
+
+define SKELETON_SYSTEMD_VAR_POST_FS
+	rm -rf $(TARGET_DIR)/var
+	ln -s usr/share/factory $(TARGET_DIR)/var
+endef
+SKELETON_SYSTEMD_FS_POST_CMD_HOOKS += SKELETON_SYSTEMD_VAR_POST_FS
+
+endif
+
 define SKELETON_SYSTEMD_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/etc
 	mkdir -p $(TARGET_DIR)/home
 	mkdir -p $(TARGET_DIR)/srv
-	mkdir -p $(TARGET_DIR)/var
-	echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
+	$(SKELETON_SYSTEMD_ROOT_RO)
+	$(SKELETON_SYSTEMD_ROOT_RW)
 	ln -sf ../usr/share/zoneinfo/$(SKELETON_SYSTEMD_LOCALTIME) \
 		$(TARGET_DIR)/etc/localtime
 	$(SKELETON_SYSTEMD_RSYNC_NETWORK)
system/Config.in +0 -1
index 07af2e0..32d6542 100644
@@ -129,7 +129,6 @@ config BR2_INIT_SYSTEMD
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10
 	select BR2_ROOTFS_MERGED_USR
 	select BR2_PACKAGE_SYSTEMD
-	select BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 	select BR2_TARGET_TZ_INFO
 
 comment "systemd needs (e)glibc toolchain, headers >= 3.10"
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#68 lore raw

PATCH v2 24/24 system: allow DHCP interface with systemd-networkd

In reply to Yann E. MORIN

It is pretty trivial to enable a DHCP interface with systemd-networkd, we just need to provide a .network config file with just the name of the interface to bring up and activate DHCP on it.

---
 package/skeleton-systemd/skeleton-systemd.mk | 12 +++++++++++-
 system/Config.in                             |  9 +++------
 2 files changed, 14 insertions(+), 7 deletions(-)
package/skeleton-systemd/skeleton-systemd.mk +11 -1
index c7c2e26..cbaded2 100644
@@ -15,7 +15,17 @@ SKELETON_SYSTEMD_ADD_SKELETON_DEPENDENCY = NO
 
 # In case we're not using systemd-networkd, use the sysv-like network infra;
 # otherwise, the necessary bits are installed by the systemd package.
-ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),)
+ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),y)
+
+define SKELETON_SYSTEMD_SET_NETWORK
+	mkdir -p $(TARGET_DIR)/etc/systemd/network
+	printf '[Match]\nName=%s\n[Network]\nDHCP=yes\n' \
+		$(SKELETON_NETWORK_DHCP_IFACE) \
+		>$(TARGET_DIR)/etc/systemd/network/$(SKELETON_NETWORK_DHCP_IFACE).network
+endef
+SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK
+
+else # BR2_PACKAGE_SYSTEMD_NETWORKD is not set
 
 define SKELETON_SYSTEMD_RSYNC_NETWORK
 	 $(call SKELETON_RSYNC,system/skeleton-net,$(TARGET_DIR))
system/Config.in +3 -6
index 32d6542..c90866c 100644
@@ -362,7 +362,7 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 config BR2_SYSTEM_DHCP
 	string "Network interface to configure through DHCP"
 	default ""
-	depends on !BR2_PACKAGE_SYSTEMD_NETWORKD && (BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN)
+	depends on BR2_PACKAGE_SYSTEMD_NETWORKD || BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN
 	help
 	  Enter here the name of the network interface (E.G. eth0) to
 	  automatically configure through DHCP at bootup.
@@ -372,11 +372,8 @@ config BR2_SYSTEM_DHCP
 	  For more complicated network setups use an overlay to overwrite
 	  /etc/network/interfaces or add a networkd configuration file.
 
-comment "automatic network configuration via DHCP is not compatible with networkd"
-	depends on BR2_PACKAGE_SYSTEMD_NETWORKD
-
-comment "automatic network configuration via DHCP needs ifupdown or busybox"
-	depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN)
+comment "automatic network configuration via DHCP needs systemd, busybox or ifupdown"
+	depends on !(BR2_PACKAGE_SYSTEMD_NETWORKD || BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN)
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
 
Signature · 1 line
2.7.4
#69 lore raw

PATCH v2 24/24 system: allow DHCP interface with systemd-networkd

Hi Yann,

Le 22/06/2016 ? 21:07, Yann E. MORIN a ?crit :

Quoted 5 lines

It is pretty trivial to enable a DHCP interface with systemd-networkd, we just need to provide a .network config file with just the name of the interface to bring up and activate DHCP on it.

Best regards,
Romain

Quoted 56 lines
---
 package/skeleton-systemd/skeleton-systemd.mk | 12 +++++++++++-
 system/Config.in                             |  9 +++------
 2 files changed, 14 insertions(+), 7 deletions(-)
package/skeleton-systemd/skeleton-systemd.mk +11 -1
index c7c2e26..cbaded2 100644
@@ -15,7 +15,17 @@ SKELETON_SYSTEMD_ADD_SKELETON_DEPENDENCY = NO
 
 # In case we're not using systemd-networkd, use the sysv-like network infra;
 # otherwise, the necessary bits are installed by the systemd package.
-ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),)
+ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),y)
+
+define SKELETON_SYSTEMD_SET_NETWORK
+	mkdir -p $(TARGET_DIR)/etc/systemd/network
+	printf '[Match]\nName=%s\n[Network]\nDHCP=yes\n' \
+		$(SKELETON_NETWORK_DHCP_IFACE) \
+		>$(TARGET_DIR)/etc/systemd/network/$(SKELETON_NETWORK_DHCP_IFACE).network
+endef
+SKELETON_SYSTEMD_TARGET_FINALIZE_HOOKS += SKELETON_SYSTEMD_SET_NETWORK
+
+else # BR2_PACKAGE_SYSTEMD_NETWORKD is not set
 
 define SKELETON_SYSTEMD_RSYNC_NETWORK
 	 $(call SKELETON_RSYNC,system/skeleton-net,$(TARGET_DIR))
system/Config.in +3 -6
index 32d6542..c90866c 100644
@@ -362,7 +362,7 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
 config BR2_SYSTEM_DHCP
 	string "Network interface to configure through DHCP"
 	default ""
-	depends on !BR2_PACKAGE_SYSTEMD_NETWORKD && (BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN)
+	depends on BR2_PACKAGE_SYSTEMD_NETWORKD || BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN
 	help
 	  Enter here the name of the network interface (E.G. eth0) to
 	  automatically configure through DHCP at bootup.
@@ -372,11 +372,8 @@ config BR2_SYSTEM_DHCP
 	  For more complicated network setups use an overlay to overwrite
 	  /etc/network/interfaces or add a networkd configuration file.
 
-comment "automatic network configuration via DHCP is not compatible with networkd"
-	depends on BR2_PACKAGE_SYSTEMD_NETWORKD
-
-comment "automatic network configuration via DHCP needs ifupdown or busybox"
-	depends on !(BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN)
+comment "automatic network configuration via DHCP needs systemd, busybox or ifupdown"
+	depends on !(BR2_PACKAGE_SYSTEMD_NETWORKD || BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_IFUPDOWN)
 
 endif # BR2_ROOTFS_SKELETON_DEFAULT
 
#70 lore raw

v2 cover system: properly handle systemd as init system (branch yem/systemd-skeleton)

In reply to Yann E. MORIN

Hello,

OK, let's try to make a quick status on this series, after the Buildroot Summer Camp and the discussions we had.

Quoted 2 lines · Yann E. MORIN

Yann E. MORIN (24):
package/skeleton: remove useless .empty file

Merged.

Quoted 1 line

system: sysvinit only selects busybox-show-others if busybox is enabled

We decided collectively to not merge this, as other packages would have to be changed, and the benefit is not very big.

Quoted 1 line

package/skeleton: respect variables namespace

Merged.

Quoted 1 line

system/skeleton: update etc/mtab with a more sensible link

Merged.

Quoted 1 line

system: systemd only really supports a R/W rootfs

Merged.

Quoted 1 line

package/systemd: disabling tty1 getty is a post-install hook

Rejected, as it was broken.

Quoted 1 line

system: provide no default for custom skeleton path

Generally agreed, but I'm waiting for a respin since there were some comments.

Quoted 1 line

system: move the rootfs skeleton choice

Looks good as well, waiting for the respin (it depends on the previous patch).

Quoted 1 line

system: do not handle network settings for custom skeleton

Ditto.

Quoted 1 line

package/perl: use dummy hostname

Merged.

Quoted 1 line

system: do not set hostname and issue for custom skeleton

Also looks good, but waiting for the respin, since it depends on the previous patches.

Quoted 2 lines

core/pkg-generic: add variable to skip skeleton dependency package/skeleton: add macro to rsync skeleton directory

Both not merged yet, they are needed only for the "split skeleton" solution, which I'll discuss below.

Quoted 2 lines

core/pkg-generic: allow packages to declare target-finalize hooks
packages: use the <PKG>_TARGET_FINALIZE_HOOKS

Both merged. For the latter, a follow-up patch is needed to also use the new mechanism in the toolchain package.

Quoted 6 lines

package/skeleton: split into sysv and custom skeleton package/skeleton: make it a virtual package package/skeleton-sysv: split into skeleton-common
system: split skeleton package/skeleton-systemd: new package system/systemd: needs timezone

OK, so this is the first big thing that remains: splitting the skeleton into multiple parts. If I summarize your solution, it consists in splitting the skeleton in several parts:

* 'skeleton', which becomes a virtual package that depends on the actual skeleton.

* 'skeleton-custom', which is used when a custom skeleton is selected, and does pretty much nothing except copy the custom skeleton

* 'skeleton-common', which contains the common parts of the systemd and sysv skeleton

* 'skeleton-sysv', which depends on skeleton-common and contains the sysv specific parts of the skeleton. In practice, this only contains the /var sub-directories, /etc/fstab, the /etc/resolv.conf symbolic link (which is the same in systemd, so it's not a real difference), and the /dev sub-directories.

* 'skeleton-systemd', which depends on skeleton-common, but does not copy itself some skeleton, as it instead just creates a bunch of directories and files. In practice, the only thing useful that it does is create a /etc/fstab file.

In addition, a 'skeleton-net' part is created, which is not a package, but just a placeholder with the ifupdown configuration, used by both the sysv init case, and the systemd-without-networkd case.

At the very least, I believe:

- the skeleton-net thing should be moved into a ifupdown-config package

- the skeleton-systemd should be simplified to not create directories that already exist in skeleton-common

- the /etc/resolv.conf file should be kept in the common skeleton

Once this is done, I continue to wonder if this multiple skeleton mechanism is really needed:

- the skeleton-systemd package does essentially nothing, except creating the fstab, which the systemd package could do.

- the skeleton-sysv package also doesn't do much, and it could be done in the existing initscripts package.

Really, the only thing that bothers me is that "initscripts" isn't a very good name for a package that also installs other things than init scripts. Perhaps naming it "sysv-base" or something would be clearer.

But maybe before taking a decision on this we simply need to see a respin that does the first cleanups suggested above, so that we can have a clearer vision of where things are going. The idea of skeleton as a virtual package is also not bad, especially if we can get rid of the weird skeleton-net situation, and really have skeleton-{common,sysv,custom,} be real packages.

Quoted 3 lines

fs: add pre- and post-command hooks
system: make systemd work on a read-only rootfs
system: allow DHCP interface with systemd-networkd

This is the second big thing: allow a systemd rootfs to be read-only. The crux of the problem is that when /var is read-only, systemd automatically mounts a tmpfs on /var, which defeats our traditional mechanism to handle read-only rootfs.

The solution that Yann has designed consists in having /var be a symlink to /usr/share/factory in the systemd skeleton. This way, during the Buildroot build, all the packages that create stuff in /var end up installing their stuff in /usr/share/factory. And then, thanks to the pre/post hooks in the FS infrastructure, the code creates some tmpfiles description for systemd for each file in /usr/share/factory and replaces /var with a directory. This way, when systemd boots, it mounts a tmpfs in /var and copies all the files from /usr/share/factory to /var.

I am a bit annoyed by the complexity of this, and the "black magic" involved, but on the other hand, I don't really see a better solution.

Another thing that bothers me is that then the solution to handle the read-only rootfs problem then becomes radically different between the sysv case and the systemd case. Maybe this is expected since the init systems are so different.

But on the other hand, our existing mechanism to handle a read-only rootfs in sysv land is not great: we create /var/log as a symlink to /tmp, and /tmp is mounted as a tmpfs. This works fines if applications just create files in /var/log. But if an application at build time create a directory in /var/log, such as /var/log/daemond, it might expect to find it at runtime, which will not be the case. The /usr/share/factory solution solves this problem.

So, should we move to this /usr/share/factory solution also for sysv init ?

Yann, what about:

(1) Getting a series that has just the respin of the preparatory

     patches ;

(2) Separate the "skeleton re-org" series from the "systemd read-only rootfs" series, so that we can progress on those topics one by one ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#71 lore raw

v2 cover system: properly handle systemd as init system (branch yem/systemd-skeleton)

Thomas, All,

On 2016-07-06 23:49 +0200, Thomas Petazzoni spake thusly:

Quoted 4 lines · Yann E. MORIN
Quoted 1 line

system: sysvinit only selects busybox-show-others if busybox is enabled

We decided collectively to not merge this, as other packages would have to be changed, and the benefit is not very big.

Yes, I replaced it with a patch that adds a comment for this variable.

Quoted 11 lines
Quoted 1 line

system: provide no default for custom skeleton path

Generally agreed, but I'm waiting for a respin since there were some comments.

Quoted 1 line

system: move the rootfs skeleton choice

Looks good as well, waiting for the respin (it depends on the previous patch).

Quoted 1 line

system: do not handle network settings for custom skeleton

Ditto.

Quoted 1 line

system: do not set hostname and issue for custom skeleton

Also looks good, but waiting for the respin, since it depends on the previous patches.

Yep, I'll respin shortly, it's almost ready.

Quoted 4 lines
Quoted 2 lines

core/pkg-generic: allow packages to declare target-finalize hooks
packages: use the <PKG>_TARGET_FINALIZE_HOOKS

Both merged. For the latter, a follow-up patch is needed to also use the new mechanism in the toolchain package.

Already done here, will be part of the respin.

Quoted 57 lines
Quoted 6 lines

package/skeleton: split into sysv and custom skeleton package/skeleton: make it a virtual package package/skeleton-sysv: split into skeleton-common
system: split skeleton package/skeleton-systemd: new package system/systemd: needs timezone

OK, so this is the first big thing that remains: splitting the skeleton into multiple parts. If I summarize your solution, it consists in splitting the skeleton in several parts:

* 'skeleton', which becomes a virtual package that depends on the actual skeleton.

* 'skeleton-custom', which is used when a custom skeleton is selected, and does pretty much nothing except copy the custom skeleton

* 'skeleton-common', which contains the common parts of the systemd and sysv skeleton

* 'skeleton-sysv', which depends on skeleton-common and contains the sysv specific parts of the skeleton. In practice, this only contains the /var sub-directories, /etc/fstab, the /etc/resolv.conf symbolic link (which is the same in systemd, so it's not a real difference), and the /dev sub-directories.

* 'skeleton-systemd', which depends on skeleton-common, but does not copy itself some skeleton, as it instead just creates a bunch of directories and files. In practice, the only thing useful that it does is create a /etc/fstab file.

In addition, a 'skeleton-net' part is created, which is not a package, but just a placeholder with the ifupdown configuration, used by both the sysv init case, and the systemd-without-networkd case.

At the very least, I believe:

- the skeleton-net thing should be moved into a ifupdown-config package

- the skeleton-systemd should be simplified to not create directories that already exist in skeleton-common

- the /etc/resolv.conf file should be kept in the common skeleton

Once this is done, I continue to wonder if this multiple skeleton mechanism is really needed:

- the skeleton-systemd package does essentially nothing, except creating the fstab, which the systemd package could do.

- the skeleton-sysv package also doesn't do much, and it could be done in the existing initscripts package.

Really, the only thing that bothers me is that "initscripts" isn't a very good name for a package that also installs other things than init scripts. Perhaps naming it "sysv-base" or something would be clearer.

Quoted 6 lines

But maybe before taking a decision on this we simply need to see a respin that does the first cleanups suggested above, so that we can have a clearer vision of where things are going. The idea of skeleton as a virtual package is also not bad, especially if we can get rid of the weird skeleton-net situation, and really have skeleton-{common,sysv,custom,} be real packages.

I'm not going to do any change right now, to let the dust settle. Once others have commented one way or another, I'll do the requested changes.

Quoted 7 lines
Quoted 3 lines

fs: add pre- and post-command hooks
system: make systemd work on a read-only rootfs
system: allow DHCP interface with systemd-networkd

This is the second big thing: allow a systemd rootfs to be read-only. The crux of the problem is that when /var is read-only, systemd automatically mounts a tmpfs on /var, which defeats our traditional

Nit: systemd *expects* /var to be a tmpfs (or at least that it be writable). It does not do the mount; we do it explicitly in the fstab.

Quoted 12 lines

mechanism to handle read-only rootfs.

The solution that Yann has designed consists in having /var be a symlink to /usr/share/factory in the systemd skeleton. This way, during the Buildroot build, all the packages that create stuff in /var end up installing their stuff in /usr/share/factory. And then, thanks to the pre/post hooks in the FS infrastructure, the code creates some tmpfiles description for systemd for each file in /usr/share/factory and replaces /var with a directory. This way, when systemd boots, it mounts a tmpfs in /var and copies all the files from /usr/share/factory to /var.

Quoted 7 lines

I am a bit annoyed by the complexity of this, and the "black magic" involved, but on the other hand, I don't really see a better solution.

Another thing that bothers me is that then the solution to handle the read-only rootfs problem then becomes radically different between the sysv case and the systemd case. Maybe this is expected since the init systems are so different.

And now that I had time to think about it, there is even another issue that I forgot to talk about: this relies on whether the user asked that the rootfs be remounted R/W at boot (BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW).

If that is that case, we currently still offer a way to build filesystems that are inherently R/O (cramfs, iso9660, squashfs...) I would suggest that we hide those filesystems in that case.

Yet, when the option is not selected does not mean that we should not allow a R/W filesystem either (the user may well want to boot a R/O ext4 but remount it for local upgrades, like a GPS database for example).

But surely, when the users asks / to be remounte R/W at boot, we *know* we can't use a R/O filesystem.

Quoted 10 lines

But on the other hand, our existing mechanism to handle a read-only rootfs in sysv land is not great: we create /var/log as a symlink to /tmp, and /tmp is mounted as a tmpfs. This works fines if applications just create files in /var/log. But if an application at build time create a directory in /var/log, such as /var/log/daemond, it might expect to find it at runtime, which will not be the case. The /usr/share/factory solution solves this problem.

So, should we move to this /usr/share/factory solution also for sysv init ?

I'm OK with that, except we'd have to provide that mechanism ourselves fot sysv init.

Quoted 4 lines

Yann, what about:

(1) Getting a series that has just the respin of the preparatory

     patches ;

Yep.

Quoted 3 lines

(2) Separate the "skeleton re-org" series from the "systemd read-only rootfs" series, so that we can progress on those topics one by one ?

Well, "systemd on read-only rootfs" anyway depends on "systemd skeleton-or-whatever-we're-gonna-do". ;-) But yes, I can do that.

Thanks for the great summary. I'll copy it for the next cover-letter I need to send for this series. ;-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#72 lore raw

v2 cover system: properly handle systemd as init system (branch yem/systemd-skeleton)

Thomas, All,

On 2016-07-07 00:34 +0200, Yann E. MORIN spake thusly:

Quoted 12 lines

On 2016-07-06 23:49 +0200, Thomas Petazzoni spake thusly:

Quoted 11 lines · Yann E. MORIN
Quoted 6 lines

package/skeleton: split into sysv and custom skeleton package/skeleton: make it a virtual package package/skeleton-sysv: split into skeleton-common
system: split skeleton package/skeleton-systemd: new package system/systemd: needs timezone

OK, so this is the first big thing that remains: splitting the skeleton into multiple parts. If I summarize your solution, it consists in splitting the skeleton in several parts:

[--SNIP--]

Quoted 29 lines
Quoted 22 lines

At the very least, I believe:

- the skeleton-net thing should be moved into a ifupdown-config package

- the skeleton-systemd should be simplified to not create directories that already exist in skeleton-common

- the /etc/resolv.conf file should be kept in the common skeleton

Once this is done, I continue to wonder if this multiple skeleton mechanism is really needed:

- the skeleton-systemd package does essentially nothing, except creating the fstab, which the systemd package could do.

- the skeleton-sysv package also doesn't do much, and it could be done in the existing initscripts package.

Really, the only thing that bothers me is that "initscripts" isn't a very good name for a package that also installs other things than init scripts. Perhaps naming it "sysv-base" or something would be clearer.

Quoted 6 lines

But maybe before taking a decision on this we simply need to see a respin that does the first cleanups suggested above, so that we can have a clearer vision of where things are going. The idea of skeleton as a virtual package is also not bad, especially if we can get rid of the weird skeleton-net situation, and really have skeleton-{common,sysv,custom,} be real packages.

Quoted 3 lines

I'm not going to do any change right now, to let the dust settle. Once others have commented one way or another, I'll do the requested changes.

Since no one commented, I'll go with Thomas' suggestion.

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

fs: add pre- and post-command hooks
system: make systemd work on a read-only rootfs
system: allow DHCP interface with systemd-networkd

This is the second big thing: allow a systemd rootfs to be read-only. The crux of the problem is that when /var is read-only, systemd automatically mounts a tmpfs on /var, which defeats our traditional mechanism to handle read-only rootfs.

[--SNIP--]

Quoted 2 lines
Quoted 2 lines

I am a bit annoyed by the complexity of this, and the "black magic" involved, but on the other hand, I don't really see a better solution.

Since there was no comment or counter-proposal, I'll keep this as-is, as a follow-up to the above series.

Quoted 13 lines
Quoted 13 lines

Another thing that bothers me is that then the solution to handle the read-only rootfs problem then becomes radically different between the sysv case and the systemd case. Maybe this is expected since the init systems are so different.

But on the other hand, our existing mechanism to handle a read-only rootfs in sysv land is not great: we create /var/log as a symlink to /tmp, and /tmp is mounted as a tmpfs. This works fines if applications just create files in /var/log. But if an application at build time create a directory in /var/log, such as /var/log/daemond, it might expect to find it at runtime, which will not be the case. The /usr/share/factory solution solves this problem.

Quoted 5 lines
Quoted 2 lines

So, should we move to this /usr/share/factory solution also for sysv init ?

I'm OK with that, except we'd have to provide that mechanism ourselves fot sysv init.

Sicne there was no comment for or against, I'll go to implementing the factory stuff for both cases, sysv-init and systemd alike.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'