From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:pending commit in: catalyst/, catalyst/targets/
Date: Wed, 22 Nov 2017 15:52:45 +0000 (UTC) [thread overview]
Message-ID: <1511313382.57055cb085a23358febf61b2c7d36627fc2815dd.dolsen@gentoo> (raw)
Message-ID: <20171122155245.-0A4rXkj3c1RoSET6cnmIpjN0HPuQsz7VuGo0Eik_Z8@z> (raw)
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
next reply other threads:[~2017-11-22 15:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 17:20 Brian Dolbec [this message]
2017-11-22 15:52 ` [gentoo-commits] proj/catalyst:pending commit in: catalyst/, catalyst/targets/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2020-04-11 20:27 [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/ Matt Turner
2015-01-01 5:59 [gentoo-commits] proj/catalyst:pending commit in: catalyst/, catalyst/targets/ Brian Dolbec
2015-02-26 4:12 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/targets/, catalyst/ Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511313382.57055cb085a23358febf61b2c7d36627fc2815dd.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox