[Yum-devel] [PATCH] Return an error code if yum can't install any of the specified packages
James Antill
james at and.org
Thu Mar 11 19:54:42 UTC 2010
People want a bash scriptable way to say "X should be installed". So
with this patch:
. If _any_ package specified: is installed already; or is found and will
be installed == yum returns 0 (or at least goes into depchecking etc.)
. If _all_ package(s) are "not found", yum turns the message "Nothing to do"
into an error (returns 1, atm).
...thus:
1. yum install -y a b && echo worked
This will echo "worked" if _either_ a or b is installed after yum
finishes, but tries to install both.
2. yum install a && yum install b && echo worked
This will echo "worked" if both are installed (and if a is not
available, b will not even try to be installed).
---
cli.py | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/cli.py b/cli.py
index a34d205..cebbae3 100644
--- a/cli.py
+++ b/cli.py
@@ -595,6 +595,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
oldcount = len(self.tsInfo)
+ done = False
for arg in userlist:
if (arg.endswith('.rpm') and (yum.misc.re_remote_url(arg) or
os.path.exists(arg))):
@@ -609,8 +610,13 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
self.term.MODE['bold'], arg,
self.term.MODE['normal'])
self._maybeYouMeant(arg)
+ else:
+ done = True
if len(self.tsInfo) > oldcount:
return 2, [_('Package(s) to install')]
+
+ if not done:
+ return 1, [_('Nothing to do')]
return 0, [_('Nothing to do')]
def updatePkgs(self, userlist, quiet=0):
--
1.6.6
More information about the Yum-devel
mailing list