blob: d883a8df48a29a05a4018cb2c924414c199b9e36 [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 \
21 file://dhcpd6.service "
22
23inherit autotools systemd
24
25SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay"
26SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service"
27SYSTEMD_AUTO_ENABLE_${PN}-server = "disable"
28
29SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service"
30SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable"
31
32TARGET_CFLAGS += "-D_GNU_SOURCE"
33EXTRA_OECONF = "--with-srv-lease-file=${localstatedir}/lib/dhcp/dhcpd.leases \
34 --with-srv6-lease-file=${localstatedir}/lib/dhcp/dhcpd6.leases \
35 --with-cli-lease-file=${localstatedir}/lib/dhcp/dhclient.leases \
36 --with-cli6-lease-file=${localstatedir}/lib/dhcp/dhclient6.leases \
37 --with-libbind=${STAGING_LIBDIR}/ \
38 "
39
40do_install_append () {
41 install -d ${D}${sysconfdir}/init.d
42 install -d ${D}${sysconfdir}/default
43 install -d ${D}${sysconfdir}/dhcp
44 install -m 0755 ${WORKDIR}/init-relay ${D}${sysconfdir}/init.d/dhcp-relay
45 install -m 0644 ${WORKDIR}/default-relay ${D}${sysconfdir}/default/dhcp-relay
46 install -m 0755 ${WORKDIR}/init-server ${D}${sysconfdir}/init.d/dhcp-server
47 install -m 0644 ${WORKDIR}/default-server ${D}${sysconfdir}/default/dhcp-server
48
49 rm -f ${D}${sysconfdir}/dhclient.conf*
50 rm -f ${D}${sysconfdir}/dhcpd.conf*
51 install -m 0644 ${WORKDIR}/dhclient.conf ${D}${sysconfdir}/dhcp/dhclient.conf
52 install -m 0644 ${WORKDIR}/dhcpd.conf ${D}${sysconfdir}/dhcp/dhcpd.conf
53
54 install -d ${D}${base_sbindir}/
55 if [ "${sbindir}" != "${base_sbindir}" ]; then
56 mv ${D}${sbindir}/dhclient ${D}${base_sbindir}/
57 fi
58 install -m 0755 ${S}/client/scripts/linux ${D}${base_sbindir}/dhclient-script
59
60 # Install systemd unit files
61 install -d ${D}${systemd_unitdir}/system
62 install -m 0644 ${WORKDIR}/dhcpd.service ${D}${systemd_unitdir}/system
63 install -m 0644 ${WORKDIR}/dhcpd6.service ${D}${systemd_unitdir}/system
64 install -m 0644 ${WORKDIR}/dhcrelay.service ${D}${systemd_unitdir}/system
65 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service ${D}${systemd_unitdir}/system/dhcrelay.service
66 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
67 sed -i -e 's,@base_bindir@,${base_bindir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
68 sed -i -e 's,@localstatedir@,${localstatedir},g' ${D}${systemd_unitdir}/system/dhcpd*.service
69}
70
71PACKAGES += "dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell"
72
73FILES_${PN} = ""
74RDEPENDS_${PN}-dev = ""
75RDEPENDS_${PN}-staticdev = ""
76
77FILES_${PN}-server = "${sbindir}/dhcpd ${sysconfdir}/init.d/dhcp-server"
78RRECOMMENDS_${PN}-server = "dhcp-server-config"
79
80FILES_${PN}-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp/dhcpd.conf"
81
82FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay"
83
84FILES_${PN}-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf"
85RDEPENDS_${PN}-client = "bash"
86
87FILES_${PN}-omshell = "${bindir}/omshell"
88
89pkg_postinst_dhcp-server() {
90 mkdir -p $D/${localstatedir}/lib/dhcp
91 touch $D/${localstatedir}/lib/dhcp/dhcpd.leases
92 touch $D/${localstatedir}/lib/dhcp/dhcpd6.leases
93}
94
95pkg_postinst_dhcp-client() {
96 mkdir -p $D/${localstatedir}/lib/dhcp
97}
98
99pkg_postrm_dhcp-server() {
100 rm -f $D/${localstatedir}/lib/dhcp/dhcpd.leases
101 rm -f $D/${localstatedir}/lib/dhcp/dhcpd6.leases
102
103 if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
104 echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
105 fi
106}
107
108pkg_postrm_dhcp-client() {
109 rm -f $D/${localstatedir}/lib/dhcp/dhclient.leases
110 rm -f $D/${localstatedir}/lib/dhcp/dhclient6.leases
111
112 if ! rmdir $D/${localstatedir}/lib/dhcp 2>/dev/null; then
113 echo "Not removing ${localstatedir}/lib/dhcp as it is non-empty."
114 fi
115}