[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2023-07-01 Thread Andreas K. Hüttel
commit: 9d6e495ca2ee55c21befc183a9a56fc5062a63c7
Author: Andreas K. Hüttel  gentoo  org>
AuthorDate: Sat Jul  1 17:44:41 2023 +
Commit: Andreas K. Hüttel  gentoo  org>
CommitDate: Sat Jul  1 19:26:14 2023 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=9d6e495c

stagebase: Fix and improve port_logdir config option

NOTE: The cleaning of log files does not work yet (and probably
never did).

Signed-off-by: Andreas K. Hüttel  gentoo.org>

 catalyst/base/stagebase.py | 7 +++
 catalyst/defaults.py   | 2 ++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 65f4306e..74d197b5 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -271,9 +271,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
 if "port_logdir" in self.settings:
 self.mount['port_logdir']['enable'] = True
-self.mount['port_logdir']['source'] = self.settings['port_logdir']
-self.env["PORT_LOGDIR"] = self.settings["port_logdir"]
-self.env["PORT_LOGDIR_CLEAN"] = PORT_LOGDIR_CLEAN
+self.mount['port_logdir']['source'] = 
normpath(self.settings['port_logdir'] + "/" + self.settings["target_subpath"] + 
"/")
+self.env["PORTAGE_LOGDIR"] = self.settings["target_logdir"]
 
 def override_cbuild(self):
 if "CBUILD" in self.makeconf:
@@ -1002,7 +1001,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 # We may need to create the source of the bind mount. 
E.g., in the
 # case of an empty package cache we must create the 
directory that
 # the binary packages will be stored into.
-source_path.mkdir(mode=0o755, exist_ok=True)
+source_path.mkdir(mode=0o755, parents=True, exist_ok=True)
 
 Path(target).mkdir(mode=0o755, parents=True, exist_ok=True)
 

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 2cede562..39b71c34 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -25,6 +25,7 @@ valid_config_file_values = frozenset([
 "sharedir",
 "storedir",
 "target_distdir",
+"target_logdir",
 "target_pkgdir",
 "var_tmpfs_portage",
 ])
@@ -53,6 +54,7 @@ confdefaults = {
 "shdir": "%(sharedir)s/targets",
 "storedir": "/var/tmp/catalyst",
 "target_distdir": "/var/cache/distfiles",
+"target_logdir": "/var/log/portage",
 "target_pkgdir": "/var/cache/binpkgs",
 }
 



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2021-02-28 Thread Andreas K. Hüttel
commit: 483385348b32fab2230f596816b6e1d0b6489962
Author: Andreas K. Hüttel  gentoo  org>
AuthorDate: Wed Feb 24 21:26:58 2021 +
Commit: Andreas K. Hüttel  gentoo  org>
CommitDate: Wed Feb 24 21:26:58 2021 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=48338534

Add option to generate BSD-style tagged hashes (can be verified by modern 
coreutils)

Signed-off-by: Andreas K. Hüttel  gentoo.org>

 catalyst/base/genbase.py | 6 +-
 catalyst/defaults.py | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index c7dd87bc..52418877 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -24,7 +24,11 @@ class GenBase():
 h.update(data)
 
 filename = os.path.split(filepath)[1]
-return f'# {name.upper()} HASH\n{h.hexdigest()}  {filename}\n'
+
+   if self.settings['digest_format'] == 'bsd':
+   return f'# {name.upper()} HASH\n{name.upper()} ({filename}) = 
{h.hexdigest()}\n'
+   else:
+   return f'# {name.upper()} HASH\n{h.hexdigest()}  {filename}\n'
 
 def gen_contents_file(self, path):
 c = self.settings['contents_map']

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index ccb0a584..2cede562 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -11,6 +11,7 @@ from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, 
LIST_XATTRS_OPTIONS
 valid_config_file_values = frozenset([
 "compression_mode",
 "digests",
+"digest_format",
 "distcc_hosts",
 "distdir",
 "envscript",
@@ -35,6 +36,7 @@ confdefaults = {
 "compressor_options": XATTRS_OPTIONS['linux'],
 "decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS['linux'],
 "decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
+"digest_format": 'linux',
 "distdir": portage.settings['DISTDIR'],
 "icecream": "/var/cache/icecream",
 'list_xattrs_opt': LIST_XATTRS_OPTIONS['linux'],



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2021-02-20 Thread Matt Turner
commit: 65d49f1028b49fed6e011526429e553ebb6c903e
Author: Felix Bier  rohde-schwarz  com>
AuthorDate: Thu Feb  4 00:38:36 2021 +
Commit: Matt Turner  gentoo  org>
CommitDate: Sat Feb 20 21:27:29 2021 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=65d49f10

Unify handling of main repo and other repos

This commit unifies the handling of the main repo and the other repos.
All are stored in one common list. A mount entry is created for
each entry in the list (previously a mount entry was only created
for the main repo and the other repos were copied into the chroot).
This means each non-main repo can now be either a directory or a
squash files (previously the non-main repos had to be directories).
The existing mount logic will bind-mount the repos that are stored as
directories, removing the need for copying.

A repos.conf entry will be created for each entry in the list.
This means a repos.conf entry for the main repo can now be created
(previously repos.conf entries were only created for the non-main
repos). The repos.conf entry will only be created if the target
location for the main repo is non-default, i.e. unequal to
/var/db/repos/gentoo. This mirrors the behavior of write_make_conf,
which only writes the PORTDIR variable to make.conf if the location
of the main repo is non-default.

As a side effect, the PORTDIR variable is now no longer needed,
and will be removed from write_make_conf in a separate commit.

Signed-off-by: Felix Bier  rohde-schwarz.com>
Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py | 88 +++---
 catalyst/defaults.py   |  5 ---
 2 files changed, 60 insertions(+), 33 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index fedc8f87..97e2318c 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -219,8 +219,17 @@ class StageBase(TargetBase, ClearBase, GenBase):
 # Setup our mount points.
 self.mount = copy.deepcopy(MOUNT_DEFAULTS)
 
-self.mount['portdir']['source'] = self.snapshot
-self.mount['portdir']['target'] = self.settings['repo_basedir'] + '/' 
+ self.settings['repo_name']
+# Create mount entry for each repository
+for path, name, _ in self.repos:
+name = get_repo_name(path)
+mount_id = f'repo_{name}'
+
+self.mount[mount_id] = {
+'enable': True,
+'source': path,
+'target': self.get_repo_location(name)
+}
+
 self.mount['distdir']['source'] = self.settings['distdir']
 self.mount["distdir"]['target'] = self.settings['target_distdir']
 
@@ -587,13 +596,41 @@ class StageBase(TargetBase, ClearBase, GenBase):
   "/busybox_config"]
 
 def set_repos(self):
+
+# Each entry in this list will be a tuple of the form
+# (source, name, default)
+#
+# source: the location of the repo on the host system,
+# either a directory or a squashfs file.
+#
+# name: the repository name parsed from the repo.
+# This is just a caching mechanism to avoid parsing the name
+# every time the source is processed.
+#
+# default: Default location where the repo is expected in the
+# target system. If this matches the path where we mount the repo to
+# (as per get_repo_location), then we can skip generating a repos.conf
+# entry for that repo. Currently this mechanism is only used for
+# the main repo, which has a default location hard-coded in
+# /usr/share/portage/config/repos.conf. For the other repos,
+# the default is set to None.
+self.repos = []
+
+# Create entry for snapshot
+default_location = Path(confdefaults['repo_basedir'], 
confdefaults['repo_name'])
+self.repos.append((self.snapshot, get_repo_name(self.snapshot), 
default_location))
+
+# Create entry for every other repo
 if 'repos' in self.settings:
 if isinstance(self.settings['repos'], str):
 self.settings['repos'] = \
 self.settings['repos'].split()
-log.info('repos directories are set to: %s',
+log.info('repos are set to: %s',
  ' '.join(self.settings['repos']))
 
+get_info = lambda repo: (repo, get_repo_name(repo), None)
+self.repos.extend(map(get_info, self.settings['repos']))
+
 def set_overlay(self):
 if self.settings["spec_prefix"] + "/overlay" in self.settings:
 if isinstance(self.settings[self.settings['spec_prefix'] + 
'/overlay'], str):
@@ -832,24 +869,19 @@ class StageBase(TargetBase, ClearBase, GenBase):
 raise CatalystError(f'Could not write {repo_conf_chroot}: {e}') 
from e
 
 def process_repos(self):
-""" We copy the contents of our repos to 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2021-01-23 Thread Matt Turner
commit: 27d7c7898bb0cccf6962b84058b0e2789bc314c1
Author: Matt Turner  gentoo  org>
AuthorDate: Mon Jan 18 03:20:41 2021 +
Commit: Matt Turner  gentoo  org>
CommitDate: Sat Jan 23 16:19:07 2021 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=27d7c789

catalyst: Deduplicate the common build_sequence steps

This also provides a single location to add a function to all targets'
build_sequence.

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py| 11 ++-
 catalyst/targets/embedded.py  |  3 ---
 catalyst/targets/livecd_stage1.py |  3 ---
 catalyst/targets/livecd_stage2.py |  3 ---
 catalyst/targets/netboot.py   |  3 ---
 catalyst/targets/stage4.py|  3 ---
 6 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 3b8d3a6e..40b60af3 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -90,7 +90,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
 self.setup_confdir,
 self.portage_overlay,
 ]
-self.build_sequence = []
+self.build_sequence = [
+self.bind,
+self.chroot_setup,
+self.setup_environment,
+]
 self.finish_sequence = []
 
 self.set_valid_build_kernel_vars(addlargs)
@@ -497,16 +501,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
 Or it calls the normal set_action_sequence() for the target stage.
 """
 if "purgeonly" in self.settings["options"]:
-self.build_sequence.append(self.remove_chroot)
+self.build_sequence = [self.remove_chroot]
 return
 self.set_action_sequence()
 
 def set_action_sequence(self):
 """Set basic stage1, 2, 3 action sequences"""
 self.build_sequence.extend([
-self.bind,
-self.chroot_setup,
-self.setup_environment,
 self.run_local,
 self.preclean,
 ])

diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 83b17ad2..b677b226 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -42,9 +42,6 @@ class embedded(StageBase):
 
 def set_action_sequence(self):
 self.build_sequence.extend([
-self.bind,
-self.chroot_setup,
-self.setup_environment,
 self.build_kernel,
 self.build_packages,
 self.root_overlay,

diff --git a/catalyst/targets/livecd_stage1.py 
b/catalyst/targets/livecd_stage1.py
index 9fe95a00..dbfa54ed 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -24,9 +24,6 @@ class livecd_stage1(StageBase):
 
 def set_action_sequence(self):
 self.build_sequence.extend([
-self.bind,
-self.chroot_setup,
-self.setup_environment,
 self.build_packages,
 ])
 self.finish_sequence.extend([

diff --git a/catalyst/targets/livecd_stage2.py 
b/catalyst/targets/livecd_stage2.py
index ab8f4a0e..e90e9f53 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,9 +87,6 @@ class livecd_stage2(StageBase):
 
 def set_action_sequence(self):
 self.build_sequence.extend([
-self.bind,
-self.chroot_setup,
-self.setup_environment,
 self.run_local,
 self.build_kernel
 ])

diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index cb5e7ae4..a2a9fcb3 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -159,9 +159,6 @@ class netboot(StageBase):
 
 def set_action_sequence(self):
 self.build_sequence.extend([
-self.bind,
-self.chroot_setup,
-self.setup_environment,
 self.build_packages,
 self.root_overlay,
 self.copy_files_to_image,

diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 9e53f070..f8383f75 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -40,9 +40,6 @@ class stage4(StageBase):
 
 def set_action_sequence(self):
 self.build_sequence.extend([
-self.bind,
-self.chroot_setup,
-self.setup_environment,
 self.build_packages,
 self.build_kernel,
 self.bootloader,



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2021-01-23 Thread Matt Turner
commit: 4f0fa29d5a2499b7178dc4d19f7693e52eb8def9
Author: Matt Turner  gentoo  org>
AuthorDate: Mon Jan 18 03:15:02 2021 +
Commit: Matt Turner  gentoo  org>
CommitDate: Sat Jan 23 16:19:07 2021 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4f0fa29d

catalyst: Deduplicate prepare_sequence assignments

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py| 13 ++---
 catalyst/targets/embedded.py  |  6 --
 catalyst/targets/livecd_stage1.py |  6 --
 catalyst/targets/livecd_stage2.py |  6 --
 catalyst/targets/netboot.py   |  6 --
 catalyst/targets/stage4.py|  6 --
 6 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 53b0a224..3b8d3a6e 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -84,7 +84,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
 "portage_overlay",
 "portage_prefix",
 ])
-self.prepare_sequence = []
+self.prepare_sequence = [
+self.unpack,
+self.config_profile_link,
+self.setup_confdir,
+self.portage_overlay,
+]
 self.build_sequence = []
 self.finish_sequence = []
 
@@ -498,12 +503,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
 def set_action_sequence(self):
 """Set basic stage1, 2, 3 action sequences"""
-self.prepare_sequence.extend([
-self.unpack,
-self.config_profile_link,
-self.setup_confdir,
-self.portage_overlay,
-])
 self.build_sequence.extend([
 self.bind,
 self.chroot_setup,

diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 7d328808..83b17ad2 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,12 +41,6 @@ class embedded(StageBase):
 StageBase.__init__(self, spec, addlargs)
 
 def set_action_sequence(self):
-self.prepare_sequence.extend([
-self.unpack,
-self.config_profile_link,
-self.setup_confdir,
-self.portage_overlay,
-])
 self.build_sequence.extend([
 self.bind,
 self.chroot_setup,

diff --git a/catalyst/targets/livecd_stage1.py 
b/catalyst/targets/livecd_stage1.py
index eb6bb0f0..9fe95a00 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,12 +23,6 @@ class livecd_stage1(StageBase):
 StageBase.__init__(self, spec, addlargs)
 
 def set_action_sequence(self):
-self.prepare_sequence.extend([
-self.unpack,
-self.config_profile_link,
-self.setup_confdir,
-self.portage_overlay,
-])
 self.build_sequence.extend([
 self.bind,
 self.chroot_setup,

diff --git a/catalyst/targets/livecd_stage2.py 
b/catalyst/targets/livecd_stage2.py
index 5fecff85..ab8f4a0e 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -86,12 +86,6 @@ class livecd_stage2(StageBase):
 print_traceback=True)
 
 def set_action_sequence(self):
-self.prepare_sequence.extend([
-self.unpack,
-self.config_profile_link,
-self.setup_confdir,
-self.portage_overlay,
-])
 self.build_sequence.extend([
 self.bind,
 self.chroot_setup,

diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 9a7e59e5..cb5e7ae4 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -158,12 +158,6 @@ class netboot(StageBase):
 self.resume.enable("empty")
 
 def set_action_sequence(self):
-self.prepare_sequence.extend([
-self.unpack,
-self.config_profile_link,
-self.setup_confdir,
-self.portage_overlay,
-])
 self.build_sequence.extend([
 self.bind,
 self.chroot_setup,

diff --git a/catalyst/targets/stage4.py b/catalyst/targets/stage4.py
index 997139a5..9e53f070 100644
--- a/catalyst/targets/stage4.py
+++ b/catalyst/targets/stage4.py
@@ -39,12 +39,6 @@ class stage4(StageBase):
 self.settings["cleanables"].remove('/etc/resolv.conf')
 
 def set_action_sequence(self):
-self.prepare_sequence.extend([
-self.unpack,
-self.config_profile_link,
-self.setup_confdir,
-self.portage_overlay,
-])
 self.build_sequence.extend([
 self.bind,
 self.chroot_setup,



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2020-10-30 Thread Matt Turner
commit: 2c28062446246e246c992ea7084a3950b1337827
Author: Matt Turner  gentoo  org>
AuthorDate: Thu Oct 29 00:32:34 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Fri Oct 30 22:40:52 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2c280624

catalyst: Use .extend() and .append() for action_sequence

Ensures that we don't overwrite and lose some settings.

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py| 6 +++---
 catalyst/targets/embedded.py  | 4 ++--
 catalyst/targets/livecd_stage1.py | 4 ++--
 catalyst/targets/livecd_stage2.py | 8 
 catalyst/targets/netboot.py   | 4 ++--
 catalyst/targets/stage4.py| 4 ++--
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 801df2fb..46b7c59c 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -478,13 +478,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
 Or it calls the normal set_action_sequence() for the target stage.
 """
 if "purgeonly" in self.settings["options"]:
-self.action_sequence = ["remove_chroot"]
+self.action_sequence.append("remove_chroot")
 return
 self.set_action_sequence()
 
 def set_action_sequence(self):
 """Set basic stage1, 2, 3 action sequences"""
-self.action_sequence = [
+self.action_sequence.extend([
 "unpack",
 "setup_confdir",
 "portage_overlay",
@@ -495,7 +495,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 "preclean",
 "unbind",
 "clean",
-]
+])
 self.set_completion_action_sequences()
 
 def set_completion_action_sequences(self):

diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 3899cf1b..75eb68e4 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,7 +41,7 @@ class embedded(StageBase):
 StageBase.__init__(self, spec, addlargs)
 
 def set_action_sequence(self):
-self.action_sequence = [
+self.action_sequence.extend([
 "unpack",
 "config_profile_link",
 "setup_confdir",
@@ -60,7 +60,7 @@ class embedded(StageBase):
 "clean",
 "capture",
 "clear_autoresume",
-]
+])
 
 def set_stage_path(self):
 self.settings["stage_path"] = normpath(

diff --git a/catalyst/targets/livecd_stage1.py 
b/catalyst/targets/livecd_stage1.py
index b8c26cb1..9dbfa506 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,7 +23,7 @@ class livecd_stage1(StageBase):
 StageBase.__init__(self, spec, addlargs)
 
 def set_action_sequence(self):
-self.action_sequence = [
+self.action_sequence.extend([
 "unpack",
 "config_profile_link",
 "setup_confdir",
@@ -34,7 +34,7 @@ class livecd_stage1(StageBase):
 "build_packages",
 "unbind",
 "clean",
-]
+])
 self.set_completion_action_sequences()
 
 def set_spec_prefix(self):

diff --git a/catalyst/targets/livecd_stage2.py 
b/catalyst/targets/livecd_stage2.py
index cac16b6e..c9b5ce08 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -87,7 +87,7 @@ class livecd_stage2(StageBase):
 print_traceback=True)
 
 def set_action_sequence(self):
-self.action_sequence = [
+self.action_sequence.extend([
 "unpack",
 "config_profile_link",
 "setup_confdir",
@@ -97,9 +97,9 @@ class livecd_stage2(StageBase):
 "setup_environment",
 "run_local",
 "build_kernel"
-]
+])
 if "fetch" not in self.settings["options"]:
-self.action_sequence += [
+self.action_sequence.extend([
 "bootloader",
 "preclean",
 "livecd_update",
@@ -114,5 +114,5 @@ class livecd_stage2(StageBase):
 "target_setup",
 "setup_overlay",
 "create_iso",
-]
+])
 self.action_sequence.append("clear_autoresume")

diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 61583f0d..e5c6d43c 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -160,7 +160,7 @@ class netboot(StageBase):
 self.resume.enable("empty")
 
 def set_action_sequence(self):
-self.action_sequence = [
+self.action_sequence.extend([
 "unpack",
 "config_profile_link",
 "setup_confdir",
@@ -179,4 +179,4 @@ class netboot(StageBase):
 "unbind",
 "clean",
 "clear_autoresume",
-]
+])


[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2020-10-30 Thread Matt Turner
commit: 3d85d537b1a00d05234cea064f863602b83ffaab
Author: Matt Turner  gentoo  org>
AuthorDate: Thu Oct 29 03:08:04 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Fri Oct 30 22:40:52 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3d85d537

catalyst: Split action_sequence into prepare/build/finish

We want to run the "build" sequence in a different mount namespace from
the "prepare" and "finish" sequences, so this splits action_sequence
into those groupings.

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py| 24 +++-
 catalyst/targets/embedded.py  |  6 +-
 catalyst/targets/livecd_stage1.py |  6 +-
 catalyst/targets/livecd_stage2.py | 10 +++---
 catalyst/targets/netboot.py   |  6 +-
 catalyst/targets/stage1.py| 12 ++--
 catalyst/targets/stage4.py|  6 +-
 7 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 46b7c59c..75c84baa 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -64,7 +64,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
 "portage_overlay",
 "portage_prefix",
 ])
-self.action_sequence = []
+self.prepare_sequence = []
+self.build_sequence = []
+self.finish_sequence = []
 
 self.set_valid_build_kernel_vars(addlargs)
 TargetBase.__init__(self, myspec, addlargs)
@@ -478,36 +480,40 @@ class StageBase(TargetBase, ClearBase, GenBase):
 Or it calls the normal set_action_sequence() for the target stage.
 """
 if "purgeonly" in self.settings["options"]:
-self.action_sequence.append("remove_chroot")
+self.build_sequence.append("remove_chroot")
 return
 self.set_action_sequence()
 
 def set_action_sequence(self):
 """Set basic stage1, 2, 3 action sequences"""
-self.action_sequence.extend([
+self.prepare_sequence.extend([
 "unpack",
 "setup_confdir",
 "portage_overlay",
+])
+self.build_sequence.extend([
 "bind",
 "chroot_setup",
 "setup_environment",
 "run_local",
 "preclean",
 "unbind",
+])
+self.finish_sequence.extend([
 "clean",
 ])
 self.set_completion_action_sequences()
 
 def set_completion_action_sequences(self):
 if "fetch" not in self.settings["options"]:
-self.action_sequence.append("capture")
+self.finish_sequence.append("capture")
 if "keepwork" in self.settings["options"]:
-self.action_sequence.append("clear_autoresume")
+self.finish_sequence.append("clear_autoresume")
 elif "seedcache" in self.settings["options"]:
-self.action_sequence.append("remove_autoresume")
+self.finish_sequence.append("remove_autoresume")
 else:
-self.action_sequence.append("remove_autoresume")
-self.action_sequence.append("remove_chroot")
+self.finish_sequence.append("remove_autoresume")
+self.finish_sequence.append("remove_chroot")
 
 def set_use(self):
 use = self.settings["spec_prefix"] + "/use"
@@ -1381,7 +1387,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 self.purge()
 
 failure = False
-for x in self.action_sequence:
+for x in self.prepare_sequence + self.build_sequence + 
self.finish_sequence:
 log.notice('--- Running action sequence: %s', x)
 sys.stdout.flush()
 try:

diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index 75eb68e4..1314ce7c 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -41,11 +41,13 @@ class embedded(StageBase):
 StageBase.__init__(self, spec, addlargs)
 
 def set_action_sequence(self):
-self.action_sequence.extend([
+self.prepare_sequence.extend([
 "unpack",
 "config_profile_link",
 "setup_confdir",
 "portage_overlay",
+])
+self.build_sequence.extend([
 "bind",
 "chroot_setup",
 "setup_environment",
@@ -55,6 +57,8 @@ class embedded(StageBase):
 "fsscript",
 "unmerge",
 "unbind",
+])
+self.finish_sequence.extend([
 "remove",
 "empty",
 "clean",

diff --git a/catalyst/targets/livecd_stage1.py 
b/catalyst/targets/livecd_stage1.py
index 9dbfa506..81367053 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,16 +23,20 @@ class livecd_stage1(StageBase):
 StageBase.__init__(self, spec, addlargs)
 
 def set_action_sequence(self):
-

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2020-10-30 Thread Matt Turner
commit: 488b06bf5dbe1eba68ac11de95f56feeb6cead83
Author: Matt Turner  gentoo  org>
AuthorDate: Thu Oct 29 15:00:42 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Fri Oct 30 22:40:52 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=488b06bf

catalyst: Run the build sequence in new mount namespace

Catalyst has a lot of code to unmount the bind mounts it's made, and
then more to try harder when something fails. This is important because
if bind mounts still exist within the chroot when clean up happens,
files outside of the chroot on the host system can inadvertently be
deleted. E.g., distfiles, binpkgs, kerncache.

Running the build sequence (the steps that need bind mounts) within a
mount namespace and exiting the mount namespace when finished ensures
that clean up can never accidentally delete files outside the chroot.

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py | 7 ---
 catalyst/main.py   | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 06ec8727..caec5935 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -15,6 +15,7 @@ from snakeoil.osutils import pjoin
 from DeComp.compress import CompressMap
 
 from catalyst import log
+from catalyst.context import namespace
 from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN)
 from catalyst.support import (CatalystError, file_locate, normpath,
   cmd, read_makeconf, ismount, file_check,
@@ -1405,9 +1406,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
 if not self.run_sequence(self.prepare_sequence):
 return False
 
-if not self.run_sequence(self.build_sequence):
-self.unbind()
-return False
+with namespace(mount=True):
+if not self.run_sequence(self.build_sequence):
+return False
 
 if not self.run_sequence(self.finish_sequence):
 return False

diff --git a/catalyst/main.py b/catalyst/main.py
index 93a4a0d3..5536471a 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -355,7 +355,7 @@ def _main(parser, opts):
 # use pid & user namespaces, but snakeoil's namespace module has signal
 # transfer issues (CTRL+C doesn't propagate), and user namespaces need
 # more work due to Gentoo build process (uses sudo/root/portage).
-with namespace(mount=True, uts=True, ipc=True, hostname='catalyst'):
+with namespace(uts=True, ipc=True, hostname='catalyst'):
 # everything is setup, so the build is a go
 try:
 success = build_target(addlargs)



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2020-04-18 Thread Matt Turner
commit: d3a8f202bf8eb82cc1d61e2b2b9da4eadc550c90
Author: Matt Turner  gentoo  org>
AuthorDate: Sat Apr 18 00:36:46 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Sat Apr 18 20:29:57 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d3a8f202

catalyst: Reformat some array definitions

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py| 17 +
 catalyst/targets/embedded.py  | 29 +++--
 catalyst/targets/livecd_stage1.py | 17 +
 catalyst/targets/livecd_stage2.py |  6 +++---
 catalyst/targets/netboot.py   | 26 +-
 catalyst/targets/stage4.py| 28 ++--
 6 files changed, 95 insertions(+), 28 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 71bf1ef9..60cb891a 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -531,10 +531,19 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
 def set_action_sequence(self):
 """Set basic stage1, 2, 3 action sequences"""
-self.settings["action_sequence"] = ["unpack", "unpack_snapshot",
-"setup_confdir", "portage_overlay",
-"bind", "chroot_setup", 
"setup_environment",
-"run_local", "preclean", "unbind", 
"clean"]
+self.settings['action_sequence'] = [
+"unpack",
+"unpack_snapshot",
+"setup_confdir",
+"portage_overlay",
+"bind",
+"chroot_setup",
+"setup_environment",
+"run_local",
+"preclean",
+"unbind",
+"clean",
+]
 self.set_completion_action_sequences()
 
 def set_completion_action_sequences(self):

diff --git a/catalyst/targets/embedded.py b/catalyst/targets/embedded.py
index e288228e..189eb722 100644
--- a/catalyst/targets/embedded.py
+++ b/catalyst/targets/embedded.py
@@ -40,12 +40,29 @@ class embedded(StageBase):
 StageBase.__init__(self, spec, addlargs)
 
 def set_action_sequence(self):
-self.settings["action_sequence"] = ["dir_setup", "unpack", 
"unpack_snapshot",
-"config_profile_link", 
"setup_confdir",
-"portage_overlay", "bind", 
"chroot_setup",
-"setup_environment", 
"build_kernel", "build_packages",
-"bootloader", "root_overlay", 
"fsscript", "unmerge",
-"unbind", "remove", "empty", 
"clean", "capture", "clear_autoresume"]
+self.settings['action_sequence'] = [
+"dir_setup",
+"unpack",
+"unpack_snapshot",
+"config_profile_link",
+"setup_confdir",
+"portage_overlay",
+"bind",
+"chroot_setup",
+"setup_environment",
+"build_kernel",
+"build_packages",
+"bootloader",
+"root_overlay",
+"fsscript",
+"unmerge",
+"unbind",
+"remove",
+"empty",
+"clean",
+"capture",
+"clear_autoresume",
+]
 
 def set_stage_path(self):
 self.settings["stage_path"] = normpath(

diff --git a/catalyst/targets/livecd_stage1.py 
b/catalyst/targets/livecd_stage1.py
index f4f6b512..727d95f2 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -23,10 +23,19 @@ class livecd_stage1(StageBase):
 StageBase.__init__(self, spec, addlargs)
 
 def set_action_sequence(self):
-self.settings["action_sequence"] = ["unpack", "unpack_snapshot",
-"config_profile_link", 
"setup_confdir", "portage_overlay",
-"bind", "chroot_setup", 
"setup_environment", "build_packages",
-"unbind", "clean"]
+self.settings['action_sequence'] = [
+"unpack",
+"unpack_snapshot",
+"config_profile_link",
+"setup_confdir",
+"portage_overlay",
+"bind",
+"chroot_setup",
+"setup_environment",
+"build_packages",
+"unbind",
+"clean",
+]
 self.set_completion_action_sequences()
 
 def set_spec_prefix(self):

diff --git a/catalyst/targets/livecd_stage2.py 
b/catalyst/targets/livecd_stage2.py
index d41321e6..09de22fb 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -88,7 +88,7 @@ class livecd_stage2(StageBase):
 print_traceback=True)
 
 def 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2020-04-17 Thread Matt Turner
commit: bcffd2ef3fc347d6ce346a1737ddbd0ed0b7dff6
Author: Matt Turner  gentoo  org>
AuthorDate: Fri Apr 17 17:27:08 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Fri Apr 17 18:55:23 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=bcffd2ef

catalyst: Make conf_values['digests'] a set

This makes it automatically deduplicate values (which I honestly don't
really care about) but also makes it so users don't need to .split()
themselves.

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/genbase.py | 2 +-
 catalyst/main.py | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index bc7f9375..eb09a4e0 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -37,5 +37,5 @@ class GenBase():
 
 with io.open(path + '.DIGESTS', 'w', encoding='utf-8') as file:
 for f in [path, path + '.CONTENTS']:
-for i in self.settings['digests'].split():
+for i in self.settings['digests']:
 file.write(self.generate_hash(f, name=i))

diff --git a/catalyst/main.py b/catalyst/main.py
index d8e791c4..c91fc8b6 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -341,8 +341,9 @@ def _main(parser, opts):
 # TODO add capability to config/spec new definitions
 
 if "digests" in conf_values:
-digests = set(conf_values['digests'].split())
 valid_digests = hashlib.algorithms_available
+digests = set(conf_values['digests'].split())
+conf_values['digests'] = digests
 
 # First validate all the requested digests are valid keys.
 if digests - valid_digests:



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2020-04-15 Thread Matt Turner
commit: 92af7453a386fb5bd1b03ba5afae6d0165fe4364
Author: Matt Turner  gentoo  org>
AuthorDate: Wed Apr 15 18:00:15 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Wed Apr 15 18:04:03 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=92af7453

catalyst: Remove dead base_dirs() function

Prior to commit 8ef6e85a57ec (catalyst: Drop BSD remnants) this was used
for some FreeBSD-specific logic.

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py | 5 +
 catalyst/targets/stage1.py | 3 ---
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index b01e4825..d993641f 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -528,7 +528,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"""Set basic stage1, 2, 3 action sequences"""
self.settings["action_sequence"] = ["unpack", "unpack_snapshot",
"setup_confdir", "portage_overlay",
-   "base_dirs", "bind", "chroot_setup", 
"setup_environment",
+   "bind", "chroot_setup", "setup_environment",
"run_local", "preclean", "unbind", "clean"]
self.set_completion_action_sequences()
 
@@ -940,9 +940,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
cmd(['rsync', '-a', x + '/', 
self.settings['chroot_path']],
env=self.env)
 
-   def base_dirs(self):
-   pass
-
def bind(self):
for x in self.mounts:
log.debug('bind(); x = %s', x)

diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 4ce0d0b4..a1a29cff 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -77,9 +77,6 @@ class stage1(StageBase):
"If you break it, you buy it.  Don't complain 
to us about it.\n"
"Don't say we did not warn you.")
 
-   def base_dirs(self):
-   pass
-
def set_mounts(self):
# stage_path/proc probably doesn't exist yet, so create it
ensure_dirs(self.settings["stage_path"]+"/proc")



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2020-04-13 Thread Matt Turner
commit: dd9e1cda4772f33fa0c3d07578c5ca6808c6dd22
Author: Matt Turner  gentoo  org>
AuthorDate: Sat Apr 11 22:23:54 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Mon Apr 13 20:43:10 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=dd9e1cda

catalyst: Clean assignments of {valid/required}_values

Making them class variables will allow us to verify that all subclasses
of TargetBase have defined them (in the next commit).

While we're moving them, change them to frozensets, since testing
membership is the thing they're useed for.

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py| 68 ++-
 catalyst/targets/embedded.py  | 24 ++
 catalyst/targets/livecd_stage1.py | 11 ---
 catalyst/targets/livecd_stage2.py | 48 +++
 catalyst/targets/netboot.py   | 29 -
 catalyst/targets/snapshot.py  | 11 +--
 catalyst/targets/stage1.py| 10 --
 catalyst/targets/stage2.py|  7 ++--
 catalyst/targets/stage3.py|  5 +--
 catalyst/targets/stage4.py| 26 +++
 10 files changed, 159 insertions(+), 80 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index b4275355..27516af6 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -27,16 +27,36 @@ class StageBase(TargetBase, ClearBase, GenBase):
the driver class for pretty much everything that Catalyst does.
"""
def __init__(self,myspec,addlargs):
-   self.required_values.extend(["version_stamp", "target", 
"subarch",
-   "rel_type", "profile", "snapshot", "source_subpath"])
-
-   self.valid_values.extend(["version_stamp", "target", "subarch",
-   "rel_type", "profile", "snapshot", "source_subpath",
-   "portage_confdir", "portage_prefix", "portage_overlay",
-   "cflags", "cxxflags", "fcflags", "fflags", "ldflags", 
"asflags",
-   "common_flags", "cbuild", "hostuse", "catalyst_use",
-   "distcc_hosts", "makeopts", "pkgcache_path", 
"kerncache_path",
-   "compression_mode", "decompression_mode"])
+   self.required_values |= frozenset([
+   "profile",
+   "rel_type",
+   "snapshot",
+   "source_subpath",
+   "subarch",
+   "target",
+   "version_stamp",
+   ])
+   self.valid_values |= self.required_values | frozenset([
+   "asflags",
+   "catalyst_use",
+   "cbuild",
+   "cflags",
+   "common_flags",
+   "compression_mode",
+   "cxxflags",
+   "decompression_mode",
+   "distcc_hosts",
+   "fcflags",
+   "fflags",
+   "hostuse",
+   "kerncache_path",
+   "ldflags",
+   "makeopts",
+   "pkgcache_path",
+   "portage_confdir",
+   "portage_overlay",
+   "portage_prefix",
+   ])
 
self.set_valid_build_kernel_vars(addlargs)
TargetBase.__init__(self, myspec, addlargs)
@@ -422,7 +442,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
def set_fsops(self):
if "fstype" in self.settings:
-   self.valid_values.append("fsops")
+   self.valid_values |= {"fsops"}
if self.settings["spec_prefix"] + "/fsops" in 
self.settings:
self.settings["fsops"] = \

self.settings[self.settings["spec_prefix"] + "/fsops"]
@@ -647,18 +667,20 @@ class StageBase(TargetBase, ClearBase, GenBase):
loopy = addlargs["boot/kernel"]
 
for x in loopy:
-   self.valid_values.append("boot/kernel/" + x + 
"/aliases")
-   self.valid_values.append("boot/kernel/" + x + 
"/config")
-   self.valid_values.append("boot/kernel/" + x + 
"/console")
-   self.valid_values.append("boot/kernel/" + x + 
"/extraversion")
-   self.valid_values.append("boot/kernel/" + x + 
"/gk_action")
-   self.valid_values.append("boot/kernel/" + x + 
"/gk_kernargs")
-   self.valid_values.append("boot/kernel/" + x + 
"/initramfs_overlay")
-   

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2020-04-13 Thread Matt Turner
commit: 2fb8d95e7c83a6e2123e9575f9fd253aae962b43
Author: Matt Turner  gentoo  org>
AuthorDate: Sat Apr 11 22:30:03 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Mon Apr 13 20:35:35 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2fb8d95e

catalyst: Just import things where they're needed

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/resume.py| 3 ++-
 catalyst/base/stagebase.py | 3 ++-
 catalyst/fileops.py| 7 +--
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/catalyst/base/resume.py b/catalyst/base/resume.py
index a0770b9d..82f97cd3 100644
--- a/catalyst/base/resume.py
+++ b/catalyst/base/resume.py
@@ -9,9 +9,10 @@ set, unset, is_set, is_unset, enabled, clear_all
 import os
 
 from snakeoil import fileutils
+from snakeoil.osutils import pjoin, listdir_files
 
 from catalyst import log
-from catalyst.fileops import ensure_dirs, pjoin, listdir_files, clear_dir
+from catalyst.fileops import ensure_dirs, clear_dir
 
 
 class AutoResume():

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index a90fc843..683e5989 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -5,6 +5,7 @@ import shutil
 import sys
 
 from snakeoil import fileutils
+from snakeoil.osutils import pjoin
 
 from DeComp.compress import CompressMap
 
@@ -17,7 +18,7 @@ from catalyst.base.targetbase import TargetBase
 from catalyst.base.clearbase import ClearBase
 from catalyst.base.genbase import GenBase
 from catalyst.lock import LockDir, LockInUse
-from catalyst.fileops import ensure_dirs, pjoin, clear_dir, clear_path
+from catalyst.fileops import ensure_dirs, clear_dir, clear_path
 from catalyst.base.resume import AutoResume
 
 

diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index fffcfc6a..671d8d9f 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -10,12 +10,7 @@ import os
 import shutil
 from stat import ST_UID, ST_GID, ST_MODE
 
-# NOTE: pjoin and listdir_files are imported here for export
-# to other catalyst modules
-# pylint: disable=unused-import
-from snakeoil.osutils import (ensure_dirs as snakeoil_ensure_dirs,
-   pjoin, listdir_files)
-# pylint: enable=unused-import
+from snakeoil.osutils import ensure_dirs as snakeoil_ensure_dirs
 
 from catalyst import log
 from catalyst.support import CatalystError



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/, catalyst/, targets/stage1/

2020-04-10 Thread Matt Turner
commit: ecdf556b4c00325bb299e012024f97e8af33c788
Author: Matt Turner  gentoo  org>
AuthorDate: Fri Apr 10 16:51:36 2020 +
Commit: Matt Turner  gentoo  org>
CommitDate: Fri Apr 10 21:03:34 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=ecdf556b

catalyst: Fix most pylint warnings

- consider-iterating-dictionary
- consider-using-enumerate
- inconsistent-return-statements
- len-as-condition
- literal-comparison
- no-else-raise
- no-else-return
- useless-return

Unfortunately there are more and they're a bit trickier.

Signed-off-by: Matt Turner  gentoo.org>

 catalyst/base/stagebase.py | 10 --
 catalyst/builder.py|  2 --
 catalyst/config.py |  2 +-
 catalyst/defaults.py   |  2 --
 catalyst/fileops.py|  2 +-
 catalyst/log.py|  3 +--
 catalyst/main.py   |  5 ++---
 catalyst/support.py| 23 +++
 catalyst/targets/stage1.py |  5 -
 targets/stage1/build.py|  6 +++---
 10 files changed, 23 insertions(+), 37 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 021f3beb..6f0a1bc3 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -474,7 +474,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"/snapshots/" + self.settings["snapshot_name"] +
self.settings["snapshot"]),
self.accepted_extensions,
-   self.settings["source_matching"] is "strict"
+   self.settings["source_matching"] == "strict"
)
log.info('SNAPSHOT_PATH set to: %s', 
self.settings['snapshot_path'])
self.settings["snapshot_path_hash"] = \
@@ -557,7 +557,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:

self.settings["action_sequence"].append("remove_autoresume")
self.settings["action_sequence"].append("remove_chroot")
-   return
 
def set_use(self):
use = self.settings["spec_prefix"] + "/use"
@@ -716,8 +715,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.unbind()
if ismount(target):
raise 
CatalystError("Auto-unbind failed for " + target)
-   else:
-   log.notice('Auto-unbind 
successful...')
+   log.notice('Auto-unbind successful...')
except CatalystError:
raise CatalystError("Unable to 
auto-unbind " + target)
 
@@ -1105,7 +1103,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
continue
myf.write("# %s is unsupported.  USE AT 
YOUR OWN RISK!\n"
% flags)
-   if flags not in self.settings or (flags is not 
"COMMON_FLAGS" and
+   if flags not in self.settings or (flags != 
"COMMON_FLAGS" and
self.settings[flags] == 
self.settings["COMMON_FLAGS"]):
myf.write('%s="${COMMON_FLAGS}"\n' % 
flags)
elif isinstance(self.settings[flags], list):
@@ -1442,7 +1440,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
if "purgetmponly" in self.settings["options"]:
self.purge()
-   return
+   return True
 
if "purgeonly" in self.settings["options"]:
log.info('StageBase: run() purgeonly')

diff --git a/catalyst/builder.py b/catalyst/builder.py
index e9f468d7..64e14c8d 100644
--- a/catalyst/builder.py
+++ b/catalyst/builder.py
@@ -1,5 +1,3 @@
-import os
-
 class generic():
def __init__(self,myspec):
self.settings=myspec

diff --git a/catalyst/config.py b/catalyst/config.py
index 5e70de41..1571db9d 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -22,7 +22,7 @@ class ParserBase():
 
def dump(self):
dump = ""
-   for x in self.values.keys():
+   for x in self.values:
dump += x + " = " + repr(self.values[x]) + "\n"
return dump
 

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index bcb59796..349f16f6 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -1,6 +1,4 @@
 
-import os
-
 from DeComp.definitions import DECOMPRESSOR_SEARCH_ORDER
 from DeComp.definitions import COMPRESSOR_PROGRAM_OPTIONS, XATTRS_OPTIONS
 from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2020-01-27 Thread Rick Farina
commit: 8441372c285726de85c71a83035a9e11cc47f037
Author: Rick Farina (Zero_Chaos)  gentoo  org>
AuthorDate: Mon Jan 27 18:50:42 2020 +
Commit: Rick Farina  gentoo  org>
CommitDate: Mon Jan 27 18:52:55 2020 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=8441372c

fix /var/tmp/portage not being forced into a tmpfs

2e91db10 accidently revealed that src tmpfs was being being used when we
meant "this might be a tmpfs, or it might not".  Fix preexisting code to
be more readable and adjust src tmpfs to be what a sane person would
expect

Signed-off-by: Rick Farina (Zero_Chaos)  gentoo.org>

 catalyst/base/stagebase.py | 6 +++---
 catalyst/defaults.py   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 85e30450..d29b48fc 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -973,13 +973,13 @@ class StageBase(TargetBase, ClearBase, GenBase):
if "snapcache" in self.settings["options"] and x == 
"portdir":
self.snapcache_lock.read_lock()
_cmd = None
-   if src == "tmpfs":
+   if src == "maybe_tmpfs":
if "var_tmpfs_portage" in self.settings:
_cmd = ['mount', '-t', 'tmpfs',
'-o', 'size=' + 
self.settings['var_tmpfs_portage'] + 'G',
src, target]
-   else:
-   _cmd = ['mount', '-t', 'tmpfs', src, 
target]
+   elif src == "tmpfs":
+   _cmd = ['mount', '-t', 'tmpfs', src, target]
else:
if os.uname()[0] == "FreeBSD":
if src == "/dev":

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index cb5f84e3..705ae931 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -99,7 +99,7 @@ SOURCE_MOUNT_DEFAULTS = {
"devpts": "/dev/pts",
"distdir": DISTDIR[:],
"portdir": PORTDIR[:],
-   "port_tmpdir": "tmpfs",
+   "port_tmpdir": "maybe_tmpfs",
"proc": "/proc",
"shm": "shmfs",
"run": "tmpfs",



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/arch/

2018-09-19 Thread Ben Kohler
commit: 14a5425fdf918f7299706196a32ee3e722315376
Author: Ben Kohler  gentoo  org>
AuthorDate: Wed Sep 19 15:42:11 2018 +
Commit: Ben Kohler  gentoo  org>
CommitDate: Wed Sep 19 15:53:12 2018 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=14a5425f

First implementation of COMMON_FLAGS for make.conf

This introduces a new variable COMMON_FLAGS for make.conf.  In catalyst,
individual arches' arch/${arch}.py files will set COMMON_FLAGS and this
will be expanded to set default values for otherwise unset {C,CXX,F,FC}FLAGS.

Eg:

COMMON_FLAGS="-O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

Individual (sub)arches can choose to set specific values for those other
*FLAGS and then they will not be set to ${COMMON_FLAGS}.

Implementation thanks to dwfreed.  Should resolve the following bugs:

https://bugs.gentoo.org/575446
https://bugs.gentoo.org/665758
https://bugs.gentoo.org/654080

 catalyst/arch/alpha.py |  18 +++
 catalyst/arch/amd64.py |  14 ++---
 catalyst/arch/arm.py   |  28 +-
 catalyst/arch/arm64.py |   3 +-
 catalyst/arch/hppa.py  |   9 ++--
 catalyst/arch/ia64.py  |   3 +-
 catalyst/arch/m68k.py  |   4 +-
 catalyst/arch/mips.py  | 132 ++---
 catalyst/arch/powerpc.py   |  36 ++---
 catalyst/arch/s390.py  |   4 +-
 catalyst/arch/sh.py|  24 -
 catalyst/arch/sparc.py |   4 +-
 catalyst/arch/x86.py   |  30 +--
 catalyst/base/stagebase.py |  14 ++---
 14 files changed, 160 insertions(+), 163 deletions(-)

diff --git a/catalyst/arch/alpha.py b/catalyst/arch/alpha.py
index a4e7cafa..813b0020 100644
--- a/catalyst/arch/alpha.py
+++ b/catalyst/arch/alpha.py
@@ -7,55 +7,55 @@ class generic_alpha(builder.generic):
"abstract base class for all alpha builders"
def __init__(self,myspec):
builder.generic.__init__(self,myspec)
-   self.settings["CFLAGS"]="-mieee -pipe"
+   self.settings["COMMON_FLAGS"]="-mieee -pipe"
 
 class arch_alpha(generic_alpha):
"builder class for generic alpha (ev4+)"
def __init__(self,myspec):
generic_alpha.__init__(self,myspec)
-   self.settings["CFLAGS"]+=" -O2 -mcpu=ev4"
+   self.settings["COMMON_FLAGS"]+=" -O2 -mcpu=ev4"
self.settings["CHOST"]="alpha-unknown-linux-gnu"
 
 class arch_ev4(generic_alpha):
"builder class for alpha ev4"
def __init__(self,myspec):
generic_alpha.__init__(self,myspec)
-   self.settings["CFLAGS"]+=" -O2 -mcpu=ev4"
+   self.settings["COMMON_FLAGS"]+=" -O2 -mcpu=ev4"
self.settings["CHOST"]="alphaev4-unknown-linux-gnu"
 
 class arch_ev45(generic_alpha):
"builder class for alpha ev45"
def __init__(self,myspec):
generic_alpha.__init__(self,myspec)
-   self.settings["CFLAGS"]+=" -O2 -mcpu=ev45"
+   self.settings["COMMON_FLAGS"]+=" -O2 -mcpu=ev45"
self.settings["CHOST"]="alphaev45-unknown-linux-gnu"
 
 class arch_ev5(generic_alpha):
"builder class for alpha ev5"
def __init__(self,myspec):
generic_alpha.__init__(self,myspec)
-   self.settings["CFLAGS"]+=" -O2 -mcpu=ev5"
+   self.settings["COMMON_FLAGS"]+=" -O2 -mcpu=ev5"
self.settings["CHOST"]="alphaev5-unknown-linux-gnu"
 
 class arch_ev56(generic_alpha):
"builder class for alpha ev56 (ev5 plus BWX)"
def __init__(self,myspec):
generic_alpha.__init__(self,myspec)
-   self.settings["CFLAGS"]+=" -O2 -mcpu=ev56"
+   self.settings["COMMON_FLAGS"]+=" -O2 -mcpu=ev56"
self.settings["CHOST"]="alphaev56-unknown-linux-gnu"
 
 class arch_pca56(generic_alpha):
"builder class for alpha pca56 (ev5 plus BWX & MAX)"
def __init__(self,myspec):
generic_alpha.__init__(self,myspec)
-   self.settings["CFLAGS"]+=" -O2 -mcpu=pca56"
+   self.settings["COMMON_FLAGS"]+=" -O2 -mcpu=pca56"
self.settings["CHOST"]="alphaev56-unknown-linux-gnu"
 
 class arch_ev6(generic_alpha):
"builder class for alpha ev6"
def __init__(self,myspec):
generic_alpha.__init__(self,myspec)
-   self.settings["CFLAGS"]+=" -O2 -mcpu=ev6"
+   self.settings["COMMON_FLAGS"]+=" -O2 -mcpu=ev6"
self.settings["CHOST"]="alphaev6-unknown-linux-gnu"
self.settings["HOSTUSE"]=["ev6"]
 
@@ -63,7 +63,7 @@ class arch_ev67(generic_alpha):
"builder class for alpha ev67 (ev6 plus CIX)"
def __init__(self,myspec):
generic_alpha.__init__(self,myspec)
-   self.settings["CFLAGS"]+=" -O2 -mcpu=ev67"
+   self.settings["COMMON_FLAGS"]+=" -O2 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2016-05-21 Thread Mike Frysinger
commit: 415c65624ff62f5ab139666cd5447bc35e1e9e8b
Author: Mike Frysinger  gentoo  org>
AuthorDate: Fri May 20 05:42:43 2016 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Fri May 20 05:42:43 2016 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=415c6562

replace ad-hoc implementations of clear_dir

A few places copy & paste the logic we have in the clear_dir func.
Punt them with a simple call to clear_dir.

 catalyst/base/stagebase.py   |  9 +
 catalyst/targets/netboot2.py | 10 ++
 catalyst/targets/snapshot.py | 20 ++--
 3 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 78e5b94..f0f3ba9 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -3,7 +3,6 @@ import os
 import imp
 import shutil
 import sys
-from stat import ST_UID, ST_GID, ST_MODE
 
 from snakeoil import fileutils
 
@@ -1202,13 +1201,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.warning('not a directory or 
does not exist, skipping "empty" operation: %s', x)
continue
log.info('Emptying directory %s', x)
-   # stat the dir, delete the dir, 
recreate the dir and set
-   # the proper perms and ownership
-   mystat=os.stat(myemp)
-   shutil.rmtree(myemp)
-   ensure_dirs(myemp, mode=0o755)
-   
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
-   os.chmod(myemp,mystat[ST_MODE])
+   clear_dir(myemp)
self.resume.enable("empty")
 
def remove(self):

diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index da856ba..87dada3 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -4,12 +4,10 @@ netboot target, version 2
 # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
 
 import os
-import shutil
-from stat import ST_UID, ST_GID, ST_MODE
 
 from catalyst import log
 from catalyst.support import (CatalystError, normpath, cmd)
-from catalyst.fileops import ensure_dirs, clear_path
+from catalyst.fileops import (ensure_dirs, clear_dir, clear_path)
 
 from catalyst.base.stagebase import StageBase
 
@@ -152,11 +150,7 @@ class netboot2(StageBase):
log.info('Emptying directory %s', x)
# stat the dir, delete the dir, 
recreate the dir and set
# the proper perms and ownership
-   mystat=os.stat(myemp)
-   shutil.rmtree(myemp)
-   ensure_dirs(myemp, mode=0o755)
-   
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
-   os.chmod(myemp,mystat[ST_MODE])
+   clear_dir(myemp)
self.resume.enable("empty")
 
def set_action_sequence(self):

diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index 7ba94b2..8a9acdd 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -2,17 +2,13 @@
 Snapshot target
 """
 
-import os
-import shutil
-from stat import ST_UID, ST_GID, ST_MODE
-
 from DeComp.compress import CompressMap
 
 from catalyst import log
 from catalyst.support import normpath, cmd
 from catalyst.base.targetbase import TargetBase
 from catalyst.base.genbase import GenBase
-from catalyst.fileops import ensure_dirs
+from catalyst.fileops import (clear_dir, ensure_dirs)
 
 
 class snapshot(TargetBase, GenBase):
@@ -102,16 +98,4 @@ class snapshot(TargetBase, GenBase):
log.info('Cleaning up ...')
 
def purge(self):
-   myemp=self.settings["tmp_path"]
-   if os.path.isdir(myemp):
-   log.notice('Emptying directory %s', myemp)
-   # stat the dir, delete the dir, recreate the dir and set
-   # the proper perms and ownership
-   mystat=os.stat(myemp)
-   # There's no easy way to change flags recursively in 
python
-   if os.uname()[0] == "FreeBSD":
-   os.system("chflags -R noschg "+myemp)
-   shutil.rmtree(myemp)
-   ensure_dirs(myemp, mode=0o755)
-   os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
-   os.chmod(myemp,mystat[ST_MODE])
+   clear_dir(self.settings['tmp_path'])



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2016-05-21 Thread Mike Frysinger
commit: 125ca190d30215de85fc3343c95784e658f75c37
Author: Mike Frysinger  gentoo  org>
AuthorDate: Fri May 20 05:43:14 2016 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Fri May 20 05:43:14 2016 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=125ca190

replace os.system with cmd

Use the existing cmd() helper for running external programs.

 catalyst/base/stagebase.py | 11 ++-
 catalyst/fileops.py|  4 ++--
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index f0f3ba9..6695ac4 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -967,16 +967,17 @@ class StageBase(TargetBase, ClearBase, GenBase):
if not ismount(target):
continue
 
-   retval=os.system("umount " + target)
-
-   if retval!=0:
+   try:
+   cmd(['umount', target])
+   except CatalystError:
log.warning('First attempt to unmount failed: 
%s', target)
log.warning('Killing any pids still running in 
the chroot')
 
self.kill_chroot_pids()
 
-   retval2 = os.system("umount " + target)
-   if retval2!=0:
+   try:
+   cmd(['umount', target])
+   except CatalystError:
ouch=1
log.warning("Couldn't umount bind 
mount: %s", target)
 

diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index 4b9e200..6971911 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -22,7 +22,7 @@ from snakeoil.osutils import (ensure_dirs as 
snakeoil_ensure_dirs,
 # pylint: enable=unused-import
 
 from catalyst import log
-from catalyst.support import CatalystError
+from catalyst.support import (cmd, CatalystError)
 
 
 def ensure_dirs(path, gid=-1, uid=-1, mode=0o755, minimal=True,
@@ -79,7 +79,7 @@ def clear_dir(target, mode=0o755, chg_flags=False, 
remove=False,
mystat = os.stat(target)
# There's no easy way to change flags recursively in 
python
if chg_flags and os.uname()[0] == "FreeBSD":
-   os.system("chflags -R noschg " + target)
+   cmd(['chflags', '-R', 'noschg', target])
log.debug('shutil.rmtree()')
shutil.rmtree(target)
except Exception:



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2016-03-23 Thread Brian Dolbec
commit: 0579e46fa1937c89cbc69a21a9596dadda5672eb
Author: Brian Dolbec  gentoo  org>
AuthorDate: Wed Mar 23 16:30:51 2016 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Wed Mar 23 16:36:45 2016 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=0579e46f

Fix commit 444e50e710f1  where I inaddvertently deleted the wrong paramter 
during the commit

Also change the default (de)compression mode and search order to the non _x 
variant.

 catalyst/base/stagebase.py | 2 +-
 catalyst/defaults.py   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 9d3841c..fe5e6d2 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1271,7 +1271,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if not self.compressor:
self.compressor = 
CompressMap(self.settings["compress_definitions"],
env=self.env, 
default_mode=self.settings['compression_mode'],
-   logger=log)
+   comp_prog=self.settings['comp_prog'])
 
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("capture"):

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 8b413f7..5ed19d1 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -33,10 +33,10 @@ valid_config_file_values.extend([ "distcc", "envscript",
 confdefaults={
"archdir": "%(PythonDir)s/arch",
"comp_prog": COMPRESSOR_PROGRAM_OPTIONS[TAR],
-   "compression_mode": 'lbzip2_x',
+   "compression_mode": 'lbzip2',
"compressor_arch": None,
"compressor_options": XATTRS_OPTIONS[TAR],
-   "decompressor_search_order": DECOMPRESSOR_XATTR_SEARCH_ORDER,
+   "decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
"distdir": "/usr/portage/distfiles",
"hash_function": "crc32",
"icecream": "/var/cache/icecream",



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2016-03-20 Thread Mike Frysinger
commit: 1016f0f3e15eb6a4e7cd203a35554d8c335e3e0a
Author: Mike Frysinger  gentoo  org>
AuthorDate: Mon Mar 21 05:14:48 2016 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Mon Mar 21 05:14:48 2016 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=1016f0f3

lint: clean up a few minor warnings

Should be no real functional changes here.

 catalyst/base/stagebase.py | 3 ---
 catalyst/main.py   | 4 +---
 catalyst/support.py| 3 +--
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 98c4959..9d3841c 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -5,9 +5,6 @@ import shutil
 import sys
 from stat import ST_UID, ST_GID, ST_MODE
 
-# for convienience
-pjoin = os.path.join
-
 from snakeoil import fileutils
 
 from DeComp.compress import CompressMap

diff --git a/catalyst/main.py b/catalyst/main.py
index 5b6b9ac..7c6a5d8 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -13,8 +13,6 @@ import sys
 
 from snakeoil import process
 
-__selfpath__ = os.path.abspath(os.path.dirname(__file__))
-
 from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
 from DeComp.contents import ContentsMap
@@ -63,7 +61,7 @@ def parse_config(config_files):
conf_values[x]=confdefaults[x]
 
# add our python base directory to use for loading target arch's
-   conf_values["PythonDir"] = __selfpath__
+   conf_values["PythonDir"] = os.path.dirname(os.path.realpath(__file__))
 
# print out any options messages
for opt in conf_values['options']:

diff --git a/catalyst/support.py b/catalyst/support.py
index 4efe96c..d13422d 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -21,8 +21,7 @@ def list_bashify(mylist):
# surround args with quotes for passing to bash,
# allows things like "<" to remain intact
mypack[x]="'"+mypack[x]+"'"
-   mypack = ' '.join(mypack)
-   return mypack
+   return ' '.join(mypack)
 
 
 class CatalystError(Exception):



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2015-11-20 Thread Brian Dolbec
commit: 3228dec78968e5f0b831cd477039decee6c79838
Author: Brian Dolbec  gentoo  org>
AuthorDate: Fri Nov 20 21:20:35 2015 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Fri Nov 20 21:24:31 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3228dec7

Debug autoextension detection not working for stage2

Remove the set_source_path() re-definition from stage2.  This only modified the 
seedcache location from the normal one to the previous build directory.
This is wrong.  The previous build location is normally cleaned and removed.
Also, if this is actually needed, then it should be done globally and 
configurable.
Add extra log messages to stagebase.
Clean out a no longer relevant log.info message

 catalyst/base/stagebase.py | 17 -
 catalyst/targets/stage2.py | 21 -
 2 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index df19c0b..69b7b0d 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -420,10 +420,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["source_path"] = 
normpath(self.settings["storedir"] +
"/tmp/" + self.settings["source_subpath"] + "/")
else:
+   log.debug('Checking source path existence and '
+   'get the final filepath. subpath: %s',
+   self.settings["source_subpath"])
self.settings["source_path"] = file_check(
normpath(self.settings["storedir"] + "/builds/" 
+
self.settings["source_subpath"])
)
+   log.debug('Source path returned from file_check is: %s',
+   self.settings["source_path"])
if os.path.isfile(self.settings["source_path"]):
# XXX: Is this even necessary if the previous 
check passes?
if os.path.exists(self.settings["source_path"]):
@@ -431,14 +436,7 @@ class StageBase(TargetBase, ClearBase, GenBase):

self.settings["hash_map"].generate_hash(

self.settings["source_path"],

hash_=self.settings["hash_function"])
-   log.info('Source path set to %s', self.settings['source_path'])
-   if os.path.isdir(self.settings["source_path"]):
-   log.warning(
-   'If this is not desired, remove this directory 
or turn off\n'
-   'seedcache in the options of catalyst.conf the 
source path\n'
-   'will then be %s',
-   normpath(self.settings['storedir'] + '/builds/' 
+
-   self.settings['source_subpath']))
+   log.notice('Source path set to %s', 
self.settings['source_path'])
 
def set_dest_path(self):
if "root_path" in self.settings:
@@ -749,7 +747,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
elif 
os.path.isdir(self.settings["source_path"]):
# We should never reach this, so 
something is very wrong
raise CatalystError(
-   "source path is a dir but 
seedcache is not enabled")
+   "source path is a dir but 
seedcache is not enabled: %s"
+   % self.settings["source_path"])
 
if _unpack:
self.mount_safety_check()

diff --git a/catalyst/targets/stage2.py b/catalyst/targets/stage2.py
index ff060d2..9658a49 100644
--- a/catalyst/targets/stage2.py
+++ b/catalyst/targets/stage2.py
@@ -3,10 +3,8 @@ stage2 target, builds upon previous stage1 tarball
 """
 # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
 
-import os
 
 from catalyst import log
-from catalyst.support import normpath
 from catalyst.base.stagebase import StageBase
 
 
@@ -19,25 +17,6 @@ class stage2(StageBase):
self.valid_values=["chost"]
StageBase.__init__(self,spec,addlargs)
 
-   def set_source_path(self):
-   if "seedcache" in self.settings["options"] and 
os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root")):
-   
self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root")
-   else:
-   

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/, catalyst/arch/, catalyst/targets/, bin/

2015-11-09 Thread Mike Frysinger
commit: 73a38c4393cc5cb4c0d915a99b4c6fb52bf8d23a
Author: Mike Frysinger  gentoo  org>
AuthorDate: Mon Nov  9 19:11:14 2015 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Mon Nov  9 19:11:14 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=73a38c43

lint: fix bad indents/trailing newlines

 bin/catalyst | 1 -
 catalyst/arch/__init__.py| 1 -
 catalyst/base/__init__.py| 1 -
 catalyst/base/genbase.py | 1 -
 catalyst/base/stagebase.py   | 2 +-
 catalyst/hash_utils.py   | 3 ---
 catalyst/targets/__init__.py | 1 -
 7 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/bin/catalyst b/bin/catalyst
index 577e899..1557ab8 100755
--- a/bin/catalyst
+++ b/bin/catalyst
@@ -39,4 +39,3 @@ except KeyboardInterrupt:
print("Aborted.")
sys.exit(130)
 sys.exit(0)
-

diff --git a/catalyst/arch/__init__.py b/catalyst/arch/__init__.py
index 8b13789..e69de29 100644
--- a/catalyst/arch/__init__.py
+++ b/catalyst/arch/__init__.py
@@ -1 +0,0 @@
-

diff --git a/catalyst/base/__init__.py b/catalyst/base/__init__.py
index 8b13789..e69de29 100644
--- a/catalyst/base/__init__.py
+++ b/catalyst/base/__init__.py
@@ -1 +0,0 @@
-

diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index 4214b45..0c8dbb9 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -51,4 +51,3 @@ class GenBase(object):
for j in array:
digest 
= hash_map.generate_hash(f, hash_=j)

myf.write(digest)
-

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index edbcaa6..df19c0b 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1067,7 +1067,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
% flags)
if (flags is not "CFLAGS" and
self.settings[flags] == 
self.settings["CFLAGS"]):
-   myf.write('%s="${CFLAGS}"\n' % 
flags)
+   myf.write('%s="${CFLAGS}"\n' % flags)
elif isinstance(self.settings[flags], list):
myf.write('%s="%s"\n'
% (flags, ' 
'.join(self.settings[flags])))

diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py
index 6e08967..1134f50 100644
--- a/catalyst/hash_utils.py
+++ b/catalyst/hash_utils.py
@@ -126,6 +126,3 @@ class HashMap(object):
result = header + "\n" + hash_result + "  " + short_file + "\n"
log.info('%s (%s) = %s', header, short_file, result)
return result
-
-
-

diff --git a/catalyst/targets/__init__.py b/catalyst/targets/__init__.py
index 8b13789..e69de29 100644
--- a/catalyst/targets/__init__.py
+++ b/catalyst/targets/__init__.py
@@ -1 +0,0 @@
-



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2015-10-08 Thread Brian Dolbec
commit: 080eab6b951ada8e6b982a71a4ff701241d7caee
Author: Brian Dolbec  gentoo  org>
AuthorDate: Thu Oct  8 19:33:17 2015 +
Commit: Brian Dolbec  gentoo  org>
CommitDate: Thu Oct  8 19:34:07 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=080eab6b

Fix argparse conversion breakage for verbose and debug settings

Argparse always defines the target variable.
Convert the use of them to normal assignment rather than a member inclusion 
test.

 catalyst/base/genbase.py |  6 +++---
 catalyst/lock.py | 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index a163638..32459b4 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -26,7 +26,7 @@ class GenBase(object):
array.sort()
for j in array:
contents = contents_map.contents(path, 
j,
-   verbose="VERBOSE" in 
self.settings)
+   
verbose=self.settings["VERBOSE"])
if contents:
myf.write(contents)
myf.close()
@@ -49,12 +49,12 @@ class GenBase(object):
if "all" in array:
for k in 
list(hash_map.hash_map):
digest = 
hash_map.generate_hash(f,hash_=k,
-   verbose 
= "VERBOSE" in self.settings)
+   
verbose=self.settings["VERBOSE"])

myf.write(digest)
else:
for j in array:
digest = 
hash_map.generate_hash(f,hash_=j,
-   verbose 
= "VERBOSE" in self.settings)
+   
verbose=self.settings["VERBOSE"])

myf.write(digest)
myf.close()
 

diff --git a/catalyst/lock.py b/catalyst/lock.py
index 3d50c06..8095a82 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -71,7 +71,7 @@ class LockDir(object):
 
def set_gid(self,gid):
if not self.islocked():
-#  if "DEBUG" in self.settings:
+#  if self.settings["DEBUG"]:
 #  print "setting gid to", gid
self.gid=gid
 
@@ -83,7 +83,7 @@ class LockDir(object):
if lockdir[-1] == "/":
lockdir=lockdir[:-1]
self.lockdir=normpath(lockdir)
-#  if "DEBUG" in self.settings:
+#  if self.settings["DEBUG"]:
 #  print "setting lockdir to", self.lockdir
else:
raise "the lock object needs a path to a dir"
@@ -91,13 +91,13 @@ class LockDir(object):
def set_lockfilename(self,lockfilename):
if not self.islocked():
self.lockfilename=lockfilename
-#  if "DEBUG" in self.settings:
+#  if self.settings["DEBUG"]:
 #  print "setting lockfilename to", 
self.lockfilename
 
def set_lockfile(self):
if not self.islocked():

self.lockfile=normpath(self.lockdir+'/'+self.lockfilename)
-#  if "DEBUG" in self.settings:
+#  if self.settings["DEBUG"]:
 #  print "setting lockfile to", self.lockfile
 
def read_lock(self):
@@ -222,7 +222,7 @@ class LockDir(object):
os.unlink(self.lockfile)
os.close(self.myfd)
self.myfd=None
-#  if "DEBUG" in self.settings:
+#  if self.settings["DEBUG"]:
 #  print "Unlinked 
lockfile..."
except Exception, e:
# We really don't care... Someone else 
has the lock.
@@ -269,7 +269,7 @@ class LockDir(object):
try:
os.link(self.myhardlock, 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/, catalyst/targets/

2015-10-06 Thread Mike Frysinger
commit: d5fc0982052ada0eaab209b8c56574220f63a698
Author: Mike Frysinger  gentoo  org>
AuthorDate: Tue Oct  6 13:57:12 2015 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Tue Oct  6 13:57:12 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d5fc0982

lint: convert funcs to @staticmethod where it makes sense

These functions don't actually utilize |self|, so make them into
@staticmethod's to quiet down the linter.

 catalyst/base/stagebase.py   | 3 ++-
 catalyst/lock.py | 9 ++---
 catalyst/targets/snapshot.py | 3 ++-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index b9dd1d5..409fcab 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1695,7 +1695,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.unbind()
raise CatalystError("build aborting due to 
livecd_update error.")
 
-   def _debug_pause_(self):
+   @staticmethod
+   def _debug_pause_():
py_input("press any key to continue: ")
 
 # vim: ts=4 sw=4 sta et sts=4 ai

diff --git a/catalyst/lock.py b/catalyst/lock.py
index 71918d6..01b1aa8 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -320,7 +320,8 @@ class LockDir(object):
del self.hardlock_paths[self.lockdir]
print self.hardlock_paths
 
-   def hardlock_name(self, path):
+   @staticmethod
+   def hardlock_name(path):
mypath=path+"/.hardlock-"+os.uname()[1]+"-"+str(os.getpid())
newpath = os.path.normpath(mypath)
if len(newpath) > 1:
@@ -328,7 +329,8 @@ class LockDir(object):
newpath = "/"+newpath.lstrip("/")
return newpath
 
-   def hardlink_is_mine(self,link,lock):
+   @staticmethod
+   def hardlink_is_mine(link, lock):
import stat
try:
myhls = os.stat(link)
@@ -347,7 +349,8 @@ class LockDir(object):
return True
return False
 
-   def hardlink_active(self, lock):
+   @staticmethod
+   def hardlink_active(lock):
if not os.path.exists(lock):
return False
 

diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index 87340b7..a117a21 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -90,7 +90,8 @@ class snapshot(TargetBase, GenBase):
def kill_chroot_pids(self):
pass
 
-   def cleanup(self):
+   @staticmethod
+   def cleanup():
print "Cleaning up..."
 
def purge(self):



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/arch/, catalyst/targets/

2015-10-06 Thread Mike Frysinger
commit: 68c5ace05cfddab5185c78e79d5c48cb30677fca
Author: Mike Frysinger  gentoo  org>
AuthorDate: Tue Oct  6 13:54:45 2015 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Tue Oct  6 13:54:45 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=68c5ace0

lint: fix bad indentation

Fix code that has excessive indentation relative to previous levels.

 catalyst/arch/x86.py  |  4 ++--
 catalyst/base/stagebase.py|  6 +++---
 catalyst/targets/livecd_stage1.py |  2 +-
 catalyst/targets/livecd_stage2.py |  2 +-
 catalyst/targets/netboot2.py  |  4 ++--
 catalyst/targets/stage2.py| 12 ++--
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/catalyst/arch/x86.py b/catalyst/arch/x86.py
index 49500b9..33b29c0 100644
--- a/catalyst/arch/x86.py
+++ b/catalyst/arch/x86.py
@@ -10,8 +10,8 @@ class generic_x86(builder.generic):
builder.generic.__init__(self,myspec)
if self.settings["buildarch"]=="amd64":
if not os.path.exists("/bin/linux32") and not 
os.path.exists("/usr/bin/linux32"):
-   raise CatalystError("required 
executable linux32 not found "
-   "(\"emerge setarch\" to fix.)", 
print_traceback=True)
+   raise CatalystError("required executable 
linux32 not found "
+   "(\"emerge setarch\" to fix.)", 
print_traceback=True)
self.settings["CHROOT"]="linux32 chroot"
self.settings["crosscompile"] = False
else:

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index a9e7848..b9dd1d5 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -853,9 +853,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
and os.path.exists(target_portdir) \
and self.resume.is_enabled("unpack_portage") \
and self.settings["snapshot_path_hash"] == 
snapshot_hash:
-   print \
-   "Valid Resume point detected, 
skipping unpack of portage tree..."
-   unpack=False
+   print \
+   "Valid Resume point detected, skipping 
unpack of portage tree..."
+   unpack = False
 
if unpack:
if "snapcache" in self.settings["options"]:

diff --git a/catalyst/targets/livecd_stage1.py 
b/catalyst/targets/livecd_stage1.py
index ff320c0..262db70 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -34,7 +34,7 @@ class livecd_stage1(StageBase):

self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"])
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_target_path"):
-   print "Resume point detected, skipping target 
path setup operation..."
+   print "Resume point detected, skipping target path 
setup operation..."
else:
# first clean up any existing target stuff
if os.path.exists(self.settings["target_path"]):

diff --git a/catalyst/targets/livecd_stage2.py 
b/catalyst/targets/livecd_stage2.py
index 870dcf9..b54f2f0 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -55,7 +55,7 @@ class livecd_stage2(StageBase):

self.settings["target_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["target_subpath"])
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_target_path"):
-   print "Resume point detected, skipping target 
path setup operation..."
+   print "Resume point detected, skipping target path 
setup operation..."
else:
# first clean up any existing target stuff
if os.path.isdir(self.settings["target_path"]):

diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index e509cf9..f2d039c 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -54,7 +54,7 @@ class netboot2(StageBase):
self.settings["target_subpath"])
if "autoresume" in self.settings["options"] \
and self.resume.is_enabled("setup_target_path"):
-   print "Resume point detected, skipping target 
path setup operation..."
+   print "Resume point detected, skipping target path 
setup 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/, targets/stage1/

2015-10-06 Thread Mike Frysinger
commit: dd3d5a4138662836243e1686167708f98fe2bf0b
Author: Mike Frysinger  gentoo  org>
AuthorDate: Tue Oct  6 14:02:42 2015 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Tue Oct  6 14:02:42 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=dd3d5a41

lint: clean up bare exception handling

It's a bad idea to use a bare except clause as you end up including
things like SystemExit, KeyboardInterrupt, and GeneratorExit, none
of which we actually want to catch.  Some of the cases in the code
were explicitly catching & passing SystemExit back up which proves
this point.

 catalyst/base/stagebase.py |  2 +-
 catalyst/lock.py   | 26 --
 catalyst/main.py   |  2 +-
 catalyst/support.py| 15 +--
 targets/stage1/build.py|  2 +-
 5 files changed, 12 insertions(+), 35 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 409fcab..e393c5b 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1015,7 +1015,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
target is fully initialized
"""
self.snapshot_lock_object.unlock()
-   except:
+   except Exception:
pass
if ouch:
"""

diff --git a/catalyst/lock.py b/catalyst/lock.py
index 01b1aa8..d6653f7 100644
--- a/catalyst/lock.py
+++ b/catalyst/lock.py
@@ -130,8 +130,6 @@ class LockDir(object):
try:
if os.stat(self.lockfile).st_gid != 
self.gid:

os.chown(self.lockfile,os.getuid(),self.gid)
-   except SystemExit, e:
-   raise
except OSError, e:
if e[0] == 2: #XXX: No such file or 
directory
return 
self.fcntl_locking(locktype)
@@ -185,7 +183,7 @@ class LockDir(object):
try:
os.close(self.myfd)
self.myfd=None
-   except:
+   except Exception:
pass
return False
 
@@ -194,8 +192,6 @@ class LockDir(object):
self.myfd = os.open(self.lockfile, 
os.O_WRONLY,0660)
unlinkfile = 1

self.locking_method(self.myfd,fcntl.LOCK_UN)
-   except SystemExit, e:
-   raise e
except Exception, e:
#if self.myfd is not None:
#print "fcntl_unlock() trying to 
close", self.myfd
@@ -213,7 +209,7 @@ class LockDir(object):
InUse=False
try:

self.locking_method(self.myfd,fcntl.LOCK_EX|fcntl.LOCK_NB)
-   except:
+   except Exception:
print "Read lock may be 
in effect. skipping lockfile delete..."
InUse=True
# We won the lock, so 
there isn't competition for it.
@@ -227,8 +223,6 @@ class LockDir(object):
self.myfd=None
 #  if "DEBUG" in self.settings:
 #  print "Unlinked 
lockfile..."
-   except SystemExit, e:
-   raise e
except Exception, e:
# We really don't care... Someone else 
has the lock.
# So it is their problem now.
@@ -273,8 +267,6 @@ class LockDir(object):
print_traceback=True)
try:
os.link(self.myhardlock, self.lockfile)
-   except SystemExit:
-   raise
except Exception:
 #  if "DEBUG" in self.settings:
 #  print "lockfile(): Hardlink: Link 
failed."
@@ -305,9 +297,7 @@ class LockDir(object):

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/, catalyst/

2015-10-06 Thread Mike Frysinger
commit: 75d1b6b8d2c1c28fb4914d33b7643e8e86940efa
Author: Mike Frysinger  gentoo  org>
AuthorDate: Tue Oct  6 17:15:18 2015 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Tue Oct  6 17:15:18 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=75d1b6b8

lint: use comments for comments, not inline docstrings

It's uncommon to dump docstrings in the middle of code in the place of
comments.  Convert them all to standard comments.

 catalyst/base/stagebase.py   | 219 ++-
 catalyst/fileops.py  |   8 +-
 catalyst/targets/snapshot.py |   8 +-
 3 files changed, 99 insertions(+), 136 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index fcdf729..813e5f1 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -49,29 +49,27 @@ class StageBase(TargetBase, ClearBase, GenBase):
GenBase.__init__(self, myspec)
ClearBase.__init__(self, myspec)
 
-   """
-   The semantics of subarchmap and machinemap changed a bit in 
2.0.3 to
-   work better with vapier's CBUILD stuff. I've removed the 
"monolithic"
-   machinemap from this file and split up its contents amongst the
-   various arch/foo.py files.
-
-   When register() is called on each module in the arch/ dir, it 
now
-   returns a tuple instead of acting on the subarchmap dict that is
-   passed to it. The tuple contains the values that were previously
-   added to subarchmap as well as a new list of CHOSTs that go 
along
-   with that arch. This allows us to build machinemap on the fly 
based
-   on the keys in subarchmap and the values of the 2nd list 
returned
-   (tmpmachinemap).
-
-   Also, after talking with vapier. I have a slightly better idea 
of what
-   certain variables are used for and what they should be set to. 
Neither
-   'buildarch' or 'hostarch' are used directly, so their value 
doesn't
-   really matter. They are just compared to determine if we are
-   cross-compiling. Because of this, they are just set to the name 
of the
-   module in arch/ that the subarch is part of to make things 
simpler.
-   The entire build process is still based off of 'subarch' like 
it was
-   previously. -agaffney
-   """
+   # The semantics of subarchmap and machinemap changed a bit in 
2.0.3 to
+   # work better with vapier's CBUILD stuff. I've removed the 
"monolithic"
+   # machinemap from this file and split up its contents amongst 
the
+   # various arch/foo.py files.
+   #
+   # When register() is called on each module in the arch/ dir, it 
now
+   # returns a tuple instead of acting on the subarchmap dict that 
is
+   # passed to it. The tuple contains the values that were 
previously
+   # added to subarchmap as well as a new list of CHOSTs that go 
along
+   # with that arch. This allows us to build machinemap on the fly 
based
+   # on the keys in subarchmap and the values of the 2nd list 
returned
+   # (tmpmachinemap).
+   #
+   # Also, after talking with vapier. I have a slightly better 
idea of what
+   # certain variables are used for and what they should be set 
to. Neither
+   # 'buildarch' or 'hostarch' are used directly, so their value 
doesn't
+   # really matter. They are just compared to determine if we are
+   # cross-compiling. Because of this, they are just set to the 
name of the
+   # module in arch/ that the subarch is part of to make things 
simpler.
+   # The entire build process is still based off of 'subarch' like 
it was
+   # previously. -agaffney
 
self.makeconf = {}
self.archmap = {}
@@ -81,16 +79,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
for x in [x[:-3] for x in os.listdir(arch_dir) if 
x.endswith(".py") and x != "__init__.py"]:
try:
fh=open(arch_dir + x + ".py")
-   """
-   This next line loads the plugin as a module and 
assigns it to
-   archmap[x]
-   """
+   # This next line loads the plugin as a module 
and assigns it to
+   # archmap[x]
self.archmap[x]=imp.load_module(x,fh, arch_dir 
+ x + ".py",
(".py", "r", imp.PY_SOURCE))
-   """
-   This next line 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/arch/

2015-09-09 Thread Richard Farina
commit: d05808a7a8313a66a0be67e89867b4c3a1fe5ca0
Author: Rick Farina (Zero_Chaos)  gentoo  org>
AuthorDate: Wed Sep  9 16:32:27 2015 +
Commit: Richard Farina  gentoo  org>
CommitDate: Wed Sep  9 16:32:27 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d05808a7

only set CHOST in make.conf if we are setting it via catalyst to override the 
profile

this commit brings catalyst into compliance with the documentation which states 
that
chost should be set if the user wants to override the profile

This also avoids the ugly warning in make.conf about how dangerous it is to 
change
your chost

 catalyst/arch/amd64.py |  7 ---
 catalyst/arch/x86.py   | 11 ---
 catalyst/base/stagebase.py |  5 +++--
 3 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/catalyst/arch/amd64.py b/catalyst/arch/amd64.py
index 1e11be9..463e8f5 100644
--- a/catalyst/arch/amd64.py
+++ b/catalyst/arch/amd64.py
@@ -12,7 +12,6 @@ class arch_amd64(generic_amd64):
def __init__(self,myspec):
generic_amd64.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -pipe"
-   self.settings["CHOST"]="x86_64-pc-linux-gnu"
#lines like this appears to be trying to set the profile 
default, better to use the profile

#self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx","sse","sse2"]}
 
@@ -21,7 +20,6 @@ class arch_nocona(generic_amd64):
def __init__(self,myspec):
generic_amd64.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -march=nocona -pipe"
-   self.settings["CHOST"]="x86_64-pc-linux-gnu"

#self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx","sse","sse2"]}
 
 # Requires gcc 4.3 to use this class
@@ -30,7 +28,6 @@ class arch_core2(generic_amd64):
def __init__(self,myspec):
generic_amd64.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -march=core2 -pipe"
-   self.settings["CHOST"]="x86_64-pc-linux-gnu"

#self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx","sse","sse2","ssse3"]}
 
 class arch_k8(generic_amd64):
@@ -38,7 +35,6 @@ class arch_k8(generic_amd64):
def __init__(self,myspec):
generic_amd64.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -march=k8 -pipe"
-   self.settings["CHOST"]="x86_64-pc-linux-gnu"

#self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx","sse","sse2","3dnow"]}
 
 class arch_k8_sse3(generic_amd64):
@@ -46,7 +42,6 @@ class arch_k8_sse3(generic_amd64):
def __init__(self,myspec):
generic_amd64.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -march=k8-sse3 -pipe"
-   self.settings["CHOST"]="x86_64-pc-linux-gnu"

#self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx","sse","sse2","3dnow"]}
 
 class arch_amdfam10(generic_amd64):
@@ -54,7 +49,6 @@ class arch_amdfam10(generic_amd64):
def __init__(self,myspec):
generic_amd64.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -march=amdfam10 -pipe"
-   self.settings["CHOST"]="x86_64-pc-linux-gnu"

#self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx","sse","sse2","3dnow"]}
 
 class arch_x32(generic_amd64):
@@ -62,7 +56,6 @@ class arch_x32(generic_amd64):
def __init__(self,myspec):
generic_amd64.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -pipe"
-   self.settings["CHOST"]="x86_64-pc-linux-gnux32"

#self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx","sse","sse2"]}
 
 def register():

diff --git a/catalyst/arch/x86.py b/catalyst/arch/x86.py
index f0c4a4c..44a6a49 100644
--- a/catalyst/arch/x86.py
+++ b/catalyst/arch/x86.py
@@ -50,14 +50,12 @@ class arch_i686(generic_x86):
def __init__(self,myspec):
generic_x86.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -march=i686 -pipe"
-   self.settings["CHOST"]="i686-pc-linux-gnu"
 
 class arch_pentium_mmx(generic_x86):
"Intel Pentium MMX CPU with MMX support"
def __init__(self,myspec):
generic_x86.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -march=pentium-mmx -pipe"
-   self.settings["CHOST"]="i686-pc-linux-gnu"
self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx"]}
 
 class arch_pentium2(generic_x86):
@@ -65,7 +63,6 @@ class arch_pentium2(generic_x86):
def __init__(self,myspec):
generic_x86.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -march=pentium2 -pipe"
-   self.settings["CHOST"]="i686-pc-linux-gnu"
self.settings["HOSTUSEEXPAND"]={"CPU_FLAGS_X86":["mmx"]}
 
 class arch_pentium3(generic_x86):
@@ -73,7 +70,6 @@ class arch_pentium3(generic_x86):
 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/, catalyst/, targets/stage1/, targets/support/

2015-08-29 Thread Brian Dolbec
commit: 6d640c0b9681b81be13ed11c52f1f037abc0d875
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Sun Feb 24 20:33:18 2013 +
Commit: Brian Dolbec dolsen AT gentoo DOT org
CommitDate: Sun Aug 30 02:09:05 2015 +
URL:https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6d640c0b

Migrate hardcoded /etc/portage paths

Create port_conf default.
Migrate all references to /etc/portage to the config's default.
Migrate all make.conf paths to the config'd default.

 catalyst/base/stagebase.py  | 15 +--
 catalyst/defaults.py|  3 ++-
 catalyst/targets/stage1.py  |  2 +-
 targets/stage1/stage1-chroot.sh | 18 +-
 targets/stage1/stage1-controller.sh |  6 +++---
 targets/support/chroot-functions.sh | 16 
 targets/support/kmerge.sh   | 10 +-
 targets/support/livecdfs-update.sh  | 12 ++--
 8 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 644bd7c..4c7f029 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -875,12 +875,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
# TODO: zmedico and I discussed making this a directory 
and pushing
# in a parent file, as well as other user-specified 
configuration.
print Configuring profile link...
-   cmd(rm -f 
+self.settings[chroot_path]+/etc/portage/make.profile,\
-   Error zapping profile 
link,env=self.env)
-   cmd(mkdir -p 
+self.settings[chroot_path]+/etc/portage/)
-   cmd(ln -sf ../.. + self.settings[portdir] + 
/profiles/ + \
-   self.settings[target_profile]+ +\
-   
self.settings[chroot_path]+/etc/portage/make.profile,\
+   cmd(rm -f  + self.settings[chroot_path] +
+   self.settings[port_conf] + /make.profile,
+   Error zapping profile link,env=self.env)
+   cmd(mkdir -p  + self.settings[chroot_path] +
+   self.settings[port_conf])
+   cmd(ln -sf ../.. + self.settings[portdir] + 
/profiles/ +
+   self.settings[target_profile] +   +
+   self.settings[chroot_path] +
+   self.settings[port_conf] + /make.profile,
Error creating profile link,env=self.env)
self.resume.enable(config_profile_link)
 

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 5cb5e3f..975e55b 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -26,7 +26,8 @@ confdefaults={
hash_function: crc32,
icecream: /var/cache/icecream,
local_overlay: /usr/local/portage,
-   make_conf: /etc/portage/make.conf,
+   port_conf: /etc/portage,
+   make_conf: %(port_conf)s/make.conf,
options: set(),
packagedir: /usr/portage/packages,
portdir: /usr/portage,

diff --git a/catalyst/targets/stage1.py b/catalyst/targets/stage1.py
index 3d3b9e9..d5cc298 100644
--- a/catalyst/targets/stage1.py
+++ b/catalyst/targets/stage1.py
@@ -32,7 +32,7 @@ class stage1(StageBase):
def set_cleanables(self):
StageBase.set_cleanables(self)
self.settings[cleanables].extend([\
-   /usr/share/zoneinfo, /etc/portage/package*])
+   /usr/share/zoneinfo, self.settings[port_conf] + 
/package*])
 
# XXX: How do these override_foo() functions differ from the ones in 
StageBase and why aren't they in stage3_target?
 

diff --git a/targets/stage1/stage1-chroot.sh b/targets/stage1/stage1-chroot.sh
index 63aa563..4afc8fe 100755
--- a/targets/stage1/stage1-chroot.sh
+++ b/targets/stage1/stage1-chroot.sh
@@ -16,7 +16,7 @@ if [ -z ${clst_buildpkgs} ]
 then
echo Your profile seems to be broken.
echo Could not build a list of build packages.
-   echo Double check your /etc/portage/make.profile link and the 
'packages' files.
+   echo Double check your ${clst_port_conf}/make.profile link and the 
'packages' files.
exit 1
 fi
 
@@ -47,27 +47,27 @@ make_destpath /tmp/stage1root
 
 ## START BUILD
 # First, we drop in a known-good baselayout
-[ -e /etc/portage/make.conf ]  \
-   echo 'USE=${USE} -build'  /etc/portage/make.conf
+[ -e ${clst_make_conf} ]  \
+   echo 'USE=${USE} -build'  ${clst_make_conf}
 run_merge --oneshot --nodeps sys-apps/baselayout
 
-sed -i '/USE=${USE} -build/d' /etc/portage/make.conf
+sed -i '/USE=${USE} -build/d' ${clst_make_conf}
 
 # Now, we install our packages
-if [ -e /etc/portage/make.conf ]; then
+if [ -e ${clst_make_conf} ]  \
echo USE=\-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\ \
-

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2015-02-26 Thread Brian Dolbec
commit: a519c380faabe8278863d4615e24194d17c78c75
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Mon Feb 25 03:52:44 2013 +
Commit: Brian Dolbec dolsen AT gentoo DOT org
CommitDate: Thu Jan  1 05:58:06 2015 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=a519c380

Fix typo in error message, clean up useless tracebacks

Remove useless python tracebacks for bash side target failures.

Conflicts:
catalyst/main.py

---
 catalyst/base/stagebase.py | 2 +-
 catalyst/main.py   | 2 --
 catalyst/support.py| 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index c16ef86..3056ce2 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1296,7 +1296,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
except CatalystError:
self.unbind()
raise CatalystError(Stage build aborting due 
to error.,
-   print_traceback=True)
+   print_traceback=False)
 
def setup_environment(self):


diff --git a/catalyst/main.py b/catalyst/main.py
index 56e57c6..7fea4e7 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -163,8 +163,6 @@ def build_target(addlargs):
try:
target.run()
except:
-   print Target run() exception:  Python traceback output 
follows:
-   catalyst.util.print_traceback()
print !!! catalyst: Error encountered during run of target  + 
\
addlargs[target]
sys.exit(1)

diff --git a/catalyst/support.py b/catalyst/support.py
index 8c4876f..8f2e5df 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -90,7 +90,7 @@ class CatalystError(Exception):
(type,value)=sys.exc_info()[:2]
if value!=None:
print
-   print Traceback valuse found.  
listing...
+   print Traceback values found.  
listing...
print 
traceback.print_exc(file=sys.stdout)
print
print !!! catalyst: +message



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2015-02-26 Thread Brian Dolbec
commit: a1c2785438593104d7c3d2ec20dd4fb25cb19884
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Sat Jun  1 06:23:46 2013 +
Commit: Brian Dolbec dolsen AT gentoo DOT org
CommitDate: Thu Jan  1 05:58:07 2015 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=a1c27854

Create AutoResume class to handle all file creation, deletion...

Create catalyst/base/resume.py.
Migrate all auto_resume operations to using the new class.

---
 catalyst/base/clearbase.py|  21 +
 catalyst/base/resume.py   | 166 ++
 catalyst/base/stagebase.py| 156 +++
 catalyst/targets/grp.py   |   4 +-
 catalyst/targets/livecd_stage1.py |   4 +-
 catalyst/targets/livecd_stage2.py |  14 ++--
 catalyst/targets/netboot2.py  |  19 +++--
 7 files changed, 250 insertions(+), 134 deletions(-)

diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py
index 8462a3c..0ebe299 100644
--- a/catalyst/base/clearbase.py
+++ b/catalyst/base/clearbase.py
@@ -13,31 +13,14 @@ class ClearBase(object):

def __init__(self, myspec):
self.settings = myspec
-
+   self.resume = None
 
 
def clear_autoresume(self):
 Clean resume points since they are no longer needed 
if autoresume in self.settings[options]:
print Removing AutoResume Points: ...
-   myemp=self.settings[autoresume_path]
-   if os.path.isdir(myemp):
-   if autoresume in self.settings[options]:
-   print Emptying directory,myemp
-   
-   stat the dir, delete the dir, recreate the dir 
and set
-   the proper perms and ownership
-   
-   mystat=os.stat(myemp)
-   if os.uname()[0] == FreeBSD:
-   cmd(chflags -R noschg +myemp,\
-   Could not remove immutable 
flag for file \
-   +myemp)
-   #cmd(rm -rf +myemp, Could not remove 
existing file: +myemp,env-self.env)
-   shutil.rmtree(myemp)
-   ensure_dirs(myemp, 0755)
-   os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
-   os.chmod(myemp,mystat[ST_MODE])
+   self.resume.clear_all()
 
 
def clear_chroot(self):

diff --git a/catalyst/base/resume.py b/catalyst/base/resume.py
new file mode 100644
index 000..e42c7dc
--- /dev/null
+++ b/catalyst/base/resume.py
@@ -0,0 +1,166 @@
+#!/usr/bin/python
+
+# Maintained in full by:
+# Catalyst Team catal...@gentoo.org
+# Release Engineering Team rel...@gentoo.org
+# Copyright 2013 Brian Dolbec dol...@gentoo.org
+
+'''resume.py
+
+Performs autoresume tracking file operations such as
+set, unset, is_set, is_unset, enabled, clear_all
+'''
+
+import os
+import shutil
+from stat import ST_UID, ST_GID, ST_MODE
+import traceback
+
+from catalyst.fileops import ensure_dirs, pjoin, listdir_files
+from catalyst.support import touch
+
+
+class AutoResumeError(Exception):
+   def __init__(self, message, print_traceback=False):
+   if message:
+   if print_traceback:
+   (type,value)=sys.exc_info()[:2]
+   if value!=None:
+   print
+   print Traceback values found.  
listing...
+   print 
traceback.print_exc(file=sys.stdout)
+   print !!! catalyst: AutoResumeError  + message
+   print
+
+
+class AutoResume(object):
+   '''Class for tracking and handling all aspects of
+   the autoresume option and related files.
+   '''
+
+
+   def __init__(self, basedir, mode=0755):
+   self.basedir = basedir
+   ensure_dirs(basedir, mode=mode, fatal=True)
+   self._points = {}
+   self._init_points_()
+
+
+   def _init_points_(self):
+   '''Internal function which reads the autoresume directory and
+   for existing autoresume points and adds them to our _points 
variable
+   '''
+   existing = listdir_files(self.basedir, False)
+   for point in existing:
+   self._points[point] = pjoin(self.basedir, point)
+
+
+   def enable(self, point, data=None):
+   '''Sets the resume point 'ON'
+
+   @param point: string.  name of the resume point to enable
+   @param data: string of information to store, or None
+ 

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/, catalyst/targets/

2015-02-26 Thread Brian Dolbec
commit: f98b415f062b624bde02d48768372c9848abe175
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Fri May 31 16:11:30 2013 +
Commit: Brian Dolbec dolsen AT gentoo DOT org
CommitDate: Thu Jan  1 05:58:07 2015 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=f98b415f

Initial creation of fileops.py

Migrate to using ensure_dirs()

---
 catalyst/base/clearbase.py| 10 -
 catalyst/base/stagebase.py| 32 +++-
 catalyst/fileops.py   | 45 +++
 catalyst/targets/grp.py   |  5 ++---
 catalyst/targets/livecd_stage1.py |  4 ++--
 catalyst/targets/livecd_stage2.py | 13 ---
 catalyst/targets/netboot2.py  |  6 +++---
 catalyst/targets/snapshot.py  | 10 -
 catalyst/targets/stage1.py| 10 -
 9 files changed, 81 insertions(+), 54 deletions(-)

diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py
index 8519acc..585d4f2 100644
--- a/catalyst/base/clearbase.py
+++ b/catalyst/base/clearbase.py
@@ -5,7 +5,7 @@ from stat import ST_UID, ST_GID, ST_MODE
 
 
 from catalyst.support import cmd, countdown
-
+from catalyst.fileops import ensure_dirs
 
 class ClearBase(object):

@@ -35,7 +35,7 @@ class ClearBase(object):
+myemp)
#cmd(rm -rf +myemp, Could not remove 
existing file: +myemp,env-self.env)
shutil.rmtree(myemp)
-   os.makedirs(myemp,0755)
+   ensure_dirs(myemp, 0755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
 
@@ -54,7 +54,7 @@ class ClearBase(object):
if os.uname()[0] == FreeBSD:
os.system(chflags -R noschg +myemp)
shutil.rmtree(myemp)
-   os.makedirs(myemp,0755)
+   ensure_dirs(myemp, mode=0755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
 
@@ -73,7 +73,7 @@ class ClearBase(object):
mystat=os.stat(myemp)
#cmd(rm -rf +myemp, Could not remove 
existing file: +myemp,env=self.env)
shutil.rmtree(myemp)
-   os.makedirs(myemp,0755)
+   ensure_dirs(myemp, mode=0755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
 
@@ -92,7 +92,7 @@ class ClearBase(object):
mystat=os.stat(myemp)
#cmd(rm -rf +myemp, Could not remove 
existing file: +myemp,env=self.env)
shutil.rmtree(myemp)
-   os.makedirs(myemp,0755)
+   ensure_dirs(myemp, mode=0755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
 

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 3056ce2..40c7362 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -18,6 +18,7 @@ from catalyst.base.targetbase import TargetBase
 from catalyst.base.clearbase import ClearBase
 from catalyst.base.genbase import GenBase
 from catalyst.lock import LockDir
+from catalyst.fileops import ensure_dirs, pjoin
 
 
 class StageBase(TargetBase, ClearBase, GenBase):
@@ -339,8 +340,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 #  
+self.settings[target_path],env=self.env)
touch(setup_target_path_resume)
 
-   if not 
os.path.exists(self.settings[storedir]+/builds/):
-   
os.makedirs(self.settings[storedir]+/builds/)
+   ensure_dirs(self.settings[storedir] + /builds/)
 
def set_fsscript(self):
if self.settings[spec_prefix]+/fsscript in self.settings:
@@ -486,8 +486,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
))
if autoresume in self.settings[options]:
print The autoresume path is  + 
self.settings[autoresume_path]
-   if not os.path.exists(self.settings[autoresume_path]):
-   os.makedirs(self.settings[autoresume_path],0755)
+   ensure_dirs(self.settings[autoresume_path], mode=0755)
 
def set_controller_file(self):

self.settings[controller_file]=normpath(self.settings[sharedir]+\
@@ -769,19 +768,15 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.clear_autoresume()
  

[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/

2015-02-25 Thread Brian Dolbec
commit: 6f01be26fb22e2b9c89453f9a4d2eeba2babf6e6
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Tue Jan 22 08:39:18 2013 +
Commit: Brian Dolbec dolsen AT gentoo DOT org
CommitDate: Thu Jan  1 05:58:06 2015 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=6f01be26

Rename a make.conf key to make_conf due to bash variable name restrictions

---
 catalyst/base/stagebase.py | 10 +-
 catalyst/defaults.py   |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index b44a957..96b1c19 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1020,7 +1020,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
def chroot_setup(self):

self.makeconf=read_makeconf(normpath(self.settings[chroot_path]+
-   self.settings[make.conf]))
+   self.settings[make_conf]))
self.override_cbuild()
self.override_chost()
self.override_cflags()
@@ -1068,7 +1068,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
 Modify and write out make.conf (for the chroot) 
makepath = normpath(self.settings[chroot_path] +
-   self.settings[make.conf])
+   self.settings[make_conf])
cmd(rm -f  + makepath,\
Could not remove  + makepath, env=self.env)
myf=open(makepath, w)
@@ -1122,9 +1122,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
myf.close()
makepath = normpath(self.settings[chroot_path] +
-   self.settings[make.conf])
+   self.settings[make_conf])
cmd(cp  + makepath +   + makepath + .catalyst,\
-   Could not backup  + 
self.settings[make.conf],env=self.env)
+   Could not backup  + 
self.settings[make_conf],env=self.env)
touch(self.settings[autoresume_path]+chroot_setup)
 
def fsscript(self):
@@ -1172,7 +1172,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
cmd(rm -rf  + self.settings[chroot_path] + 
self.settings[local_overlay],
Could not remove  + 
self.settings[local_overlay], env=self.env)
cmd(sed -i '/^PORTDIR_OVERLAY/d' 
+self.settings[chroot_path]+\
-   /etc/portage/make.conf,\
+   self.settings[make_conf],\
Could not remove PORTDIR_OVERLAY from 
make.conf,env=self.env)
 
 Clean up old and obsoleted files in /etc 

diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index ce7e919..2839a3d 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -25,8 +25,8 @@ confdefaults={
hash_function: crc32,
icecream: /var/cache/icecream,
local_overlay: /usr/local/portage,
-   make.conf: /etc/portage/make.conf,
-   options: ,
+   make_conf: /etc/portage/make.conf,
+   options: set(),
packagedir: /usr/portage/packages,
portdir: /usr/portage,
port_tmpdir: /var/tmp/portage,



[gentoo-commits] proj/catalyst:master commit in: catalyst/base/, catalyst/targets/

2015-02-25 Thread Brian Dolbec
commit: 5fa2b2a910c45401f132e7ed7e9da9a993762252
Author: Brian Dolbec dolsen AT gentoo DOT org
AuthorDate: Tue Feb 12 03:51:52 2013 +
Commit: Brian Dolbec dolsen AT gentoo DOT org
CommitDate: Thu Jan  1 05:58:05 2015 +
URL:
http://sources.gentoo.org/gitweb/?p=proj/catalyst.git;a=commit;h=5fa2b2a9

[1 of 3] Move base stage and target files to thier own sub-pkg

Fix an indent error in grp_target.py

---
 catalyst/base/__init__.py  |  1 +
 catalyst/{targets = base}/clearbase.py|  0
 catalyst/{targets = base}/genbase.py  |  0
 .../generic_stage_target.py = base/stagebase.py}  |  8 ++---
 catalyst/{targets = base}/targetbase.py   |  0
 catalyst/targets/embedded_target.py| 12 
 catalyst/targets/grp_target.py | 34 +-
 catalyst/targets/livecd_stage1_target.py   | 21 -
 catalyst/targets/livecd_stage2_target.py   | 13 +
 catalyst/targets/netboot2_target.py| 17 +++
 catalyst/targets/netboot_target.py | 15 ++
 catalyst/targets/snapshot_target.py|  4 +--
 catalyst/targets/stage1_target.py  | 17 ++-
 catalyst/targets/stage2_target.py  | 15 ++
 catalyst/targets/stage3_target.py  | 12 
 catalyst/targets/stage4_target.py  |  8 ++---
 catalyst/targets/tinderbox_target.py   | 11 ---
 17 files changed, 113 insertions(+), 75 deletions(-)

diff --git a/catalyst/base/__init__.py b/catalyst/base/__init__.py
new file mode 100644
index 000..8b13789
--- /dev/null
+++ b/catalyst/base/__init__.py
@@ -0,0 +1 @@
+

diff --git a/catalyst/targets/clearbase.py b/catalyst/base/clearbase.py
similarity index 100%
rename from catalyst/targets/clearbase.py
rename to catalyst/base/clearbase.py

diff --git a/catalyst/targets/genbase.py b/catalyst/base/genbase.py
similarity index 100%
rename from catalyst/targets/genbase.py
rename to catalyst/base/genbase.py

diff --git a/catalyst/targets/generic_stage_target.py 
b/catalyst/base/stagebase.py
similarity index 99%
rename from catalyst/targets/generic_stage_target.py
rename to catalyst/base/stagebase.py
index 296eee3..bebb5dc 100644
--- a/catalyst/targets/generic_stage_target.py
+++ b/catalyst/base/stagebase.py
@@ -14,13 +14,13 @@ from catalyst.defaults import (SOURCE_MOUNT_DEFAULTS, 
TARGET_MOUNT_DEFAULTS,
PORT_LOGDIR_CLEAN)
 from catalyst.support import (CatalystError, msg, file_locate, normpath,
touch, cmd, warn, list_bashify, read_makeconf, read_from_clst, ismount)
-from catalyst.targets.targetbase import TargetBase
-from catalyst.targets.clearbase import ClearBase
-from catalyst.targets.genbase import GenBase
+from catalyst.base.targetbase import TargetBase
+from catalyst.base.clearbase import ClearBase
+from catalyst.base.genbase import GenBase
 from catalyst.lock import LockDir
 
 
-class generic_stage_target(TargetBase, ClearBase, GenBase):
+class StageBase(TargetBase, ClearBase, GenBase):

This class does all of the chroot setup, copying of files, etc. It is
the driver class for pretty much everything that Catalyst does.

diff --git a/catalyst/targets/targetbase.py b/catalyst/base/targetbase.py
similarity index 100%
rename from catalyst/targets/targetbase.py
rename to catalyst/base/targetbase.py

diff --git a/catalyst/targets/embedded_target.py 
b/catalyst/targets/embedded_target.py
index 7cee7a6..528d545 100644
--- a/catalyst/targets/embedded_target.py
+++ b/catalyst/targets/embedded_target.py
@@ -10,12 +10,12 @@ ROOT=/tmp/submerge emerge --something foo bar .
 
 # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
 
-import os,string,imp,types,shutil
-from catalyst.support import *
-from generic_stage_target import *
-from stat import *
 
-class embedded_target(generic_stage_target):
+from catalyst.support import normpath
+
+from catalyst.base.stagebase import StageBase
+
+class embedded_target(StageBase):

Builder class for embedded target

@@ -27,7 +27,7 @@ class embedded_target(generic_stage_target):
if embedded/fs-type in addlargs:
self.valid_values.append(embedded/fs-ops)
 
-   generic_stage_target.__init__(self,spec,addlargs)
+   StageBase.__init__(self,spec,addlargs)
self.set_build_kernel_vars(addlargs)
 
def set_action_sequence(self):

diff --git a/catalyst/targets/grp_target.py b/catalyst/targets/grp_target.py
index 033db75..deba80a 100644
--- a/catalyst/targets/grp_target.py
+++ b/catalyst/targets/grp_target.py
@@ -3,11 +3,18 @@ Gentoo Reference Platform (GRP) target
 
 # NOTE: That^^ docstring has influence catalyst-spec(5) man page generation.
 
-import os,types,glob
-from catalyst.support import *
-from generic_stage_target import *
+import os
+import