Something went wrong on our end
-
Andrei Gherzan authored
It was proposed and approved in #824 to relicense the Yocto/OE files in this repository to MIT. This will make collaboration with the upstream easier. Fixes: eclipse/oniro-core/oniro#824 Signed-off-by:
Andrei Gherzan <andrei.gherzan@huawei.com>
Andrei Gherzan authoredIt was proposed and approved in #824 to relicense the Yocto/OE files in this repository to MIT. This will make collaboration with the upstream easier. Fixes: eclipse/oniro-core/oniro#824 Signed-off-by:
Andrei Gherzan <andrei.gherzan@huawei.com>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
writables.bbclass 6.84 KiB
# SPDX-FileCopyrightText: Huawei Inc.
#
# SPDX-License-Identifier: MIT
# This class provides support for defining, at the level of the recipe, the
# required writable paths. It provides support for maintaining persistent or
# volatile state at runtime for read-only filesystems.
#
# To take advantage of the provided functionality, one would define a set of
# writable as part of WRITABLES:
# WRITABLES = "logs database misc"
#
# Each writable's associated path is defined using a VarFlag:
#
# WRITABLE_PATH[logs] = "/foo/bar/logs"
# WRITABLE_PATH[database] = "/foo/bar/db"
# WRITABLE_PATH[misc] = "/foo/bar/misc"
#
# Each WRITABLE_PATH is a directory.
#
# By default, each writable is of type persistent (it will use a bind mount
# from the state partition to the writable's path). This can be switched to
# volatile by defining:
#
# WRITABLE_TYPE[logs] = "volatile"
#
# The supported types are "volatile" and "persistent".
#
# This will use a tmpfs for the provided writable path.
inherit systemd
# The read-write area needs to be provided by the OS in the form of a rw
# mountpoint handled with systemd mount unit. In this way the state/writable
# systemd mount units this class generates, will have the correct dependency on
# having the read-write partition mounted.
SYSTEM_STATE_RUNTIME_MOUNTPOINT ??= "/run/mount/sysdata"
SYSTEM_STATE_MOUNT_UNIT ??= "run-mount-sysdata.mount"
# The mount units depend on having the system state partition mounted at a
# known location as described above. The respective system partition mount
# units are part of the oniro-mounts package. This provides the
# SYSTEM_STATE_MOUNT_UNIT systemd mount unit.
RDEPENDS:${PN} += "oniro-mounts"
# This is the root filesystem hierarchy used as part of the bind mount units to
# provide read-write locations.
SYSDATA_OVERLAY ??= "rootfs-overlay"
def escapeSystemdUnitName(path):
escapeMap = {
'/': '-',
'-': "\\x2d",
'\\': "\\x5d"
}
return "".join([escapeMap.get(c, c) for c in path.strip('/')])
def mountUnitName(unit):
return escapeSystemdUnitName(unit) + '.mount'
def write_mount_unit(writable, what, dst):
"""Writes a mount unit to destination - argument `dst`. The mount unit is
described as a dictionary (argument `writable`) for most of the mount
unit parts with the exception of `What` which is provided by the
argument 'what'."""
MountUnit = "[Unit]\n" \
"DefaultDependencies=no\n" \
"Conflicts=umount.target\n" \
"Before=local-fs.target umount.target\n"