Skip to content

Commit 8a4670b

Browse files
authored
PHPC-2011: Upgrade libmongoc to 1.20.0 and libmongocrypt to 1.3.0 (#1279)
* PHPC-2011: Bump libmongocrypt to 1.3.0 * PHPC-2011: Bump libmongoc to 1.20.0 * Script to update submodule sources in config.m4 and config.w32
1 parent 36f6ce0 commit 8a4670b

File tree

9 files changed

+75
-18
lines changed

9 files changed

+75
-18
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ reflect the new sources and/or package version.
136136
```
137137
$ cd src/libmongoc
138138
$ git fetch
139-
$ git checkout 1.15.0
139+
$ git checkout 1.20.0
140140
```
141141

142142
During development, it may be necessary to temporarily point the libmongoc
@@ -175,9 +175,10 @@ collectively enumerate all of the the sources within the libmongoc submodule to
175175
include in a bundled build.
176176

177177
These variables should each have a shell command in a preceding comment, which
178-
should be run to regenerate that particular list of source files. In the event
179-
that either libmongoc or libbson introduce a new source directory, that will
180-
need to be manually added (follow prior art).
178+
should be run to regenerate that particular list of source files. Each command
179+
may be run manually or `scripts/update-submodule-sources.php` may be used to
180+
update all variables. In the event that either libmongoc or libbson introduce a
181+
new source directory, that will need to be manually added (follow prior art).
181182

182183
#### Update package dependencies
183184

@@ -189,11 +190,11 @@ error message in the `pkg-config` blocks for both libmongoc and libbson.
189190
For example, the following lines might be updated for libmongoc:
190191

191192
```
192-
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.15.0; then
193+
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.20.0; then
193194
194195
...
195196
196-
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.15.0)
197+
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.20.0)
197198
```
198199

199200
#### Update tested versions in Evergreen configuration
@@ -221,7 +222,7 @@ and by ensuring that the test suite passes. Once done, commit the changes to all
221222
of the above files/paths. For example:
222223

223224
```
224-
$ git commit -m "Bump libmongoc to 1.15.0" config.m4 config.w32 src/libmongoc src/LIBMONGOC_VERSION_CURRENT
225+
$ git commit -m "Bump libmongoc to 1.20.0" config.m4 config.w32 src/libmongoc src/LIBMONGOC_VERSION_CURRENT
225226
```
226227

227228
### Updating libmongocrypt
@@ -231,12 +232,13 @@ To update libmongocrypt, the steps are similar to the above:
231232
```
232233
$ cd src/libmongocrypt
233234
$ git fetch
234-
$ git checkout 1.0.1
235+
$ git checkout 1.3.0
235236
$ make libmongocrypt-version-current
236237
```
237238

238-
Package dependencies in `config.m4` must also be updated, as do the sources in
239-
the PECL generation script.
239+
Package dependencies in `config.m4` must also be updated (either manually or
240+
with `scripts/update-submodule-sources.php`), as do the sources in the PECL
241+
generation script.
240242

241243
## Releasing
242244

config.m4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ if test "$PHP_MONGODB" != "no"; then
338338
dnl This include modifies the value of $PHP_MONGODB_CLIENT_SIDE_ENCRYPTION to "yes"
339339
dnl or "no" depending on whether dependencies for libmongocrypt are fulfilled
340340
_include([scripts/autotools/libmongocrypt/CheckSSL.m4])
341+
_include([scripts/autotools/libmongocrypt/Endian.m4])
341342
_include([scripts/autotools/libmongocrypt/Version.m4])
342343

343344
PHP_MONGODB_BSON_VERSION_STRING="Bundled ($BSON_VERSION)"
@@ -443,7 +444,7 @@ if test "$PHP_MONGODB" != "no"; then
443444
AC_SUBST(MONGOCRYPT_ENABLE_TRACE, 1)
444445

445446
dnl Generated with: find src/libmongocrypt/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 4- | sort -dz | tr '\000' ' '
446-
PHP_MONGODB_MONGOCRYPT_SOURCES="mongocrypt-binary.c mongocrypt-buffer.c mongocrypt.c mongocrypt-cache.c mongocrypt-cache-collinfo.c mongocrypt-cache-key.c mongocrypt-cache-oauth.c mongocrypt-ciphertext.c mongocrypt-crypto.c mongocrypt-ctx.c mongocrypt-ctx-datakey.c mongocrypt-ctx-decrypt.c mongocrypt-ctx-encrypt.c mongocrypt-endpoint.c mongocrypt-kek.c mongocrypt-key-broker.c mongocrypt-key.c mongocrypt-kms-ctx.c mongocrypt-log.c mongocrypt-marking.c mongocrypt-opts.c mongocrypt-status.c mongocrypt-traverse-util.c"
447+
PHP_MONGODB_MONGOCRYPT_SOURCES="mongocrypt-binary.c mongocrypt-buffer.c mongocrypt.c mongocrypt-cache.c mongocrypt-cache-collinfo.c mongocrypt-cache-key.c mongocrypt-cache-oauth.c mongocrypt-ciphertext.c mongocrypt-crypto.c mongocrypt-ctx.c mongocrypt-ctx-datakey.c mongocrypt-ctx-decrypt.c mongocrypt-ctx-encrypt.c mongocrypt-endpoint.c mongocrypt-kek.c mongocrypt-key-broker.c mongocrypt-key.c mongocrypt-kms-ctx.c mongocrypt-log.c mongocrypt-marking.c mongocrypt-opts.c mongocrypt-status.c mongocrypt-traverse-util.c mongocrypt-util.c"
447448

448449
dnl Generated with: find src/libmongocrypt/src/crypto -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
449450
PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES="cng.c commoncrypto.c libcrypto.c none.c"
@@ -455,7 +456,7 @@ if test "$PHP_MONGODB" != "no"; then
455456
PHP_MONGODB_MONGOCRYPT_OS_WIN_SOURCES="os_mutex.c os_once.c"
456457

457458
dnl Generated with: find src/libmongocrypt/kms-message/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
458-
PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES="hexlify.c kms_azure_request.c kms_b64.c kms_caller_identity_request.c kms_crypto_apple.c kms_crypto_libcrypto.c kms_crypto_none.c kms_crypto_windows.c kms_decrypt_request.c kms_encrypt_request.c kms_gcp_request.c kms_kv_list.c kms_message.c kms_port.c kms_request.c kms_request_opt.c kms_request_str.c kms_response.c kms_response_parser.c sort.c"
459+
PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES="hexlify.c kms_azure_request.c kms_b64.c kms_caller_identity_request.c kms_crypto_apple.c kms_crypto_libcrypto.c kms_crypto_none.c kms_crypto_windows.c kms_decrypt_request.c kms_encrypt_request.c kms_gcp_request.c kms_kmip_reader_writer.c kms_kmip_request.c kms_kmip_response.c kms_kmip_response_parser.c kms_kv_list.c kms_message.c kms_port.c kms_request.c kms_request_opt.c kms_request_str.c kms_response.c kms_response_parser.c sort.c"
459460

460461
PHP_MONGODB_LIBMONGOCRYPT_CFLAGS="$PHP_MONGODB_BUNDLED_CFLAGS $PHP_MONGODB_LIBMONGOCRYPT_CFLAGS"
461462
PHP_MONGODB_ADD_SOURCES([src/libmongocrypt/src/], $PHP_MONGODB_MONGOCRYPT_SOURCES, $PHP_MONGODB_LIBMONGOCRYPT_CFLAGS)

config.w32

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ if (PHP_MONGODB != "no") {
264264
if (PHP_MONGODB_CLIENT_SIDE_ENCRYPTION != "no" && mongoc_ssl_found) {
265265
mongoc_opts.MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION = 1;
266266

267+
ADD_FLAG("CFLAGS_MONGODB", "/D KMS_MESSAGE_LITTLE_ENDIAN=1");
267268
ADD_FLAG("CFLAGS_MONGODB", "/I" + configure_module_dirname + "/src/libmongocrypt/src");
268269
ADD_FLAG("CFLAGS_MONGODB", "/I" + configure_module_dirname + "/src/libmongocrypt/kms-message/src");
269270
ADD_FLAG("CFLAGS_MONGODB", "/I" + configure_module_dirname + "/src/libmongocrypt-compat");
@@ -279,7 +280,7 @@ if (PHP_MONGODB != "no") {
279280
};
280281

281282
// Generated with: find src/libmongocrypt/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 4- | sort -dz | tr '\000' ' '
282-
var PHP_MONGODB_MONGOCRYPT_SOURCES="mongocrypt-binary.c mongocrypt-buffer.c mongocrypt.c mongocrypt-cache.c mongocrypt-cache-collinfo.c mongocrypt-cache-key.c mongocrypt-cache-oauth.c mongocrypt-ciphertext.c mongocrypt-crypto.c mongocrypt-ctx.c mongocrypt-ctx-datakey.c mongocrypt-ctx-decrypt.c mongocrypt-ctx-encrypt.c mongocrypt-endpoint.c mongocrypt-kek.c mongocrypt-key-broker.c mongocrypt-key.c mongocrypt-kms-ctx.c mongocrypt-log.c mongocrypt-marking.c mongocrypt-opts.c mongocrypt-status.c mongocrypt-traverse-util.c";
283+
var PHP_MONGODB_MONGOCRYPT_SOURCES="mongocrypt-binary.c mongocrypt-buffer.c mongocrypt.c mongocrypt-cache.c mongocrypt-cache-collinfo.c mongocrypt-cache-key.c mongocrypt-cache-oauth.c mongocrypt-ciphertext.c mongocrypt-crypto.c mongocrypt-ctx.c mongocrypt-ctx-datakey.c mongocrypt-ctx-decrypt.c mongocrypt-ctx-encrypt.c mongocrypt-endpoint.c mongocrypt-kek.c mongocrypt-key-broker.c mongocrypt-key.c mongocrypt-kms-ctx.c mongocrypt-log.c mongocrypt-marking.c mongocrypt-opts.c mongocrypt-status.c mongocrypt-traverse-util.c mongocrypt-util.c";
283284

284285
// Generated with: find src/libmongocrypt/src/crypto -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
285286
var PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES="cng.c commoncrypto.c libcrypto.c none.c";
@@ -291,7 +292,7 @@ if (PHP_MONGODB != "no") {
291292
var PHP_MONGODB_MONGOCRYPT_OS_WIN_SOURCES="os_mutex.c os_once.c";
292293

293294
// Generated with: find src/libmongocrypt/kms-message/src -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f 5- | sort -dz | tr '\000' ' '
294-
var PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES="hexlify.c kms_azure_request.c kms_b64.c kms_caller_identity_request.c kms_crypto_apple.c kms_crypto_libcrypto.c kms_crypto_none.c kms_crypto_windows.c kms_decrypt_request.c kms_encrypt_request.c kms_gcp_request.c kms_kv_list.c kms_message.c kms_port.c kms_request.c kms_request_opt.c kms_request_str.c kms_response.c kms_response_parser.c sort.c";
295+
var PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES="hexlify.c kms_azure_request.c kms_b64.c kms_caller_identity_request.c kms_crypto_apple.c kms_crypto_libcrypto.c kms_crypto_none.c kms_crypto_windows.c kms_decrypt_request.c kms_encrypt_request.c kms_gcp_request.c kms_kmip_reader_writer.c kms_kmip_request.c kms_kmip_response.c kms_kmip_response_parser.c kms_kv_list.c kms_message.c kms_port.c kms_request.c kms_request_opt.c kms_request_str.c kms_response.c kms_response_parser.c sort.c";
295296

296297
MONGODB_ADD_SOURCES("/src/libmongocrypt/src", PHP_MONGODB_MONGOCRYPT_SOURCES);
297298
MONGODB_ADD_SOURCES("/src/libmongocrypt/src/crypto", PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
AC_C_BIGENDIAN
2+
if test "x$ac_cv_c_bigendian" = "xyes"; then
3+
PHP_MONGODB_BUNDLED_CFLAGS="$PHP_MONGODB_BUNDLED_CFLAGS -DKMS_MESSAGE_BIG_ENDIAN=1"
4+
else
5+
PHP_MONGODB_BUNDLED_CFLAGS="$PHP_MONGODB_BUNDLED_CFLAGS -DKMS_MESSAGE_LITTLE_ENDIAN=1"
6+
fi

scripts/update-submodule-sources.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
$cmd = "find %s -maxdepth 1 -name '*.c' -print0 | cut -sz -d / -f %d- | sort -dz | tr '\\000' ' '";
4+
5+
$vars = [
6+
'PHP_MONGODB_COMMON_SOURCES' => 'src/libmongoc/src/common',
7+
'PHP_MONGODB_KMS_MESSAGE_SOURCES' => 'src/libmongoc/src/kms-message/src',
8+
'PHP_MONGODB_BSON_SOURCES' => 'src/libmongoc/src/libbson/src/bson',
9+
'PHP_MONGODB_JSONSL_SOURCES' => 'src/libmongoc/src/libbson/src/jsonsl',
10+
'PHP_MONGODB_MONGOC_SOURCES' => 'src/libmongoc/src/libmongoc/src/mongoc',
11+
'PHP_MONGODB_ZLIB_SOURCES' => 'src/libmongoc/src/zlib-1.2.11',
12+
'PHP_MONGODB_MONGOCRYPT_SOURCES' => 'src/libmongocrypt/src',
13+
'PHP_MONGODB_MONGOCRYPT_CRYPTO_SOURCES' => 'src/libmongocrypt/src/crypto',
14+
'PHP_MONGODB_MONGOCRYPT_OS_POSIX_SOURCES' => 'src/libmongocrypt/src/os_posix',
15+
'PHP_MONGODB_MONGOCRYPT_OS_WIN_SOURCES' => 'src/libmongocrypt/src/os_win',
16+
'PHP_MONGODB_MONGOCRYPT_KMS_MESSAGE_SOURCES' => 'src/libmongocrypt/kms-message/src',
17+
];
18+
19+
$patterns = [];
20+
$replacements = [];
21+
22+
foreach ($vars as $var => $path) {
23+
$cutNth = 2 + substr_count($path, '/');
24+
25+
$files = trim(shell_exec(sprintf($cmd, $path, $cutNth)));
26+
27+
$patterns[] = sprintf('/(%s=")([^"]*)(";?)/', $var);
28+
$replacements[] = '$1' . $files . '$3';
29+
}
30+
31+
$files = [
32+
realpath(__DIR__ . '/../config.m4') => count($patterns),
33+
// config.w32 does not use PHP_MONGODB_ZLIB_SOURCES (PHPC-1111)
34+
realpath(__DIR__ . '/../config.w32') => count($patterns) - 1,
35+
];
36+
37+
foreach ($files as $file => $expectedCount) {
38+
$replaced = preg_replace($patterns, $replacements, file_get_contents($file), 1, $count);
39+
40+
if ($count !== $expectedCount) {
41+
fprintf(STDERR, "Skipping %s: Expected %d replacements but only matched %d\n", basename($file), $expectedCount, $count);
42+
continue;
43+
}
44+
45+
printf("Updated %s\n", basename($file));
46+
file_put_contents($file, $replaced);
47+
}

src/LIBMONGOCRYPT_VERSION_CURRENT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.1
1+
1.3.0

src/LIBMONGOC_VERSION_CURRENT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.11.1-20211103+gitb93e345178
1+
1.20.0

src/libmongoc

Submodule libmongoc updated 128 files

src/libmongocrypt

Submodule libmongocrypt updated 146 files

0 commit comments

Comments
 (0)