[yum-commits] 2 commits - cli.py docs/yum.8 yum/__init__.py yum/repos.py yum.spec
zpavlas at osuosl.org
zpavlas at osuosl.org
Wed Oct 17 09:37:03 UTC 2012
cli.py | 6 ++++++
docs/yum.8 | 6 ++++++
yum.spec | 2 ++
yum/__init__.py | 35 +++++++++++++++++++++++++++++++++--
yum/repos.py | 4 ++++
5 files changed, 51 insertions(+), 2 deletions(-)
New commits:
commit 05666dc9295fb433d1b081068dbe74e535cfc228
Author: ZdenÄk Pavlas <zpavlas at redhat.com>
Date: Fri Oct 12 15:21:44 2012 +0200
background downloading with --downloadonly
- just temp rpm files, no temporary directories
- 'predownload' hook runs when 'yum.pid' lock is still held
- 'postdownload' hook is skipped if we run downloadonly
It may be worth to relock after downloading, save partial downloads,
and run postdownload hooks, not sure.
predownload hooks run when locked, so this does not break presto,
but drpms download in foreground. Finally a good reason to move
it to core :)
diff --git a/yum/__init__.py b/yum/__init__.py
index 25f4ca4..c161fc9 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2239,6 +2239,14 @@ much more problems).
self.verbose_logger.debug(_("using local copy of %s") %(po,))
continue
+ if downloadonly:
+ # download to temp file
+ rpmfile = po.localpath
+ po.localpath += '.%d.tmp' % os.getpid()
+ try: os.rename(rpmfile, po.localpath)
+ except OSError: pass
+ po.basepath # prefetch now; fails when repos are closed
+
remote_pkgs.append(po)
remote_size += po.size
@@ -2247,6 +2255,11 @@ much more problems).
# way to save this, report the error and return
if (self.conf.cache or repo_cached) and errors:
return errors
+ if downloadonly:
+ # close DBs, unlock
+ self.repos.close()
+ self.closeRpmDB()
+ self.doUnlock()
remote_pkgs.sort(mediasort)
# This is kind of a hack and does nothing in non-Fedora versions,
@@ -2316,7 +2329,21 @@ much more problems).
if callback_total is not None and not errors:
callback_total(remote_pkgs, remote_size, beg_download)
- self.plugins.run('postdownload', pkglist=pkglist, errors=errors)
+ if downloadonly:
+ for po in remote_pkgs:
+ rpmfile = po.localpath.rsplit('.', 2)[0]
+ if po in errors:
+ # we may throw away partial file here- but we don't lock,
+ # so can't rename tempfile to rpmfile safely
+ misc.unlink_f(po.localpath)
+ if po not in errors:
+ # verifyPkg() didn't complain, so (potentially)
+ # overwriting another copy should not be a problem
+ os.rename(po.localpath, rpmfile)
+ po.localpath = rpmfile
+ else:
+ # XXX: Run unlocked? Skip this for now..
+ self.plugins.run('postdownload', pkglist=pkglist, errors=errors)
# Close curl object after we've downloaded everything.
if hasattr(urlgrabber.grabber, 'reset_curl_obj'):
commit 639a768c93d8c18a1906bb22840d4acb5efa7ac4
Author: ZdenÄk Pavlas <zpavlas at redhat.com>
Date: Fri Oct 5 09:01:29 2012 +0200
swallow "downloadonly" plugin
Commandline options added:
--downloadonly: Don't update, just download.
--downloaddir=directory: Specifies alternative DL directory.
diff --git a/cli.py b/cli.py
index cf2c369..4122d5d 100755
--- a/cli.py
+++ b/cli.py
@@ -2084,6 +2084,8 @@ class YumOptionParser(OptionParser):
self.base.conf.assumeyes = 1
if opts.assumeno:
self.base.conf.assumeno = 1
+ self.base.conf.downloadonly = opts.dlonly
+ self.base.conf.downloaddir = opts.dldir
# Treat users like root as much as possible:
if not self.base.setCacheDir():
@@ -2305,6 +2307,10 @@ class YumOptionParser(OptionParser):
help=_("control whether color is used"))
group.add_option("", "--releasever", dest="releasever", default=None,
help=_("set value of $releasever in yum config and repo files"))
+ group.add_option("--downloadonly", dest="dlonly", action="store_true",
+ help=_("don't update, just download"))
+ group.add_option("--downloaddir", dest="dldir", default=None,
+ help=_("specifies an alternate directory to store packages"))
group.add_option("", "--setopt", dest="setopts", default=[],
action="append", help=_("set arbitrary config and repo options"))
diff --git a/docs/yum.8 b/docs/yum.8
index dab01f6..65ff448 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -586,6 +586,12 @@ configuration to stop this).
This option makes yum go slower, checking for things that shouldn't be possible
making it more tolerant of external errors.
.br
+.IP "\fB\-\-downloadonly\fP"
+Don't update, just download.
+.br
+.IP "\fB\-\-downloaddir=directory\fP"
+Specifies an alternate directory to store packages.
+.br
.IP "\fB\-\-setopt=option=value\fP"
Set any config option in yum config or repo files. For options in the global
config just use: \-\-setopt=option=value for repo options use: \-\-setopt=repoid.option=value
diff --git a/yum.spec b/yum.spec
index 65c62a9..60a19d4 100644
--- a/yum.spec
+++ b/yum.spec
@@ -79,6 +79,8 @@ Obsoletes: yum-plugin-protect-packages < 1.1.27-0
Provides: yum-protect-packages = 1.1.27-0.yum
Provides: yum-plugin-protect-packages = 1.1.27-0.yum
Obsoletes: yum-plugin-download-order <= 0.2-2
+Obsoletes: yum-plugin-downloadonly <= 3.4.3-44
+Provides: yum-plugin-downloadonly = 3.4.3-44.yum
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
diff --git a/yum/__init__.py b/yum/__init__.py
index a159706..25f4ca4 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -21,6 +21,7 @@ The Yum RPM software updater.
import os
import os.path
import rpm
+import sys
def _rpm_ver_atleast(vertup):
""" Check if rpm is at least the current vertup. Can return False/True/None
@@ -2219,6 +2220,7 @@ much more problems).
self.history.close()
self.plugins.run('predownload', pkglist=pkglist)
+ downloadonly = getattr(self.conf, 'downloadonly', False)
repo_cached = False
remote_pkgs = []
remote_size = 0
@@ -2245,7 +2247,6 @@ much more problems).
# way to save this, report the error and return
if (self.conf.cache or repo_cached) and errors:
return errors
-
remote_pkgs.sort(mediasort)
# This is kind of a hack and does nothing in non-Fedora versions,
@@ -2321,6 +2322,9 @@ much more problems).
if hasattr(urlgrabber.grabber, 'reset_curl_obj'):
urlgrabber.grabber.reset_curl_obj()
+ if downloadonly and not errors: # caller handles errors
+ self.verbose_logger.info(_('exiting because --downloadonly specified'))
+ sys.exit(self.exit_code)
return errors
def verifyHeader(self, fo, po, raiseError):
diff --git a/yum/repos.py b/yum/repos.py
index 6d4c20e..de5da1e 100644
--- a/yum/repos.py
+++ b/yum/repos.py
@@ -129,6 +129,10 @@ class RepoStorage:
# so nothing else touches us
if not repo.enabled:
self.disableRepo(repo.id)
+ else:
+ pkgdir = getattr(self.ayum.conf, 'downloaddir', None)
+ if pkgdir:
+ repo.pkgdir = pkgdir
self._setup = True
self.retrieveAllMD()
More information about the Yum-commits
mailing list