Skip to content

Commit 59749dc

Browse files
authored
Allow to specify selected packages to --no-system (#914)
This allows to test a recipe which has a valid prefer_system_check without uninstalling the given system package.
1 parent b59ec57 commit 59749dc

File tree

8 files changed

+27
-20
lines changed

8 files changed

+27
-20
lines changed

alibuild_helpers/args.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ def doParseArgs():
176176
build_system = build_parser.add_mutually_exclusive_group()
177177
build_system.add_argument("--always-prefer-system", dest="preferSystem", action="store_true",
178178
help="Always use system packages when compatible.")
179-
build_system.add_argument("--no-system", dest="noSystem", action="store_true",
180-
help="Never use system packages, even if compatible.")
179+
build_system.add_argument("--no-system", dest="noSystem", nargs="?", const="*", default=None, metavar="PACKAGES",
180+
help="Never use system packages for the provided, command separated, PACKAGES, even if compatible.")
181181

182182
# Options for clean subcommand
183183
clean_parser.add_argument("-a", "--architecture", dest="architecture", metavar="ARCH", default=detectedArch,
@@ -237,8 +237,8 @@ def doParseArgs():
237237
deps_system = deps_parser.add_mutually_exclusive_group()
238238
deps_system.add_argument("--always-prefer-system", dest="preferSystem", action="store_true",
239239
help="Always use system packages when compatible.")
240-
deps_system.add_argument("--no-system", dest="noSystem", action="store_true",
241-
help="Never use system packages, even if compatible.")
240+
deps_system.add_argument("--no-system", dest="noSystem", nargs="?", const="*", default=None, metavar="PACKAGES",
241+
help="Never use system packages for PACKAGES, even if compatible.")
242242

243243
# Options for the doctor subcommand
244244
doctor_parser.add_argument("packages", metavar="PACKAGE", nargs="+",
@@ -258,8 +258,8 @@ def doParseArgs():
258258
doctor_system = doctor_parser.add_mutually_exclusive_group()
259259
doctor_system.add_argument("--always-prefer-system", dest="preferSystem", action="store_true",
260260
help="Always use system packages when compatible.")
261-
doctor_system.add_argument("--no-system", dest="noSystem", action="store_true",
262-
help="Never use system packages, even if compatible.")
261+
doctor_system.add_argument("--no-system", dest="noSystem", nargs="?", const="*", default=None, metavar="PACKAGES",
262+
help="Never use system packages for the provided, command separated, PACKAGES, even if compatible.")
263263

264264
doctor_docker = doctor_parser.add_argument_group(title="Use a Docker container", description="""\
265265
If you're planning to build inside a Docker container, e.g. using aliBuild
@@ -457,14 +457,14 @@ def finaliseArgs(args, parser):
457457

458458
# On selected platforms, caching is active by default
459459
if args.architecture in S3_SUPPORTED_ARCHS and not args.preferSystem and not args.no_remote_store:
460-
args.noSystem = True
460+
args.noSystem = "*"
461461
if not args.remoteStore:
462462
args.remoteStore = "https://s3.cern.ch/swift/v1/alibuild-repo"
463463
elif args.no_remote_store:
464464
args.remoteStore = ""
465465

466466
if args.remoteStore or args.writeStore:
467-
args.noSystem = True
467+
args.noSystem = "*"
468468

469469
if args.remoteStore.endswith("::rw") and args.writeStore:
470470
parser.error("cannot specify ::rw and --write-store at the same time")

alibuild_helpers/init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def doInit(args):
5050
specs=specs,
5151
configDir=args.configDir,
5252
preferSystem=False,
53-
noSystem=True,
53+
noSystem="*",
5454
architecture="",
5555
disable=[],
5656
defaults=args.defaults,

alibuild_helpers/utilities.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,14 @@ def getPackageList(packages, specs, configDir, preferSystem, noSystem,
498498
systemREMatches = re.match(systemRE, architecture)
499499
except TypeError:
500500
dieOnError(True, "Malformed entry prefer_system: %s in %s" % (systemRE, spec["package"]))
501-
if not noSystem and (preferSystem or systemREMatches):
501+
502+
noSystemList = []
503+
if noSystem == "*":
504+
noSystemList = [spec["package"]]
505+
elif noSystem is not None:
506+
noSystemList = noSystem.split(",")
507+
508+
if (spec["package"] not in noSystemList) and (preferSystem or systemREMatches):
502509
requested_version = resolve_version(spec, defaults, "unavailable", "unavailable")
503510
cmd = "REQUESTED_VERSION={version}\n{check}".format(
504511
version=quote(requested_version),

tests/test_args.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ class FakeExit(Exception):
4848
((), "build --force-unknown-architecture -j 10 zlib --disable gcc --disable foo,bar" , [("disable", ["gcc", "foo", "bar"])]),
4949
((), "init zlib --dist master" , [("dist", {"repo": "alisw/alidist", "ver": "master"})]),
5050
((), "init zlib --dist ktf/alidist@dev" , [("dist", {"repo": "ktf/alidist", "ver": "dev"})]),
51-
((), "build --force-unknown-architecture zlib --remote-store rsync://test.local/" , [("noSystem", True), ("remoteStore", "rsync://test.local/")]),
52-
((), "build --force-unknown-architecture zlib --remote-store rsync://test.local/::rw", [("noSystem", True), ("remoteStore", "rsync://test.local/"), ("writeStore", "rsync://test.local/")]),
53-
((), "build --force-unknown-architecture zlib --no-remote-store --remote-store rsync://test.local/", [("noSystem", False), ("remoteStore", "")]),
54-
((), "build zlib --architecture slc7_x86-64" , [("noSystem", True), ("preferSystem", False), ("remoteStore", "https://s3.cern.ch/swift/v1/alibuild-repo")]),
55-
((), "build zlib --architecture ubuntu1804_x86-64" , [("noSystem", False), ("preferSystem", False), ("remoteStore", "")]),
51+
((), "build --force-unknown-architecture zlib --remote-store rsync://test.local/" , [("noSystem", "*"), ("remoteStore", "rsync://test.local/")]),
52+
((), "build --force-unknown-architecture zlib --remote-store rsync://test.local/::rw", [("noSystem", "*"), ("remoteStore", "rsync://test.local/"), ("writeStore", "rsync://test.local/")]),
53+
((), "build --force-unknown-architecture zlib --no-remote-store --remote-store rsync://test.local/", [("noSystem", None), ("remoteStore", "")]),
54+
((), "build zlib --architecture slc7_x86-64" , [("noSystem", "*"), ("preferSystem", False), ("remoteStore", "https://s3.cern.ch/swift/v1/alibuild-repo")]),
55+
((), "build zlib --architecture ubuntu1804_x86-64" , [("noSystem", None), ("preferSystem", False), ("remoteStore", "")]),
5656
((), "build zlib -a slc7_x86-64" , [("docker", False), ("dockerImage", None), ("docker_extra_args", ["--network=host"])]),
5757
((), "build zlib -a slc7_x86-64 --docker-image registry.cern.ch/alisw/some-builder" , [("docker", True), ("dockerImage", "registry.cern.ch/alisw/some-builder")]),
5858
((), "build zlib -a slc7_x86-64 --docker" , [("docker", True), ("dockerImage", "registry.cern.ch/alisw/slc7-builder")]),

tests/test_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def test_coverDoBuild(self, mock_debug, mock_listdir, mock_warning, mock_git_git
268268
jobs=2,
269269
annotate={},
270270
preferSystem=[],
271-
noSystem=False,
271+
noSystem=None,
272272
debug=True,
273273
dryRun=False,
274274
aggressiveCleanup=False,

tests/test_deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def depsOpen(fn, mode):
5757
dockerImage=None,
5858
docker_extra_args=["--network=host"],
5959
preferSystem=[],
60-
noSystem=True,
60+
noSystem="*",
6161
architecture="slc7_x86-64",
6262
disable=[],
6363
neat=True,

tests/test_doctor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def resetOut():
8080
docker_extra_args=["--network=host"],
8181
debug=False,
8282
preferSystem=[],
83-
noSystem=False,
83+
noSystem="*",
8484
architecture="osx_x86-64",
8585
disable=[],
8686
defaults="release")

tests/test_packagelist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ def getPackageListWithDefaults(packages, force_rebuild=()):
8989
specs=specs,
9090
configDir="CONFIG_DIR",
9191
# Make sure getPackageList considers prefer_system_check.
92-
# (Even with preferSystem=False + noSystem=False, it is sufficient
92+
# (Even with preferSystem=False + noSystem=None, it is sufficient
9393
# if the prefer_system regex matches the architecture.)
9494
preferSystem=True,
95-
noSystem=False,
95+
noSystem=None,
9696
architecture="ARCH",
9797
disable=[],
9898
defaults="release",

0 commit comments

Comments
 (0)