blob: d46130d49b984d61f87ef05406fc7671bd1f618c [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"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080011LIC_FILES_CHKSUM = "file://LICENSE;beginline=4;md5=004a4db50a1e20972e924a8618747c01"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080013DEPENDS = "openssl bind"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014
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 "
Brad Bishop08902b02019-08-20 09:16:51 -040024UPSTREAM_CHECK_URI = "http://ftp.isc.org/isc/dhcp/"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050025UPSTREAM_CHECK_REGEX = "(?P<pver>\d+\.\d+\.(\d+?))/"
26
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080027inherit autotools-brokensep systemd useradd update-rc.d
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050028
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
Brad Bishop1d80a2e2019-11-15 16:35:03 -050046CFLAGS += "-D_GNU_SOURCE"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047EXTRA_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 \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050051 --enable-paranoia --disable-static \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060052 --with-randomdev=/dev/random \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053 --with-libbind=${STAGING_DIR_HOST} \
54 --enable-libtool \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055 "
56
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057#Enable shared libs per dhcp README
58do_configure_prepend () {
59 cp configure.ac+lt configure.ac
60}
61
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062do_install_append () {
63 install -d ${D}${sysconfdir}/init.d
64 install -d ${D}${sysconfdir}/default
65 install -d ${D}${sysconfdir}/dhcp
66 install -m 0755 ${WORKDIR}/init-relay ${D}${sysconfdir}/init.d/dhcp-relay
67 install -m 0644 ${WORKDIR}/default-relay ${D}${sysconfdir}/default/dhcp-relay
68 install -m 0755 ${WORKDIR}/init-server ${D}${sysconfdir}/init.d/dhcp-server
69 install -m 0644 ${WORKDIR}/default-server ${D}${sysconfdir}/default/dhcp-server
70
71 rm -f ${D}${sysconfdir}/dhclient.conf*
72 rm -f ${D}${sysconfdir}/dhcpd.conf*
73 install -m 0644 ${WORKDIR}/dhclient.conf ${D}${sysconfdir}/dhcp/dhclient.conf
74 install -m 0644 ${WORKDIR}/dhcpd.conf ${D}${sysconfdir}/dhcp/dhcpd.conf
75
76 install -d ${D}${base_sbindir}/
77 if [ "${sbindir}" != "${base_sbindir}" ]; then
78 mv ${D}${sbindir}/dhclient ${D}${base_sbindir}/
79 fi
80 install -m 0755 ${S}/client/scripts/linux ${D}${base_sbindir}/dhclient-script
81
82 # Install systemd unit files
83 install -d ${D}${systemd_unitdir}/system
84 install -m 0644 ${WORKDIR}/dhcpd.service ${D}${systemd_unitdir}/system
85 install -m 0644 ${WORKDIR}/dhcpd6.service ${D}${systemd_unitdir}/system
86 install -m 0644 ${WORKDIR}/dhcrelay.service ${D}${systemd_unitdir}/system
87 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service ${D}${systemd_unitdir}/system/dhcrelay.service
88 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
89 sed -i -e 's,@base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
90 sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
Brad Bishopd7bf8c12018-02-25 22:55:05 -050091 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcrelay.service
92
93 install -d ${D}${base_sbindir}
94 install -m 0755 ${WORKDIR}/dhclient-systemd-wrapper ${D}${base_sbindir}/dhclient-systemd-wrapper
95 install -m 0644 ${WORKDIR}/dhclient.service ${D}${systemd_unitdir}/system
96 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhclient.service
97 sed -i -e 's,@BASE_SBINDIR@,${base_sbindir},g' ${D}${systemd_unitdir}/system/dhclient.service
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098}
99
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500100PACKAGES += "dhcp-libs dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500102PACKAGES_remove = "${PN}"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500103RDEPENDS_${PN}-client += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'iproute2', '', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104RDEPENDS_${PN}-dev = ""
105RDEPENDS_${PN}-staticdev = ""
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800106FILES_${PN}-libs = "${libdir}/libdhcpctl.so.0* ${libdir}/libomapi.so.0* ${libdir}/libdhcp.so.0*"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500107
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108FILES_${PN}-server = "${sbindir}/dhcpd ${sysconfdir}/init.d/dhcp-server"
109RRECOMMENDS_${PN}-server = "dhcp-server-config"
110
111FILES_${PN}-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp/dhcpd.conf"
112
113FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
114
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500115FILES_${PN}-client = "${base_sbindir}/dhclient \
116 ${base_sbindir}/dhclient-script \
117 ${sysconfdir}/dhcp/dhclient.conf \
118 ${base_sbindir}/dhclient-systemd-wrapper \
119 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500120
121FILES_${PN}-omshell = "${bindir}/omshell"
122
123pkg_postinst_dhcp-server() {
124 mkdir -p $D/${localstatedir}/lib/dhcp
125 touch $D/${localstatedir}/lib/dhcp/dhcpd.leases
126 touch $D/${localstatedir}/lib/dhcp/dhcpd6.leases
127}
128
129pkg_postinst_dhcp-client() {
130 mkdir -p $D/${localstatedir}/lib/dhcp
131}
132
133pkg_postrm_dhcp-server() {
134 rm -f $D/${localstatedir}/lib/dhcp/dhcpd.leases
135 rm -f $D/${localstatedir}/lib/dhcp/dhcpd6.leases
136
137 if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
138 echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
139 fi
140}
141
142pkg_postrm_dhcp-client() {
143 rm -f $D/${localstatedir}/lib/dhcp/dhclient.leases
144 rm -f $D/${localstatedir}/lib/dhcp/dhclient6.leases
145
146 if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
147 echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
148 fi
149}