diff --git a/buildscripts/package_test_internal.py b/buildscripts/package_test_internal.py index fa3e2ac0e70..b923a0e6f77 100644 --- a/buildscripts/package_test_internal.py +++ b/buildscripts/package_test_internal.py @@ -259,6 +259,23 @@ 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 25ceffc1dc2..ea89dc94633 100755 --- a/buildscripts/packager_enterprise.py +++ b/buildscripts/packager_enterprise.py @@ -28,6 +28,7 @@ # echo "Now put the dist gnupg signing keys in ~root/.gnupg" import errno +from glob import glob import os import re import shutil @@ -35,8 +36,6 @@ import sys import tempfile import time -from glob import glob - sys.path.append(os.getcwd()) import packager # pylint: disable=wrong-import-position @@ -255,8 +254,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_HASH=$(git stash create) && git archive \"${GIT_HASH}\" %s/ )" - "| (cd \"%s\" && tar xvf -)" % (srcdir, pkgdir, sdir) + "(cd \"%s\" && git archive %s %s/ ) | (cd \"%s\" && tar xvf -)" % + (srcdir, spec.metadata_gitspec(), 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 33b63d3d8d4..83f47f2ab3f 100644 --- a/site_scons/site_tools/distsrc.py +++ b/site_scons/site_tools/distsrc.py @@ -20,19 +20,18 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -import io +import SCons import os import os.path as ospath -import shutil import subprocess +import shutil import tarfile import time import zipfile +import io from distutils.spawn import find_executable -import SCons - __distsrc_callbacks = [] @@ -175,7 +174,6 @@ 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") @@ -194,22 +192,11 @@ def distsrc_action_generator(source, target, env, for_signature): print("Invalid file format for distsrc. Must be tar or zip file") env.Exit(1) - 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, - ]) + git_cmd = ('"%s" archive --format %s --output %s --prefix ${MONGO_DIST_SRC_PREFIX} HEAD' % + (git_path, target_ext, target[0])) return [ - SCons.Action.Action(create_archive, "Creating archive for $TARGET"), + SCons.Action.Action(git_cmd, "Running git archive for $TARGET"), SCons.Action.Action( run_distsrc_callbacks, "Running distsrc callbacks for $TARGET",