diff options
author | 2023-12-09 22:48:50 +0200 | |
---|---|---|
committer | 2023-12-09 22:48:50 +0200 | |
commit | 386f0b197e4d2fe0170058163c932a463bad1e82 (patch) | |
tree | f5b44b58b30289ae7c9e3c2c04cf33836ee82474 | |
parent | tatt: pass configuration to specific package and not all env (diff) | |
download | pkgdev-386f0b197e4d2fe0170058163c932a463bad1e82.tar.gz pkgdev-386f0b197e4d2fe0170058163c932a463bad1e82.tar.bz2 pkgdev-386f0b197e4d2fe0170058163c932a463bad1e82.zip |
tatt: add support for extra env files
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | data/share/bash-completion/completions/pkgdev | 11 | ||||
-rw-r--r-- | src/pkgdev/scripts/pkgdev_tatt.py | 26 | ||||
-rw-r--r-- | src/pkgdev/tatt/template.sh.jinja | 3 |
3 files changed, 39 insertions, 1 deletions
diff --git a/data/share/bash-completion/completions/pkgdev b/data/share/bash-completion/completions/pkgdev index 4bc29e7..bbad831 100644 --- a/data/share/bash-completion/completions/pkgdev +++ b/data/share/bash-completion/completions/pkgdev @@ -214,6 +214,7 @@ _pkgdev() { --template-file --logs-dir --emerge-opts + --extra-env-file " case "${prev}" in @@ -226,6 +227,16 @@ _pkgdev() { --logs-dir) COMPREPLY=($(compgen -d -- "${cur}")) ;; + --extra-env-file) + if [[ -d /etc/portage/env/ ]]; then + pushd /etc/portage/env/ >& /dev/null + local SETS=( * ) + COMPREPLY=($(compgen -W "${SETS[*]}" -- "${cur}" )) + popd >& /dev/null + else + COMPREPLY=() + fi + ;; *) COMPREPLY+=($(compgen -W "${subcmd_options}" -- "${cur}")) ;; diff --git a/src/pkgdev/scripts/pkgdev_tatt.py b/src/pkgdev/scripts/pkgdev_tatt.py index 16b2bc6..37454fc 100644 --- a/src/pkgdev/scripts/pkgdev_tatt.py +++ b/src/pkgdev/scripts/pkgdev_tatt.py @@ -150,6 +150,11 @@ template_opts.add_argument( Options to be passed to emerge invocations. Taken from ``--emerge-opts``. + ``extra_env_files`` + A list of extra /etc/portage/env/ file names, to be added to + ``package.env`` entry when testing the package. Taken from + ``--extra-env-file``. + ``log_dir`` irectory to save build logs for failing tasks. Taken from ``--logs-dir``. @@ -172,6 +177,17 @@ template_opts.add_argument( to ``emerge`` invocations. """, ) +template_opts.add_argument( + "--extra-env-file", + default=[], + metavar="ENV_FILE", + action=arghparse.CommaSeparatedValuesAppend, + help="Extra /etc/portage/env/ file names, to be used while testing packages. Can be passed multiple times.", + docs=""" + Comma separated filenames under /etc/portage/env/, which will all be + included in the package.env entry when testing the package. + """, +) portage_config = Path("/etc/portage") portage_accept_keywords = portage_config / "package.accept_keywords" @@ -181,6 +197,13 @@ portage_env = portage_config / "env" @tatt.bind_final_check +def _tatt_validate(parser, namespace): + for filename in namespace.extra_env_file: + if not (env_file := portage_env / filename).exists(): + parser.error(f"extra env file '{env_file}' doesn't exist") + + +@tatt.bind_final_check def _validate_args(parser, namespace): if namespace.bug is not None: if namespace.keywording is not None: @@ -254,7 +277,7 @@ def _groupby_use_expand( return use_flags, use_expand_dict -def _build_job(namespace, pkg, is_test): +def _build_job(namespace, pkg, is_test: bool): use_expand_prefixes = tuple(s.lower() + "_" for s in namespace.domain.profile.use_expand) default_on_iuse = tuple(use[1:] for use in pkg.iuse if use.startswith("+")) immutable, enabled, _disabled = namespace.domain.get_package_use_unconfigured(pkg) @@ -373,6 +396,7 @@ def main(options, out, err): job_name=job_name, log_dir=options.logs_dir, emerge_opts=options.emerge_opts, + extra_env_files=options.extra_env_file, cleanup_files=cleanup_files, ) with open(script_name := job_name + ".sh", "w") as output: diff --git a/src/pkgdev/tatt/template.sh.jinja b/src/pkgdev/tatt/template.sh.jinja index 1123822..5c9d6fb 100644 --- a/src/pkgdev/tatt/template.sh.jinja +++ b/src/pkgdev/tatt/template.sh.jinja @@ -102,6 +102,9 @@ tatt_test_pkg() { printf "%s pkgdev_tatt_{{ job_name }}_no_test\n" "${1:?}" > "/etc/portage/package.env/pkgdev_tatt_{{ job_name }}/${CP}" local TFEATURES="${FEATURES}" fi + {% for env in extra_env_files %} + printf "%s {{env}}\n" "${1}" >> "/etc/portage/package.env/pkgdev_tatt_{{ job_name }}/${CP}" + {% endfor %} printf "%s %s\n" "${1:?}" "${TUSE}" > "/etc/portage/package.use/pkgdev_tatt_{{ job_name }}/${CP}" |