diff options
author | Michał Górny <mgorny@gentoo.org> | 2019-10-06 21:44:55 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2019-10-09 08:00:35 +0200 |
commit | 0d34d89d5028ac24cb45ed43ee1eed9cc9836e0c (patch) | |
tree | 0b314b3bb24c0d38c8177caf4d34598adbbe3cea /lib/portage/_emirrordist/DeletionTask.py | |
parent | fetch: Support GLEP 75 mirror structure (diff) | |
download | portage-0d34d89d5028ac24cb45ed43ee1eed9cc9836e0c.tar.gz portage-0d34d89d5028ac24cb45ed43ee1eed9cc9836e0c.tar.bz2 portage-0d34d89d5028ac24cb45ed43ee1eed9cc9836e0c.zip |
emirrordist: Implement mirror layout.conf support
Read mirror layout from layout.conf in distfiles directory. When
multiple layouts are used, fetch according to the first one and then
hardlink according to the remaining layouts. Similarly, when deleting
recycle or delete according to the first layout, then unlink according
to all remaining layouts.
Reviewed-by: Zac Medico <zmedico@gentoo.org>
Closes: https://github.com/gentoo/portage/pull/463
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'lib/portage/_emirrordist/DeletionTask.py')
-rw-r--r-- | lib/portage/_emirrordist/DeletionTask.py | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/lib/portage/_emirrordist/DeletionTask.py b/lib/portage/_emirrordist/DeletionTask.py index 7d10957fa..db5ac5ffb 100644 --- a/lib/portage/_emirrordist/DeletionTask.py +++ b/lib/portage/_emirrordist/DeletionTask.py @@ -1,4 +1,4 @@ -# Copyright 2013 Gentoo Foundation +# Copyright 2013-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import errno @@ -15,10 +15,10 @@ class DeletionTask(CompositeTask): def _start(self): distfile_path = os.path.join( - self.config.options.distfiles, self.distfile) + self.config.options.distfiles, + self.config.layouts[0].get_path(self.distfile)) if self.config.options.recycle_dir is not None: - distfile_path = os.path.join(self.config.options.distfiles, self.distfile) recycle_path = os.path.join( self.config.options.recycle_dir, self.distfile) if self.config.options.dry_run: @@ -28,13 +28,14 @@ class DeletionTask(CompositeTask): logging.debug(("move '%s' from " "distfiles to recycle") % self.distfile) try: - os.rename(distfile_path, recycle_path) + # note: distfile_path can be a symlink here + os.rename(os.path.realpath(distfile_path), recycle_path) except OSError as e: if e.errno != errno.EXDEV: logging.error(("rename %s from distfiles to " "recycle failed: %s") % (self.distfile, e)) else: - self.returncode = os.EX_OK + self._delete_links() self._async_wait() return @@ -62,8 +63,7 @@ class DeletionTask(CompositeTask): success = False if success: - self._success() - self.returncode = os.EX_OK + self._delete_links() else: self.returncode = 1 @@ -93,14 +93,33 @@ class DeletionTask(CompositeTask): success = False if success: - self._success() - self.returncode = os.EX_OK + self._delete_links() else: self.returncode = 1 self._current_task = None self.wait() + def _delete_links(self): + success = True + for layout in self.config.layouts[1:]: + distfile_path = os.path.join( + self.config.options.distfiles, + layout.get_path(self.distfile)) + try: + os.unlink(distfile_path) + except OSError as e: + if e.errno not in (errno.ENOENT, errno.ESTALE): + logging.error("%s unlink failed in distfiles: %s" % + (self.distfile, e)) + success = False + + if success: + self._success() + self.returncode = os.EX_OK + else: + self.returncode = 1 + def _success(self): cpv = "unknown" |