MCPcopy Index your code
hub / github.com/saltstack/salt / rpm

Function rpm

tools/pkg/build.py:321–393  ·  view source on GitHub ↗

Build the RPM package.

(
    ctx: Context,
    onedir: str = None,  # pylint: disable=bad-whitespace
    relenv_version: str = None,
    python_version: str = None,
    arch: str = None,
    key_id: str = None,
)

Source from the content-addressed store, hash-verified

319 },
320)
321def rpm(
322 ctx: Context,
323 onedir: str = None, # pylint: disable=bad-whitespace
324 relenv_version: str = None,
325 python_version: str = None,
326 arch: str = None,
327 key_id: str = None,
328):
329 """
330 Build the RPM package.
331 """
332 onci = "GITHUB_WORKFLOW" in os.environ
333 checkout = pathlib.Path.cwd()
334 if onedir:
335 onedir_artifact = checkout / "artifacts" / onedir
336 _check_pkg_build_files_exist(ctx, onedir_artifact=onedir_artifact)
337 ctx.info(
338 f"Building the package using the onedir artifact {str(onedir_artifact)}"
339 )
340 os.environ["SALT_ONEDIR_ARCHIVE"] = str(onedir_artifact)
341 else:
342 ctx.info("Building the package from the source files")
343 if arch is None:
344 ctx.error(
345 "Building the package from the source files but the arch to build for has not been given"
346 )
347 ctx.exit(1)
348 ctx.info("Building the package from the source files")
349 shared_constants = tools.utils.get_cicd_shared_context()
350 if not python_version:
351 python_version = shared_constants["python_version"]
352 if not relenv_version:
353 relenv_version = shared_constants["relenv_version"]
354 if TYPE_CHECKING:
355 assert python_version
356 assert relenv_version
357 new_env = {
358 "SALT_RELENV_VERSION": relenv_version,
359 "SALT_PYTHON_VERSION": python_version,
360 "SALT_PACKAGE_ARCH": str(arch),
361 "RELENV_FETCH_VERSION": relenv_version,
362 }
363 for key, value in new_env.items():
364 os.environ[key] = value
365
366 env = os.environ.copy()
367 env["PIP_CONSTRAINT"] = str(
368 tools.utils.REPO_ROOT / "requirements" / "constraints.txt"
369 )
370 spec_file = checkout / "pkg" / "rpm" / "salt.spec"
371 ctx.run(
372 "rpmbuild", "-bb", f"--define=_salt_src {checkout}", str(spec_file), env=env
373 )
374 if key_id:
375 if onci:
376 path = "/github/home/rpmbuild/RPMS/"
377 else:
378 path = "~/rpmbuild/RPMS/"

Callers

nothing calls this directly

Calls 8

exitMethod · 0.80
listFunction · 0.50
infoMethod · 0.45
errorMethod · 0.45
itemsMethod · 0.45
copyMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected