From 47b32e3c2d6a7c3b77583f2ed1516bfd48bf14c3 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Wed, 7 Nov 2007 19:44:12 -0500 Subject: [PATCH] Move the _link function to the __init__ of pypungi to be used by both gather and pungi. Attempt to hardlink release note files instead of copy them. (helps preserve timestamps) --- Changelog | 3 +++ pypungi/__init__.py | 11 +++++++++++ pypungi/gather.py | 15 ++------------- pypungi/pungi.py | 4 ++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Changelog b/Changelog index 0709b800..29d398a5 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +* Wed Nov 07 2007 Jesse Keating +- Preserve timestamps on release note files + * Mon Oct 29 2007 Jesse Keating - Check to see if the cached package is same size or larger and if so remove it. Otherwise regets will freak out. diff --git a/pypungi/__init__.py b/pypungi/__init__.py index 0f28cebe..4ef84cc4 100644 --- a/pypungi/__init__.py +++ b/pypungi/__init__.py @@ -68,3 +68,14 @@ def _doRunCommand(command, logger, rundir='/tmp', output=subprocess.PIPE, error= logger.error(err) raise OSError, "Got an error from %s: %s" % (command[0], err) +def _link(local, target): + try: + os.link(local, target) + except OSError, e: + if e.errno != 18: # EXDEV + self.logger.error('Got an error linking from cache: %s' % e) + raise OSError, e + + # Can't hardlink cross file systems + shutil.copy2(local, target) + diff --git a/pypungi/gather.py b/pypungi/gather.py index 21d16e24..2c2c8f83 100755 --- a/pypungi/gather.py +++ b/pypungi/gather.py @@ -293,17 +293,6 @@ class Gather(pypungi.PungiBase): if not srpm in self.srpmlist: self.srpmlist.append(srpm) - def _link(self, local, target): - try: - os.link(local, target) - except OSError, e: - if e.errno != 18: # EXDEV - self.logger.error('Got an error linking from cache: %s' % e) - raise OSError, e - - # Can't hardlink cross file systems - shutil.copy2(local, target) - def _downloadPackageList(self, polist, relpkgdir): """Cycle through the list of package objects and download them from their respective repos.""" @@ -337,7 +326,7 @@ class Gather(pypungi.PungiBase): self.logger.debug("%s already exists and appears to be complete" % local) if os.path.exists(target): os.remove(target) # avoid traceback after interrupted download - self._link(local, target) + pypungi._link(local, target) continue elif os.path.exists(local): # Check to see if the file on disk is bigger, and if so, remove it @@ -355,7 +344,7 @@ class Gather(pypungi.PungiBase): if not os.path.exists(local) or not os.path.samefile(path, local): shutil.copy2(path, local) - self._link(local, target) + pypungi._link(local, target) self.logger.info('Finished downloading packages.') diff --git a/pypungi/pungi.py b/pypungi/pungi.py index 8416ba08..17baccf7 100755 --- a/pypungi/pungi.py +++ b/pypungi/pungi.py @@ -208,8 +208,8 @@ class Pungi(pypungi.PungiBase): for filename in filelist: for regex in fileres: if regex.match(filename) and not os.path.exists(os.path.join(self.topdir, filename)): - self.logger.info("Copying release note file %s" % filename) - shutil.copy(os.path.join(dirpath, filename), os.path.join(self.topdir, filename)) + self.logger.info("Linking release note file %s" % filename) + pypungi._link(os.path.join(dirpath, filename), os.path.join(self.topdir, filename)) self.common_files.append(filename) # Walk the tree for our dirs