Skip to content

Commit

Permalink
Add mechanism to attempt install without failing
Browse files Browse the repository at this point in the history
In OpenEmbedded, for complementary and 'attemptonly' package processing,
we need a way to instruct smart to try to install, but ignore any
failures (usually conflicts).

This option only works for the install operation.

Signed-off-by: Mark Hatle <[email protected]>
  • Loading branch information
Mark Hatle authored and bluelightning committed Dec 13, 2013
1 parent e467193 commit 47ed1bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions smart/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def option_parser():
parser = OptionParser(usage=USAGE,
description=DESCRIPTION,
examples=EXAMPLES)
parser.add_option("--attempt", action="store_true",
help=_("attempt to install packages, ignore failures"))
parser.add_option("--stepped", action="store_true",
help=_("split operation in steps"))
parser.add_option("--urls", action="store_true",
Expand Down Expand Up @@ -80,6 +82,9 @@ def main(ctrl, opts):
if not opts.args:
raise Error, _("no package(s) given")

if opts.attempt:
sysconf.set("attempt-install", True, soft=True)

if opts.explain:
sysconf.set("explain-changesets", True, soft=True)

Expand Down
14 changes: 11 additions & 3 deletions smart/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,17 @@ def run(self):
else:
op = REMOVE
if op is INSTALL or op is REINSTALL:
self._install(pkg, changeset, locked, pending)
if pkg in changeset:
changeset.setRequested(pkg, True)
try:
self._install(pkg, changeset, locked, pending)
if pkg in changeset:
changeset.setRequested(pkg, True)
except Failed, e:
if sysconf.has("attempt-install", soft=True):
if pkg in changeset:
del changeset[pkg]
continue
else:
raise Failed, e
elif op is REMOVE:
self._remove(pkg, changeset, locked, pending)
elif op is UPGRADE:
Expand Down

0 comments on commit 47ed1bf

Please sign in to comment.