diff options
author | Ryan Egesdahl <ryan.egesdahl@mongodb.com> | 2023-04-12 21:39:32 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-12 22:19:16 +0000 |
commit | 677dd87ca6f923f38dd9c5f4b1120d76203a72b7 (patch) | |
tree | d49de24de73e3591db63cd384e9c971f4a15b209 | |
parent | 851cfd2d0aaaf3ae877608236d1aad10eedd7f9e (diff) | |
download | mongo-677dd87ca6f923f38dd9c5f4b1120d76203a72b7.tar.gz |
SERVER-70425 Stash before using git archive
-rw-r--r-- | buildscripts/package_test_internal.py | 17 | ||||
-rwxr-xr-x | buildscripts/packager_enterprise.py | 7 | ||||
-rw-r--r-- | site_scons/site_tools/distsrc.py | 25 |
3 files changed, 23 insertions, 26 deletions
diff --git a/buildscripts/package_test_internal.py b/buildscripts/package_test_internal.py index b923a0e6f77..fa3e2ac0e70 100644 --- a/buildscripts/package_test_internal.py +++ b/buildscripts/package_test_internal.py @@ -259,23 +259,6 @@ def get_test_args(package_manager: str, package_files: List[str]) -> TestArgs: def setup(test_args: TestArgs): logging.info("Setting up test environment.") - # TODO SERVER-70425: We can remove these once we have figured out why - # packager.py sometimes uses distro files from older revisions. - # Remove the PIDFile, PermissionsStartOnly, and Type configurations from - # the systemd service file because they are not needed for simple-type - # (non-forking) services and confuse the systemd emulator script. - run_and_log("sed -Ei '/^PIDFile=|PermissionsStartOnly=|Type=/d' {}/mongod.service".format( - test_args["systemd_units_dir"])) - # Ensure RuntimeDirectory has been added to the systemd unit file. - run_and_log("sed -Ei '/^ExecStart=.*/a RuntimeDirectory=mongodb' {}/mongod.service".format( - test_args["systemd_units_dir"])) - # Remove the journal: line (and the next) from mongod.conf, which is a - # removed configuration. The Debian version of the config never got updated. - run_and_log("sed -i '/journal:/,+1d' /etc/mongod.conf") - # Remove fork: and pidFilePath: from mongod.conf because we want mongod to be - # a non-forking service under systemd. - run_and_log("sed -Ei '/fork:|pidFilePath:/d' /etc/mongod.conf") - # Ensure systemd doesn't try to start anything automatically so we can do # it in our tests run_and_log("mkdir -p /run/systemd/system") diff --git a/buildscripts/packager_enterprise.py b/buildscripts/packager_enterprise.py index ea89dc94633..25ceffc1dc2 100755 --- a/buildscripts/packager_enterprise.py +++ b/buildscripts/packager_enterprise.py @@ -28,7 +28,6 @@ # echo "Now put the dist gnupg signing keys in ~root/.gnupg" import errno -from glob import glob import os import re import shutil @@ -36,6 +35,8 @@ import sys import tempfile import time +from glob import glob + sys.path.append(os.getcwd()) import packager # pylint: disable=wrong-import-position @@ -254,8 +255,8 @@ def make_package(distro, build_os, arch, spec, srcdir): # FIXME: sh-dash-cee is bad. See if tarfile can do this. packager.sysassert([ "sh", "-c", - "(cd \"%s\" && git archive %s %s/ ) | (cd \"%s\" && tar xvf -)" % - (srcdir, spec.metadata_gitspec(), pkgdir, sdir) + "(cd \"%s\" && GIT_HASH=$(git stash create) && git archive \"${GIT_HASH}\" %s/ )" + "| (cd \"%s\" && tar xvf -)" % (srcdir, pkgdir, sdir) ]) # Splat the binaries under sdir. The "build" stages of the # packaging infrastructure will move the files to wherever they diff --git a/site_scons/site_tools/distsrc.py b/site_scons/site_tools/distsrc.py index 83f47f2ab3f..33b63d3d8d4 100644 --- a/site_scons/site_tools/distsrc.py +++ b/site_scons/site_tools/distsrc.py @@ -20,18 +20,19 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -import SCons +import io import os import os.path as ospath -import subprocess import shutil +import subprocess import tarfile import time import zipfile -import io from distutils.spawn import find_executable +import SCons + __distsrc_callbacks = [] @@ -174,6 +175,7 @@ def distsrc_action_generator(source, target, env, for_signature): # This is done in two stages because env.WhereIs doesn't seem to work # correctly on Windows, but we still want to be able to override the PATH # using the env. + git_path = env.WhereIs("git") if not git_path: git_path = find_executable("git") @@ -192,11 +194,22 @@ def distsrc_action_generator(source, target, env, for_signature): print("Invalid file format for distsrc. Must be tar or zip file") env.Exit(1) - git_cmd = ('"%s" archive --format %s --output %s --prefix ${MONGO_DIST_SRC_PREFIX} HEAD' % - (git_path, target_ext, target[0])) + def create_archive(target=None, source=None, env=None): + stash_id = subprocess.check_output([git_path, "stash", "create"]).decode("utf-8").strip() + subprocess.check_call([ + git_path, + "archive", + "--format", + target_ext, + "--output", + str(target[0]), + "--prefix", + env["MONGO_DIST_SRC_PREFIX"], + stash_id, + ]) return [ - SCons.Action.Action(git_cmd, "Running git archive for $TARGET"), + SCons.Action.Action(create_archive, "Creating archive for $TARGET"), SCons.Action.Action( run_distsrc_callbacks, "Running distsrc callbacks for $TARGET", |