* [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/
@ 2017-11-29 17:20 99% Brian Dolbec
0 siblings, 0 replies; 1+ results
From: Brian Dolbec @ 2017-11-29 17:20 UTC (permalink / raw
To: gentoo-commits
commit: 57055cb085a23358febf61b2c7d36627fc2815dd
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 6 20:51:23 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Nov 22 01:16:22 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=57055cb0
stage1: Fix seedcache to clean out the original seed root, keep only the stage1root
Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>
catalyst/fileops.py | 23 +++++++++++++++++++++++
catalyst/targets/stage1.py | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index ef4ee8d1..5e51f1fc 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -107,3 +107,26 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False,
def clear_path(target):
"""Nuke |target| regardless of it being a dir or file."""
clear_dir(target, remove=True)
+
+
+def move_path(src, dest):
+ '''Move a source target to a new destination
+
+ :param src: source path to move
+ :param dest: destination path to move it to
+ :returns: boolean
+ '''
+ log.debug('Start move_path(%s, %s)', src, dest)
+ if os.path.isdir(src) and not os.path.islink(src):
+ if os.path.exists(dest):
+ log.warning('Removing existing target destination: %s', dest)
+ if not clear_dir(dest, remove=True):
+ return False
+ log.debug('Moving source...')
+ try:
+ shutil.move(src, dest)
+ except Exception:
+ log.error('move_path failed', exc_info=True)
+ return False
+ return True
+ return False
diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 18ef520d..cc4366b6 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -9,7 +9,7 @@ from snakeoil import fileutils
from catalyst import log
from catalyst.support import normpath
-from catalyst.fileops import ensure_dirs
+from catalyst.fileops import ensure_dirs, move_path
from catalyst.base.stagebase import StageBase
@@ -86,3 +86,40 @@ class stage1(StageBase):
self.mounts.append("stage1root/proc")
self.target_mounts["stage1root/proc"] = "/tmp/stage1root/proc"
self.mountmap["stage1root/proc"] = "/proc"
+
+ def set_completion_action_sequences(self):
+ '''Override function for stage1
+
+ Its purpose is to move the new stage1root out of the seed stage
+ and rename it to the stage1 chroot_path after cleaning the seed stage
+ chroot for re-use in stage2 without the need to unpack it.
+ '''
+ if "fetch" not in self.settings["options"]:
+ self.settings["action_sequence"].append("capture")
+ if "keepwork" in self.settings["options"]:
+ self.settings["action_sequence"].append("clear_autoresume")
+ elif "seedcache" in self.settings["options"]:
+ self.settings["action_sequence"].append("remove_autoresume")
+ self.settings["action_sequence"].append("clean_stage1")
+ else:
+ self.settings["action_sequence"].append("remove_autoresume")
+ self.settings["action_sequence"].append("remove_chroot")
+ return
+
+
+ def clean_stage1(self):
+ '''seedcache is enabled, so salvage the /tmp/stage1root,
+ remove the seed chroot'''
+ log.notice('Salvaging the stage1root from the chroot path ...')
+ # move the self.settings["stage_path"] outside of the self.settings["chroot_path"]
+ tmp_path = normpath(self.settings["storedir"] + "/tmp/" + "stage1root")
+ if move_path(self.settings["stage_path"], tmp_path):
+ self.remove_chroot()
+ # move it to self.settings["chroot_path"]
+ if not move_path(tmp_path, self.settings["chroot_path"]):
+ log.error('clean_stage1 failed, see previous log messages for details')
+ return False
+ log.notice('Successfully moved and cleaned the stage1root for the seedcache')
+ return True
+ log.error('clean_stage1 failed to move the stage1root to a temporary loation')
+ return False
^ permalink raw reply related [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-11-29 17:20 99% [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/ Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox