From bd2ffef69fba5df233ea098fc6f82f5399bbb053 Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Wed, 25 Oct 2006 05:27:15 +0000 Subject: [PATCH] check in patch from Mark McLoughlin to fix handling of local repos in reposync, repotrack and yumdownloader. --- reposync.py | 6 ++++-- repotrack.py | 5 ++++- yumdownloader.py | 10 +++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/reposync.py b/reposync.py index b3b1844..cdb5193 100644 --- a/reposync.py +++ b/reposync.py @@ -34,6 +34,7 @@ import os import sys +import shutil from optparse import OptionParser from urlparse import urljoin @@ -186,9 +187,10 @@ def main(): if not opts.quiet: my.logger.info( 'Downloading %s' % os.path.basename(remote)) pkg.localpath = local # Hack: to set the localpath we want. - repo.getPackage(pkg) - + path = repo.getPackage(pkg) + if not os.path.exists(local) or not os.path.samefile(path, local): + shutil.copy2(path, local) if __name__ == "__main__": main() diff --git a/repotrack.py b/repotrack.py index 3d27a9e..b382ed4 100644 --- a/repotrack.py +++ b/repotrack.py @@ -23,6 +23,7 @@ import os import sys +import shutil from optparse import OptionParser from urlparse import urljoin import logging @@ -235,8 +236,10 @@ def main(): if not opts.quiet: my.logger.info('Downloading %s' % os.path.basename(remote)) pkg.localpath = local # Hack: to set the localpath to what we want. - repo.getPackage(pkg) + path = repo.getPackage(pkg) + if not os.path.exists(local) or not os.path.samefile(path, local): + shutil.copy2(path, local) if __name__ == "__main__": main() diff --git a/yumdownloader.py b/yumdownloader.py index 986d9ba..0edab26 100644 --- a/yumdownloader.py +++ b/yumdownloader.py @@ -21,6 +21,7 @@ sys.path.insert(0, '/usr/share/yum-cli') import yum import yum.Errors import os +import shutil import output import rpmUtils.arch from urlgrabber.progress import TextMeter @@ -174,7 +175,14 @@ def main(): # Disable cache otherwise things won't download repo.cache = 0 download.localpath = local # Hack: to set the localpath we want. - repo.getPackage(download) + path = repo.getPackage(download) + + if not os.path.exists(local) or not os.path.samefile(path, local): + progress = TextMeter() + progress.start(basename=os.path.basename(local), + size=os.stat(path).st_size) + shutil.copy2(path, local) + progress.end(progress.size) if __name__ == '__main__': main() -- 2.20.1