blob: 550fbc30d34f5466a2716c459c352ee954e429fb [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001SUMMARY = "mongodb"
2LICENSE = "SSPL-1 & Apache-2.0 & Zlib"
3LIC_FILES_CHKSUM = "file://LICENSE-Community.txt;md5=3a865f27f11f43ecbe542d9ea387dcf1 \
4 file://APACHE-2.0.txt;md5=3b83ef96387f14655fc854ddc3c6bd57"
5
6DEPENDS = "openssl libpcap zlib boost curl python3 \
7 python3-setuptools-native \
8 python3-pyyaml-native python3-cheetah-native \
9 python3-psutil-native python3-regex-native \
10 "
11
Andrew Geisslerd688a012020-09-18 13:36:00 -050012inherit scons dos2unix siteinfo python3native systemd useradd
Andrew Geissler82c905d2020-04-13 13:39:40 -050013
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050014PV = "4.4.19"
Patrick Williams864cc432023-02-09 14:54:44 -060015#v4.4.18
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050016SRCREV = "9a996e0ad993148b9650dc402e6d3b1804ad3b8a"
Andrew Geissler595f6302022-01-24 19:11:47 +000017SRC_URI = "git://github.com/mongodb/mongo.git;branch=v4.4;protocol=https \
Andrew Geissler82c905d2020-04-13 13:39:40 -050018 file://0001-Tell-scons-to-use-build-settings-from-environment-va.patch \
19 file://0001-Use-long-long-instead-of-int64_t.patch \
20 file://0001-Use-__GLIBC__-to-control-use-of-gnu_get_libc_version.patch \
21 file://0002-Add-a-definition-for-the-macro-__ELF_NATIVE_CLASS.patch \
22 file://arm64-support.patch \
23 file://0001-IntelRDFPMathLib20U1-Check-for-__DEFINED_wchar_t.patch \
24 file://0001-Support-deprecated-resolver-functions.patch \
25 file://0003-Fix-unknown-prefix-env.patch \
26 file://1296.patch \
Andrew Geisslerd688a012020-09-18 13:36:00 -050027 file://0001-Fix-compilation-with-fno-common.patch \
28 file://0001-stacktrace-Define-ARCH_BITS-for-x86.patch \
Andrew Geissler97771a32021-03-05 15:23:11 -060029 file://0001-include-needed-c-header.patch \
Andrew Geissler32b11992021-03-31 13:37:05 -050030 file://disable_runtime_check.patch \
31 file://ppc64_ARCH_BITS.patch \
Patrick Williams213cb262021-08-07 19:21:33 -050032 file://PTHREAD_STACK_MIN.patch \
Patrick Williams03907ee2022-05-01 06:28:52 -050033 file://0001-add-explict-static_cast-size_t-to-maxMemoryUsageByte.patch \
34 file://0001-server-Adjust-the-cache-alignment-assumptions.patch \
Patrick Williams92b42cb2022-09-03 06:53:57 -050035 file://0001-The-std-lib-unary-binary_function-base-classes-are-d.patch \
Patrick Williams864cc432023-02-09 14:54:44 -060036 file://0001-free_mon-Include-missing-cstdint.patch \
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050037 file://0001-apply-msvc-workaround-for-clang-16.patch \
38 file://0001-Fix-type-mismatch-on-32bit-arches.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050039 "
Patrick Williams213cb262021-08-07 19:21:33 -050040SRC_URI:append:libc-musl ="\
Andrew Geissler82c905d2020-04-13 13:39:40 -050041 file://0001-Mark-one-of-strerror_r-implementation-glibc-specific.patch \
42 file://0002-Fix-default-stack-size-to-256K.patch \
43 file://0004-wiredtiger-Disable-strtouq-on-musl.patch \
Andrew Geissler517393d2023-01-13 08:55:19 -060044 file://0001-wiredtiger-Avoid-using-off64_t.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050045 "
46
Patrick Williams213cb262021-08-07 19:21:33 -050047SRC_URI:append:toolchain-clang = "\
Andrew Geissler82c905d2020-04-13 13:39:40 -050048 file://0001-asio-Dont-use-experimental-with-clang.patch \
49 "
50
51S = "${WORKDIR}/git"
52
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050053CVE_CHECK_IGNORE += "\
54 CVE-2014-8180 \
55 CVE-2017-18381 \
56 CVE-2017-2665 \
57"
58
Andrew Geissler82c905d2020-04-13 13:39:40 -050059COMPATIBLE_HOST ?= '(x86_64|i.86|powerpc64|arm|aarch64).*-linux'
60
61PACKAGECONFIG ??= "tcmalloc system-pcre"
62# gperftools compilation fails for arm below v7 because of missing support of
63# dmb operation. So we use system-allocator instead of tcmalloc
Patrick Williams213cb262021-08-07 19:21:33 -050064PACKAGECONFIG:remove:armv6 = "tcmalloc"
65PACKAGECONFIG:remove:libc-musl = "tcmalloc"
66PACKAGECONFIG:remove:riscv64 = "tcmalloc"
67PACKAGECONFIG:remove:riscv32 = "tcmalloc"
Andrew Geissler82c905d2020-04-13 13:39:40 -050068
69PACKAGECONFIG[tcmalloc] = "--use-system-tcmalloc,--allocator=system,gperftools,"
70PACKAGECONFIG[shell] = ",--js-engine=none,,"
71PACKAGECONFIG[system-pcre] = "--use-system-pcre,,libpcre,"
72
Andrew Geissler32b11992021-03-31 13:37:05 -050073MONGO_ARCH ?= "${HOST_ARCH}"
Patrick Williams213cb262021-08-07 19:21:33 -050074MONGO_ARCH:powerpc64le = "ppc64le"
Andrew Geissler69721092021-07-23 12:57:00 -040075WIREDTIGER ?= "off"
Patrick Williams213cb262021-08-07 19:21:33 -050076WIREDTIGER:x86-64 = "on"
77WIREDTIGER:aarch64 = "on"
Andrew Geissler32b11992021-03-31 13:37:05 -050078
Patrick Williams864cc432023-02-09 14:54:44 -060079# ld.gold: fatal error: build/59f4f0dd/mongo/mongod: Structure needs cleaning
80LDFLAGS:append:x86:libc-musl = " -fuse-ld=bfd"
81LDFLAGS:remove:toolchain-clang = "-fuse-ld=bfd"
82
Andrew Geisslerd688a012020-09-18 13:36:00 -050083EXTRA_OESCONS = "PREFIX=${prefix} \
84 DESTDIR=${D} \
Patrick Williams864cc432023-02-09 14:54:44 -060085 MAXLINELENGTH='2097152' \
Andrew Geissler82c905d2020-04-13 13:39:40 -050086 LIBPATH=${STAGING_LIBDIR} \
87 LINKFLAGS='${LDFLAGS}' \
88 CXXFLAGS='${CXXFLAGS}' \
Andrew Geissler32b11992021-03-31 13:37:05 -050089 TARGET_ARCH=${MONGO_ARCH} \
Andrew Geisslerd688a012020-09-18 13:36:00 -050090 MONGO_VERSION=${PV} \
91 OBJCOPY=${OBJCOPY} \
Andrew Geissler82c905d2020-04-13 13:39:40 -050092 --ssl \
93 --disable-warnings-as-errors \
94 --use-system-zlib \
95 --nostrip \
96 --endian=${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
Andrew Geissler69721092021-07-23 12:57:00 -040097 --wiredtiger='${WIREDTIGER}' \
Andrew Geisslerd688a012020-09-18 13:36:00 -050098 --separate-debug \
99 ${PACKAGECONFIG_CONFARGS}"
100
Andrew Geisslerd688a012020-09-18 13:36:00 -0500101USERADD_PACKAGES = "${PN}"
Patrick Williams213cb262021-08-07 19:21:33 -0500102USERADD_PARAM:${PN} = "--system --no-create-home --home-dir /var/run/${BPN} --shell /bin/false --user-group ${BPN}"
Andrew Geisslerd688a012020-09-18 13:36:00 -0500103
Andrew Geissler82c905d2020-04-13 13:39:40 -0500104scons_do_compile() {
Andrew Geissler595f6302022-01-24 19:11:47 +0000105 ${STAGING_BINDIR_NATIVE}/scons ${PARALLEL_MAKE} ${EXTRA_OESCONS} install-core ||
Andrew Geissler82c905d2020-04-13 13:39:40 -0500106 die "scons build execution failed."
107}
108
109scons_do_install() {
Andrew Geissler595f6302022-01-24 19:11:47 +0000110 # install binaries
111 install -d ${D}${bindir}
112 for i in mongod mongos mongo; do
Patrick Williams864cc432023-02-09 14:54:44 -0600113 if [ -f ${B}/build/*/mongo/$i ]; then
114 install -m 0755 ${B}/build/*/mongo/$i ${D}${bindir}
Andrew Geissler595f6302022-01-24 19:11:47 +0000115 else
116 bbnote "$i does not exist"
117 fi
118 done
Andrew Geisslerd688a012020-09-18 13:36:00 -0500119
Andrew Geissler595f6302022-01-24 19:11:47 +0000120 # install config
121 install -d ${D}${sysconfdir}
122 install -m 0644 ${S}/debian/mongod.conf ${D}${sysconfdir}
Andrew Geisslerd688a012020-09-18 13:36:00 -0500123
Andrew Geissler595f6302022-01-24 19:11:47 +0000124 # install systemd service
125 install -d ${D}${systemd_system_unitdir}
126 install -m 0644 ${S}/debian/mongod.service ${D}${systemd_system_unitdir}
Andrew Geisslerd688a012020-09-18 13:36:00 -0500127
Andrew Geissler595f6302022-01-24 19:11:47 +0000128 # install mongo data folder
129 install -m 755 -d ${D}${localstatedir}/lib/${BPN}
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500130 chown ${BPN}:${BPN} ${D}${localstatedir}/lib/${BPN}
Andrew Geisslerd688a012020-09-18 13:36:00 -0500131
Andrew Geissler595f6302022-01-24 19:11:47 +0000132 # Create /var/log/mongodb in runtime.
133 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}" ]; then
134 install -d ${D}${nonarch_libdir}/tmpfiles.d
135 echo "d ${localstatedir}/log/${BPN} 0755 ${BPN} ${BPN} -" > ${D}${nonarch_libdir}/tmpfiles.d/${BPN}.conf
136 fi
137 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'sysvinit', d)}" ]; then
138 install -d ${D}${sysconfdir}/default/volatiles
139 echo "d ${BPN} ${BPN} 0755 ${localstatedir}/log/${BPN} none" > ${D}${sysconfdir}/default/volatiles/99_${BPN}
140 fi
Andrew Geissler82c905d2020-04-13 13:39:40 -0500141}
Andrew Geisslerd688a012020-09-18 13:36:00 -0500142
Patrick Williams213cb262021-08-07 19:21:33 -0500143CONFFILES:${PN} = "${sysconfdir}/mongod.conf"
Andrew Geisslerd688a012020-09-18 13:36:00 -0500144
Patrick Williams213cb262021-08-07 19:21:33 -0500145SYSTEMD_SERVICE:${PN} = "mongod.service"
Andrew Geissler595f6302022-01-24 19:11:47 +0000146
147FILES:${PN} += "${nonarch_libdir}/tmpfiles.d"