blob: e94370786adad95ee1f4d7f8c03a120ad7c2bb05 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SECTION = "console/network"
2SUMMARY = "Internet Software Consortium DHCP package"
3DESCRIPTION = "DHCP (Dynamic Host Configuration Protocol) is a protocol \
4which allows individual devices on an IP network to get their own \
5network configuration information from a server. DHCP helps make it \
6easier to administer devices."
7
8HOMEPAGE = "http://www.isc.org/"
9
10LICENSE = "ISC"
11LIC_FILES_CHKSUM = "file://LICENSE;beginline=4;md5=c5c64d696107f84b56fe337d14da1753"
12
13DEPENDS = "openssl bind"
14
Brad Bishopd7bf8c12018-02-25 22:55:05 -050015SRC_URI = "http://ftp.isc.org/isc/dhcp/${PV}/dhcp-${PV}.tar.gz \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016 file://init-relay file://default-relay \
17 file://init-server file://default-server \
18 file://dhclient.conf file://dhcpd.conf \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019 file://dhclient-systemd-wrapper \
20 file://dhclient.service \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021 file://dhcpd.service file://dhcrelay.service \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050022 file://dhcpd6.service \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050023 "
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050024UPSTREAM_CHECK_URI = "ftp://ftp.isc.org/isc/dhcp/"
25UPSTREAM_CHECK_REGEX = "(?P<pver>\d+\.\d+\.(\d+?))/"
26
27inherit autotools systemd useradd update-rc.d
28
29USERADD_PACKAGES = "${PN}-server"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050030USERADD_PARAM_${PN}-server = "--system --no-create-home --home-dir /var/run/${BPN} --shell /bin/false --user-group ${BPN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay ${PN}-client"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service"
34SYSTEMD_AUTO_ENABLE_${PN}-server = "disable"
35
36SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service"
37SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable"
38
Brad Bishopd7bf8c12018-02-25 22:55:05 -050039SYSTEMD_SERVICE_${PN}-client = "dhclient.service"
40SYSTEMD_AUTO_ENABLE_${PN}-client = "disable"
41
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050042INITSCRIPT_PACKAGES = "dhcp-server"
43INITSCRIPT_NAME_dhcp-server = "dhcp-server"
44INITSCRIPT_PARAMS_dhcp-server = "defaults"
45
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046TARGET_CFLAGS += "-D_GNU_SOURCE"
47EXTRA_OECONF = "--with-srv-lease-file=${localstatedir}/lib/dhcp/dhcpd.leases \
48 --with-srv6-lease-file=${localstatedir}/lib/dhcp/dhcpd6.leases \
49 --with-cli-lease-file=${localstatedir}/lib/dhcp/dhclient.leases \
50 --with-cli6-lease-file=${localstatedir}/lib/dhcp/dhclient6.leases \
51 --with-libbind=${STAGING_LIBDIR}/ \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050052 --enable-paranoia --disable-static \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060053 --with-randomdev=/dev/random \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054 "
55
56do_install_append () {
57 install -d ${D}${sysconfdir}/init.d
58 install -d ${D}${sysconfdir}/default
59 install -d ${D}${sysconfdir}/dhcp
60 install -m 0755 ${WORKDIR}/init-relay ${D}${sysconfdir}/init.d/dhcp-relay
61 install -m 0644 ${WORKDIR}/default-relay ${D}${sysconfdir}/default/dhcp-relay
62 install -m 0755 ${WORKDIR}/init-server ${D}${sysconfdir}/init.d/dhcp-server
63 install -m 0644 ${WORKDIR}/default-server ${D}${sysconfdir}/default/dhcp-server
64
65 rm -f ${D}${sysconfdir}/dhclient.conf*
66 rm -f ${D}${sysconfdir}/dhcpd.conf*
67 install -m 0644 ${WORKDIR}/dhclient.conf ${D}${sysconfdir}/dhcp/dhclient.conf
68 install -m 0644 ${WORKDIR}/dhcpd.conf ${D}${sysconfdir}/dhcp/dhcpd.conf
69
70 install -d ${D}${base_sbindir}/
71 if [ "${sbindir}" != "${base_sbindir}" ]; then
72 mv ${D}${sbindir}/dhclient ${D}${base_sbindir}/
73 fi
74 install -m 0755 ${S}/client/scripts/linux ${D}${base_sbindir}/dhclient-script
75
76 # Install systemd unit files
77 install -d ${D}${systemd_unitdir}/system
78 install -m 0644 ${WORKDIR}/dhcpd.service ${D}${systemd_unitdir}/system
79 install -m 0644 ${WORKDIR}/dhcpd6.service ${D}${systemd_unitdir}/system
80 install -m 0644 ${WORKDIR}/dhcrelay.service ${D}${systemd_unitdir}/system
81 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service ${D}${systemd_unitdir}/system/dhcrelay.service
82 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
83 sed -i -e 's,@base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
84 sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
Brad Bishopd7bf8c12018-02-25 22:55:05 -050085 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcrelay.service
86
87 install -d ${D}${base_sbindir}
88 install -m 0755 ${WORKDIR}/dhclient-systemd-wrapper ${D}${base_sbindir}/dhclient-systemd-wrapper
89 install -m 0644 ${WORKDIR}/dhclient.service ${D}${systemd_unitdir}/system
90 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhclient.service
91 sed -i -e 's,@BASE_SBINDIR@,${base_sbindir},g' ${D}${systemd_unitdir}/system/dhclient.service
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092}
93
Brad Bishopd7bf8c12018-02-25 22:55:05 -050094PACKAGES += "dhcp-libs dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095
Brad Bishopd7bf8c12018-02-25 22:55:05 -050096PACKAGES_remove = "${PN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097RDEPENDS_${PN}-dev = ""
98RDEPENDS_${PN}-staticdev = ""
99
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500100FILES_${PN}-libs = "${libdir}/libdhcpctl.so.0* ${libdir}/libomapi.so.0*"
101
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102FILES_${PN}-server = "${sbindir}/dhcpd ${sysconfdir}/init.d/dhcp-server"
103RRECOMMENDS_${PN}-server = "dhcp-server-config"
104
105FILES_${PN}-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp/dhcpd.conf"
106
107FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
108
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500109FILES_${PN}-client = "${base_sbindir}/dhclient \
110 ${base_sbindir}/dhclient-script \
111 ${sysconfdir}/dhcp/dhclient.conf \
112 ${base_sbindir}/dhclient-systemd-wrapper \
113 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114
115FILES_${PN}-omshell = "${bindir}/omshell"
116
117pkg_postinst_dhcp-server() {
118 mkdir -p $D/${localstatedir}/lib/dhcp
119 touch $D/${localstatedir}/lib/dhcp/dhcpd.leases
120 touch $D/${localstatedir}/lib/dhcp/dhcpd6.leases
121}
122
123pkg_postinst_dhcp-client() {
124 mkdir -p $D/${localstatedir}/lib/dhcp
125}
126
127pkg_postrm_dhcp-server() {
128 rm -f $D/${localstatedir}/lib/dhcp/dhcpd.leases
129 rm -f $D/${localstatedir}/lib/dhcp/dhcpd6.leases
130
131 if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
132 echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
133 fi
134}
135
136pkg_postrm_dhcp-client() {
137 rm -f $D/${localstatedir}/lib/dhcp/dhclient.leases
138 rm -f $D/${localstatedir}/lib/dhcp/dhclient6.leases
139
140 if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
141 echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
142 fi
143}