system: properly handle systemd as init system (branch yem/systemd-skeleton)
PATCH 1/24 package/skeleton: remove useless .empty file
In reply to Yann E. MORINSe 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
Signature · 1 line
2.7.4
PATCH 2/24 system: sysvinit only selects busybox-show-others if busybox is enabled
In reply to Yann E. MORINBR2_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.
---
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
@@ -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
PATCH 3/24 package/skeleton: respect variables namespace
In reply to Yann E. MORINIn makefiles, variable have global scope. We readitionally 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 namings for the variables:
- some are indeed prefixed with SKELETON_
- some are prefixed with SYSTEM_
- some are not prefixed
Clean up thiese 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
@@ -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
PATCH 4/24 system/skeleton: update etc/mtab with a more sensible link
In reply to Yann E. MORINCurrently, 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 to day 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 is 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
@@ -1 +1 @@ -/proc/mounts +../proc/self/mounts
Signature · 1 line
2.7.4
PATCH 5/24 system: systemd only really supports a R/W rootfs
In reply to Yann E. MORINSupporting 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
@@ -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
PATCH 6/24 package/systemd: disabling tty1 getty is a post-install hook
In reply to Yann E. MORINCurrently, 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
@@ -205,10 +205,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
@@ -222,10 +227,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
@@ -246,7 +247,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
PATCH 7/24 system: provide no default for custom skeleton path
In reply to Yann E. MORINBeing 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
@@ -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
PATCH 8/24 system: move the rootfs skeleton choice
In reply to Yann E. MORINIn 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
@@ -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
PATCH 9/24 system: do not handle network settings for custom skeleton
In reply to Yann E. MORIN--- package/skeleton/skeleton.mk | 8 ++++---- system/Config.in | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-)
package/skeleton/skeleton.mk +4 -4
@@ -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
@@ -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
PATCH 10/24 package/perl: use dummy hostname
In reply to Yann E. MORINThe 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.
Use a dummy hostname.
--- package/perl/perl.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
package/perl/perl.mk +1 -1
@@ -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
PATCH 11/24 system: do not set hostname and issue for custom skeleton
In reply to Yann E. MORIN---
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
@@ -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
@@ -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
PATCH 12/24 core/pkg-generic: add variable to skip skeleton dependency
In reply to Yann E. MORINWe 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.
--- package/pkg-generic.mk | 7 +++++-- package/skeleton/skeleton.mk | 1 + 2 files changed, 6 insertions(+), 2 deletions(-)
package/pkg-generic.mk +5 -2
@@ -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
@@ -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
PATCH 13/24 package/skeleton: add macro to rsync skeleton directory
In reply to Yann E. MORINThe 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 wants 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
@@ -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
PATCH 14/24 core/pkg-generic: allow packages to declare target-finalize hooks
In reply to Yann E. MORINCurrently, 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 soltuion 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
@@ -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
@@ -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
PATCH 15/24 packages: use the <PKG>_TARGET_FINALIZE_HOOKS
In reply to Yann E. MORINRegister package-specific target-finalize hooks with the newly-introduced <PKG>_TARGET_FINALIZE_HOOKS.
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 16/24 package/skeleton: split into sysv and custom skeleton
In reply to Yann E. MORINCurrently, 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 direcoty 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 namagement to its own package.
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 17/24 package/skeleton: make it a virtual package
In reply to Yann E. MORINThe 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.
--- 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 | 12 ++++++++++-- package/skeleton/skeleton.mk | 11 ++--------- system/Config.in | 2 ++ 7 files changed, 26 insertions(+), 11 deletions(-)
package/skeleton-custom/Config.in +4 -0
@@ -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
@@ -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
@@ -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
@@ -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 +10 -2
@@ -1,7 +1,15 @@ +# 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'. 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
@@ -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
@@ -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
PATCH 18/24 package/skeleton-sysv: split into skeleton-common
In reply to Yann E. MORINAdd 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 19/24 system: split skeleton
In reply to Yann E. MORINMove 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/.emptypackage/skeleton-sysv/skeleton-sysv.mk +7 -0
@@ -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
system/skeleton-net/etc/network/if-post-down.d/.empty renamed from system/skeleton/etc/network/if-post-down.d/.empty +0 -0
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
system/skeleton-net/etc/network/if-up.d/.empty renamed from system/skeleton/etc/network/if-down.d/.empty +0 -0
system/skeleton-sysv/dev/log renamed from system/skeleton/dev/log +0 -0
system/skeleton-sysv/dev/pts/.empty renamed from system/skeleton/dev/shm/.empty +0 -0
system/skeleton-sysv/dev/shm/.empty renamed from system/skeleton/dev/pts/.empty +0 -0
system/skeleton-sysv/etc/fstab renamed from system/skeleton/etc/fstab +0 -0
system/skeleton-sysv/etc/resolv.conf renamed from system/skeleton/etc/resolv.conf +0 -0
system/skeleton-sysv/var/cache renamed from system/skeleton/var/cache +0 -0
system/skeleton-sysv/var/lib/misc renamed from system/skeleton/var/lib/misc +0 -0
system/skeleton-sysv/var/lock renamed from system/skeleton/var/lock +0 -0
system/skeleton-sysv/var/log renamed from system/skeleton/var/log +0 -0
system/skeleton-sysv/var/run renamed from system/skeleton/var/run +0 -0
system/skeleton-sysv/var/spool renamed from system/skeleton/var/spool +0 -0
system/skeleton-sysv/var/tmp renamed from system/skeleton/var/tmp +0 -0
system/skeleton/dev/.empty new file +0 -0
Signature · 1 line
2.7.4
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... ;-)
Regards,
Yann E. MORIN.
The following changes since commit 494b0a5b6b0018bfd05ae5d7c09f57c881ed2b72
gst1-imx: make kernel dependency optional (2016-06-12 22:38:19 +0200)
are available in the git repository at:
https://git.busybox.net/~ymorin/git/buildroot
for you to fetch changes up to 4bfd9509ba59300ae2fa25be5cebfd6786ca7f7c
system: allow DHCP interface with systemd-networkd (2016-06-12 22:46:00 +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 | 106 ++++++++++
package/skeleton-sysv/Config.in | 7 +
package/skeleton-sysv/skeleton-sysv.mk | 79 ++++++++
package/skeleton/Config.in | 10 +
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, 548 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. | '------------------------------^-------^------------------^--------------------'
PATCH 20/24 package/skeleton-systemd: new package
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.
systemd does not like being booted without any timezone info, 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/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
@@ -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
@@ -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
@@ -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
PATCH 21/24 system/systemd: needs timezone
In reply to Yann E. MORINsystemd 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
@@ -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
@@ -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
PATCH 22/24 fs: add pre- and post-command hooks
In reply to Yann E. MORINIn 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.
Doing the tweaks in target-finalise is not possible, as there is no way to undo the tweak (i.e. we'd need to restore the /var symlink so that subsequent builds continue to work).
Add two pre- and post-hooks that packages can set, that are called right before and 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
@@ -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
@@ -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
PATCH 23/24 system: make systemd work on a read-only rootfs
In reply to Yann E. MORINWhen 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 to /var/something, but only if it does not already exist.
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/soemthing
But if the source is not given, then it is implicitly tken 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 tree 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, or /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 dorectory before assembing 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
@@ -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
@@ -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
PATCH 24/24 system: allow DHCP interface with systemd-networkd
In reply to Yann E. MORINIt is prett 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 | 11 ++++++++++- system/Config.in | 9 +++------ 2 files changed, 13 insertions(+), 7 deletions(-)
package/skeleton-systemd/skeleton-systemd.mk +10 -1
@@ -15,7 +15,16 @@ 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 + 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
@@ -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
cover system: properly handle systemd as init system (branch yem/systemd-skeleton)
In reply to Yann E. MORINAll,
On 2016-06-12 23:55 +0200, Yann E. MORIN spake thusly:
Quoted 4 lines
Hello All!
This series is a proposal to fix our handling of systemd as an init system.
I've marked this series as Changes Requested: the commit logs were not really complete. So I detaield each commit a bit more.
I'll respin a new version of the series by the end of the day.
Regards,
Yann E. MORIN.
Quoted 201 lines
Our default skeleton is not well suited for systemd:
- we have
/var/loga 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... ;-)
Regards,
Yann E. MORIN.The following changes since commit
494b0a5b6b0018bfd05ae5d7c09f57c881ed2b72gst1-imx: make kernel dependency optional (2016-06-12 22:38:19 +0200)
are available in the git repository at:
https://git.busybox.net/~ymorin/git/buildroot
for you to fetch changes up to
4bfd9509ba59300ae2fa25be5cebfd6786ca7f7csystem: allow DHCP interface with systemd-networkd (2016-06-12 22:46:00 +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-networkddocs/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 | 106 ++++++++++ package/skeleton-sysv/Config.in | 7 + package/skeleton-sysv/skeleton-sysv.mk | 79 ++++++++ package/skeleton/Config.in | 10 + 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, 548 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. | '------------------------------^-------^------------------^--------------------'
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. | '------------------------------^-------^------------------^--------------------'