Skip to content

Commit 2734f82

Browse files
Trevor159MongoDB Bot
authored and
MongoDB Bot
committedDec 14, 2023
Revert "SERVER-75033 Capture core dumps from test failures on macOS"
This reverts commit d6072dc. GitOrigin-RevId: 46a18f2
1 parent 5d6ea60 commit 2734f82

File tree

5 files changed

+68
-100
lines changed

5 files changed

+68
-100
lines changed
 

‎etc/evergreen_yml_components/definitions.yml

+17-2
Original file line numberDiff line numberDiff line change
@@ -2939,7 +2939,15 @@ tasks:
29392939
archive-dist-test
29402940
task_compile_flags: >-
29412941
PREFIX=dist-test
2942-
sign_macos_archive: true
2942+
- command: subprocess.exec
2943+
params:
2944+
binary: bash
2945+
add_expansions_to_env: true
2946+
args:
2947+
- "src/evergreen/run_python_script.sh"
2948+
- "evergreen/macos_notary.py"
2949+
- "mongodb-binaries.${ext|tgz}"
2950+
29432951
- command: s3.put
29442952
params:
29452953
optional: true
@@ -8157,7 +8165,14 @@ tasks:
81578165
${additional_package_targets|}
81588166
task_compile_flags: >-
81598167
--legacy-tarball
8160-
sign_macos_archive: true
8168+
- command: subprocess.exec
8169+
params:
8170+
binary: bash
8171+
add_expansions_to_env: true
8172+
args:
8173+
- "src/evergreen/run_python_script.sh"
8174+
- "evergreen/macos_notary.py"
8175+
- "mongodb-dist.${ext|tgz}"
81618176
- func: "f_expansions_write"
81628177
- command: subprocess.exec
81638178
params:

‎etc/macos_dev_entitlements.xml

-10
This file was deleted.
File renamed without changes.

‎evergreen/macos_notary.py

+46-61
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import argparse
21
import os
32
import platform
43
import shutil
@@ -7,13 +6,15 @@
76
import zipfile
87
import stat
98
import sys
10-
import yaml
11-
129

1310
if platform.system().lower() != 'darwin':
1411
print("Not a macos system, skipping macos signing.")
1512
sys.exit(0)
1613

14+
if len(sys.argv) < 2:
15+
print("Must provide at least 1 archive to sign.")
16+
sys.exit(1)
17+
1718
supported_archs = {
1819
'arm64': 'arm64',
1920
'x86_64': 'amd64'
@@ -24,21 +25,13 @@
2425
print(f"Unsupported platform uname arch: {arch}, must be {supported_archs.keys()}")
2526
sys.exit(1)
2627

27-
expansions_file = "../expansions.yml"
28-
if not os.path.exists(expansions_file):
29-
print("Evergreen expansions file not found. Skipping macos_notary.")
30-
sys.exit(0)
31-
32-
with open(expansions_file) as file:
33-
expansions = yaml.safe_load(file)
34-
35-
should_sign = expansions.get("sign_macos_archive", None)
36-
if not should_sign:
37-
print("sign_macos_archive expansion not found not found or false. Skipping macos_notary.")
38-
sys.exit(0)
39-
4028
macnotary_name = f'darwin_{supported_archs[arch]}'
4129

30+
if os.environ['project'] == "mongodb-mongo-master-nightly":
31+
signing_type = 'notarizeAndSign'
32+
else:
33+
signing_type = 'sign'
34+
4235
macnotary_url = f'https://macos-notary-1628249594.s3.amazonaws.com/releases/client/latest/{macnotary_name}.zip'
4336
print(f'Fetching macnotary tool from: {macnotary_url}')
4437
local_filename, headers = urllib.request.urlretrieve(macnotary_url, f'{macnotary_name}.zip')
@@ -49,51 +42,43 @@
4942
os.chmod(f'{macnotary_name}/macnotary', st.st_mode | stat.S_IEXEC)
5043

5144
failed = False
52-
parser = argparse.ArgumentParser(
53-
prog="MacOS Notary",
54-
description="Sign and/or notarize a tarball containing unsigned binaries.",
55-
)
56-
parser.add_argument("--archive-name", "-a", action="store", required=True)
57-
parser.add_argument("--entitlements-file", "-e", action="store", required=True)
58-
parser.add_argument("--signing-type", "-s", action="store", required=True)
59-
args = parser.parse_args()
60-
archive_name = args.archive_name
61-
entitlements_file = args.entitlements_file
62-
signing_type = args.signing_type
63-
64-
archive_base, archive_ext = os.path.splitext(archive_name)
65-
unsigned_archive = f'{archive_base}_unsigned{archive_ext}'
66-
shutil.move(archive_name, unsigned_archive)
67-
68-
signing_cmd = [
69-
f'./{macnotary_name}/macnotary',
70-
'-f', f'{unsigned_archive}',
71-
'-m', f'{signing_type}',
72-
'-u', 'https://dev.macos-notary.build.10gen.cc/api',
73-
'-k', 'server',
74-
'--entitlements', entitlements_file,
75-
'--verify',
76-
'-b', 'server.mongodb.com',
77-
'-i', f'{expansions["task_id"]}',
78-
'-c', f'{expansions["project"]}',
79-
'-o', f'{archive_name}'
80-
]
81-
82-
signing_env = os.environ.copy()
83-
signing_env['MACOS_NOTARY_SECRET'] = expansions.get("macos_notarization_secret", "")
84-
print(' '.join(signing_cmd))
85-
p = subprocess.Popen(signing_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=signing_env)
86-
87-
print(f"Signing tool completed with exitcode: {p.returncode}")
88-
for line in iter(p.stdout.readline, b''):
89-
print(f'macnotary: {line.decode("utf-8").strip()}')
90-
p.wait()
91-
92-
if p.returncode != 0:
93-
failed = True
94-
shutil.move(unsigned_archive, archive_name)
95-
else:
96-
os.unlink(unsigned_archive)
45+
archives = sys.argv[1:]
46+
47+
for archive in archives:
48+
archive_base, archive_ext = os.path.splitext(archive)
49+
unsigned_archive = f'{archive_base}_unsigned{archive_ext}'
50+
shutil.move(archive, unsigned_archive)
51+
52+
signing_cmd = [
53+
f'./{macnotary_name}/macnotary',
54+
'-f', f'{unsigned_archive}',
55+
'-m', f'{signing_type}',
56+
'-u', 'https://dev.macos-notary.build.10gen.cc/api',
57+
'-k', 'server',
58+
'--entitlements', 'etc/macos_entitlements.xml',
59+
'--verify',
60+
'-b', 'server.mongodb.com',
61+
'-i', f'{os.environ["task_id"]}',
62+
'-c', f'{os.environ["project"]}',
63+
'-o', f'{archive}'
64+
]
65+
66+
signing_env = os.environ.copy()
67+
signing_env['MACOS_NOTARY_SECRET'] = os.environ["macos_notarization_secret"]
68+
print(' '.join(signing_cmd))
69+
p = subprocess.Popen(signing_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=signing_env)
70+
71+
print(f"Signing tool completed with exitcode: {p.returncode}")
72+
for line in iter(p.stdout.readline, b''):
73+
print(f'macnotary: {line.decode("utf-8").strip()}')
74+
p.wait()
75+
76+
if p.returncode != 0:
77+
failed = True
78+
shutil.move(unsigned_archive, archive)
79+
else:
80+
os.unlink(unsigned_archive)
9781

9882
if failed:
9983
exit(1)
84+

‎site_scons/site_tools/auto_archive.py

+5-27
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,6 @@ def archive_builder(source, target, env, for_signature):
290290
return cmd
291291

292292

293-
def macos_archive_sign_builder(source, target, env, for_signature):
294-
if env['PLATFORM'] != 'darwin' or env.GetOption("ninja") != 'disabled':
295-
return ""
296-
297-
if env.GetOption("release") is not None:
298-
print("MacOS release build found, signing with release entitlements.")
299-
entitlements_file = 'etc/macos_release_entitlements.xml'
300-
signing_type = 'notarizeAndSign'
301-
else:
302-
print("MacOS dev build found, signing with insecure development entitlements.")
303-
entitlements_file = 'etc/macos_dev_entitlements.xml'
304-
signing_type = 'sign'
305-
306-
archive_name = env.File(target[0])
307-
macos_notory_cmd = f"{sys.executable} evergreen/macos_notary.py --archive-name={archive_name} --entitlements-file={entitlements_file} --signing-type={signing_type}"
308-
309-
return macos_notory_cmd
310-
311-
312293
def exists(env):
313294
return True
314295

@@ -318,14 +299,11 @@ def generate(env):
318299
env.Tool("auto_install_binaries")
319300

320301
bld = SCons.Builder.Builder(
321-
action=SCons.Action.ListAction([
322-
SCons.Action.CommandGeneratorAction(
323-
archive_builder,
324-
{"cmdstr": "Building package ${TARGETS[0]} from ${SOURCES[1:]}"}
325-
if not env.Verbose() else {"cmdstr": ""},
326-
),
327-
SCons.Action.CommandGeneratorAction(macos_archive_sign_builder, {})
328-
]))
302+
action=SCons.Action.CommandGeneratorAction(
303+
archive_builder,
304+
{"cmdstr": "Building package ${TARGETS[0]} from ${SOURCES[1:]}"}
305+
if not env.Verbose() else {"cmdstr": ""},
306+
))
329307
env.Append(BUILDERS={"AutoArchive": bld})
330308
env["AUTO_ARCHIVE_TARBALL_SUFFIX"] = env.get(
331309
"AUTO_ARCHIVE_TARBALL_SUFFIX",

0 commit comments

Comments
 (0)