1 # The list of packages that should have xinetd configurations added. For
2 # each entry, optionally have a XINETD_SERVICE_[package] that lists the service
3 # names in this package. If this variable isn't set, [package] is used.
4 XINETD_PACKAGES ?= "${PN}"
6 # This class will be included in any recipe that supports xinetd,
7 # even if the xinetd DISTRO_FEATURE isn't enabled. As such don't
8 # make any changes directly but check the DISTRO_FEATURES first.
10 if "xinetd" in d.getVar("DISTRO_FEATURES", True).split():
11 d.appendVar("DEPENDS", " xinetd")
15 if ${@base_contains('DISTRO_FEATURES', 'xinetd', 'true', 'false', d)}; then
16 install -d ${D}${sysconfdir}/xinetd.d
17 for srcfile in ${WORKDIR}/*.xinetd.in; do
18 dstfile=`basename $srcfile .xinetd.in`
19 sed -e 's,@BINDIR@,${bindir},' \
20 -e 's,@SBINDIR@,${sbindir},' \
21 $srcfile > ${D}${sysconfdir}/xinetd.d/$dstfile
22 chmod 644 ${D}${sysconfdir}/xinetd.d/$dstfile
28 [ -z "$D" ] && PID=`pidof xinetd` && kill -HUP $PID || true
31 python xinetd_populate_packages() {
32 if "xinetd" not in d.getVar("DISTRO_FEATURES", True).split():
35 if d.getVar("SYSTEMD_BBCLASS_ENABLED", True):
36 bb.note("disabling xinetd.bbclass for %s due to systemd being enabled" % pkg)
39 def package_get_var(pkg, var):
40 val = (d.getVar('%s_%s' % (var, pkg), True) or "").strip()
42 val = (d.getVar(var, True) or "").strip()
45 def package_append_script(pkg, script_type, shell_function):
46 script = package_get_var(pkg, 'pkg_%s' % script_type) or '#!/bin/sh\n'
47 if not script.endswith('\n'):
49 script += d.getVar(shell_function, True)
50 if not script.endswith('\n'):
52 d.setVar('pkg_%s_%s' % (script_type, pkg), script)
54 def xinetd_check_package(pkg):
55 packages = d.getVar('PACKAGES', True).split()
56 if not pkg in packages:
57 bb.error('%s does not appear in package list, please add it' % pkg)
59 def xinetd_add_rdepends(pkg):
60 bb.note("adding xinetd dependency to %s" % pkg)
62 rdepends = (d.getVar('RDEPENDS_%s' % pkg, True) or "").split()
63 if not 'xinetd' in rdepends:
64 rdepends.append('xinetd')
65 d.setVar('RDEPENDS_%s' % pkg, ' '.join(rdepends))
67 def xinetd_generate_package_scripts(pkg):
68 bb.note('adding xinetd postinst and postrm scripts to %s' % pkg)
69 package_append_script(pkg, 'postinst', 'xinetd_reload')
70 package_append_script(pkg, 'postrm', 'xinetd_reload')
72 def xinetd_append_file(pkg, file_append):
73 if os.path.exists(oe.path.join(d.getVar("D", True), file_append)):
74 var_name = 'FILES_%s' % pkg
75 files = (d.getVar(var_name, False) or "").split()
76 if file_append not in files:
77 files.append(file_append)
78 d.setVar(var_name, ' '.join(files))
80 def xinetd_check_services():
81 path = oe.path.join(d.getVar('sysconfdir', True), 'xinetd.d')
82 for pkg in d.getVar('XINETD_PACKAGES', True).split():
83 services = package_get_var(pkg, 'XINETD_SERVICE').split()
84 if len(services) == 0:
86 for service in services:
87 xinetd_append_file(pkg, oe.path.join(path, service))
89 # run all modifications once when creating package
90 if os.path.exists(d.getVar("D", True)):
91 for pkg in d.getVar('XINETD_PACKAGES', True).split():
92 xinetd_check_package(pkg)
93 xinetd_generate_package_scripts(pkg)
94 xinetd_add_rdepends(pkg)
95 xinetd_check_services()
98 PACKAGESPLITFUNCS_prepend = "xinetd_populate_packages "