Added
Link Here
|
1 |
PORTNAME= mongosh |
2 |
DISTVERSIONPREFIX= v |
3 |
DISTVERSION= 2.2.5 |
4 |
CATEGORIES= databases shells net |
5 |
MASTER_SITES= https://registry.npmjs.org/mongodb-client-encryption/-/:mongocrypt \ |
6 |
https://registry.npmjs.org/kerberos/-/:kerberos \ |
7 |
https://registry.npmjs.org/os-dns-native/-/:dns \ |
8 |
https://github.com/${GH_ACCOUNT}/${PORTNAME}/releases/download/${DISTVERSIONFULL}/:modules |
9 |
# https://nodejs.org/dist/latest-v${NODEJS_VERSION}.x/:node |
10 |
DISTFILES= mongodb-client-encryption-${MONGO_CRYPT_VER}.tgz:mongocrypt \ |
11 |
kerberos-${KERBEROS_VER}.tgz:kerberos \ |
12 |
os-dns-native-${OSDNSNATIVE_VER}.tgz:dns \ |
13 |
${NODE_MODULES_TARBALL}:modules \ |
14 |
# ${NODEJS_TARBALL}:node \ |
15 |
# SHASUMS256.txt:node |
16 |
DIST_SUBDIR= ${PORTNAME} |
17 |
EXTRACT_ONLY= ${DISTFILE_DEFAULT} |
18 |
|
19 |
MAINTAINER= fabien.amelinck+freebsd@advens.fr |
20 |
COMMENT= MongoDB Shell CLI REPL |
21 |
WWW= https://github.com/mongodb-js/mongosh/ |
22 |
|
23 |
LICENSE= APACHE20 |
24 |
|
25 |
FETCH_DEPENDS= npm${NODEJS_SUFFIX}>0:www/npm${NODEJS_SUFFIX} |
26 |
BUILD_DEPENDS= bash>0:shells/bash \ |
27 |
brotli>=1.0.9,1:archivers/brotli \ |
28 |
c-ares>=1.17.2:dns/c-ares \ |
29 |
libnghttp2>=1.45.1:www/libnghttp2 \ |
30 |
libuv>=1.42.0:devel/libuv \ |
31 |
objdump:devel/binutils \ |
32 |
git>0:devel/git \ |
33 |
${PREFIX}/include/gssapi/gssapi_generic.h:security/krb5 |
34 |
RUN_DEPENDS= ca_root_nss>=0:security/ca_root_nss |
35 |
LIB_DEPENDS= libmongocrypt.so:databases/libmongocrypt \ |
36 |
libbrotlidec.so:archivers/brotli \ |
37 |
libcares.so:dns/c-ares \ |
38 |
libnghttp2.so:www/libnghttp2 \ |
39 |
libuv.so:devel/libuv |
40 |
|
41 |
USES= compiler:c++11-lib gmake localbase pkgconfig nodejs:20,build python:build ssl |
42 |
|
43 |
USE_GITHUB= yes |
44 |
GH_ACCOUNT= VultureProject |
45 |
GH_PROJECT= mongosh |
46 |
|
47 |
MPROTECT_DISABLE= bin/mongosh |
48 |
|
49 |
CXXFLAGS+= -DNODE_API_EXPERIMENTAL \ |
50 |
-DNODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT |
51 |
|
52 |
CUSTOM_ENV= SEGMENT_API_KEY=dummy BUILD_TYPE=dynamic |
53 |
CONFIGURE_ENV= ${CUSTOM_ENV} |
54 |
MAKE_ENV= ${CUSTOM_ENV} \ |
55 |
NODE_JS_VERSION=file://${_DISTDIR}/${NODEJS_TARBALL} \ |
56 |
BOXEDNODE_CONFIGURE_ARGS="--shared-brotli,--shared-cares,--shared-libuv,--shared-nghttp2,--shared-zlib,--shared-openssl,--openssl-use-def-ca-store,--without-npm" |
57 |
REINPLACE_ARGS= -i '' |
58 |
|
59 |
MONGO_CRYPT_VER=6.0.0 |
60 |
KERBEROS_VER= 2.1.0 |
61 |
OSDNSNATIVE_VER=1.2.0 |
62 |
NODE_MODULES_DIR= ${WRKSRC}/node_modules |
63 |
NODE_MODULES_TARBALL= ${PORTNAME}-${DISTVERSIONFULL}-node-modules.tar.xz |
64 |
NPM_CACHE_DIR= /tmp/.npm |
65 |
NODEJS_TARBALL= node-v${NODEJS_PORTVERSION}.tar.gz |
66 |
|
67 |
post-fetch: |
68 |
.if !exists(/tmp/checkpoint) |
69 |
${FETCH_CMD} -o ${_DISTDIR} https://nodejs.org/dist/v${NODEJS_PORTVERSION}/${NODEJS_TARBALL} |
70 |
${FETCH_CMD} -o ${_DISTDIR} https://nodejs.org/dist/v${NODEJS_PORTVERSION}/SHASUMS256.txt |
71 |
${TOUCH} /tmp/checkpoint |
72 |
.endif |
73 |
|
74 |
post-extract: |
75 |
.if !exists(${NODE_MODULES_DIR}) |
76 |
${TAR} -xzf /${_DISTDIR}/${NODE_MODULES_TARBALL} -C ${WRKSRC} |
77 |
${REINPLACE_CMD} -e "s/'make'/'gmake'/g" \ |
78 |
-e "s/'V='/'V=0'/g" \ |
79 |
-e 's/(await (0, nv_1.default)(range)).pop()/{"version": "${NODEJS_PORTVERSION}"}/g' \ |
80 |
-e "s|\$${releaseBaseUrl}/\(SHASUMS256.txt\)|${_DISTDIR}/\1|g" \ |
81 |
-e 's/await (0, node_fetch_1.default)(shaSumsUrl)/{"ok":1}/g' \ |
82 |
-e "s/shaSums.text()/fs_1.promises.readFile(shaSumsUrl, 'utf8')/g" \ |
83 |
-e "s/catch (_a) { }/catch (_a) { console.error(_a) }/g" \ |
84 |
${NODE_MODULES_DIR}/boxednode/lib/index.js |
85 |
${GREP} -A20 "const shaSumsUrl" ${NODE_MODULES_DIR}/boxednode/lib/index.js |
86 |
${REINPLACE_CMD} -e "s|\('install',\) \('--ignore-scripts'\)|\1 '--offline', '--cache ${NPM_CACHE_DIR}', \2|g" \ |
87 |
${NODE_MODULES_DIR}/boxednode/lib/native-addons.js |
88 |
${GREP} "ignore-scripts" ${NODE_MODULES_DIR}/boxednode/lib/native-addons.js |
89 |
.endif |
90 |
|
91 |
post-patch: |
92 |
${FIND} ${WRKSRC}/scripts -name "*.orig" -delete |
93 |
${CP} -v ${FILESDIR}/node-patches/* ${WRKSRC}/scripts/nodejs-patches |
94 |
|
95 |
do-configure: |
96 |
.for module in mongodb-client-encryption kerberos os-dns-native |
97 |
cd ${NODE_MODULES_DIR}/${module} && ${CONFIGURE_ENV} node-gyp configure --nodedir=${LOCALBASE} |
98 |
.endfor |
99 |
|
100 |
do-build: |
101 |
.for module in mongodb-client-encryption kerberos os-dns-native |
102 |
cd ${NODE_MODULES_DIR}/${module} && ${MAKE_ENV} ${MAKE_CMD} BUILDTYPE=Release -C build -d |
103 |
.endfor |
104 |
${REINPLACE_CMD} 's/"version": "0.0.0-dev.0"/"version": "${DISTVERSION}"/g' ${WRKSRC}/packages/cli-repl/package.json |
105 |
cd ${WRKSRC} && ${MAKE_ENV} /usr/local/bin/npm run compile-exec |
106 |
|
107 |
do-install: |
108 |
${INSTALL_PROGRAM} ${WRKSRC}/dist/mongosh ${STAGEDIR}${PREFIX}/bin |
109 |
|
110 |
npm-pkg-list: extract |
111 |
${GREP} registry.npmjs.org ${WRKSRC}/package-lock.json | \ |
112 |
| ${SED} -E 's/^[[:space:]]+//g' \ |
113 |
| ${SED} -E 's#^.*org/|.tgz",##g' \ |
114 |
| ${SORT} \ |
115 |
| /usr/bin/uniq \ |
116 |
| ${SED} -E 's/(.*)-([^-])/\1@\2/g' \ |
117 |
| ${SED} -E 's|/-/.*@|@|g' \ |
118 |
> ${FILESDIR}/npm-pkg.list |
119 |
|
120 |
.for module in mongodb-client-encryption kerberos os-dns-native mongodb-crypt-library-version glibc-version |
121 |
cd ${NODE_MODULES_DIR}/${module} && /usr/local/bin/npm list 2>/dev/null \ |
122 |
| ${GREP} UNMET \ |
123 |
| ${AWK} 'BEGIN{FS="UNMET DEPENDENCY "}{print $$2}' \ |
124 |
> ${FILESDIR}/npm-pkg-${module}.list |
125 |
.endfor |
126 |
|
127 |
node-modules-archive: build |
128 |
${RM} -R ${NODE_MODULES_DIR} |
129 |
.for module in mongodb-client-encryption kerberos os-dns-native |
130 |
${MKDIR} -v ${NODE_MODULES_DIR}/${module} |
131 |
${TAR} -xzf ${_DISTDIR}/${module}-*.tgz -C ${NODE_MODULES_DIR}/${module} --strip-components 1 |
132 |
.endfor |
133 |
for f in ${FILESDIR}/node-modules-patches/*; do patch -N -d ${WRKSRC} < $$f; done |
134 |
|
135 |
cd ${WRKSRC} && npx cross-env PUPPETEER_SKIP_DOWNLOAD=1 /usr/local/bin/npm install --cache ${NPM_CACHE_DIR} |
136 |
|
137 |
.for module in mongodb-client-encryption kerberos os-dns-native mongodb-crypt-library-version glibc-version |
138 |
/usr/local/bin/npm cache add $$(cat ${FILESDIR}/npm-pkg-${module}.list) --cache ${NPM_CACHE_DIR} || true |
139 |
cd ${NODE_MODULES_DIR}/${module} && ${CONFIGURE_ENV} /usr/local/bin/npm install --ignore-scripts --cache ${NPM_CACHE_DIR} |
140 |
.endfor |
141 |
${FIND} ${WRKSRC} -name "*.orig" -or -name "*.bak" -delete |
142 |
|
143 |
cd ${WRKSRC} && ${TAR} -cJf /tmp/${NODE_MODULES_TARBALL} node_modules |
144 |
|
145 |
.include <bsd.port.mk> |
146 |
.include "${PORTSDIR}/www/node${NODEJS_VERSION}/Makefile.version" |