David Stes
2024-03-31 8cdd197ba643eb2608c5aab87567625bb9336cee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"). You may
# only use this file in accordance with the terms of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
 
#
# Copyright 2017 Alexander Pyhalov
# Copyright 2018 Michal Nowak
# Copyright 2021 Andreas Grueninger, Grueninger GmbH, (grueni). All rights reserved.
# Copyright 2021 erwinlem
#
 
# if gcc11 is available use openssl 1.1 and remove OPENSSL* from BUILD_ARGS
 
BUILD_BITS= 64
BUILD_STYLE= justmake
USE_OPENSSL10= yes
 
include ../../../make-rules/shared-macros.mk
 
COMPONENT_NAME=    mongodb
COMPONENT_MAJOR_VERSION= 4.4
COMPONENT_MINOR_VERSION= 15
COMPONENT_VERSION= $(COMPONENT_MAJOR_VERSION).$(COMPONENT_MINOR_VERSION)
COMPONENT_SUMMARY= MongoDB distributed document-oriented database
COMPONENT_PROJECT_URL=    https://www.mongodb.com/
COMPONENT_FMRI=    database/mongodb-44
COMPONENT_CLASSIFICATION= System/Databases
COMPONENT_SRC=        $(COMPONENT_NAME)-src-r$(COMPONENT_VERSION)
COMPONENT_ARCHIVE=    $(COMPONENT_SRC).tar.gz
COMPONENT_ARCHIVE_URL=    https://fastdl.mongodb.org/src/$(COMPONENT_ARCHIVE)
COMPONENT_ARCHIVE_HASH=    sha256:fb7ef14e2539df0addc1e350ad2a0fdb7dd078a60d49ab15d9932f193ea1da33
COMPONENT_LICENSE= SSPL
COMPONENT_LICENSE_FILE=    LICENSE-Community.txt
 
include $(WS_MAKE_RULES)/common.mk
 
BUILD_DIR_TOOLS= $(BUILD_DIR)/tools
BUILD_TOOLS= $(BUILD_DIR_TOOLS)/.built
INSTALL_TOOLS= $(BUILD_DIR_TOOLS)/.installed
 
MONGO_PREFIX=$(USRDIR)/$(COMPONENT_NAME)/$(COMPONENT_MAJOR_VERSION)
 
PYTHON_VERSION= 3.9
GCC_VERSION= 10
GMAKE= scons VERBOSE=1 
CORES= $(shell psrinfo -t)
GOROOT= $(shell go env | grep GOROOT | awk -F= '{ print $$2 }' | tr -d '"')
 
ENV= /usr/bin/env -i
 
COMPONENT_BUILD_ARGS += LIBPATH="$(OPENSSL_PREFIX)/lib/$(MACH64):$(USRLIBDIR.$(BITS))"
COMPONENT_BUILD_ARGS +=    CPPPATH="$(OPENSSL_PREFIX)/include"
COMPONENT_BUILD_ARGS += DESTDIR=$(PROTO_DIR)
COMPONENT_BUILD_ARGS += PREFIX=$(MONGO_PREFIX)
COMPONENT_BUILD_ARGS += TARGET_ARCH=x86_64
COMPONENT_BUILD_ARGS += CC="$(CC)"
COMPONENT_BUILD_ARGS += CXX="$(CXX)"
COMPONENT_BUILD_ARGS += CFLAGS="$(CFLAGS)"
COMPONENT_BUILD_ARGS += CXXFLAGS="$(CXXFLAGS) -fpermissive"
COMPONENT_BUILD_ARGS += LINKFLAGS="$(LDFLAGS) -lkstat"
COMPONENT_BUILD_ARGS += AR=/usr/bin/gar
COMPONENT_BUILD_ARGS += CCFLAGS="-I$(USRINCDIR)/pcre -DSOLARIS"
COMPONENT_BUILD_ARGS += --js-engine=mozjs
COMPONENT_BUILD_ARGS += --use-system-pcre
COMPONENT_BUILD_ARGS += --use-system-zlib
COMPONENT_BUILD_ARGS += --server-js=on
COMPONENT_BUILD_ARGS += --ssl
COMPONENT_BUILD_ARGS += --release
COMPONENT_BUILD_ARGS += --disable-ggdb
COMPONENT_BUILD_ARGS += --disable-warnings-as-errors
COMPONENT_BUILD_ARGS += -j $(CORES)
 
COMPONENT_INSTALL_ARGS = $(COMPONENT_BUILD_ARGS)
 
COMPONENT_BUILD_TARGETS= install-core    
 
# just a dummy for scons
COMPONENT_INSTALL_TARGETS= --version
 
TEST_SUITES += core
TEST_SUITES += dbtest
TEST_SUITES += dur_jscore_passthrough
TEST_SUITES += jstestfuzz
TEST_SUITES += jstestfuzz_replication
TEST_SUITES += jstestfuzz_sharded
TEST_SUITES += replica_sets_jscore_passthrough
TEST_SUITES += unittests
 
# patches must be done before cloney
COMPONENT_PREP_ACTION += \
    $(CP) -r $(COMPONENT_DIR)/files/mozjs-60/solaris  $(SOURCE_DIR)/src/third_party/mozjs-60/platform/x86_64/; \
    cd $(SOURCE_DIR)/src/third_party/mozjs-60/extract; \
    $(GPATCH) $(GPATCH_FLAGS) < $(COMPONENT_DIR)/files/0-gc-memory.patch; \
    $(GPATCH) $(GPATCH_FLAGS) < $(COMPONENT_DIR)/files/0-old-configure.patch; \
    $(GPATCH) $(GPATCH_FLAGS) < $(COMPONENT_DIR)/files/0-wasm-WasmSignalHandlers.patch; 
 
COMPONENT_PRE_BUILD_ACTION += \
 ($(PYTHON) -m pip install -r $(@D)/etc/pip/compile-requirements.txt) 
 
COMPONENT_POST_INSTALL_ACTION += ( \
    $(MKDIR) $(PROTO_DIR)$(MONGO_PREFIX)/man/man1; \
    $(CP) $(BUILD_DIR_64)/debian/*.1  $(PROTO_DIR)$(MONGO_PREFIX)/man/man1/; \
    $(CP) $(BUILD_DIR_64)/debian/mongo{,d,s,ldap,kerberos}.1  $(PROTO_DIR)$(MONGO_PREFIX)/man/man1/; )
 
$(BUILD_TOOLS):    $(BUILD_64)
    ($(MKDIR) $(BUILD_DIR_TOOLS)/src/github.com/mongodb; \
    cd $(BUILD_DIR_TOOLS)/src/github.com/mongodb; \
    git clone https://github.com/mongodb/mongo-tools; \
    cd mongo-tools; \
    git checkout 100.3.1; \
    $(GPATCH) $(GPATCH_FLAGS) < $(COMPONENT_DIR)/files/13-mongotools.patch; \
    GOROOT=$(GOROOT) ./make build)
    $(TOUCH) $(@)
 
$(INSTALL_TOOLS): $(BUILD_TOOLS) $(INSTALL_64)
    $(MKDIR) $(PROTO_DIR)$(MONGO_PREFIX)/bin
    $(CP) $(BUILD_DIR_TOOLS)/src/github.com/mongodb/mongo-tools/bin/* $(PROTO_DIR)$(MONGO_PREFIX)/bin
    $(TOUCH) $(@)
 
# A bit of magic to replace spaces with commas
comma:= ,
empty:=
space:= $(empty) $(empty)
 
COMPONENT_TEST_CMD = $(PYTHON) buildscripts/resmoke.py \
            --continueOnFailure \
            --dbpathPrefix=/tmp/db \
            --suites=$(subst $(space),$(comma),$(TEST_SUITES))
 
COMPONENT_TEST_TARGETS =
 
COMPONENT_TEST_TRANSFORMS +=    '-e "s/\[resmoke\][ -+0-9T:\.\-]*//"' \
                                '-e "s/\s\s*[0-9][0-9]*\.[0-9][0-9]* seconds/ SEC seconds/"' \
                                '-n ' \
                                '-e "/Summary of all suites/,\\$$p"'
 
# Not strictly necessary
$(TEST_64):     $(INSTALL_64) $(INSTALL_TOOLS)
 
build:        $(BUILD_64) $(BUILD_TOOLS)
 
install: $(INSTALL_TOOLS)
 
test:        $(TEST_64)
 
# Test requirements
REQUIRED_PACKAGES += library/python/urllib3-39
 
# Build dependencies
REQUIRED_PACKAGES += developer/gcc-10
REQUIRED_PACKAGES += developer/build/scons
REQUIRED_PACKAGES += developer/golang
REQUIRED_PACKAGES += library/python/psutil
REQUIRED_PACKAGES += library/python/typing
 
# Auto-generated dependencies via `gmake GMAKE=gmake REQUIRED_PACKAGES`
REQUIRED_PACKAGES += $(GCC_RUNTIME_PKG)
REQUIRED_PACKAGES += $(GXX_RUNTIME_PKG)
REQUIRED_PACKAGES += SUNWcs
REQUIRED_PACKAGES += library/security/openssl
REQUIRED_PACKAGES += library/pcre
REQUIRED_PACKAGES += library/zlib
REQUIRED_PACKAGES += system/library
REQUIRED_PACKAGES += system/library/boost
REQUIRED_PACKAGES += system/library/libpcap
REQUIRED_PACKAGES += system/library/math
REQUIRED_PACKAGES += web/curl