Skip to content

Commit

Permalink
Provide base skeleton for gentoo to pass test_cli tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed Apr 30, 2024
1 parent a5df85f commit 39b79fc
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 6 deletions.
8 changes: 4 additions & 4 deletions neurodocker/cli/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_fail_on_empty_args(cmd: str):


@pytest.mark.parametrize("cmd", _cmds)
@pytest.mark.parametrize("pkg_manager", ["apt", "yum"])
@pytest.mark.parametrize("pkg_manager", ["apt", "portage", "yum"])
def test_fail_on_no_base(cmd: str, pkg_manager: str):
runner = CliRunner()
result = runner.invoke(generate, [cmd, "--pkg-manager", pkg_manager])
Expand All @@ -34,7 +34,7 @@ def test_fail_on_no_pkg_manager(cmd: str):


@pytest.mark.parametrize("cmd", _cmds)
@pytest.mark.parametrize("pkg_manager", ["apt", "yum"])
@pytest.mark.parametrize("pkg_manager", ["apt", "portage", "yum"])
def test_minimal_args(cmd: str, pkg_manager: str):
runner = CliRunner()
result = runner.invoke(
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_optioneatall_type_issue_498():


@pytest.mark.parametrize("cmd", _cmds)
@pytest.mark.parametrize("pkg_manager", ["apt", "yum"])
@pytest.mark.parametrize("pkg_manager", ["apt", "portage", "yum"])
def test_all_args(cmd: str, pkg_manager: str):
runner = CliRunner()
result = runner.invoke(
Expand Down Expand Up @@ -156,7 +156,7 @@ def test_all_args(cmd: str, pkg_manager: str):
# is what registers the templates. Using the `docker` function
# (`reproenv generate docker`) directly does not fire `generate`.
@pytest.mark.parametrize("cmd", _cmds)
@pytest.mark.parametrize("pkg_manager", ["apt", "yum"])
@pytest.mark.parametrize("pkg_manager", ["apt", "portage", "yum"])
def test_render_registered(cmd: str, pkg_manager: str):
template_path = Path(__file__).parent
runner = CliRunner(env={"REPROENV_TEMPLATE_PATH": str(template_path)})
Expand Down
21 changes: 21 additions & 0 deletions neurodocker/reproenv/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,8 @@ def _indent_run_instruction(string: str, indent=4) -> str:
def _install(pkgs: list[str], pkg_manager: str, opts: str = None) -> str:
if pkg_manager == "apt":
return _apt_install(pkgs, opts)
elif pkg_manager == "portage":
return _portage_install(pkgs, opts)
elif pkg_manager == "yum":
return _yum_install(pkgs, opts)
# TODO: add debs here?
Expand Down Expand Up @@ -802,6 +804,25 @@ def install_one(url: str):
return s


def _portage_install(pkgs: list[str], opts: str = None, sort=True) -> str:
"""Return command to install packages with `portage` (Gentoo).
`opts` are options passed to `emerge`.
Default is "--autounmask-continue".
"""
pkgs = sorted(pkgs) if sort else pkgs
opts = "--autounmask-continue" if opts is None else opts

s = """\
emerge {opts} \\
{pkgs}
rm -rf /var/tmp/portage/*
""".format(
opts=opts, pkgs=" \\\n ".join(pkgs)
)
return s.strip()


def _yum_install(pkgs: list[str], opts: str = None, sort=True) -> str:
"""Return command to install packages with `yum` (CentOS, Fedora).
Expand Down
2 changes: 2 additions & 0 deletions neurodocker/reproenv/schemas/renderer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
"type": "string",
"enum": [
"apt",
"portage",
"yum"
],
"examples": [
"apt",
"portage",
"yum"
]
},
Expand Down
1 change: 1 addition & 0 deletions neurodocker/reproenv/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class _InstallationDependenciesType(TypedDict, total=False):

apt: list[str]
debs: list[str]
portage: list[str]
yum: list[str]


Expand Down
21 changes: 21 additions & 0 deletions neurodocker/templates/gentoo-portage/make.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### This file contains system-wide build variables, including Gentoo variables such as USE, which enable/disable optional package features.

COMMON_FLAGS="-O2 -pipe -march=native"
# Comment the following out on systems with less than 8 threads
MAKEOPTS="--jobs 8 --load-average 9"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

# NOTE: This stage was built with the bindist Use flag enabled

# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C

USE="${USE} science"
ACCEPT_LICENSE="*"

# Needed in the container environment
#FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### This is needed because ::science packages are generally not marked as stable
*/* ~amd64
2 changes: 2 additions & 0 deletions neurodocker/templates/gentoo-portage/package.mask/bugs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### This is empty, thankfully.
### If we find bugs in some version of some package we can blacklist the package, version, or feature that causes it here.
6 changes: 6 additions & 0 deletions neurodocker/templates/gentoo-portage/repos.conf/gentoo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gentoo]
location = /var/db/repos/gentoo
# We sync manually, but we need sync-uri to be written down somewhere to do so
sync-type = git
sync-uri = https://anongit.gentoo.org/git/repo/gentoo.git
sync-git-verify-commit-signature = yes
6 changes: 6 additions & 0 deletions neurodocker/templates/gentoo-portage/repos.conf/science
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[science]
location = /var/db/repos/science
# We sync manually, but we need sync-uri to be written down somewhere to do so
sync-type = git
sync-uri = https://anongit.gentoo.org/git/proj/sci.git
priority = 7777
8 changes: 6 additions & 2 deletions neurodocker/templates/gentoo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
name: gentoo
url: https://www.gentoo.org/
binaries:
# ATM template jsonschema demands having urls and instructions.
# In the future we might use urls to point to git repositories
# which are currently under gentoo-portage/ config files.
urls:
something: not-used
instructions: |
FROM docker.io/gentoo/portage:20240324 as portage
FROM docker.io/gentoo/stage3:20240318
Expand All @@ -17,7 +22,7 @@ binaries:
ARG FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox"
# This will be bound, and contents available outside of container
RUN mkdir /outputs
COPY .gentoo/portage/ /etc/portage/
COPY gentoo-portage/ /etc/portage/
# Moving gentoo repo from default rsync to git
RUN rm /var/db/repos/gentoo -rf
# Cloning manually to prevent vdb update, pinning state via git
Expand Down Expand Up @@ -46,4 +51,3 @@ binaries:
### Emerge cool stuff here
### Autounmask-continue enables all features on dependencies which the top level packages require
### By default this needs user confirmation which would interrupt the build.
RUN emerge --autounmask-continue afni fsl

0 comments on commit 39b79fc

Please sign in to comment.