summaryrefslogtreecommitdiff
path: root/lib/spack/spack/cmd/mark.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/cmd/mark.py')
-rw-r--r--lib/spack/spack/cmd/mark.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/spack/spack/cmd/mark.py b/lib/spack/spack/cmd/mark.py
index cf816a21f5..f613522d2c 100644
--- a/lib/spack/spack/cmd/mark.py
+++ b/lib/spack/spack/cmd/mark.py
@@ -8,12 +8,10 @@ import sys
from llnl.util import tty
import spack.cmd
-import spack.error
-import spack.package_base
-import spack.repo
import spack.store
from spack.cmd.common import arguments
-from spack.database import InstallStatuses
+
+from ..enums import InstallRecordStatus
description = "mark packages as explicitly or implicitly installed"
section = "admin"
@@ -70,8 +68,7 @@ def find_matching_specs(specs, allow_multiple_matches=False):
has_errors = False
for spec in specs:
- install_query = [InstallStatuses.INSTALLED]
- matching = spack.store.STORE.db.query_local(spec, installed=install_query)
+ matching = spack.store.STORE.db.query_local(spec, installed=InstallRecordStatus.INSTALLED)
# For each spec provided, make sure it refers to only one package.
# Fail and ask user to be unambiguous if it doesn't
if not allow_multiple_matches and len(matching) > 1:
@@ -83,8 +80,8 @@ def find_matching_specs(specs, allow_multiple_matches=False):
has_errors = True
# No installed package matches the query
- if len(matching) == 0 and spec is not any:
- tty.die("{0} does not match any installed packages.".format(spec))
+ if len(matching) == 0 and spec is not None:
+ tty.die(f"{spec} does not match any installed packages.")
specs_from_cli.extend(matching)
@@ -101,8 +98,9 @@ def do_mark(specs, explicit):
specs (list): list of specs to be marked
explicit (bool): whether to mark specs as explicitly installed
"""
- for spec in specs:
- spack.store.STORE.db.update_explicit(spec, explicit)
+ with spack.store.STORE.db.write_transaction():
+ for spec in specs:
+ spack.store.STORE.db.mark(spec, "explicit", explicit)
def mark_specs(args, specs):
@@ -119,6 +117,6 @@ def mark(parser, args):
" Use `spack mark --all` to mark ALL packages.",
)
- # [any] here handles the --all case by forcing all specs to be returned
- specs = spack.cmd.parse_specs(args.specs) if args.specs else [any]
+ # [None] here handles the --all case by forcing all specs to be returned
+ specs = spack.cmd.parse_specs(args.specs) if args.specs else [None]
mark_specs(args, specs)