mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Change the spec and rules file to use tools, and build from source using tools for rpms and debs
This commit is contained in:
parent
77377f7aae
commit
230337b32e
5 changed files with 99 additions and 32 deletions
2
.github/workflows/build-deb-packages.yml
vendored
2
.github/workflows/build-deb-packages.yml
vendored
|
@ -87,7 +87,7 @@ jobs:
|
|||
working-directory: pkgs/checkout/
|
||||
if: ${{ matrix.src == true}}
|
||||
run: |
|
||||
tools pkg build deb
|
||||
tools pkg build deb --arch x86_64
|
||||
|
||||
- name: Cleanup
|
||||
run: |
|
||||
|
|
2
.github/workflows/build-rpm-packages.yml
vendored
2
.github/workflows/build-rpm-packages.yml
vendored
|
@ -74,7 +74,7 @@ jobs:
|
|||
- name: Build RPM
|
||||
if: ${{ matrix.src == true}}
|
||||
run: |
|
||||
tools pkg build rpm
|
||||
tools pkg build rpm --arch x86_64
|
||||
|
||||
- name: Upload RPMs
|
||||
uses: actions/upload-artifact@v3
|
||||
|
|
|
@ -17,24 +17,18 @@ ifeq ("${SALT_ONEDIR_ARCHIVE}", "")
|
|||
override_dh_auto_build:
|
||||
mkdir -p build/onedir
|
||||
python3 -m venv --clear --copies build/onedir/venv
|
||||
build/onedir/venv/bin/python3 -m pip install relenv
|
||||
build/onedir/venv/bin/python3 -m pip install relenv==$${SALT_RELENV_VERSION}
|
||||
export PY=$$(build/onedir/venv/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()') \
|
||||
&& build/onedir/venv/bin/python3 -m pip install -r requirements/static/ci/py$${PY}/tools.txt
|
||||
build/onedir/venv/bin/relenv fetch
|
||||
build/onedir/venv/bin/relenv toolchain fetch
|
||||
build/onedir/venv/bin/relenv create build/onedir/salt
|
||||
build/onedir/salt/bin/python3 -m pip install "pip>=22.3.1,<23.0" "setuptools>=65.6.3,<66" "wheel"
|
||||
export PY=$$(build/onedir/salt/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()') \
|
||||
&& build/onedir/salt/bin/python3 -m pip install -r requirements/static/pkg/py$${PY}/linux.txt --no-binary=':all:'
|
||||
build/onedir/venv/bin/tools pkg build onedir-dependencies --arch $${SALT_PACKAGE_ARCH} --python-version $${SALT_PYTHON_VERSION} --package-name $${SALT_PACKAGE_NAME} --platform linux
|
||||
|
||||
# Fix any hardcoded paths to the relenv python binary on any of the scripts installed in the <onedir>/bin directory
|
||||
find build/onedir/salt/bin/ -type f -exec sed -i 's:#!/\(.*\)salt/bin/python3:#!/bin/sh\n"exec" "$$(dirname $$(readlink -f $$0))/python3" "$$0" "$$@":g' {} \;
|
||||
|
||||
export USE_STATIC_REQUIREMENTS=1 \
|
||||
&& export RELENV_PIP_DIR=1 \
|
||||
&& build/onedir/salt/bin/python3 -m pip install --no-warn-script-location .
|
||||
build/onedir/salt/bin/python3 -m venv --clear --copies build/onedir/tools
|
||||
export PY=$$(build/onedir/tools/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()') \
|
||||
&& build/onedir/tools/bin/python3 -m pip install -r requirements/static/ci/py$${PY}/tools.txt
|
||||
build/onedir/tools/bin/tools pkg pre-archive-cleanup --pkg build/onedir/salt
|
||||
build/onedir/venv/bin/tools pkg build salt-onedir . --package-name $${SALT_PACKAGE_NAME} --platform linux
|
||||
build/onedir/venv/bin/tools pkg pre-archive-cleanup --pkg build/onedir/salt
|
||||
else
|
||||
override_dh_auto_build:
|
||||
# The relenv onedir is being provided, all setup up until Salt is installed
|
||||
|
|
|
@ -136,26 +136,20 @@ cd $RPM_BUILD_DIR
|
|||
|
||||
%if "%{getenv:SALT_ONEDIR_ARCHIVE}" == ""
|
||||
python3 -m venv --clear --copies build/venv
|
||||
build/venv/bin/python3 -m pip install relenv
|
||||
build/venv/bin/python3 -m pip install relenv==${SALT_RELENV_VERSION}
|
||||
export PY=$(build/venv/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()')
|
||||
build/venv/bin/python3 -m pip install -r %{_salt_src}/requirements/static/ci/py${PY}/tools.txt
|
||||
build/venv/bin/relenv fetch
|
||||
build/venv/bin/relenv toolchain fetch
|
||||
build/venv/bin/relenv create build/salt
|
||||
build/salt/bin/python3 -m pip install "pip>=22.3.1,<23.0" "setuptools>=65.6.3,<66" "wheel"
|
||||
export PY=$(build/salt/bin/python3 -c 'import sys; sys.stdout.write("{}.{}".format(*sys.version_info)); sys.stdout.flush()')
|
||||
build/salt/bin/python3 -m pip install -r %{_salt_src}/requirements/static/pkg/py${PY}/linux.txt --no-binary=':all:'
|
||||
cd %{_salt_src}
|
||||
$RPM_BUILD_DIR/build/venv/bin/tools pkg build onedir-dependencies --arch ${SALT_PACKAGE_ARCH} --python-version ${SALT_PYTHON_VERSION} --package-name $RPM_BUILD_DIR/${SALT_PACKAGE_NAME} --platform linux
|
||||
|
||||
# Fix any hardcoded paths to the relenv python binary on any of the scripts installed in
|
||||
# the <onedir>/bin directory
|
||||
find build/salt/bin/ -type f -exec sed -i 's:#!/\(.*\)salt/bin/python3:#!/bin/sh\n"exec" "$(dirname $(readlink -f $0))/python3" "$0" "$@":g' {} \;
|
||||
find $RPM_BUILD_DIR/build/salt/bin/ -type f -exec sed -i 's:#!/\(.*\)salt/bin/python3:#!/bin/sh\n"exec" "$(dirname $(readlink -f $0))/python3" "$0" "$@":g' {} \;
|
||||
|
||||
export USE_STATIC_REQUIREMENTS=1
|
||||
export RELENV_PIP_DIR=1
|
||||
build/salt/bin/python3 -m pip install --no-warn-script-location %{_salt_src}
|
||||
|
||||
build/salt/bin/python3 -m venv --clear --copies build/tools
|
||||
build/tools/bin/python3 -m pip install -r %{_salt_src}/requirements/static/ci/py${PY}/tools.txt
|
||||
cd %{_salt_src}
|
||||
$RPM_BUILD_DIR/build/tools/bin/tools pkg pre-archive-cleanup --pkg $RPM_BUILD_DIR/build/salt
|
||||
$RPM_BUILD_DIR/build/venv/bin/tools pkg build salt-onedir . --package-name $RPM_BUILD_DIR/${SALT_PACKAGE_NAME} --platform linux
|
||||
$RPM_BUILD_DIR/build/venv/bin/tools pkg pre-archive-cleanup --pkg $RPM_BUILD_DIR/build/salt
|
||||
%else
|
||||
# The relenv onedir is being provided, all setup up until Salt is installed
|
||||
# is expected to be done
|
||||
|
|
|
@ -12,6 +12,7 @@ import tarfile
|
|||
import zipfile
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import yaml
|
||||
from ptscripts import Context, command_group
|
||||
|
||||
import tools.utils
|
||||
|
@ -27,23 +28,44 @@ build = command_group(
|
|||
)
|
||||
|
||||
|
||||
def _get_shared_constants():
|
||||
shared_constants = tools.utils.REPO_ROOT / "cicd" / "shared-context.yml"
|
||||
return yaml.safe_load(shared_constants.read_text())
|
||||
|
||||
|
||||
@build.command(
|
||||
name="deb",
|
||||
arguments={
|
||||
"onedir": {
|
||||
"help": "The name of the onedir artifact, if given it should be under artifacts/",
|
||||
"help": "The path to the onedir artifact",
|
||||
},
|
||||
"relenv_version": {
|
||||
"help": "The version of relenv to use",
|
||||
},
|
||||
"python_version": {
|
||||
"help": "The version of python to build with using relenv",
|
||||
},
|
||||
"arch": {
|
||||
"help": "The arch to build for",
|
||||
},
|
||||
"package_name": {
|
||||
"help": "The name of the relenv environment to create",
|
||||
},
|
||||
},
|
||||
)
|
||||
def debian(
|
||||
ctx: Context,
|
||||
onedir: str = None, # pylint: disable=bad-whitespace
|
||||
relenv_version: str = None,
|
||||
python_version: str = None,
|
||||
arch: str = None,
|
||||
package_name: str = None,
|
||||
):
|
||||
"""
|
||||
Build the deb package.
|
||||
"""
|
||||
checkout = pathlib.Path.cwd()
|
||||
env_args = []
|
||||
env_args = ["-e", "SALT_ONEDIR_ARCHIVE"]
|
||||
if onedir:
|
||||
onedir_artifact = checkout / "artifacts" / onedir
|
||||
_check_pkg_build_files_exist(ctx, onedir_artifact=onedir_artifact)
|
||||
|
@ -51,9 +73,29 @@ def debian(
|
|||
f"Building the package using the onedir artifact {str(onedir_artifact)}"
|
||||
)
|
||||
os.environ["SALT_ONEDIR_ARCHIVE"] = str(onedir_artifact)
|
||||
env_args.extend(["-e", "SALT_ONEDIR_ARCHIVE"])
|
||||
else:
|
||||
if arch is None:
|
||||
ctx.error(
|
||||
"Building the package from the source files but the arch to build for has not been given"
|
||||
)
|
||||
ctx.exit(1)
|
||||
if package_name is None:
|
||||
package_name = "build/onedir/salt"
|
||||
ctx.debug(
|
||||
f"Building the package in {str(package_name)} since package_name has not been given"
|
||||
)
|
||||
ctx.info(f"Building the package from the source files")
|
||||
shared_constants = _get_shared_constants()
|
||||
new_env = {
|
||||
"SALT_RELENV_VERSION": relenv_version or shared_constants["relenv_version"],
|
||||
"SALT_PYTHON_VERSION": python_version
|
||||
or shared_constants["python_version_linux"],
|
||||
"SALT_PACKAGE_NAME": str(package_name),
|
||||
"SALT_PACKAGE_ARCH": str(arch),
|
||||
}
|
||||
for key, value in new_env.items():
|
||||
os.environ[key] = value
|
||||
env_args.extend(["-e", key])
|
||||
|
||||
ctx.run("ln", "-sf", "pkg/debian/", ".")
|
||||
ctx.run("debuild", *env_args, "-uc", "-us")
|
||||
|
@ -65,13 +107,29 @@ def debian(
|
|||
name="rpm",
|
||||
arguments={
|
||||
"onedir": {
|
||||
"help": "The name of the onedir artifact, if given it should be under artifacts/",
|
||||
"help": "The path to the onedir artifact",
|
||||
},
|
||||
"relenv_version": {
|
||||
"help": "The version of relenv to use",
|
||||
},
|
||||
"python_version": {
|
||||
"help": "The version of python to build with using relenv",
|
||||
},
|
||||
"arch": {
|
||||
"help": "The arch to build for",
|
||||
},
|
||||
"package_name": {
|
||||
"help": "The name of the relenv environment to create",
|
||||
},
|
||||
},
|
||||
)
|
||||
def rpm(
|
||||
ctx: Context,
|
||||
onedir: str = None, # pylint: disable=bad-whitespace
|
||||
relenv_version: str = None,
|
||||
python_version: str = None,
|
||||
arch: str = None,
|
||||
package_name: str = None,
|
||||
):
|
||||
"""
|
||||
Build the RPM package.
|
||||
|
@ -86,6 +144,27 @@ def rpm(
|
|||
os.environ["SALT_ONEDIR_ARCHIVE"] = str(onedir_artifact)
|
||||
else:
|
||||
ctx.info(f"Building the package from the source files")
|
||||
if arch is None:
|
||||
ctx.error(
|
||||
"Building the package from the source files but the arch to build for has not been given"
|
||||
)
|
||||
ctx.exit(1)
|
||||
if package_name is None:
|
||||
package_name = "build/salt"
|
||||
ctx.debug(
|
||||
f"Building the package in {str(package_name)} since package_name has not been given"
|
||||
)
|
||||
ctx.info(f"Building the package from the source files")
|
||||
shared_constants = _get_shared_constants()
|
||||
new_env = {
|
||||
"SALT_RELENV_VERSION": relenv_version or shared_constants["relenv_version"],
|
||||
"SALT_PYTHON_VERSION": python_version
|
||||
or shared_constants["python_version_linux"],
|
||||
"SALT_PACKAGE_NAME": str(package_name),
|
||||
"SALT_PACKAGE_ARCH": str(arch),
|
||||
}
|
||||
for key, value in new_env.items():
|
||||
os.environ[key] = value
|
||||
|
||||
spec_file = checkout / "pkg" / "rpm" / "salt.spec"
|
||||
ctx.run("rpmbuild", "-bb", f"--define=_salt_src {checkout}", str(spec_file))
|
||||
|
|
Loading…
Add table
Reference in a new issue