Andrew Geissler | f1e4406 | 2021-04-15 15:52:46 -0500 | [diff] [blame] | 1 | SUMMARY = "The Suricata Engine is an Open Source Next Generation Intrusion Detection and Prevention Engine" |
| 2 | |
| 3 | require suricata.inc |
| 4 | |
| 5 | DEPENDS = "lz4 libhtp" |
| 6 | |
| 7 | LIC_FILES_CHKSUM = "file://LICENSE;beginline=1;endline=2;md5=c70d8d3310941dcdfcd1e02800a1f548" |
| 8 | |
| 9 | SRC_URI += " \ |
| 10 | file://volatiles.03_suricata \ |
| 11 | file://tmpfiles.suricata \ |
| 12 | file://suricata.yaml \ |
| 13 | file://suricata.service \ |
| 14 | file://run-ptest \ |
| 15 | file://fixup.patch \ |
| 16 | " |
| 17 | |
| 18 | SRC_URI += " \ |
| 19 | crate://crates.io/autocfg/1.0.1 \ |
| 20 | crate://crates.io/semver-parser/0.7.0 \ |
| 21 | crate://crates.io/arrayvec/0.4.12 \ |
| 22 | crate://crates.io/ryu/1.0.5 \ |
| 23 | crate://crates.io/libc/0.2.86 \ |
| 24 | crate://crates.io/bitflags/1.2.1 \ |
| 25 | crate://crates.io/version_check/0.9.2 \ |
| 26 | crate://crates.io/memchr/2.3.4 \ |
| 27 | crate://crates.io/nodrop/0.1.14 \ |
| 28 | crate://crates.io/cfg-if/0.1.9 \ |
| 29 | crate://crates.io/static_assertions/0.3.4 \ |
| 30 | crate://crates.io/getrandom/0.1.16 \ |
| 31 | crate://crates.io/cfg-if/1.0.0 \ |
| 32 | crate://crates.io/siphasher/0.3.3 \ |
| 33 | crate://crates.io/ppv-lite86/0.2.10 \ |
| 34 | crate://crates.io/proc-macro-hack/0.5.19 \ |
| 35 | crate://crates.io/proc-macro2/0.4.30 \ |
| 36 | crate://crates.io/unicode-xid/0.1.0 \ |
| 37 | crate://crates.io/syn/0.15.44 \ |
| 38 | crate://crates.io/build_const/0.2.1 \ |
| 39 | crate://crates.io/num-derive/0.2.5 \ |
| 40 | crate://crates.io/base64/0.11.0 \ |
| 41 | crate://crates.io/widestring/0.4.3 \ |
| 42 | crate://crates.io/md5/0.7.0 \ |
| 43 | crate://crates.io/uuid/0.8.2 \ |
| 44 | crate://crates.io/byteorder/1.4.2 \ |
| 45 | crate://crates.io/semver/0.9.0 \ |
| 46 | crate://crates.io/nom/5.1.1 \ |
| 47 | crate://crates.io/num-traits/0.2.14 \ |
| 48 | crate://crates.io/num-integer/0.1.44 \ |
| 49 | crate://crates.io/num-bigint/0.2.6 \ |
| 50 | crate://crates.io/num-bigint/0.3.1 \ |
| 51 | crate://crates.io/num-rational/0.2.4 \ |
| 52 | crate://crates.io/num-complex/0.2.4 \ |
| 53 | crate://crates.io/num-iter/0.1.42 \ |
| 54 | crate://crates.io/phf_shared/0.8.0 \ |
| 55 | crate://crates.io/crc/1.8.1 \ |
| 56 | crate://crates.io/rustc_version/0.2.3 \ |
| 57 | crate://crates.io/phf/0.8.0 \ |
| 58 | crate://crates.io/lexical-core/0.6.7 \ |
| 59 | crate://crates.io/time/0.1.44 \ |
| 60 | crate://crates.io/quote/0.6.13 \ |
| 61 | crate://crates.io/rand_core/0.5.1 \ |
| 62 | crate://crates.io/rand_chacha/0.2.2 \ |
| 63 | crate://crates.io/rand_pcg/0.2.1 \ |
| 64 | crate://crates.io/num-traits/0.1.43 \ |
| 65 | crate://crates.io/rand/0.7.3 \ |
| 66 | crate://crates.io/enum_primitive/0.1.1 \ |
| 67 | crate://crates.io/phf_generator/0.8.0 \ |
| 68 | crate://crates.io/phf_codegen/0.8.0 \ |
| 69 | crate://crates.io/tls-parser/0.9.4 \ |
| 70 | crate://crates.io/num/0.2.1 \ |
| 71 | crate://crates.io/rusticata-macros/2.1.0 \ |
| 72 | crate://crates.io/ntp-parser/0.4.0 \ |
| 73 | crate://crates.io/der-oid-macro/0.2.0 \ |
| 74 | crate://crates.io/der-parser/3.0.4 \ |
| 75 | crate://crates.io/ipsec-parser/0.5.0 \ |
| 76 | crate://crates.io/x509-parser/0.6.5 \ |
| 77 | crate://crates.io/der-parser/4.1.0 \ |
| 78 | crate://crates.io/snmp-parser/0.6.0 \ |
| 79 | crate://crates.io/kerberos-parser/0.5.0 \ |
| 80 | crate://crates.io/wasi/0.10.0+wasi-snapshot-preview1 \ |
| 81 | crate://crates.io/winapi/0.3.9 \ |
| 82 | crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \ |
| 83 | crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \ |
| 84 | crate://crates.io/log/0.4.0 \ |
| 85 | crate://crates.io/rand_hc/0.2.0 \ |
| 86 | crate://crates.io/wasi/0.9.0+wasi-snapshot-preview1 \ |
| 87 | " |
| 88 | |
| 89 | # test case support |
| 90 | SRC_URI += " \ |
| 91 | crate://crates.io/test-case/1.0.1 \ |
| 92 | crate://crates.io/proc-macro2/1.0.1 \ |
| 93 | crate://crates.io/quote/1.0.1 \ |
| 94 | crate://crates.io/syn/1.0.1 \ |
| 95 | crate://crates.io/unicode-xid/0.2.0 \ |
| 96 | " |
| 97 | |
| 98 | inherit autotools pkgconfig python3native systemd ptest cargo |
| 99 | |
| 100 | EXTRA_OECONF += " --disable-debug \ |
| 101 | --disable-gccmarch-native \ |
| 102 | --enable-non-bundled-htp \ |
| 103 | --disable-suricata-update \ |
| 104 | --with-libhtp-includes=${STAGING_INCDIR} --with-libhtp-libraries=${STAGING_LIBDIR} \ |
| 105 | " |
| 106 | |
| 107 | CARGO_SRC_DIR = "rust" |
| 108 | |
| 109 | B = "${S}" |
| 110 | |
| 111 | PACKAGECONFIG ??= "jansson file pcre yaml python pcap cap-ng net nfnetlink nss nspr " |
| 112 | PACKAGECONFIG_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'unittests', '', d)}" |
| 113 | |
| 114 | PACKAGECONFIG[pcre] = "--with-libpcre-includes=${STAGING_INCDIR} --with-libpcre-libraries=${STAGING_LIBDIR}, ,libpcre ," |
| 115 | PACKAGECONFIG[yaml] = "--with-libyaml-includes=${STAGING_INCDIR} --with-libyaml-libraries=${STAGING_LIBDIR}, ,libyaml ," |
| 116 | PACKAGECONFIG[pcap] = "--with-libpcap-includes=${STAGING_INCDIR} --with-libpcap-libraries=${STAGING_LIBDIR}, ,libpcap" |
| 117 | PACKAGECONFIG[cap-ng] = "--with-libcap_ng-includes=${STAGING_INCDIR} --with-libcap_ng-libraries=${STAGING_LIBDIR}, ,libcap-ng , " |
| 118 | PACKAGECONFIG[net] = "--with-libnet-includes=${STAGING_INCDIR} --with-libnet-libraries=${STAGING_LIBDIR}, , libnet," |
| 119 | PACKAGECONFIG[nfnetlink] = "--with-libnfnetlink-includes=${STAGING_INCDIR} --with-libnfnetlink-libraries=${STAGING_LIBDIR}, ,libnfnetlink ," |
| 120 | PACKAGECONFIG[nfq] = "--enable-nfqueue, --disable-nfqueue,libnetfilter-queue," |
| 121 | |
| 122 | PACKAGECONFIG[jansson] = "--with-libjansson-includes=${STAGING_INCDIR} --with-libjansson-libraries=${STAGING_LIBDIR},,jansson, jansson" |
| 123 | PACKAGECONFIG[file] = ",,file, file" |
| 124 | PACKAGECONFIG[nss] = "--with-libnss-includes=${STAGING_INCDIR} --with-libnss-libraries=${STAGING_LIBDIR}, nss, nss," |
| 125 | PACKAGECONFIG[nspr] = "--with-libnspr-includes=${STAGING_INCDIR} --with-libnspr-libraries=${STAGING_LIBDIR}, nspr, nspr," |
| 126 | PACKAGECONFIG[python] = "--enable-python, --disable-python, python3, python3-core" |
| 127 | PACKAGECONFIG[unittests] = "--enable-unittests, --disable-unittests," |
| 128 | |
| 129 | export logdir = "${localstatedir}/log" |
| 130 | |
| 131 | CACHED_CONFIGUREVARS = "ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes" |
| 132 | |
| 133 | do_configure_prepend () { |
| 134 | oe_runconf |
| 135 | } |
| 136 | |
| 137 | do_compile () { |
| 138 | # we do this to bypass the make provided by this pkg |
| 139 | # patches Makefile to skip the subdir |
| 140 | cargo_do_compile |
| 141 | |
| 142 | # Finish building |
| 143 | cd ${S} |
| 144 | make |
| 145 | } |
| 146 | |
| 147 | do_install () { |
| 148 | install -d ${D}${sysconfdir}/suricata |
| 149 | |
| 150 | oe_runmake install DESTDIR=${D} |
| 151 | |
| 152 | install -d ${D}${sysconfdir}/suricata ${D}${sysconfdir}/default/volatiles |
| 153 | install -m 0644 ${WORKDIR}/volatiles.03_suricata ${D}${sysconfdir}/default/volatiles/03_suricata |
| 154 | |
| 155 | install -m 0644 ${S}/threshold.config ${D}${sysconfdir}/suricata |
| 156 | install -m 0644 ${S}/suricata.yaml ${D}${sysconfdir}/suricata |
| 157 | |
| 158 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then |
| 159 | install -d ${D}${sysconfdir}/tmpfiles.d |
| 160 | install -m 0644 ${WORKDIR}/tmpfiles.suricata ${D}${sysconfdir}/tmpfiles.d/suricata.conf |
| 161 | |
| 162 | install -d ${D}${systemd_unitdir}/system |
| 163 | sed -e s:/etc:${sysconfdir}:g \ |
| 164 | -e s:/var/run:/run:g \ |
| 165 | -e s:/var:${localstatedir}:g \ |
| 166 | -e s:/usr/bin:${bindir}:g \ |
| 167 | -e s:/bin/kill:${base_bindir}/kill:g \ |
| 168 | -e s:/usr/lib:${libdir}:g \ |
| 169 | ${WORKDIR}/suricata.service > ${D}${systemd_unitdir}/system/suricata.service |
| 170 | fi |
| 171 | |
| 172 | # Remove /var/run as it is created on startup |
| 173 | rm -rf ${D}${localstatedir}/run |
| 174 | |
| 175 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${bindir}/suricatasc |
| 176 | sed -i -e "s:#!.*$:#!${USRBINPATH}/env ${PYTHON_PN}:g" ${D}${bindir}/suricatactl |
| 177 | } |
| 178 | |
| 179 | pkg_postinst_ontarget_${PN} () { |
| 180 | if command -v systemd-tmpfiles >/dev/null; then |
| 181 | systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/suricata.conf |
| 182 | elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then |
| 183 | ${sysconfdir}/init.d/populate-volatile.sh update |
| 184 | fi |
| 185 | } |
| 186 | |
| 187 | SYSTEMD_PACKAGES = "${PN}" |
| 188 | |
| 189 | PACKAGES =+ "${PN}-python" |
| 190 | FILES_${PN} += "${systemd_unitdir} ${sysconfdir}/tmpfiles.d" |
| 191 | FILES_${PN}-python = "${bindir}/suricatasc ${PYTHON_SITEPACKAGES_DIR}" |
| 192 | |
| 193 | CONFFILES_${PN} = "${sysconfdir}/suricata/suricata.yaml" |