xref: /OK3568_Linux_fs/yocto/meta-openembedded/meta-networking/recipes-support/dnsmasq/dnsmasq.inc (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunSUMMARY = "Lightweight, easy to configure DNS forwarder and DHCP server"
2*4882a593SmuzhiyunHOMEPAGE = "http://www.thekelleys.org.uk/dnsmasq/doc.html"
3*4882a593SmuzhiyunSECTION = "net"
4*4882a593Smuzhiyun# GPLv3 was added in version 2.41 as license option
5*4882a593SmuzhiyunLICENSE = "GPL-2.0-only | GPL-3.0-only"
6*4882a593SmuzhiyunLIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
7*4882a593Smuzhiyun                    file://COPYING-v3;md5=d32239bcb673463ab874e80d47fae504 \
8*4882a593Smuzhiyun                    "
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun#at least versions 2.69 and prior are moved to the archive folder on the server
11*4882a593SmuzhiyunSRC_URI = "http://www.thekelleys.org.uk/dnsmasq/${@['archive/', ''][float(d.getVar('PV').split('.')[1]) > 69]}dnsmasq-${PV}.tar.gz;name=dnsmasq-${PV} \
12*4882a593Smuzhiyun           file://init \
13*4882a593Smuzhiyun           file://dnsmasq.conf \
14*4882a593Smuzhiyun           file://dnsmasq-resolvconf.service \
15*4882a593Smuzhiyun           file://dnsmasq-noresolvconf.service \
16*4882a593Smuzhiyun           file://dnsmasq-resolved.conf \
17*4882a593Smuzhiyun           file://CVE-2023-28450.patch \
18*4882a593Smuzhiyun"
19*4882a593Smuzhiyun
20*4882a593Smuzhiyuninherit pkgconfig update-rc.d systemd
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunINITSCRIPT_NAME = "dnsmasq"
23*4882a593SmuzhiyunINITSCRIPT_PARAMS = "defaults"
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunPACKAGECONFIG ?= ""
26*4882a593SmuzhiyunPACKAGECONFIG[dbus] = ",,dbus"
27*4882a593SmuzhiyunPACKAGECONFIG[idn] = ",,libidn"
28*4882a593SmuzhiyunPACKAGECONFIG[conntrack] = ",,libnetfilter-conntrack"
29*4882a593SmuzhiyunPACKAGECONFIG[lua] = ",,lua"
30*4882a593SmuzhiyunPACKAGECONFIG[resolvconf] = ",,,resolvconf"
31*4882a593SmuzhiyunEXTRA_OEMAKE = "\
32*4882a593Smuzhiyun    'COPTS=${@bb.utils.contains('PACKAGECONFIG', 'dbus', '-DHAVE_DBUS', '', d)} \
33*4882a593Smuzhiyun           ${@bb.utils.contains('PACKAGECONFIG', 'idn', '-DHAVE_IDN', '', d)} \
34*4882a593Smuzhiyun           ${@bb.utils.contains('PACKAGECONFIG', 'conntrack', '-DHAVE_CONNTRACK', '', d)} \
35*4882a593Smuzhiyun           ${@bb.utils.contains('PACKAGECONFIG', 'lua', '-DHAVE_LUASCRIPT', '', d)}' \
36*4882a593Smuzhiyun    'CFLAGS=${CFLAGS}' \
37*4882a593Smuzhiyun    'LDFLAGS=${LDFLAGS}' \
38*4882a593Smuzhiyun"
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunSRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'resolvconf', 'file://dnsmasq.resolvconf file://99_dnsmasq file://dnsmasq-resolvconf-helper', '', d)}"
41*4882a593Smuzhiyun
42*4882a593Smuzhiyundo_compile:append() {
43*4882a593Smuzhiyun    # build dhcp_release
44*4882a593Smuzhiyun    cd ${S}/contrib/lease-tools
45*4882a593Smuzhiyun    oe_runmake
46*4882a593Smuzhiyun}
47*4882a593Smuzhiyun
48*4882a593Smuzhiyundo_install () {
49*4882a593Smuzhiyun    oe_runmake "PREFIX=${D}${prefix}" \
50*4882a593Smuzhiyun               "BINDIR=${D}${bindir}" \
51*4882a593Smuzhiyun               "MANDIR=${D}${mandir}" \
52*4882a593Smuzhiyun               install
53*4882a593Smuzhiyun    install -d ${D}${sysconfdir}/ ${D}${sysconfdir}/init.d ${D}${sysconfdir}/dnsmasq.d
54*4882a593Smuzhiyun    install -m 644 ${WORKDIR}/dnsmasq.conf ${D}${sysconfdir}/
55*4882a593Smuzhiyun    install -m 755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/dnsmasq
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun    install -d ${D}${systemd_unitdir}/system
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun    if [ "${@bb.utils.filter('PACKAGECONFIG', 'resolvconf', d)}" ]; then
60*4882a593Smuzhiyun        install -m 0644 ${WORKDIR}/dnsmasq-resolvconf.service ${D}${systemd_unitdir}/system/dnsmasq.service
61*4882a593Smuzhiyun    else
62*4882a593Smuzhiyun        install -m 0644 ${WORKDIR}/dnsmasq-noresolvconf.service ${D}${systemd_unitdir}/system/dnsmasq.service
63*4882a593Smuzhiyun    fi
64*4882a593Smuzhiyun    install -d ${D}${sysconfdir}/systemd/resolved.conf.d/
65*4882a593Smuzhiyun    install -m 0644 ${WORKDIR}/dnsmasq-resolved.conf ${D}${sysconfdir}/systemd/resolved.conf.d/
66*4882a593Smuzhiyun
67*4882a593Smuzhiyun    install -m 0755 ${S}/contrib/lease-tools/dhcp_release ${D}${bindir}
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun    if [ "${@bb.utils.filter('PACKAGECONFIG', 'dbus', d)}" ]; then
70*4882a593Smuzhiyun        install -d ${D}${sysconfdir}/dbus-1/system.d
71*4882a593Smuzhiyun        install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
72*4882a593Smuzhiyun    fi
73*4882a593Smuzhiyun    if [ "${@bb.utils.filter('PACKAGECONFIG', 'resolvconf', d)}" ]; then
74*4882a593Smuzhiyun        install -d ${D}${sysconfdir}/resolvconf/update.d/
75*4882a593Smuzhiyun        install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun        install -d ${D}${sysconfdir}/default/volatiles
78*4882a593Smuzhiyun        install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
79*4882a593Smuzhiyun        install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}
80*4882a593Smuzhiyun    fi
81*4882a593Smuzhiyun}
82*4882a593Smuzhiyun
83*4882a593SmuzhiyunCONFFILES:${PN} = "${sysconfdir}/dnsmasq.conf"
84*4882a593Smuzhiyun
85*4882a593SmuzhiyunRPROVIDES:${PN} += "${PN}-systemd"
86*4882a593SmuzhiyunRREPLACES:${PN} += "${PN}-systemd"
87*4882a593SmuzhiyunRCONFLICTS:${PN} += "${PN}-systemd"
88*4882a593SmuzhiyunSYSTEMD_SERVICE:${PN} = "dnsmasq.service"
89