1SUMMARY = "Publishes & browses available services on a link according to the Zeroconf / Bonjour protocol"
2DESCRIPTION = "Bonjour, also known as zero-configuration networking, enables automatic discovery of computers, devices, and services on IP networks."
3HOMEPAGE = "http://developer.apple.com/networking/bonjour/"
4LICENSE = "Apache-2.0 & BSD-3-Clause"
5LIC_FILES_CHKSUM = "file://LICENSE;md5=31c50371921e0fb731003bbc665f29bf"
6
7DEPENDS:append:libc-musl = " musl-nscd"
8
9RPROVIDES:${PN} += "libdns_sd.so"
10
11# matches annotated tag mDNSResponder-1310.140.1
12SRCREV = "1d1de95b98fba2077d34c9d78b839a96aa0e1c77"
13BRANCH = "rel/mDNSResponder-1310"
14SRC_URI = "git://github.com/apple-oss-distributions/mDNSResponder;protocol=https;branch=${BRANCH} \
15           file://mdns.service \
16           file://0001-mdns-include-stddef.h-for-NULL.patch \
17           file://0002-mdns-cross-compilation-fixes-for-bitbake.patch \
18           file://0001-Create-subroutine-for-cleaning-recent-interfaces.patch \
19           file://0002-Create-subroutine-for-tearing-down-an-interface.patch \
20           file://0003-Track-interface-socket-family.patch \
21           file://0004-Use-list-for-changed-interfaces.patch \
22           file://0006-Remove-unneeded-function.patch \
23           file://0008-Mark-deleted-interfaces-as-being-changed.patch \
24           file://0009-Fix-possible-NULL-dereference.patch \
25           file://0010-Handle-errors-from-socket-calls.patch \
26           file://0011-Change-a-dynamic-allocation-to-file-scope-variable.patch \
27           file://0001-dns-sd-Include-missing-headers.patch \
28           file://0006-make-Add-top-level-Makefile.patch \
29           "
30
31CVE_PRODUCT = "apple:mdnsresponder"
32
33# CVE-2007-0613 is not applicable as it only affects Apple products
34# i.e. ichat,mdnsresponder, instant message framework and MacOS.
35# Also, https://www.exploit-db.com/exploits/3230 shows the part of code
36# affected by CVE-2007-0613 which is not preset in upstream source code.
37# Hence, CVE-2007-0613 does not affect other Yocto implementations and
38# is not reported for other distros can be marked whitelisted.
39# Links:
40# https://vulmon.com/vulnerabilitydetails?qid=CVE-2007-0613
41# https://www.incibe-cert.es/en/early-warning/vulnerabilities/cve-2007-0613
42# https://security-tracker.debian.org/tracker/CVE-2007-0613
43# https://vulmon.com/vulnerabilitydetails?qid=CVE-2007-0613
44CVE_CHECK_IGNORE += "CVE-2007-0613"
45
46PARALLEL_MAKE = ""
47
48# We install a stub Makefile in the top directory so that the various checks
49# in base.bbclass pass their tests for a Makefile, this ensures (that amongst
50# other things) the sstate checks will clean the build directory when the
51# task hashes changes.
52#
53# We can't use the approach of setting ${S} to mDNSPosix as we need
54# DEBUG_PREFIX_MAP to cover files which come from the Clients directory too.
55S = "${WORKDIR}/git"
56
57EXTRA_OEMAKE += "os=linux DEBUG=0 'CC=${CC}' 'LD=${CCLD} ${LDFLAGS}'"
58
59TARGET_CC_ARCH += "${LDFLAGS}"
60
61do_install () {
62    cd mDNSPosix
63
64    install -d ${D}${sbindir}
65    install -m 0755 build/prod/mdnsd ${D}${sbindir}
66
67    install -d ${D}${libdir}
68    cp build/prod/libdns_sd.so ${D}${libdir}/libdns_sd.so.1
69    chmod 0644 ${D}${libdir}/libdns_sd.so.1
70    ln -s libdns_sd.so.1 ${D}${libdir}/libdns_sd.so
71
72    install -d ${D}${includedir}
73    install -m 0644 ../mDNSShared/dns_sd.h ${D}${includedir}
74
75    install -d ${D}${mandir}/man8
76    install -m 0644 ../mDNSShared/mDNSResponder.8 ${D}${mandir}/man8/mdnsd.8
77
78    install -d ${D}${bindir}
79    install -m 0755 ../Clients/build/dns-sd ${D}${bindir}
80
81    install -d ${D}${libdir}
82    oe_libinstall -C build/prod -so libnss_mdns-0.2 ${D}${libdir}
83    ln -s libnss_mdns-0.2.so ${D}${libdir}/libnss_mdns.so.2
84
85    install -d ${D}${sysconfdir}
86    install -m 0644 nss_mdns.conf ${D}${sysconfdir}
87
88    install -d ${D}${mandir}/man5
89    install -m 0644 nss_mdns.conf.5 ${D}${mandir}/man5
90
91    install -d ${D}${mandir}/man8
92    install -m 0644 libnss_mdns.8 ${D}${mandir}/man8
93
94    install -d ${D}${systemd_unitdir}/system/
95    install -m 0644 ${WORKDIR}/mdns.service ${D}${systemd_unitdir}/system/
96}
97
98pkg_postinst:${PN} () {
99    sed -e '/^hosts:/s/\s*\<mdns\>//' \
100        -e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2 mdns\3\4\5/' \
101        -i $D/etc/nsswitch.conf
102}
103
104pkg_prerm:${PN} () {
105    sed -e '/^hosts:/s/\s*\<mdns\>//' \
106        -e '/^hosts:/s/\s*mdns//' \
107        -i $D/etc/nsswitch.conf
108}
109
110inherit systemd
111
112SYSTEMD_SERVICE:${PN} = "mdns.service"
113
114FILES:${PN} += "${systemd_unitdir}/system/mdns.service"
115FILES:${PN} += "${libdir}/libdns_sd.so.1 \
116                ${bindir}/dns-sd \
117                ${libdir}/libnss_mdns-0.2.so \
118                ${sysconfdir}/nss_mdns.conf"
119
120FILES:${PN}-dev += "${libdir}/libdns_sd.so \
121                    ${includedir}/dns_sd.h "
122
123FILES:${PN}-man += "${mandir}/man8/mdnsd.8 \
124                    ${mandir}/man5/nss_mdns.conf.5 \
125                    ${mandir}/man8/libnss_mdns.8"
126
127PACKAGES = "${PN} ${PN}-dev ${PN}-man ${PN}-dbg"
128