Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev: (2 commits)
  Add simple install-n etc. functions for rel-eng. Takes giant yum shell install lists from ~12 seconds to ~2.
  ...
  • Loading branch information
james-antill committed Feb 20, 2012
2 parents a381302 + d56dcaa commit 52ec843
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
18 changes: 16 additions & 2 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def _pkg2ups(pkg, reqpo=None):

return ret

def installPkgs(self, userlist):
def installPkgs(self, userlist, basecmd='install'):
"""Attempt to take the user specified list of packages or
wildcards and install them, or if they are installed, update
them to a newer version. If a complete version number is
Expand Down Expand Up @@ -815,7 +815,21 @@ def installPkgs(self, userlist):
continue # it was something on disk and it ended in rpm
# no matter what we don't go looking at repos
try:
txmbrs = self.install(pattern=arg)
if False: pass
elif basecmd == 'install-n':
txmbrs = self.install(name=arg)
elif basecmd == 'install-na':
n,a = arg.split('.')
txmbrs = self.install(name=n, arch=a)
elif basecmd == 'install-nevra':
nevr,a = arg.rsplit('.', 2)
n,ev,r = nevr.rsplit('-', 3)
e,v = ev.split(':', 2)
txmbrs = self.install(name=n,
epoch=e, version=v, release=r, arch=a)
else:
assert basecmd == 'install', basecmd
txmbrs = self.install(pattern=arg)
except yum.Errors.InstallError:
self.verbose_logger.log(yum.logginglevels.INFO_2,
_('No package %s%s%s available.'),
Expand Down
5 changes: 5 additions & 0 deletions docs/yum.8
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ like localinstall\&. If the name doesn't match a package, then package
"provides" are searched (e.g. "_sqlitecache.so()(64bit)") as are
filelists (Eg. "/usr/bin/yum"). Also note that for filelists, wildcards will
match multiple packages\&.

Because install does a lot of work to make it as easy as possible to use, there
are also a few specific install commands "\fBinstall-n\fP", "\fBinstall-na\fP"
and "\fBinstall-nevra\fP". These only work on package names, and do not process
wildcards etc.
.IP
.IP "\fBupdate\fP"
If run without any packages, update will update every currently
Expand Down
29 changes: 19 additions & 10 deletions output.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,13 @@ def reportDownloadSize(self, packages, installonly=False):
locsize = 0
insize = 0
error = False

def _call_log(*args):
if self.verbose_logger.isEnabledFor(yum.logginglevels.INFO_1):
self.verbose_logger.log(logginglevels.INFO_1, *args)
elif self.conf.assumeno or not self.conf.assumeyes:
self.logger.warn(logginglevels.INFO_1, *args)

for pkg in packages:
# Just to be on the safe side, if for some reason getting
# the package size fails, log the error and don't report download
Expand Down Expand Up @@ -1359,15 +1366,12 @@ def reportDownloadSize(self, packages, installonly=False):

if (not error):
if locsize:
self.verbose_logger.log(logginglevels.INFO_1, _("Total size: %s"),
self.format_number(totsize))
_call_log(_("Total size: %s"), self.format_number(totsize))
if locsize != totsize:
self.verbose_logger.log(logginglevels.INFO_1, _("Total download size: %s"),
self.format_number(totsize - locsize))
_call_log(_("Total download size: %s"),
self.format_number(totsize - locsize))
if installonly:
self.verbose_logger.log(logginglevels.INFO_1,
_("Installed size: %s"),
self.format_number(insize))
_call_log(_("Installed size: %s"), self.format_number(insize))

def reportRemoveSize(self, packages):
"""Report the total size of packages being removed.
Expand All @@ -1388,9 +1392,14 @@ def reportRemoveSize(self, packages):
self.logger.error(_('There was an error calculating installed size'))
break
if (not error):
self.verbose_logger.log(logginglevels.INFO_1,
_("Installed size: %s"),
self.format_number(totsize))
if self.verbose_logger.isEnabledFor(yum.logginglevels.INFO_1):
self.verbose_logger.log(logginglevels.INFO_1,
_("Installed size: %s"),
self.format_number(totsize))
elif self.conf.assumeno or not self.conf.assumeyes:
self.logger.warn(logginglevels.INFO_1,
_("Installed size: %s"),
self.format_number(totsize))

def listTransaction(self):
"""Return a string representation of the transaction in an
Expand Down
4 changes: 2 additions & 2 deletions yumcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def getNames(self):
:return: a list containing the names of this command
"""
return ['install']
return ['install', 'install-n', 'install-na', 'install-nevra']

def getUsage(self):
"""Return a usage string for this command.
Expand Down Expand Up @@ -340,7 +340,7 @@ def doCommand(self, base, basecmd, extcmds):
"""
self.doneCommand(base, _("Setting up Install Process"))
try:
return base.installPkgs(extcmds)
return base.installPkgs(extcmds, basecmd=basecmd)
except yum.Errors.YumBaseError, e:
return 1, [str(e)]

Expand Down

0 comments on commit 52ec843

Please sign in to comment.