Skip to content

Commit

Permalink
[reposync] Add --urls option (RhBug:1686602)
Browse files Browse the repository at this point in the history
This is compatibility with yum-utils version of the reposync.
When the --urls switch is used, packages are not downloaded from
repositories, only their URLs are printed.

https://bugzilla.redhat.com/show_bug.cgi?id=1686602
  • Loading branch information
m-blaha committed Jul 12, 2019
1 parent 7bb30c0 commit 09f7c5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/reposync.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Options
``--remote-time``
Try to set the timestamps of the downloaded files to those on the remote side.

``-u, --urls``
Just print urls of what would be downloaded, don't download.

Besides these reposync specific options the ``dnf reposync`` command also accepts all general DNF options. This is especially useful for specifying which repositories should be synchronized (``--repoid`` option). See `Options` in :manpage:`dnf(8)` for details.

--------
Expand Down
13 changes: 12 additions & 1 deletion plugins/reposync.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def set_argparser(parser):
parser.add_argument('--remote-time', default=False, action='store_true',
help=_('try to set local timestamps of local files by '
'the one on the server'))
parser.add_argument('-u', '--urls', default=False, action='store_true',
help=_("Just list urls of what would be downloaded, "
"don't download"))

def configure(self):
demands = self.cli.demands
Expand Down Expand Up @@ -113,7 +116,10 @@ def run(self):
if self.opts.downloadcomps:
self.getcomps(repo)
pkglist = self.get_pkglist(repo)
self.download_packages(repo, pkglist)
if self.opts.urls:
self.print_urls(pkglist)
else:
self.download_packages(repo, pkglist)
if self.opts.delete:
self.delete_old_local_packages(pkglist)

Expand Down Expand Up @@ -203,3 +209,8 @@ def download_packages(self, repo, pkglist):
target_dir = os.path.dirname(self.pkg_download_path(pkg))
dnf.util.ensure_dir(target_dir)
shutil.copy(pkg_path, target_dir)

def print_urls(self, pkglist):
for pkg in pkglist:
url = pkg.remote_location(schemes=None)
print(url)

0 comments on commit 09f7c5c

Please sign in to comment.