Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,27 @@
SUMMARY = "Default settings"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
PROVIDES += "virtual/phosphor-settings-defaults"
PR = "r1"
SRC_URI += "file://defaults.yaml"
SRC_URI += "file://host-template.yaml"
SETTINGS_HOST_TEMPLATES:append = " host-template.yaml"
S = "${WORKDIR}"
inherit phosphor-settings-manager
inherit native
do_install() {
DEST=${D}${settings_datadir}
install -d ${DEST}
install defaults.yaml ${DEST}
for i in ${OBMC_HOST_INSTANCES};
do
for f in ${SETTINGS_HOST_TEMPLATES};
do
sed "s/{}/${i}/g" ${f} >> ${DEST}/defaults.yaml
done
done
}
@@ -0,0 +1,42 @@
/xyz/openbmc_project/control/minimum_ship_level_required:
- Interface: xyz.openbmc_project.Control.MinimumShipLevel
Properties:
MinimumShipLevelRequired:
Default: 'true'
/xyz/openbmc_project/time/sync_method:
- Interface: xyz.openbmc_project.Time.Synchronization
Properties:
TimeSyncMethod:
Default: Synchronization::Method::NTP
/xyz/openbmc_project/control/power_supply_attributes:
- Interface: xyz.openbmc_project.Control.PowerSupplyAttributes
Properties:
DeratingFactor:
Default: 90
/xyz/openbmc_project/control/power_supply_redundancy:
- Interface: xyz.openbmc_project.Control.PowerSupplyRedundancy
Properties:
PowerSupplyRedundancyEnabled:
Default: 'true'
/xyz/openbmc_project/logging/rest_api_logs:
- Interface: xyz.openbmc_project.Object.Enable
Properties:
Enabled:
Default: 'false'
/xyz/openbmc_project/logging/settings:
- Interface: xyz.openbmc_project.Logging.Settings
Properties:
QuiesceOnHwError:
Default: 'false'
/xyz/openbmc_project/software/apply_time:
- Interface: xyz.openbmc_project.Software.ApplyTime
Properties:
RequestedApplyTime:
Default: ApplyTime::RequestedApplyTimes::OnReset
@@ -0,0 +1,109 @@
/xyz/openbmc_project/control/host{}/auto_reboot:
- Interface: xyz.openbmc_project.Control.Boot.RebootPolicy
Properties:
AutoReboot:
Default: 'true'
/xyz/openbmc_project/control/host{}/auto_reboot/one_time:
- Interface: xyz.openbmc_project.Control.Boot.RebootPolicy
Properties:
AutoReboot:
Default: 'true'
/xyz/openbmc_project/control/host{}/boot:
- Interface: xyz.openbmc_project.Control.Boot.Source
Properties:
BootSource:
Default: Source::Sources::Default
- Interface: xyz.openbmc_project.Control.Boot.Mode
Properties:
BootMode:
Default: Mode::Modes::Regular
- Interface: xyz.openbmc_project.Control.Boot.Type
Properties:
BootType:
Default: Type::Types::EFI
- Interface: xyz.openbmc_project.Object.Enable
Properties:
Enabled:
Default: 'false'
/xyz/openbmc_project/control/host{}/boot/one_time:
- Interface: xyz.openbmc_project.Object.Enable
Properties:
Enabled:
Default: 'false'
/xyz/openbmc_project/control/host{}/power_cap:
- Interface: xyz.openbmc_project.Control.Power.Cap
Properties:
PowerCap:
Default: 0
Validation:
Type: "range"
Validator: "0..1000"
Unit: "Watts"
PowerCapEnable:
Default: 'false'
/xyz/openbmc_project/control/host{}/power_restore_policy:
- Interface: xyz.openbmc_project.Control.Power.RestorePolicy
Properties:
PowerRestorePolicy:
Default: RestorePolicy::Policy::AlwaysOff
PowerRestoreDelay:
Default: 0
/xyz/openbmc_project/control/host{}/power_restore_policy/one_time:
- Interface: xyz.openbmc_project.Control.Power.RestorePolicy
Properties:
PowerRestorePolicy:
Default: RestorePolicy::Policy::None
PowerRestoreDelay:
Default: 0
/xyz/openbmc_project/control/host{}/restriction_mode:
- Interface: xyz.openbmc_project.Control.Security.RestrictionMode
Properties:
RestrictionMode:
Default: RestrictionMode::Modes::None
/xyz/openbmc_project/control/host{}/TPMEnable:
- Interface: xyz.openbmc_project.Control.TPM.Policy
Properties:
TPMEnable:
Default: 'false'
/xyz/openbmc_project/control/host{}/turbo_allowed:
- Interface: xyz.openbmc_project.Control.Host.TurboAllowed
Properties:
TurboAllowed:
Default: 'true'
/xyz/openbmc_project/network/host{}/intf:
- Interface: xyz.openbmc_project.Network.MACAddress
Properties:
MACAddress:
Default: '"00:00:00:00:00:00"'
Validation:
Type: "regex"
Validator: '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
#needs to implement address validation TODO openbmc/issues/2046
/xyz/openbmc_project/network/host{}/intf/addr:
- Interface: xyz.openbmc_project.Network.IP
Properties:
Address:
Default: '"0.0.0.0"'
PrefixLength:
Default: 0
Validation:
Type: "range"
Validator: 0..128
Unit: "bits"
Origin:
Default: IP::AddressOrigin::Static
Gateway:
Default: '"0.0.0.0"'
Type:
Default: IP::Protocol::IPv4
@@ -0,0 +1,5 @@
HOMEPAGE = "http://github.com/openbmc/phosphor-settingsd"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=fa818a259cbed7ce8bc2a22d35a464fc"
SRC_URI += "git://github.com/openbmc/phosphor-settingsd;branch=master;protocol=https"
SRCREV = "3132eca71967ef11dc671b51e452968edbf93fdc"
@@ -0,0 +1,24 @@
/xyz/openbmc_project/control/host0/boot:
- Interface: xyz.openbmc_project.Control.Boot.Source
Properties:
BootSource:
Default: Source::Sources::Default
- Interface: xyz.openbmc_project.Control.Boot.Mode
Properties:
BootMode:
Default: Mode::Modes::Regular
- Interface: xyz.openbmc_project.Control.Boot.Type
Properties:
BootType:
Default: Type::Types::EFI
- Interface: xyz.openbmc_project.Object.Enable
Properties:
Enabled:
Default: 'false'
/xyz/openbmc_project/control/host0/boot/one_time:
- Interface: xyz.openbmc_project.Object.Enable
Properties:
Enabled:
Default: 'false'
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""Loads a "target" YAML file and overwrites its values with values from
"override" YAML files.
Override files are processed in the order given.
Usage:
merge_settings.py <target yaml> [override/remove yamls]
"""
import sys
import yaml
import copy
def dict_merge(target, source, remove):
"""Deep merge for dicts.
Works like dict.update() that recursively updates/removes any dict values
present in both parameters.
Args:
target (dict): Values to be overwritten by corresponding values from
`source`.
source (dict): Overriding values. Not changed by call.
remove (bool): If this is true then it removes the entry provided in
'source' along with all entries under it from 'target'. Otherwise
it overrides the values from 'source'
Returns:
`target` with values overwritten/removed from those in `source` at any
and all levels of nested dicts.
"""
if not isinstance(source, dict):
return source
for k, v in source.items():
if k in target and isinstance(target[k], dict):
dict_merge(target[k], v, remove)
else:
if remove is True and k in target:
target.pop(k)
else:
target[k] = copy.deepcopy(v)
return target
if len(sys.argv) < 2:
sys.exit('Argument required: target yaml')
if len(sys.argv) == 2:
# No overrides to handle
sys.exit()
target_filename = sys.argv[1]
with open(target_filename) as target_file:
data = yaml.safe_load(target_file)
print('Loaded target YAML file ' + target_filename)
for override_filename in sys.argv[2:]:
if override_filename.endswith('.override.yml'):
with open(override_filename) as override_file:
override = yaml.safe_load(override_file)
dict_merge(data, override, False)
print('Merged override YAML file ' + override_filename)
elif override_filename.endswith('.remove.yml'):
with open(override_filename) as override_file:
override = yaml.safe_load(override_file)
dict_merge(data, override, True)
print('Removed data from source YAML file' + override_filename)
with open(target_filename, 'w') as target_file:
yaml.dump(data, target_file)
print('Wrote merged target YAML file ' + target_filename)
@@ -0,0 +1,12 @@
[Unit]
Description=Phosphor Settings Daemon
[Service]
ExecStart=/usr/bin/env phosphor-settings-manager
SyslogIdentifier=phosphor-settings-manager
Restart=always
Type=dbus
BusName={BUSNAME}
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,71 @@
SUMMARY = "Phosphor Settings Manager"
DESCRIPTION = "Phosphor Settings Manager is an application that creates \
d-bus objects to represent various user settings."
PR = "r1"
PV = "1.0+git${SRCPV}"
inherit meson pkgconfig
inherit obmc-phosphor-dbus-service
inherit python3native
inherit phosphor-settings-manager
require phosphor-settings-manager.inc
DBUS_SERVICE:${PN} = "xyz.openbmc_project.Settings.service"
DEPENDS += "${PYTHON_PN}-pyyaml-native"
DEPENDS += "${PYTHON_PN}-mako-native"
DEPENDS += "${PYTHON_PN}-sdbus++-native"
DEPENDS += "virtual/phosphor-settings-defaults"
DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'obmc-mrw', 'phosphor-settings-read-settings-mrw-native', '', d)}"
DEPENDS += "sdbusplus"
DEPENDS += "phosphor-dbus-interfaces"
DEPENDS += "phosphor-logging"
DEPENDS += "libcereal"
S = "${WORKDIR}/git"
SRC_URI += "file://merge_settings.py"
# 'boot_type' configuration parameter is used to add support for
# the Legacy/EFI boot override selector for systems with x86 host
PACKAGECONFIG[boot_type] = ""
SRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'boot_type', 'file://boot_type.override.yml', '', d)}"
EXTRA_OEMESON = " \
-Dsettings_yaml=${STAGING_DIR_NATIVE}${settings_datadir}/defaults.yaml \
"
# Collect files in SRC_URI that end in ".override.yml" or ".remove.yml" and call a script that
# writes/removes their contents from that of settings.yaml, which is then updated to
# the merged data values.
# This doesn't correctly handle globs in ".override.yml" entries in SRC_URI.
python do_merge_settings () {
import subprocess
# TODO: Perform the merge in a temporary directory?
workdir = d.getVar('WORKDIR', True)
nativedir = d.getVar('STAGING_DIR_NATIVE', True)
settingsdir = d.getVar('settings_datadir', True)
settingsdir = settingsdir[1:]
settingsdir = os.path.join(nativedir, settingsdir)
cmd = []
cmd.append(os.path.join(workdir, 'merge_settings.py'))
cmd.append(os.path.join(settingsdir, 'defaults.yaml'))
# Used for any settings from the MRW
use_mrw = bb.utils.contains('DISTRO_FEATURES', 'obmc-mrw', 'true', '', d)
if (use_mrw == 'true'):
cmd.append(os.path.join(settingsdir, 'mrw-settings.override.yaml'))
fetch = bb.fetch2.Fetch([], d)
override_urls = [url for url in fetch.urls if url.endswith(('.override.yml', '.remove.yml'))]
for url in override_urls:
bb.debug(2, 'Overriding with source: ' + url)
local_base = os.path.basename(fetch.localpath(url))
filename = os.path.join(workdir, local_base)
cmd.append(filename)
# Invoke the script and don't catch any resulting exception.
subprocess.check_call(cmd)
}
# python-pyyaml-native is installed by do_configure, so put this task after
addtask merge_settings after do_configure before do_compile
@@ -0,0 +1,33 @@
# Generates MRW settings override yaml for phosphor-settings-manager
# The default YAML file, mrw-override-settings.yaml, is empty, therefore no
# settings will be overwritten. To override, modify mrw-override-settings.yaml.
SUMMARY = "Generates MRW settings override YAML for phosphor-settings-manager."
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
DEPENDS += "mrw-native mrw-perl-tools-native"
PR = "r1"
SRC_URI += "file://mrw-override-settings.yaml"
S = "${WORKDIR}"
inherit phosphor-settings-manager
inherit mrw-xml
inherit native
do_install() {
DEST=${D}${config_datadir}
install -D mrw-override-settings.yaml ${DEST}/mrw-override-settings.yaml
SETTINGS=${D}${settings_datadir}
install -d ${SETTINGS}
# gen_settings.pl replaces any MRW variables with their value
${bindir}/perl-native/perl \
${bindir}/gen_settings.pl \
-i ${mrw_datadir}/${MRW_XML} \
-s ${DEST}/mrw-override-settings.yaml \
-o ${SETTINGS}/mrw-settings.override.yaml \
${MRW_EXPRESSION_VARS} \
-f
}
MRW_EXPRESSION_VARS ?= ""
@@ -0,0 +1,3 @@
# Default MRW settings override definition YAML - empty.
# Any MRW variables, marked by MRW_<MRW variable name>, are replaced with their
# MRW value.
@@ -0,0 +1 @@
../phosphor-settings-manager/merge_settings.py