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 def xinetd_enabled(d):
11 distro_features = d.getVar('DISTRO_FEATURES', True).split()
12 return 'xinetd' in distro_features and 'sysvinit' in distro_features
14 python __anonymous() {
16 d.appendVar("DEPENDS", " xinetd")
20 if ${@['false', 'true'][xinetd_enabled(d)]}; then
21 install -d ${D}${sysconfdir}/xinetd.d
22 for srcfile in ${WORKDIR}/*.xinetd.in; do
23 dstfile=`basename $srcfile .xinetd.in`
24 sed -e 's,@BINDIR@,${bindir},' \
25 -e 's,@SBINDIR@,${sbindir},' \
26 $srcfile > ${D}${sysconfdir}/xinetd.d/$dstfile
27 chmod 644 ${D}${sysconfdir}/xinetd.d/$dstfile
33 [ -z "$D" ] && PID=`pidof xinetd` && kill -HUP $PID || true
36 python xinetd_populate_packages() {
37 if not xinetd_enabled(d):
40 def package_get_var(pkg, var):
41 val = (d.getVar('%s_%s' % (var, pkg), True) or "").strip()
43 val = (d.getVar(var, True) or "").strip()
46 def package_append_script(pkg, script_type, shell_function):
47 script = package_get_var(pkg, 'pkg_%s' % script_type) or '#!/bin/sh\n'
48 if not script.endswith('\n'):
50 script += d.getVar(shell_function, True)
51 if not script.endswith('\n'):
53 d.setVar('pkg_%s_%s' % (script_type, pkg), script)
55 def xinetd_check_package(pkg):
56 packages = d.getVar('PACKAGES', True).split()
57 if not pkg in packages:
58 bb.error('%s does not appear in package list, please add it' % pkg)
60 def xinetd_add_rrecommends(pkg):
61 bb.note("adding xinetd dependency to %s" % pkg)
63 rrecommends = (d.getVar('RRECOMMENDS_%s' % pkg, True) or "").split()
64 if not 'xinetd' in rrecommends:
65 rrecommends.append('xinetd')
66 d.setVar('RRECOMMENDS_%s' % pkg, ' '.join(rrecommends))
68 def xinetd_generate_package_scripts(pkg):
69 bb.note('adding xinetd postinst and postrm scripts to %s' % pkg)
70 package_append_script(pkg, 'postinst', 'xinetd_reload')
71 package_append_script(pkg, 'postrm', 'xinetd_reload')
73 def xinetd_append_file(pkg, file_append):
74 if os.path.exists(oe.path.join(d.getVar("D", True), file_append)):
75 var_name = 'FILES_%s' % pkg
76 files = (d.getVar(var_name, False) or "").split()
77 if file_append not in files:
78 files.append(file_append)
79 d.setVar(var_name, ' '.join(files))
81 def xinetd_check_services():
82 path = oe.path.join(d.getVar('sysconfdir', True), 'xinetd.d')
83 for pkg in d.getVar('XINETD_PACKAGES', True).split():
84 services = package_get_var(pkg, 'XINETD_SERVICE').split()
85 if len(services) == 0:
87 for service in services:
88 xinetd_append_file(pkg, oe.path.join(path, service))
90 # run all modifications once when creating package
91 if os.path.exists(d.getVar("D", True)):
92 for pkg in d.getVar('XINETD_PACKAGES', True).split():
93 xinetd_check_package(pkg)
94 xinetd_generate_package_scripts(pkg)
95 xinetd_add_rrecommends(pkg)
96 xinetd_check_services()
99 PACKAGESPLITFUNCS_prepend = "xinetd_populate_packages "