Skip to content

Commit 0001642

Browse files
committed
Add /update-submodule command and fix update-sbom.sh TTY flag
1 parent dfd3cfc commit 0001642

3 files changed

Lines changed: 72 additions & 2 deletions

File tree

.claude/CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ Each class is implemented as a pair of `.c` / `.h` files (and a `.stub.php` for
9191
- `src/libmongoc` – mongo-c-driver (includes libbson)
9292
- `src/libmongocrypt` – client-side encryption library
9393

94-
Build configurations (`config.m4` for Autotools, `config.w32` for Windows) enumerate all bundled source files. When updating a submodule, run `scripts/update-submodule-sources.php` to regenerate these lists and update version checks in both files.
94+
Build configurations (`config.m4` for Autotools, `config.w32` for Windows) enumerate all bundled source files.
95+
Use the `/update-submodule` command when updating a submodule.
9596

9697
### Test Format (PHPT)
9798

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Update a bundled C library submodule to a new version and apply all required changes.
2+
3+
Arguments: `$ARGUMENTS``libmongoc <version>` or `libmongocrypt <version>`, e.g. `libmongocrypt 1.17.3`
4+
5+
Current state:
6+
- libmongoc: !`cat src/libmongoc/VERSION_CURRENT 2>/dev/null || echo "(unknown)"`
7+
- libmongocrypt: !`cat src/LIBMONGOCRYPT_VERSION_CURRENT 2>/dev/null || echo "(unknown)"`
8+
9+
## Steps to perform
10+
11+
### 1. Update the submodule pointer
12+
13+
Fetch tags and checkout the requested version tag:
14+
15+
```bash
16+
git -C src/<submodule> fetch --tags
17+
git -C src/<submodule> checkout <version>
18+
```
19+
20+
Verify with `git submodule status src/<submodule>`.
21+
22+
### 2. Regenerate source lists
23+
24+
```bash
25+
php scripts/update-submodule-sources.php
26+
```
27+
28+
This updates `config.m4` and `config.w32` with the current list of C source files.
29+
30+
### 3. Update pkg-config version requirements in config.m4
31+
32+
Read `config.m4` and update the minimum version in the `PKG_CHECK_MODULES` call(s):
33+
34+
- **libmongoc**: update `bson2 >= X.Y.Z` and `mongoc2 >= X.Y.Z`
35+
- **libmongocrypt**: update `libmongocrypt >= X.Y.Z`
36+
37+
Also update the corresponding `AC_MSG_ERROR` messages.
38+
39+
### 4. Update LIBMONGOCRYPT_VERSION_CURRENT (libmongocrypt only)
40+
41+
For libmongocrypt updates, update `src/LIBMONGOCRYPT_VERSION_CURRENT` with the new version string.
42+
43+
### 5. Update the SBOM
44+
45+
The SBOM requires Docker. Start colima if not running:
46+
47+
```bash
48+
colima status 2>/dev/null | grep -q "Running" || colima start
49+
```
50+
51+
Then generate the updated SBOM:
52+
53+
```bash
54+
bash scripts/update-sbom.sh
55+
```
56+
57+
This updates `sbom.json` using the versions in `src/libmongoc/VERSION_CURRENT` and `src/LIBMONGOCRYPT_VERSION_CURRENT`.
58+
59+
### 6. Commit
60+
61+
Stage and commit all changed files:
62+
63+
- `src/<submodule>` (submodule pointer)
64+
- `config.m4` (source lists + version requirements)
65+
- `config.w32` (source lists, if changed)
66+
- `src/LIBMONGOCRYPT_VERSION_CURRENT` (libmongocrypt only)
67+
- `sbom.json`
68+
69+
Commit message: `PHPC-XXXX Upgrade <submodule> to <version>`

scripts/update-sbom.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ echo "pkg:github/mongodb/mongo-c-driver@${LIBMONGOC_VERSION}" > $PURLS_FILE
1212
echo "pkg:github/mongodb/libmongocrypt@${LIBMONGOCRYPT_VERSION}" >> $PURLS_FILE
1313

1414
# Use silkbomb to update the sbom.json file
15-
docker run --platform="linux/amd64" -it --rm -v ${ROOT_DIR}:/pwd \
15+
docker run --platform="linux/amd64" -i --rm -v ${ROOT_DIR}:/pwd \
1616
artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:1.0 \
1717
update --sbom-in /pwd/sbom.json --purls /pwd/purls.txt --sbom-out /pwd/sbom.json
1818

0 commit comments

Comments
 (0)