From 78d46de2564ada5729e2d2eaf4a07b386a7c93c2 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 24 Oct 2024 15:11:08 +0200 Subject: [PATCH] build.py: Require --etc-portage on non-Gentoo hosts --- binary_gentoo/internal/cli/build.py | 7 ++++++- binary_gentoo/internal/cli/tests/test_build.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/binary_gentoo/internal/cli/build.py b/binary_gentoo/internal/cli/build.py index 4c8b598..e21f162 100644 --- a/binary_gentoo/internal/cli/build.py +++ b/binary_gentoo/internal/cli/build.py @@ -164,8 +164,13 @@ def parse_command_line(argv): "--etc-portage", dest="host_etc_portage", metavar="DIR", + required=not HOST_IS_GENTOO, default="/etc/portage", - help='enforce specific location for /etc/portage (default: "%(default)s")', + help=( + 'enforce specific location for /etc/portage (default: "%(default)s")' + if HOST_IS_GENTOO + else "specify /etc/portage location (required)" + ), ) parser_group_flavors_or_image = parser.add_mutually_exclusive_group() diff --git a/binary_gentoo/internal/cli/tests/test_build.py b/binary_gentoo/internal/cli/tests/test_build.py index 9c1bfea..01893c9 100644 --- a/binary_gentoo/internal/cli/tests/test_build.py +++ b/binary_gentoo/internal/cli/tests/test_build.py @@ -107,6 +107,7 @@ def _run_gentoo_build_with_subprocess_mocked( TemporaryDirectory() as temp_pkgdir, TemporaryDirectory() as temp_portdir, TemporaryDirectory() as temp_logdir, + TemporaryDirectory() as temp_etcportagedir, ): argv = ( [ @@ -119,6 +120,8 @@ def _run_gentoo_build_with_subprocess_mocked( temp_portdir, "--logdir", temp_logdir, + "--etc-portage", + temp_etcportagedir, "--gentoo-profile", "default/linux/profile123", "--cflags",