我想添加自定义yocto systemd服务。
我指的是[Enable systemd services using yocto
但无法使用bb代码。未安装在文件系统中。
(eth0.service代码可以)
如何解决?
eth0_0.1.bb
SUMMARY = "Install and start a systemd service"
SECTION = "eth0"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI += "file://eth0.service"
S = "${WORKDIR}"
inherit systemd
SYSTEMD_SERVICE_${PN} = "eth0.service"
do_install() {
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/eth0.service ${D}${systemd_system_unitdir}/
}
FILES_${PN} += "/lib/systemd/system"
REQUIRED_DISTRO_FEATURES= "systemd"
eth0.service
[Unit]
Description=Network interfaces
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-eth0.device
After=sys.subsystem-net-devices-eth0.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "ifup eth0"
ExecStop=/bin/sh -c "ifdown eth0"
[Install]
WantedBy=multi-user.target
答案 0 :(得分:0)
如果您似乎拥有inherit systemd
和SYSTEMD_SERVICE_${PN} = "eth0.service"
,则应该这样做。因此,我认为您需要添加的是SYSTEMD_AUTO_ENABLE = "enable"
并确保.service
文件具有您似乎也拥有的[Install]
部分。其次,还要确保通过IMAGE_INSTALL_append = " eth0"
local.conf
将包添加到图像
答案 1 :(得分:0)
对于网络,您还可以创建一个systemd _%。bbappend
import xml.etree.ElementTree as ET
tree = ET.parse('input.xml')
root = tree.getroot()
tree2 = ET.parse('output.xml')
root2 = tree2.getroot()
for s3birch in root.findall("./Scene/TransformGroup/TransformGroup[@name='birch_stage2']"):
translation = s3birch.get('translation')
rotation = s3birch.get('rotation')
scale = s3birch.get('scale')
nodeid = s3birch.get('nodeId')
print('Translation = ', translation)
print('rotation = ', rotation)
print('Scale = ', scale)
print('NodeId = ', nodeid)
for shape in root.findall("./Scene/TransformGroup/TransformGroup[@name='birch_stage2']/Shape[@shapeId='1']"):
shape_nodeid1 = shape.get('nodeId')
print('Shape 1 nodeId = ', shape_nodeid1)
for shape2 in root.findall("./Scene/TransformGroup/TransformGroup[@name='birch_stage2']/Shape/Shape[@shapeId='2']"):
shape_nodeid2 = shape2.get('nodeId')
print('Shape 2 nodeId = ', shape_nodeid2)
for shape3 in root.findall("./Scene/TransformGroup/TransformGroup[@name='birch_stage2']/Shape[@shapeId='3']"):
shape_nodeid3 = shape3.get('nodeId')
print('Shape 3 nodeId = ', shape_nodeid3)
for new_s3birch in root2.findall("./Scene/TransformGroup/TransformGroup[@name='birch_stage2']"):
old_translation = new_s3birch.get('translation')
print(*Old translation = ', old_translation)
new_s3birch.set('translation', translation)
与output.xml
:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://eth0.network"
FILES_${PN} += "{sysconfdir}/systemd/network/* "
do_install_append() {
install -d ${D}${systemd_unitdir}/network/
install -m 0644 ${WORKDIR}/*.network ${D}${systemd_unitdir}/network/
}