blob: 5e396f15946e66d9428617493bda0e66fadf7052 [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
15SRC_URI = "ftp://ftp.isc.org/isc/dhcp/${PV}/dhcp-${PV}.tar.gz \
16 file://define-macro-_PATH_DHCPD_CONF-and-_PATH_DHCLIENT_CON.patch \
17 file://init-relay file://default-relay \
18 file://init-server file://default-server \
19 file://dhclient.conf file://dhcpd.conf \
20 file://dhcpd.service file://dhcrelay.service \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050021 file://dhcpd6.service \
22 file://search-for-libxml2.patch "
Patrick Williamsc124f4f2015-09-15 14:41:29 -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"
30USERADD_PARAM_${PN}-server = "--system --no-create-home --home-dir /var/run/${PN} --shell /bin/false --user-group ${PN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031
32SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay"
33SYSTEMD_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
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039INITSCRIPT_PACKAGES = "dhcp-server"
40INITSCRIPT_NAME_dhcp-server = "dhcp-server"
41INITSCRIPT_PARAMS_dhcp-server = "defaults"
42
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043TARGET_CFLAGS += "-D_GNU_SOURCE"
44EXTRA_OECONF = "--with-srv-lease-file=${localstatedir}/lib/dhcp/dhcpd.leases \
45 --with-srv6-lease-file=${localstatedir}/lib/dhcp/dhcpd6.leases \
46 --with-cli-lease-file=${localstatedir}/lib/dhcp/dhclient.leases \
47 --with-cli6-lease-file=${localstatedir}/lib/dhcp/dhclient6.leases \
48 --with-libbind=${STAGING_LIBDIR}/ \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050049 --enable-paranoia \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 "
51
52do_install_append () {
53 install -d ${D}${sysconfdir}/init.d
54 install -d ${D}${sysconfdir}/default
55 install -d ${D}${sysconfdir}/dhcp
56 install -m 0755 ${WORKDIR}/init-relay ${D}${sysconfdir}/init.d/dhcp-relay
57 install -m 0644 ${WORKDIR}/default-relay ${D}${sysconfdir}/default/dhcp-relay
58 install -m 0755 ${WORKDIR}/init-server ${D}${sysconfdir}/init.d/dhcp-server
59 install -m 0644 ${WORKDIR}/default-server ${D}${sysconfdir}/default/dhcp-server
60
61 rm -f ${D}${sysconfdir}/dhclient.conf*
62 rm -f ${D}${sysconfdir}/dhcpd.conf*
63 install -m 0644 ${WORKDIR}/dhclient.conf ${D}${sysconfdir}/dhcp/dhclient.conf
64 install -m 0644 ${WORKDIR}/dhcpd.conf ${D}${sysconfdir}/dhcp/dhcpd.conf
65
66 install -d ${D}${base_sbindir}/
67 if [ "${sbindir}" != "${base_sbindir}" ]; then
68 mv ${D}${sbindir}/dhclient ${D}${base_sbindir}/
69 fi
70 install -m 0755 ${S}/client/scripts/linux ${D}${base_sbindir}/dhclient-script
71
72 # Install systemd unit files
73 install -d ${D}${systemd_unitdir}/system
74 install -m 0644 ${WORKDIR}/dhcpd.service ${D}${systemd_unitdir}/system
75 install -m 0644 ${WORKDIR}/dhcpd6.service ${D}${systemd_unitdir}/system
76 install -m 0644 ${WORKDIR}/dhcrelay.service ${D}${systemd_unitdir}/system
77 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service ${D}${systemd_unitdir}/system/dhcrelay.service
78 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
79 sed -i -e 's,@base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
80 sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
81}
82
83PACKAGES += "dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell"
84
85FILES_${PN} = ""
86RDEPENDS_${PN}-dev = ""
87RDEPENDS_${PN}-staticdev = ""
88
89FILES_${PN}-server = "${sbindir}/dhcpd ${sysconfdir}/init.d/dhcp-server"
90RRECOMMENDS_${PN}-server = "dhcp-server-config"
91
92FILES_${PN}-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp/dhcpd.conf"
93
94FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
95
96FILES_${PN}-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf"
97RDEPENDS_${PN}-client = "bash"
98
99FILES_${PN}-omshell = "${bindir}/omshell"
100
101pkg_postinst_dhcp-server() {
102 mkdir -p $D/${localstatedir}/lib/dhcp
103 touch $D/${localstatedir}/lib/dhcp/dhcpd.leases
104 touch $D/${localstatedir}/lib/dhcp/dhcpd6.leases
105}
106
107pkg_postinst_dhcp-client() {
108 mkdir -p $D/${localstatedir}/lib/dhcp
109}
110
111pkg_postrm_dhcp-server() {
112 rm -f $D/${localstatedir}/lib/dhcp/dhcpd.leases
113 rm -f $D/${localstatedir}/lib/dhcp/dhcpd6.leases
114
115 if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
116 echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
117 fi
118}
119
120pkg_postrm_dhcp-client() {
121 rm -f $D/${localstatedir}/lib/dhcp/dhclient.leases
122 rm -f $D/${localstatedir}/lib/dhcp/dhclient6.leases
123
124 if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
125 echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
126 fi
127}