Build the deb package.
(
ctx: Context,
onedir: str = None, # pylint: disable=bad-whitespace
relenv_version: str = None,
python_version: str = None,
arch: str = None,
)
| 229 | }, |
| 230 | ) |
| 231 | def debian( |
| 232 | ctx: Context, |
| 233 | onedir: str = None, # pylint: disable=bad-whitespace |
| 234 | relenv_version: str = None, |
| 235 | python_version: str = None, |
| 236 | arch: str = None, |
| 237 | ): |
| 238 | """ |
| 239 | Build the deb package. |
| 240 | """ |
| 241 | checkout = pathlib.Path.cwd() |
| 242 | env_args = ["-e", "SALT_ONEDIR_ARCHIVE"] |
| 243 | if onedir: |
| 244 | onedir_artifact = checkout / "artifacts" / onedir |
| 245 | _check_pkg_build_files_exist(ctx, onedir_artifact=onedir_artifact) |
| 246 | ctx.info( |
| 247 | f"Building the package using the onedir artifact {str(onedir_artifact)}" |
| 248 | ) |
| 249 | os.environ["SALT_ONEDIR_ARCHIVE"] = str(onedir_artifact) |
| 250 | else: |
| 251 | if arch is None: |
| 252 | ctx.error( |
| 253 | "Building the package from the source files but the arch to build for has not been given" |
| 254 | ) |
| 255 | ctx.exit(1) |
| 256 | ctx.info("Building the package from the source files") |
| 257 | shared_constants = tools.utils.get_cicd_shared_context() |
| 258 | if not python_version: |
| 259 | python_version = shared_constants["python_version"] |
| 260 | if not relenv_version: |
| 261 | relenv_version = shared_constants["relenv_version"] |
| 262 | if TYPE_CHECKING: |
| 263 | assert python_version |
| 264 | assert relenv_version |
| 265 | new_env = { |
| 266 | "SALT_RELENV_VERSION": relenv_version, |
| 267 | "SALT_PYTHON_VERSION": python_version, |
| 268 | "SALT_PACKAGE_ARCH": str(arch), |
| 269 | "RELENV_FETCH_VERSION": relenv_version, |
| 270 | } |
| 271 | for key, value in new_env.items(): |
| 272 | os.environ[key] = value |
| 273 | env_args.extend(["-e", key]) |
| 274 | |
| 275 | cargo_home = os.environ.get("CARGO_HOME") |
| 276 | user_cargo_bin = os.path.expanduser("~/.cargo/bin") |
| 277 | if os.path.exists(user_cargo_bin): |
| 278 | ctx.info( |
| 279 | f"The path '{user_cargo_bin}' exists so adding --prepend-path={user_cargo_bin}" |
| 280 | ) |
| 281 | env_args.append(f"--prepend-path={user_cargo_bin}") |
| 282 | elif cargo_home is not None: |
| 283 | cargo_home_bin = os.path.join(cargo_home, "bin") |
| 284 | ctx.info( |
| 285 | f"The 'CARGO_HOME' environment variable is set, so adding --prepend-path={cargo_home_bin}" |
| 286 | ) |
| 287 | env_args.append(f"--prepend-path={cargo_home_bin}") |
| 288 |