blob: b3574a7ff6850df81a324abe2dd447364eea35d1 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001SUMMARY = "BGP/OSPF/RIP routing daemon"
2DESCRIPTION = "Quagga is a routing software suite, providing \
3implementations of OSPFv2, OSPFv3, RIP v1 and v2, RIPv3 and BGPv4 for \
4Unix platforms, particularly FreeBSD, Linux, Solaris and NetBSD. \
5Quagga is a fork of GNU Zebra which was developed by Kunihiro \
6Ishiguro. The Quagga tree aims to build a more involved community \
7around Quagga than the current centralised model of GNU Zebra."
8HOMEPAGE = "http://www.nongnu.org/quagga/"
9SECTION = "net"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050010
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011
12LICENSE = "GPL-2.0 & LGPL-2.0"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050013LIC_FILES_CHKSUM = "file://COPYING;md5=81bcece21748c91ba9992349a91ec11d \
14 file://COPYING.LIB;md5=01ef24401ded36cd8e5d18bfe947240c"
15
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016DEPENDS = "readline ncurses perl-native c-ares"
17DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'snmp', 'net-snmp', '', d)}"
18SNMP_CONF="${@bb.utils.contains('DISTRO_FEATURES', 'snmp', '--enable-snmp', '', d)}"
19
Patrick Williamsb48b7b42016-08-17 15:04:38 -050020# the "ip" command from busybox is not sufficient (flush by protocol flushes all routes)
Patrick Williams213cb262021-08-07 19:21:33 -050021RDEPENDS:${PN} += "iproute2"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050022
Andrew Geissler32b11992021-03-31 13:37:05 -050023SRC_URI = "https://github.com/Quagga/quagga/releases/download/quagga-${PV}/quagga-${PV}.tar.gz \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050024 file://quagga.init \
25 file://quagga.default \
26 file://watchquagga.init \
27 file://watchquagga.default \
28 file://volatiles.03_quagga \
29 file://quagga.pam \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050030 file://bgpd.service \
31 file://isisd.service \
32 file://ospf6d.service \
33 file://ospfd.service \
34 file://ripd.service \
35 file://ripngd.service \
36 file://zebra.service \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050037 "
Patrick Williamsb48b7b42016-08-17 15:04:38 -050038
Brad Bishop6e60e8b2018-02-01 10:27:11 -050039PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050040PACKAGECONFIG[cap] = "--enable-capabilities,--disable-capabilities,libcap"
41PACKAGECONFIG[pam] = "--with-libpam, --without-libpam, libpam"
42
Andrew Geisslerd688a012020-09-18 13:36:00 -050043inherit autotools update-rc.d useradd systemd pkgconfig multilib_header update-alternatives
Patrick Williamsb48b7b42016-08-17 15:04:38 -050044
Andrew Geisslerbffdb3e2020-08-21 16:13:29 -050045CFLAGS += "-fcommon"
46
Patrick Williamsddad1a12017-02-23 20:36:32 -060047SYSTEMD_PACKAGES = "${PN} ${PN}-bgpd ${PN}-isisd ${PN}-ospf6d ${PN}-ospfd ${PN}-ripd ${PN}-ripngd"
Patrick Williams213cb262021-08-07 19:21:33 -050048SYSTEMD_SERVICE:${PN}-bgpd = "bgpd.service"
49SYSTEMD_SERVICE:${PN}-isisd = "isisd.service"
50SYSTEMD_SERVICE:${PN}-ospf6d = "ospf6d.service"
51SYSTEMD_SERVICE:${PN}-ospfd = "ospfd.service"
52SYSTEMD_SERVICE:${PN}-ripd = "ripd.service"
53SYSTEMD_SERVICE:${PN}-ripngd = "ripngd.service"
54SYSTEMD_SERVICE:${PN} = "zebra.service"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050055
56EXTRA_OECONF = "--sysconfdir=${sysconfdir}/quagga \
57 --localstatedir=${localstatedir}/run/quagga \
58 --enable-exampledir=${docdir}/quagga/examples/ \
59 --enable-vtysh \
60 --enable-isisd \
Patrick Williamsddad1a12017-02-23 20:36:32 -060061 ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '--enable-watchquagga', '--disable-watchquagga', d)} \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050062 --enable-ospfclient=yes \
63 --enable-multipath=64 \
64 --enable-user=quagga \
65 --enable-group=quagga \
66 --enable-vty-group=quaggavty \
67 --enable-configfile-mask=0640 \
68 --enable-logfile-mask=0640 \
69 --enable-rtadv \
70 --enable-linux24-tcp-md5 \
71 ap_cv_cc_pie=no \
72 ${SNMP_CONF}"
73
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
75
Patrick Williamsb48b7b42016-08-17 15:04:38 -050076do_install () {
77 # Install init script and default settings
78 install -m 0755 -d ${D}${sysconfdir}/default ${D}${sysconfdir}/init.d \
79 ${D}${sysconfdir}/quagga ${D}${sysconfdir}/default/volatiles
80 install -m 0644 ${WORKDIR}/quagga.default ${D}${sysconfdir}/default/quagga
81 install -m 0644 ${WORKDIR}/watchquagga.default ${D}${sysconfdir}/default/watchquagga
82 install -m 0755 ${WORKDIR}/quagga.init ${D}${sysconfdir}/init.d/quagga
83 install -m 0755 ${WORKDIR}/watchquagga.init ${D}${sysconfdir}/init.d/watchquagga
Andrew Geissler4b7c1152020-11-30 19:55:29 -060084 install -m 0644 ${WORKDIR}/volatiles.03_quagga ${D}${sysconfdir}/default/volatiles/03_quagga
Patrick Williamsb48b7b42016-08-17 15:04:38 -050085
86 # Install sample configurations for the daemons
Patrick Williamsddad1a12017-02-23 20:36:32 -060087 for f in bgpd vtysh isisd ospfd ripngd zebra ripd ospf6d; do
Patrick Williamsb48b7b42016-08-17 15:04:38 -050088 install -m 0640 ${S}/$f/$f.conf.sample ${D}${sysconfdir}/quagga/$f.conf.sample
89 done
90
Patrick Williamsddad1a12017-02-23 20:36:32 -060091 for f in bgpd vtysh isisd ospfd ripngd zebra ripd ospf6d; do
92 touch ${D}${sysconfdir}/quagga/$f.conf
Patrick Williamsb48b7b42016-08-17 15:04:38 -050093 done
94 chown quagga:quaggavty ${D}${sysconfdir}/quagga
95 chown quagga:quagga ${D}${sysconfdir}/quagga/*.conf
96 chmod 750 ${D}${sysconfdir}/quagga
97 chmod 640 ${D}${sysconfdir}/quagga/*.conf
98
99 # Install quagga
100 oe_runmake install DESTDIR=${D} prefix=${prefix} \
101 sbindir=${sbindir} \
102 sysconfdir=${sysconfdir}/quagga \
103 localstatedir=${localstatedir}/run/quagga
104
105 # Fix hardcoded paths
106 sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/*
107 sed -i 's!/usr/bin/!${bindir}/!g' ${D}${sysconfdir}/init.d/quagga
108 sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/* ${D}${sysconfdir}/default/watchquagga
Andrew Geissler4b7c1152020-11-30 19:55:29 -0600109 sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/* ${D}${sysconfdir}/default/volatiles/03_quagga
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500110 sed -i 's!^PATH=.*!PATH=${base_sbindir}:${sbindir}:${base_bindir}:${bindir}!' ${D}${sysconfdir}/init.d/*
Andrew Geissler82c905d2020-04-13 13:39:40 -0500111 sed -i 's!--with-libtool-sysroot=[^ "]*!!' ${D}${includedir}/quagga/version.h
112
113 oe_multilib_header quagga/version.h
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500114
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500115 # For PAM
116 for feature in ${DISTRO_FEATURES}; do
117 if [ "$feature" = "pam" ]; then
118 install -D -m 644 ${WORKDIR}/quagga.pam ${D}/${sysconfdir}/pam.d/quagga
119 break
120 fi
121 done
122
Patrick Williamsddad1a12017-02-23 20:36:32 -0600123 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
Andrew Geissler82c905d2020-04-13 13:39:40 -0500124 install -d ${D}${nonarch_libdir}/tmpfiles.d
125 echo "d /run/quagga 0755 quagga quagga -" \
126 > ${D}${nonarch_libdir}/tmpfiles.d/${BPN}.conf
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500127 fi
128
129 # Remove sysinit script if sysvinit is not in DISTRO_FEATURES
130 if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'false', 'true', d)}; then
131 rm -rf ${D}${sysconfdir}/init.d/
132 rm -f ${D}${sysconfdir}/default/watchquagga
133 fi
134
135 install -d ${D}${systemd_unitdir}/system
Patrick Williamsddad1a12017-02-23 20:36:32 -0600136 for i in bgpd isisd ospf6d ospfd ripd ripngd zebra; do
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500137 install -m 0644 ${WORKDIR}/$i.service ${D}${systemd_unitdir}/system
138 done
139 sed -e 's,@BASE_SBINDIR@,${base_sbindir},g' \
140 -e 's,@SYSCONFDIR@,${sysconfdir},g' \
141 -e 's,@SBINDIR@,${sbindir},g' \
142 -e 's,@base_bindir@,${base_bindir},g' \
143 -e 's,@localstatedir@,${localstatedir},g' \
144 -i ${D}${systemd_unitdir}/system/*.service
145}
146
Patrick Williams213cb262021-08-07 19:21:33 -0500147DEPENDS:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd-systemctl-native', '', d)}"
148pkg_postinst:${PN} () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500149 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd sysvinit', 'true', 'false', d)}; then
150 if [ -n "$D" ]; then
151 OPTS="--root=$D"
152 fi
153 systemctl $OPTS mask quagga.service
154 fi
155}
156
157# Split into a main package and separate per-protocol packages
Patrick Williamsddad1a12017-02-23 20:36:32 -0600158PACKAGE_BEFORE_PN = "${PN}-ospfd ${PN}-ospf6d ${PN}-bgpd \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500159 ${PN}-ripd ${PN}-ripngd ${PN}-isisd \
Patrick Williamsddad1a12017-02-23 20:36:32 -0600160 ${PN}-ospfclient ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', '${PN}-watchquagga', '', d)}"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500161
Patrick Williams213cb262021-08-07 19:21:33 -0500162RDEPENDS:${PN} += "${PN}-bgpd ${PN}-isisd ${PN}-ospf6d ${PN}-ospfd ${PN}-ripd ${PN}-ripngd"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500163
Patrick Williams213cb262021-08-07 19:21:33 -0500164FILES:${PN}-ospfd = "${sbindir}/ospfd ${libdir}/libospf.so.*"
165FILES:${PN}-ospf6d = "${sbindir}/ospf6d"
166FILES:${PN}-bgpd = "${sbindir}/bgpd"
167FILES:${PN}-ripd = "${sbindir}/ripd"
168FILES:${PN}-ripngd = "${sbindir}/ripngd"
169FILES:${PN}-isisd = "${sbindir}/isisd"
170FILES:${PN}-ospfclient = "${sbindir}/ospfclient ${libdir}/libospfapiclient.so.*"
171FILES:${PN}-watchquagga = "${sbindir}/watchquagga ${sysconfdir}/default/watchquagga \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500172 ${sysconfdir}/init.d/watchquagga"
173
Patrick Williams213cb262021-08-07 19:21:33 -0500174FILES:${PN} += "${nonarch_libdir}/tmpfiles.d/*.conf"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500175
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500176# Indicate that the default files are configuration files
Patrick Williams213cb262021-08-07 19:21:33 -0500177CONFFILES:${PN} = "${sysconfdir}/default/quagga \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500178 ${sysconfdir}/quagga/bgpd.conf \
179 ${sysconfdir}/quagga/vtysh.conf \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500180 ${sysconfdir}/quagga/isisd.conf \
181 ${sysconfdir}/quagga/ospfd.conf \
182 ${sysconfdir}/quagga/ripngd.conf \
183 ${sysconfdir}/quagga/zebra.conf \
184 ${sysconfdir}/quagga/ripd.conf \
185 ${sysconfdir}/quagga/ospf6d.conf \
186 "
Patrick Williams213cb262021-08-07 19:21:33 -0500187CONFFILES:${PN}-watchquagga = "${sysconfdir}/default/watchquagga"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500188
189# Stop the names being rewritten due to the internal shared libraries
Patrick Williams213cb262021-08-07 19:21:33 -0500190DEBIAN_NOAUTONAME:${PN}-ospfd = "1"
191DEBIAN_NOAUTONAME:${PN}-ospfclient = "1"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500192
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500193# Main init script starts all deamons
194# Seperate init script for watchquagga
195INITSCRIPT_PACKAGES = "${PN} ${PN}-watchquagga"
Patrick Williams213cb262021-08-07 19:21:33 -0500196INITSCRIPT_NAME:${PN} = "quagga"
197INITSCRIPT_PARAMS:${PN} = "defaults 15 85"
198INITSCRIPT_NAME:${PN}-watchquagga = "watchquagga"
199INITSCRIPT_PARAMS:${PN}-watchquagga = "defaults 90 10"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500200
201# Add quagga's user and group
202USERADD_PACKAGES = "${PN}"
Patrick Williams213cb262021-08-07 19:21:33 -0500203GROUPADD_PARAM:${PN} = "--system quagga ; --system quaggavty"
204USERADD_PARAM:${PN} = "--system --home ${localstatedir}/run/quagga/ -M -g quagga -G quaggavty --shell /bin/false quagga"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500205
Patrick Williams213cb262021-08-07 19:21:33 -0500206pkg_postinst:${PN} () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500207 if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then
208 ${sysconfdir}/init.d/populate-volatile.sh update
209 fi
210}
211
212# Stop apps before uninstall
Patrick Williams213cb262021-08-07 19:21:33 -0500213pkg_prerm:${PN} () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500214 ${sysconfdir}/init.d/quagga stop
215}
216
Patrick Williams213cb262021-08-07 19:21:33 -0500217pkg_prerm:${PN}-ospfd () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500218 ${sysconfdir}/init.d/quagga stop ospfd
219}
220
Patrick Williams213cb262021-08-07 19:21:33 -0500221pkg_prerm:${PN}-ospf6d () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500222 ${sysconfdir}/init.d/quagga stop ospf6d
223}
224
Patrick Williams213cb262021-08-07 19:21:33 -0500225pkg_prerm:${PN}-bgpd () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500226 ${sysconfdir}/init.d/quagga stop bgpd
227}
228
Patrick Williams213cb262021-08-07 19:21:33 -0500229pkg_prerm:${PN}-ripd () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500230 ${sysconfdir}/init.d/quagga stop ripd
231}
232
Patrick Williams213cb262021-08-07 19:21:33 -0500233pkg_prerm:${PN}-ripngd () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500234 ${sysconfdir}/init.d/quagga stop ripngd
235}
236
Patrick Williams213cb262021-08-07 19:21:33 -0500237pkg_prerm:${PN}-isisd () {
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500238 ${sysconfdir}/init.d/quagga stop isisd
239}
Andrew Geisslerd688a012020-09-18 13:36:00 -0500240
Patrick Williams213cb262021-08-07 19:21:33 -0500241ALTERNATIVE:${PN} = "pimd"
Andrew Geisslerd688a012020-09-18 13:36:00 -0500242ALTERNATIVE_LINK_NAME[pimd] = "${sbindir}/pimd"
243