Initial Commit

- initial default booting image
This commit is contained in:
2026-11-06 20:45:42 +01:00
commit b8783708ae
15201 changed files with 602532 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
config BR2_PACKAGE_SKELETON_INIT_SYSTEMD
bool
select BR2_PACKAGE_HAS_SKELETON
select BR2_PACKAGE_SKELETON_INIT_COMMON
config BR2_PACKAGE_PROVIDES_SKELETON
default "skeleton-init-systemd" if BR2_PACKAGE_SKELETON_INIT_SYSTEMD

View File

@@ -0,0 +1,15 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# Modelled after systemd's tmp.mount
[Unit]
Description=Buildroot /var tmpfs
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target
[Mount]
What=tmpfs
Where=/var
Type=tmpfs
Options=nosuid,nodev,size=50%%,nr_inodes=1m

View File

@@ -0,0 +1,59 @@
#!/bin/sh
#
# The systemd-tmpfiles has the ability to grab information
# from the filesystem (instead from the running system).
#
# tmpfs directories (/tmp, /proc, ...) are skipped since they're not
# relevant for the rootfs image.
#
# However there are a few specifiers that *always* will grab
# information from the running system examples are %a, %b, %m, %H
# (Architecture, Boot UUID, Machine UUID, Hostname).
#
# See [1] for historic information.
#
# This script will (conservatively) skip tmpfiles lines that have
# such an specifier to prevent leaking host information.
#
# shell expansion is critical to be POSIX compliant,
# this script won't work with zsh in its default mode for example.
#
# The script takes several measures to handle more complex stuff
# like passing this correctly:
# f+ "/var/example" - - - - %B\n%o\n%w\n%W%%\n
#
# [1] - https://github.com/systemd/systemd/pull/16187
[ -n "${HOST_SYSTEMD_TMPFILES-}" ] ||
HOST_SYSTEMD_TMPFILES=systemd-tmpfiles
[ -n "${1-}" -a -d "${1-}"/usr/lib/tmpfiles.d ] ||
{ echo 1>&2 "$0: need ROOTFS argument"; exit 1; }
${HOST_SYSTEMD_TMPFILES} --no-pager --cat-config --root="$1" |
sed -e '/^[[:space:]]*#/d' -e 's,^[[:space:]]*,,' -e '/^$/d' |
while read -r line; do
# it is allowed to use quotes around arguments,
# so let the shell pack the arguments
eval "set -- $line"
# dont output warnings for directories we dont process
[ "${2#/dev}" = "${2}" ] && [ "${2#/proc}" = "${2}" ] &&
[ "${2#/run}" = "${2}" ] && [ "${2#/sys}" = "${2}" ] &&
[ "${2#/tmp}" = "${2}" ] && [ "${2#/mnt}" = "${2}" ] ||
continue
# blank out all specs that are ok to use,
# test if some remain. (Specs up to date with v250)
if echo "$2 ${7-}" | sed -e 's,%[%BCEgGhLMosStTuUVwW],,g' | grep -v -q '%'; then
# no "bad" specifiers, pass the line unmodified
eval "printf '%s\n' '$line'"
else
# warn
eval "printf 'ignored spec: %s\n' '$line' 1>&2"
fi
done |
TMPDIR= TEMP= TMP= ${HOST_SYSTEMD_TMPFILES} --create --boot --root="$1" \
--exclude-prefix=/dev --exclude-prefix=/proc --exclude-prefix=/run \
--exclude-prefix=/sys --exclude-prefix=/tmp --exclude-prefix=/mnt \
-

View File

@@ -0,0 +1,7 @@
# Create legacy directories for buildroot
# This is a subset of systemd's legacy.conf
d /run/lock 0755 root root -
d /run/lock/subsys 0755 root root -
L /var/lock - - - - ../run/lock

View File

@@ -0,0 +1,19 @@
[Unit]
Description=Variable storage overlay setup
ConditionPathIsSymbolicLink=!/var
DefaultDependencies=no
RequiresMountsFor=/run/buildroot/mounts/var
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/mkdir -p /run/buildroot/mounts/var/lower /run/buildroot/mounts/var/upper /run/buildroot/mounts/var/work
# Ideally, we would like to use a systemd mount unit to manage the bind
# mount. Unfortunately, that creates a circular dependency: such a unit
# would have What=/var while var.mount has Where=/var so that introduces
# an implicit dependency from that unit to var.mount, but var.mount
# would have an explicit dependency to be ordered after that unit.
# So we handle the bind mount manually.
ExecStart=/usr/bin/mount -n -o bind,private /var /run/buildroot/mounts/var/lower
ExecStop=/usr/bin/umount -l /run/buildroot/mounts/var/lower

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Variable storage overlay
Documentation=man:file-hierarchy(7)
ConditionPathIsSymbolicLink=!/var
DefaultDependencies=no
After=prepare-var-overlay.service
BindsTo=prepare-var-overlay.service
[Mount]
What=overlay_var
Where=/var
Type=overlay
Options=lowerdir=/run/buildroot/mounts/var/lower,upperdir=/run/buildroot/mounts/var/upper,workdir=/run/buildroot/mounts/var/work,redirect_dir=on,index=on,xino=on
LazyUnmount=true

View File

@@ -0,0 +1,102 @@
################################################################################
#
# skeleton-init-systemd
#
################################################################################
SKELETON_INIT_SYSTEMD_LICENSE = GPL-2.0-or-later, LGPL-2.1-or-later (factory/var.mount)
# 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
# on skeleton.
SKELETON_INIT_SYSTEMD_ADD_TOOLCHAIN_DEPENDENCY = NO
SKELETON_INIT_SYSTEMD_ADD_SKELETON_DEPENDENCY = NO
SKELETON_INIT_SYSTEMD_DEPENDENCIES = skeleton-init-common
SKELETON_INIT_SYSTEMD_PROVIDES = skeleton
ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW
echo "/dev/root / auto rw 0 1" >$(TARGET_DIR)/etc/fstab
endef
else
define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW
echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab
endef
# 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.
ifeq ($(BR2_INIT_SYSTEMD_VAR_FACTORY),y)
define SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR_FACTORY
rm -rf $(TARGET_DIR)/usr/share/factory/var
mv $(TARGET_DIR)/var $(TARGET_DIR)/usr/share/factory/var
mkdir -p $(TARGET_DIR)/var
mkdir -p $(TARGET_DIR)/usr/lib/tmpfiles.d
for i in $(TARGET_DIR)/usr/share/factory/var/* \
$(TARGET_DIR)/usr/share/factory/var/lib/* \
$(TARGET_DIR)/usr/share/factory/var/lib/systemd/*; do \
[ -e "$${i}" ] || continue; \
j="$${i#$(TARGET_DIR)/usr/share/factory}"; \
if [ -L "$${i}" ]; then \
printf "L+! %s - - - - %s\n" \
"$${j}" "../usr/share/factory/$${j}" \
|| exit 1; \
else \
printf "C! %s - - - -\n" "$${j}" \
|| exit 1; \
fi; \
done >$(TARGET_DIR)/usr/lib/tmpfiles.d/00-buildroot-var.conf
$(INSTALL) -D -m 0644 $(SKELETON_INIT_SYSTEMD_PKGDIR)/factory/var.mount \
$(TARGET_DIR)/usr/lib/systemd/system/var.mount
endef
SKELETON_INIT_SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR_FACTORY
endif # BR2_INIT_SYSTEMD_VAR_FACTORY
ifeq ($(BR2_INIT_SYSTEMD_VAR_OVERLAYFS),y)
define SKELETON_INIT_SYSTEMD_LINUX_CONFIG_FIXUPS
$(call KCONFIG_ENABLE_OPT,CONFIG_OVERLAY_FS)
endef
define SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR_OVERLAYFS
$(INSTALL) -D -m 0644 \
$(SKELETON_INIT_SYSTEMD_PKGDIR)/overlayfs/prepare-var-overlay.service \
$(TARGET_DIR)/usr/lib/systemd/system/prepare-var-overlay.service
$(INSTALL) -D -m 0644 \
$(SKELETON_INIT_SYSTEMD_PKGDIR)/overlayfs/var.mount \
$(TARGET_DIR)/usr/lib/systemd/system/var.mount
endef
SKELETON_INIT_SYSTEMD_POST_INSTALL_TARGET_HOOKS += SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR_OVERLAYFS
endif # BR2_INIT_SYSTEMD_VAR_OVERLAYFS
endif # BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW
ifeq ($(BR2_INIT_SYSTEMD_POPULATE_TMPFILES),y)
define SKELETON_INIT_SYSTEMD_CREATE_TMPFILES_HOOK
HOST_SYSTEMD_TMPFILES=$(HOST_DIR)/bin/systemd-tmpfiles \
$(SKELETON_INIT_SYSTEMD_PKGDIR)/fakeroot_tmpfiles.sh $(TARGET_DIR)
endef
SKELETON_INIT_SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SKELETON_INIT_SYSTEMD_CREATE_TMPFILES_HOOK
endif # BR2_INIT_SYSTEMD_POPULATE_TMPFILES
define SKELETON_INIT_SYSTEMD_INSTALL_TARGET_CMDS
mkdir -p $(TARGET_DIR)/home
mkdir -p $(TARGET_DIR)/srv
mkdir -p $(TARGET_DIR)/var
ln -s ../run $(TARGET_DIR)/var/run
# prevent install scripts to create var/lock as directory
ln -s ../run/lock $(TARGET_DIR)/var/lock
install -D -m644 $(SKELETON_INIT_SYSTEMD_PKGDIR)/legacy.conf $(TARGET_DIR)/usr/lib/tmpfiles.d/legacy.conf
$(SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW)
endef
$(eval $(generic-package))