Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame^] | 1 | SECTION = "console/network" |
| 2 | SUMMARY = "Internet Software Consortium DHCP package" |
| 3 | DESCRIPTION = "DHCP (Dynamic Host Configuration Protocol) is a protocol \ |
| 4 | which allows individual devices on an IP network to get their own \ |
| 5 | network configuration information from a server. DHCP helps make it \ |
| 6 | easier to administer devices." |
| 7 | |
| 8 | HOMEPAGE = "http://www.isc.org/" |
| 9 | |
| 10 | LICENSE = "ISC" |
| 11 | LIC_FILES_CHKSUM = "file://LICENSE;beginline=4;md5=c5c64d696107f84b56fe337d14da1753" |
| 12 | |
| 13 | DEPENDS = "openssl bind" |
| 14 | |
| 15 | SRC_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 | |
| 23 | inherit autotools systemd |
| 24 | |
| 25 | SYSTEMD_PACKAGES = "${PN}-server ${PN}-relay" |
| 26 | SYSTEMD_SERVICE_${PN}-server = "dhcpd.service dhcpd6.service" |
| 27 | SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" |
| 28 | |
| 29 | SYSTEMD_SERVICE_${PN}-relay = "dhcrelay.service" |
| 30 | SYSTEMD_AUTO_ENABLE_${PN}-relay = "disable" |
| 31 | |
| 32 | TARGET_CFLAGS += "-D_GNU_SOURCE" |
| 33 | EXTRA_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 | |
| 40 | do_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 | |
| 71 | PACKAGES += "dhcp-server dhcp-server-config dhcp-client dhcp-relay dhcp-omshell" |
| 72 | |
| 73 | FILES_${PN} = "" |
| 74 | RDEPENDS_${PN}-dev = "" |
| 75 | RDEPENDS_${PN}-staticdev = "" |
| 76 | |
| 77 | FILES_${PN}-server = "${sbindir}/dhcpd ${sysconfdir}/init.d/dhcp-server" |
| 78 | RRECOMMENDS_${PN}-server = "dhcp-server-config" |
| 79 | |
| 80 | FILES_${PN}-server-config = "${sysconfdir}/default/dhcp-server ${sysconfdir}/dhcp/dhcpd.conf" |
| 81 | |
| 82 | FILES_${PN}-relay = "${sbindir}/dhcrelay ${sysconfdir}/init.d/dhcp-relay ${sysconfdir}/default/dhcp-relay" |
| 83 | |
| 84 | FILES_${PN}-client = "${base_sbindir}/dhclient ${base_sbindir}/dhclient-script ${sysconfdir}/dhcp/dhclient.conf" |
| 85 | RDEPENDS_${PN}-client = "bash" |
| 86 | |
| 87 | FILES_${PN}-omshell = "${bindir}/omshell" |
| 88 | |
| 89 | pkg_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 | |
| 95 | pkg_postinst_dhcp-client() { |
| 96 | mkdir -p $D/${localstatedir}/lib/dhcp |
| 97 | } |
| 98 | |
| 99 | pkg_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 | |
| 108 | pkg_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 | } |