* [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/
@ 2015-10-09 21:06 Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2015-10-09 21:06 UTC (permalink / raw
To: gentoo-commits
commit: 5048aad7bdfbfcc0e7e3562a80fc97a344818b55
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 9 13:27:46 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Oct 9 13:27:46 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=5048aad7
hash_utils: convert to log module
This has the nice side-effect of not needing the verbose param anymore,
so the prototypes & callers all get updated to stop passing that around.
catalyst/base/genbase.py | 6 ++----
catalyst/base/stagebase.py | 6 ++----
catalyst/hash_utils.py | 24 +++++++++---------------
catalyst/targets/stage2.py | 3 +--
4 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/catalyst/base/genbase.py b/catalyst/base/genbase.py
index 32459b4..a33f924 100644
--- a/catalyst/base/genbase.py
+++ b/catalyst/base/genbase.py
@@ -48,13 +48,11 @@ class GenBase(object):
if os.path.exists(f):
if "all" in array:
for k in list(hash_map.hash_map):
- digest = hash_map.generate_hash(f,hash_=k,
- verbose=self.settings["VERBOSE"])
+ digest = hash_map.generate_hash(f, hash_=k)
myf.write(digest)
else:
for j in array:
- digest = hash_map.generate_hash(f,hash_=j,
- verbose=self.settings["VERBOSE"])
+ digest = hash_map.generate_hash(f, hash_=j)
myf.write(digest)
myf.close()
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index bffafb7..88d71ba 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -435,8 +435,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["source_path_hash"] = \
self.settings["hash_map"].generate_hash(
self.settings["source_path"],
- hash_ = self.settings["hash_function"],
- verbose = False)
+ hash_=self.settings["hash_function"])
print "Source path set to "+self.settings["source_path"]
if os.path.isdir(self.settings["source_path"]):
print "\tIf this is not desired, remove this directory or turn off"
@@ -464,8 +463,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["snapshot_path_hash"] = \
self.settings["hash_map"].generate_hash(
self.settings["snapshot_path"],
- hash_ = self.settings["hash_function"],
- verbose = False)
+ hash_=self.settings["hash_function"])
def set_snapcache_path(self):
self.settings["snapshot_cache_path"]=\
diff --git a/catalyst/hash_utils.py b/catalyst/hash_utils.py
index 0262422..3db61f1 100644
--- a/catalyst/hash_utils.py
+++ b/catalyst/hash_utils.py
@@ -3,6 +3,7 @@ import os
from collections import namedtuple
from subprocess import Popen, PIPE
+from catalyst import log
from catalyst.support import CatalystError
@@ -65,32 +66,28 @@ class HashMap(object):
del obj
- def generate_hash(self, file_, hash_="crc32", verbose=False):
+ def generate_hash(self, file_, hash_="crc32"):
'''Prefered method of generating a hash for the passed in file_
@param file_: the file to generate the hash for
@param hash_: the hash algorythm to use
- @param verbose: boolean
@returns the hash result
'''
try:
return getattr(self, self.hash_map[hash_].func)(
file_,
- hash_,
- verbose
- )
+ hash_)
except:
raise CatalystError("Error generating hash, is appropriate " + \
"utility installed on your system?", traceback=True)
- def calc_hash(self, file_, hash_, verbose=False):
+ def calc_hash(self, file_, hash_):
'''
Calculate the hash for "file_"
@param file_: the file to generate the hash for
@param hash_: the hash algorythm to use
- @param verbose: boolean
@returns the hash result
'''
_hash = self.hash_map[hash_]
@@ -101,36 +98,33 @@ class HashMap(object):
mylines = source.communicate()[0]
mylines=mylines[0].split()
result=mylines[0]
- if verbose:
- print _hash.id + " (%s) = %s" % (file_, result)
+ log.info('%s (%s) = %s', _hash.id, file_, result)
return result
- def calc_hash2(self, file_, hash_type, verbose=False):
+ def calc_hash2(self, file_, hash_type):
'''
Calculate the hash for "file_"
@param file_: the file to generate the hash for
@param hash_: the hash algorythm to use
- @param verbose: boolean
@returns the hash result
'''
_hash = self.hash_map[hash_type]
args = [_hash.cmd]
args.extend(_hash.args)
args.append(file_)
- #print("DEBUG: calc_hash2; args =", args)
+ log.debug('args = %r', args)
source = Popen(args, stdout=PIPE)
output = source.communicate()
lines = output[0].split('\n')
- #print("DEBUG: calc_hash2; output =", output)
+ log.debug('output = %s', output)
header = lines[0]
h_f = lines[1].split()
hash_result = h_f[0]
short_file = os.path.split(h_f[1])[1]
result = header + "\n" + hash_result + " " + short_file + "\n"
- if verbose:
- print header + " (%s) = %s" % (short_file, result)
+ log.info('%s (%s) = %s', header, short_file, result)
return result
diff --git a/catalyst/targets/stage2.py b/catalyst/targets/stage2.py
index e6965cc..786aaa4 100644
--- a/catalyst/targets/stage2.py
+++ b/catalyst/targets/stage2.py
@@ -29,8 +29,7 @@ class stage2(StageBase):
self.settings["source_path_hash"] = \
self.settings["hash_map"].generate_hash(
self.settings["source_path"],\
- hash_=self.settings["hash_function"],
- verbose=False)
+ hash_=self.settings["hash_function"])
print "Source path set to "+self.settings["source_path"]
if os.path.isdir(self.settings["source_path"]):
print "\tIf this is not desired, remove this directory or turn off seedcache in the options of catalyst.conf"
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/
@ 2015-10-24 6:58 Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2015-10-24 6:58 UTC (permalink / raw
To: gentoo-commits
commit: 01c4051e0870a78214c85811737edbff9f8e4b20
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 12 00:49:36 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Oct 12 00:49:36 2015 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=01c4051e
convert octals to py3 compat
catalyst/base/clearbase.py | 4 ++--
catalyst/base/resume.py | 4 ++--
catalyst/base/stagebase.py | 14 +++++++-------
catalyst/fileops.py | 2 +-
catalyst/targets/netboot2.py | 2 +-
catalyst/targets/snapshot.py | 2 +-
6 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/catalyst/base/clearbase.py b/catalyst/base/clearbase.py
index 3817196..9a4c625 100644
--- a/catalyst/base/clearbase.py
+++ b/catalyst/base/clearbase.py
@@ -30,13 +30,13 @@ class ClearBase(object):
def clear_chroot(self):
self.chroot_lock.unlock()
log.notice('Clearing the chroot path ...')
- clear_dir(self.settings["chroot_path"], 0755, True)
+ clear_dir(self.settings["chroot_path"], 0o755, True)
def remove_chroot(self):
self.chroot_lock.unlock()
log.notice('Removing the chroot path ...')
- clear_dir(self.settings["chroot_path"], 0755, True, remove=True)
+ clear_dir(self.settings["chroot_path"], 0o755, True, remove=True)
def clear_packages(self, remove=False):
diff --git a/catalyst/base/resume.py b/catalyst/base/resume.py
index 99d8abc..70d9a4f 100644
--- a/catalyst/base/resume.py
+++ b/catalyst/base/resume.py
@@ -25,7 +25,7 @@ class AutoResume(object):
'''
- def __init__(self, basedir, mode=0755):
+ def __init__(self, basedir, mode=0o755):
self.basedir = basedir
ensure_dirs(basedir, mode=mode, fatal=True)
self._points = {}
@@ -131,7 +131,7 @@ class AutoResume(object):
@remove: boolean, passed through to clear_dir()
@return boolean
'''
- if clear_dir(self.basedir, mode=0755, chg_flags=True, remove=remove):
+ if clear_dir(self.basedir, mode=0o755, chg_flags=True, remove=remove):
self._points = {}
return True
return False
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 4a0b482..438e4d3 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -492,7 +492,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
))
if "autoresume" in self.settings["options"]:
log.info('The autoresume path is %s', self.settings['autoresume_path'])
- self.resume = AutoResume(self.settings["autoresume_path"], mode=0755)
+ self.resume = AutoResume(self.settings["autoresume_path"], mode=0o755)
def set_controller_file(self):
self.settings["controller_file"]=normpath(self.settings["sharedir"]+\
@@ -773,10 +773,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
ensure_dirs(self.settings["chroot_path"]+"/tmp",mode=1777)
if "pkgcache" in self.settings["options"]:
- ensure_dirs(self.settings["pkgcache_path"],mode=0755)
+ ensure_dirs(self.settings["pkgcache_path"],mode=0o755)
if "kerncache" in self.settings["options"]:
- ensure_dirs(self.settings["kerncache_path"],mode=0755)
+ ensure_dirs(self.settings["kerncache_path"],mode=0o755)
log.notice('%s', display_msg % unpack_info)
@@ -848,7 +848,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
cleanup_cmd = "rm -rf " + target_portdir
log.info('unpack() cleanup_cmd = %s', cleanup_cmd)
cmd(cleanup_cmd,cleanup_errmsg,env=self.env)
- ensure_dirs(target_portdir, mode=0755)
+ ensure_dirs(target_portdir, mode=0o755)
log.notice('Unpacking portage tree (this can take a long time) ...')
if not self.decompressor.extract(unpack_info):
@@ -932,11 +932,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
_cmd = ''
log.debug('bind(); x = %s', x)
target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
- ensure_dirs(target, mode=0755)
+ ensure_dirs(target, mode=0o755)
if not os.path.exists(self.mountmap[x]):
if self.mountmap[x] not in ["tmpfs", "shmfs"]:
- ensure_dirs(self.mountmap[x], mode=0755)
+ ensure_dirs(self.mountmap[x], mode=0o755)
src=self.mountmap[x]
log.debug('bind(); src = %s', src)
@@ -1218,7 +1218,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# the proper perms and ownership
mystat=os.stat(myemp)
shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0755)
+ ensure_dirs(myemp, mode=0o755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
self.resume.enable("empty")
diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index 8fb2a36..1ef6b4c 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -37,7 +37,7 @@ def ensure_dirs(path, gid=-1, uid=-1, mode=0o755, minimal=True,
:param mode: permissions to set any created directories to
:param minimal: boolean controlling whether or not the specified mode
must be enforced, or is the minimal permissions necessary. For example,
- if mode=0755, minimal=True, and a directory exists with mode 0707,
+ if mode=0o755, minimal=True, and a directory exists with mode 0707,
this will restore the missing group perms resulting in 757.
:param failback: function to run in the event of a failed attemp
to create the directory.
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index d882a06..8644786 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -157,7 +157,7 @@ class netboot2(StageBase):
# the proper perms and ownership
mystat=os.stat(myemp)
shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0755)
+ ensure_dirs(myemp, mode=0o755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
self.resume.enable("empty")
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index d19f4ef..dbc4b1c 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -106,6 +106,6 @@ class snapshot(TargetBase, GenBase):
if os.uname()[0] == "FreeBSD":
os.system("chflags -R noschg "+myemp)
shutil.rmtree(myemp)
- ensure_dirs(myemp, mode=0755)
+ ensure_dirs(myemp, mode=0o755)
os.chown(myemp,mystat[ST_UID],mystat[ST_GID])
os.chmod(myemp,mystat[ST_MODE])
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/
@ 2016-03-23 20:31 Brian Dolbec
0 siblings, 0 replies; 7+ messages in thread
From: Brian Dolbec @ 2016-03-23 20:31 UTC (permalink / raw
To: gentoo-commits
commit: 966bff4dae7ed88aa807282ae299c3c0da1f966d
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 23 20:02:11 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Mar 23 20:02:11 2016 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=966bff4d
catalyst: Apply patches from Yuta for additional needed bsd changes bug 574422
I did do some editing of his changes.
Original author: Yuta Satoh
X-Gentoo-bug: 574422
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=574422
catalyst/base/stagebase.py | 3 ++-
catalyst/defaults.py | 5 ++++-
catalyst/main.py | 4 +++-
catalyst/targets/snapshot.py | 3 ++-
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index fe5e6d2..5e87f44 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -144,7 +144,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.decompressor = CompressMap(self.settings["decompress_definitions"],
env=self.env,
search_order=self.settings["decompressor_search_order"],
- comp_prog=self.settings["comp_prog"])
+ comp_prog=self.settings["comp_prog"],
+ decomp_opt=self.settings["decomp_opt"])
self.accepted_extensions = self.decompressor.search_order_extensions(
self.settings["decompressor_search_order"])
log.notice("Source file specification matching setting is: %s",
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 5ed19d1..0bba6f4 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -1,8 +1,9 @@
import os
-from DeComp.definitions import DECOMPRESSOR_XATTR_SEARCH_ORDER
+from DeComp.definitions import DECOMPRESSOR_SEARCH_ORDER
from DeComp.definitions import COMPRESSOR_PROGRAM_OPTIONS, XATTRS_OPTIONS
+from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS
# Used for the (de)compressor definitions
if os.uname()[0] in ["Linux", "linux"]:
@@ -36,10 +37,12 @@ confdefaults={
"compression_mode": 'lbzip2',
"compressor_arch": None,
"compressor_options": XATTRS_OPTIONS[TAR],
+ "decomp_opt": DECOMPRESSOR_PROGRAM_OPTIONS[TAR],
"decompressor_search_order": DECOMPRESSOR_SEARCH_ORDER,
"distdir": "/usr/portage/distfiles",
"hash_function": "crc32",
"icecream": "/var/cache/icecream",
+ 'list_xattrs_opt': LIST_XATTRS_OPTIONS[TAR],
"local_overlay": "/usr/local/portage",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
diff --git a/catalyst/main.py b/catalyst/main.py
index 7c6a5d8..51d2b04 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -330,7 +330,9 @@ def _main(parser, opts):
# initialize our contents generator
contents_map = ContentsMap(CONTENTS_DEFINITIONS,
- comp_prog=conf_values['comp_prog'])
+ comp_prog=conf_values['comp_prog'],
+ decomp_opt=conf_values['decomp_opt'],
+ list_xattrs_opt=conf_values['list_xattrs_opt'])
conf_values["contents_map"] = contents_map
# initialze our hash and contents generators
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index dbc4b1c..3b6cc16 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -64,7 +64,8 @@ class snapshot(TargetBase, GenBase):
log.notice('Compressing Portage snapshot tarball ...')
compressor = CompressMap(self.settings["compress_definitions"],
- env=self.env, default_mode=self.settings['compression_mode'])
+ env=self.env, default_mode=self.settings['compression_mode'],
+ comp_prog=self.settings["comp_prog"])
infodict = compressor.create_infodict(
source=self.settings["repo_name"],
destination=self.settings["snapshot_path"],
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/
@ 2016-05-20 4:06 Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2016-05-20 4:06 UTC (permalink / raw
To: gentoo-commits
commit: 7f4fd57ff9b591acee49c675dcdc77973896cbce
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu May 19 19:23:40 2016 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri May 20 03:36:16 2016 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7f4fd57f
clear_path: new helper for nuking dirs
Add a simple helper to replace all calls to `rm -rf`.
Fix a thinko in the previous commit where the os.unlink call was
given the wrong variable.
catalyst/base/stagebase.py | 18 +++++++-----------
catalyst/fileops.py | 7 ++++++-
catalyst/targets/netboot2.py | 12 +++++-------
3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 6aa854b..9b74685 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -18,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
+from catalyst.fileops import ensure_dirs, pjoin, clear_dir, clear_path
from catalyst.base.resume import AutoResume
if sys.version_info[0] >= 3:
@@ -870,9 +870,8 @@ 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.
log.info('Configuring profile link...')
- cmd("rm -f " + self.settings["chroot_path"] +
- self.settings["port_conf"] + "/make.profile",
- "Error zapping profile link",env=self.env)
+ clear_path(self.settings['chroot_path'] +
+ self.settings['port_conf'] + '/make.profile')
ensure_dirs(self.settings['chroot_path'] + self.settings['port_conf'])
cmd("ln -sf ../.." + self.settings["portdir"] + "/profiles/" +
self.settings["target_profile"] + " " +
@@ -1050,8 +1049,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"])
- cmd("rm -f " + makepath,\
- "Could not remove " + makepath, env=self.env)
+ clear_path(makepath)
myf=open(makepath, "w")
myf.write("# These settings were set by the catalyst build script "
"that automatically\n# built this stage.\n")
@@ -1164,8 +1162,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
for x in self.settings["cleanables"]:
log.notice('Cleaning chroot: %s', x)
- cmd("rm -rf "+self.settings["destpath"]+x,"Couldn't clean "+\
- x,env=self.env)
+ clear_path(self.settings["destpath"] + x)
# Put /etc/hosts back into place
if os.path.exists(self.settings["chroot_path"]+"/etc/hosts.catalyst"):
@@ -1175,8 +1172,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# Remove our overlay
if os.path.exists(self.settings["chroot_path"] + self.settings["local_overlay"]):
- cmd("rm -rf " + self.settings["chroot_path"] + self.settings["local_overlay"],
- "Could not remove " + self.settings["local_overlay"], env=self.env)
+ clear_path(self.settings["chroot_path"] + self.settings["local_overlay"])
make_conf = self.settings['chroot_path'] + self.settings['make_conf']
try:
@@ -1234,7 +1230,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# We're going to shell out for all these cleaning
# operations, so we get easy glob handling.
log.notice('livecd: removing %s', x)
- os.system("rm -rf "+self.settings["chroot_path"]+x)
+ clear_path(self.settings["chroot_path"] + x)
try:
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+\
diff --git a/catalyst/fileops.py b/catalyst/fileops.py
index 5fbca26..4b9e200 100644
--- a/catalyst/fileops.py
+++ b/catalyst/fileops.py
@@ -87,7 +87,7 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False,
return False
elif os.path.exists(target):
if clear_nondir:
- os.unlink(clear_nondir)
+ os.unlink(target)
else:
log.info('clear_dir failed: %s: is not a directory', target)
return False
@@ -101,3 +101,8 @@ def clear_dir(target, mode=0o755, chg_flags=False, remove=False,
log.debug('DONE, returning True')
return True
+
+
+def clear_path(target):
+ """Nuke |target| regardless of it being a dir or file."""
+ clear_dir(target, remove=True)
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index 769b945..986ce01 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -9,7 +9,7 @@ from stat import ST_UID, ST_GID, ST_MODE
from catalyst import log
from catalyst.support import (CatalystError, normpath, cmd, list_bashify)
-from catalyst.fileops import ensure_dirs
+from catalyst.fileops import ensure_dirs, clear_path
from catalyst.base.stagebase import StageBase
@@ -56,10 +56,8 @@ class netboot2(StageBase):
log.notice('Resume point detected, skipping target path setup operation...')
else:
# first clean up any existing target stuff
- if os.path.isfile(self.settings["target_path"]):
- cmd("rm -f "+self.settings["target_path"], \
- "Could not remove existing file: "+self.settings["target_path"],env=self.env)
- self.resume.enable("setup_target_path")
+ clear_path(self.settings['target_path'])
+ self.resume.enable("setup_target_path")
ensure_dirs(self.settings["storedir"]+"/builds/")
def copy_files_to_image(self):
@@ -135,8 +133,8 @@ class netboot2(StageBase):
# we're going to shell out for all these cleaning operations,
# so we get easy glob handling
log.notice('netboot2: removing %s', x)
- os.system("rm -rf " + self.settings["chroot_path"] +
- self.settings["merge_path"] + x)
+ clear_path(self.settings['chroot_path'] +
+ self.settings['merge_path'] + x)
def empty(self):
if "autoresume" in self.settings["options"] \
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/
@ 2016-05-20 4:06 Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2016-05-20 4:06 UTC (permalink / raw
To: gentoo-commits
commit: 6d58e52613836152667142219da1d0559f0b0325
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu May 19 19:38:11 2016 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri May 20 03:36:40 2016 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6d58e526
cmd: drop |myexc| argument
This is not set by every call, and it's only used when logging error
messages. Instead, construct the message dynamically from the cmd
that we're running.
catalyst/base/stagebase.py | 83 +++++++++++++++++++------------------------
catalyst/support.py | 4 +--
catalyst/targets/netboot2.py | 2 +-
catalyst/targets/snapshot.py | 3 +-
catalyst/targets/tinderbox.py | 2 +-
5 files changed, 41 insertions(+), 53 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 9b74685..2009ab6 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -648,7 +648,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
killcmd = normpath(self.settings["sharedir"] +
self.settings["shdir"] + "/support/kill-chroot-pids.sh")
if os.path.exists(killcmd):
- cmd(killcmd, "kill-chroot-pids script failed.",env=self.env)
+ cmd(killcmd, env=self.env)
def mount_safety_check(self):
"""
@@ -877,7 +877,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.settings["target_profile"] + " " +
self.settings["chroot_path"] +
self.settings["port_conf"] + "/make.profile",
- "Error creating profile link",env=self.env)
+ env=self.env)
self.resume.enable("config_profile_link")
def setup_confdir(self):
@@ -893,7 +893,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
# We want to make sure rsync copies the dirs into each
# other and not as subdirs.
cmd('rsync -a %s/ %s/' % (self.settings['portage_confdir'], dest),
- "Error copying %s" % self.settings["port_conf"],
env=self.env)
self.resume.enable("setup_confdir")
@@ -906,7 +905,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
ensure_dirs(self.settings['chroot_path'] + self.settings['local_overlay'])
cmd("cp -a "+x+"/* "+self.settings["chroot_path"]+\
self.settings["local_overlay"],\
- "Could not copy portage_overlay",env=self.env)
+ env=self.env)
def root_overlay(self):
""" Copy over the root_overlay """
@@ -915,10 +914,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
"/root_overlay"]:
if os.path.exists(x):
log.info('Copying root_overlay: %s', x)
- cmd("rsync -a "+x+"/ "+\
- self.settings["chroot_path"],\
- self.settings["spec_prefix"]+"/root_overlay: "+x+\
- " copy failed.",env=self.env)
+ cmd('rsync -a ' + x + '/ ' + self.settings['chroot_path'],
+ env=self.env)
def base_dirs(self):
pass
@@ -954,7 +951,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
_cmd = "mount --bind " + src + " " + target
log.debug('bind(); _cmd = %s', _cmd)
- cmd(_cmd, "Bind mounting Failed", env=self.env, fail_func=self.unbind)
+ cmd(_cmd, env=self.env, fail_func=self.unbind)
log.debug('bind(); finished :D')
def unbind(self):
@@ -1017,7 +1014,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Setting up chroot...')
cmd("cp /etc/resolv.conf " + self.settings["chroot_path"] + "/etc/",
- "Could not copy resolv.conf into place.",env=self.env)
+ env=self.env)
# Copy over the envscript, if applicable
if "envscript" in self.settings:
@@ -1035,16 +1032,16 @@ class StageBase(TargetBase, ClearBase, GenBase):
cmd("cp "+self.settings["envscript"]+" "+\
self.settings["chroot_path"]+"/tmp/envscript",\
- "Could not copy envscript into place.",env=self.env)
+ env=self.env)
# Copy over /etc/hosts from the host in case there are any
# specialties in there
if os.path.exists(self.settings["chroot_path"]+"/etc/hosts"):
cmd("mv "+self.settings["chroot_path"]+"/etc/hosts "+\
self.settings["chroot_path"]+"/etc/hosts.catalyst",\
- "Could not backup /etc/hosts",env=self.env)
+ env=self.env)
cmd("cp /etc/hosts "+self.settings["chroot_path"]+"/etc/hosts",\
- "Could not copy /etc/hosts",env=self.env)
+ env=self.env)
# Modify and write out make.conf (for the chroot)
makepath = normpath(self.settings["chroot_path"] +
@@ -1141,8 +1138,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
if "fsscript" in self.settings:
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings["controller_file"]+\
- " fsscript","fsscript script failed.",env=self.env)
+ cmd(self.settings['controller_file'] + ' fsscript',
+ env=self.env)
self.resume.enable("fsscript")
def rcupdate(self):
@@ -1152,7 +1149,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+" rc-update",\
- "rc-update script failed.",env=self.env)
+ env=self.env)
self.resume.enable("rcupdate")
def clean(self):
@@ -1168,7 +1165,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if os.path.exists(self.settings["chroot_path"]+"/etc/hosts.catalyst"):
cmd("mv -f "+self.settings["chroot_path"]+"/etc/hosts.catalyst "+\
self.settings["chroot_path"]+"/etc/hosts",\
- "Could not replace /etc/hosts",env=self.env)
+ env=self.env)
# Remove our overlay
if os.path.exists(self.settings["chroot_path"] + self.settings["local_overlay"]):
@@ -1188,11 +1185,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
if os.path.exists(self.settings["stage_path"]+"/etc"):
cmd("find "+self.settings["stage_path"]+\
"/etc -maxdepth 1 -name \"*-\" | xargs rm -f",\
- "Could not remove stray files in /etc",env=self.env)
+ env=self.env)
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings["controller_file"]+" clean",\
- "clean script failed.",env=self.env)
+ cmd(self.settings['controller_file'] + ' clean', env=self.env)
self.resume.enable("clean")
def empty(self):
@@ -1233,8 +1229,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
clear_path(self.settings["chroot_path"] + x)
try:
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings["controller_file"]+\
- " clean","Clean failed.",env=self.env)
+ cmd(self.settings['controller_file'] + ' clean',
+ env=self.env)
self.resume.enable("remove")
except:
self.unbind()
@@ -1247,8 +1243,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
try:
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings["controller_file"]+\
- " preclean","preclean script failed.",env=self.env)
+ cmd(self.settings['controller_file'] + ' preclean',
+ env=self.env)
self.resume.enable("preclean")
except:
@@ -1305,7 +1301,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if os.path.exists(self.settings["controller_file"]):
log.info('run_local() starting controller script...')
cmd(self.settings["controller_file"]+" run",\
- "run script failed.",env=self.env)
+ env=self.env)
self.resume.enable("run_local")
else:
log.info('run_local() no controller_file found... %s',
@@ -1442,9 +1438,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
# Before cleaning, unmerge stuff
try:
- cmd(self.settings["controller_file"]+\
- " unmerge "+ myunmerge,"Unmerge script failed.",\
- env=self.env)
+ cmd(self.settings['controller_file'] +
+ ' unmerge ' + myunmerge, env=self.env)
log.info('unmerge shell script')
except CatalystError:
self.unbind()
@@ -1459,7 +1454,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Setting up filesystems per filesystem type')
cmd(self.settings["controller_file"]+\
" target_image_setup "+ self.settings["target_path"],\
- "target_image_setup script failed.",env=self.env)
+ env=self.env)
self.resume.enable("target_setup")
def setup_overlay(self):
@@ -1470,10 +1465,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
if self.settings["spec_prefix"]+"/overlay" in self.settings:
for x in self.settings[self.settings["spec_prefix"]+"/overlay"]:
if os.path.exists(x):
- cmd("rsync -a "+x+"/ "+\
- self.settings["target_path"],\
- self.settings["spec_prefix"]+"overlay: "+x+\
- " copy failed.",env=self.env)
+ cmd('rsync -a ' + x + '/ ' + self.settings['target_path'],
+ env=self.env)
self.resume.enable("setup_overlay")
def create_iso(self):
@@ -1484,7 +1477,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# Create the ISO
if "iso" in self.settings:
cmd(self.settings["controller_file"]+" iso "+\
- self.settings["iso"],"ISO creation script failed.",\
+ self.settings['iso'],
env=self.env)
self.gen_contents_file(self.settings["iso"])
self.gen_digest_file(self.settings["iso"])
@@ -1510,7 +1503,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cmd(self.settings["controller_file"]+\
" build_packages "+mypack,\
- "Error in attempt to build packages",env=self.env)
+ env=self.env)
fileutils.touch(build_packages_resume)
self.resume.enable("build_packages")
except CatalystError:
@@ -1530,8 +1523,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if isinstance(mynames, str):
mynames=[mynames]
# Execute the script that sets up the kernel build environment
- cmd(self.settings["controller_file"]+\
- " pre-kmerge ","Runscript pre-kmerge failed",\
+ cmd(self.settings['controller_file'] + ' pre-kmerge',
env=self.env)
for kname in mynames:
self._build_kernel(kname=kname)
@@ -1569,9 +1561,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
self._copy_initramfs_overlay(kname=kname)
# Execute the script that builds the kernel
- cmd("/bin/bash "+self.settings["controller_file"]+\
- " kernel "+kname,\
- "Runscript kernel build failed",env=self.env)
+ cmd(self.settings['controller_file'] + ' kernel ' + kname,
+ env=self.env)
if "boot/kernel/"+kname+"/initramfs_overlay" in self.settings:
if os.path.exists(self.settings["chroot_path"]+\
@@ -1583,9 +1574,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.resume.is_enabled("build_kernel_"+kname)
# Execute the script that cleans up the kernel build environment
- cmd("/bin/bash "+self.settings["controller_file"]+\
- " post-kmerge ",
- "Runscript post-kmerge failed",env=self.env)
+ cmd(self.settings['controller_file'] + ' post-kmerge',
+ env=self.env)
def _copy_kernel_config(self, kname):
key = 'boot/kernel/' + kname + '/config'
@@ -1598,7 +1588,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cmd('cp ' + self.settings[key] + ' ' +
self.settings['chroot_path'] + '/var/tmp/' + kname + '.config',
- "Couldn't copy kernel config: %s" % self.settings[key],
env=self.env)
except CatalystError:
@@ -1626,7 +1615,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
cmd(self.settings["controller_file"]+\
" bootloader " + self.settings["target_path"].rstrip('/'),\
- "Bootloader script failed.",env=self.env)
+ env=self.env)
self.resume.enable("bootloader")
except CatalystError:
self.unbind()
@@ -1638,8 +1627,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Resume point detected, skipping build_packages operation...')
else:
try:
- cmd(self.settings["controller_file"]+\
- " livecd-update","livecd-update failed.",env=self.env)
+ cmd(self.settings['controller_file'] + ' livecd-update',
+ env=self.env)
self.resume.enable("livecd_update")
except CatalystError:
diff --git a/catalyst/support.py b/catalyst/support.py
index d13422d..0ce49d2 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -30,7 +30,7 @@ class CatalystError(Exception):
log.error('CatalystError: %s', message, exc_info=print_traceback)
-def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
+def cmd(mycmd, env=None, debug=False, fail_func=None):
if env is None:
env = {}
log.debug('cmd: %r', mycmd)
@@ -50,7 +50,7 @@ def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None):
if fail_func:
log.error('CMD(), NON-Zero command return. Running fail_func().')
fail_func()
- raise CatalystError("cmd() NON-zero return value from: %s" % myexc,
+ raise CatalystError("cmd() NON-zero return value from: %s" % args,
print_traceback=False)
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index 986ce01..568b791 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -107,7 +107,7 @@ class netboot2(StageBase):
for x in self.settings["netboot2/overlay"]:
if os.path.exists(x):
cmd("rsync -a "+x+"/ "+\
- self.settings["chroot_path"] + self.settings["merge_path"], "netboot2/overlay: "+x+" copy failed.",env=self.env)
+ self.settings["chroot_path"] + self.settings["merge_path"], env=self.env)
self.resume.enable("setup_overlay")
def move_kernels(self):
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index 3b6cc16..196166a 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -59,8 +59,7 @@ class snapshot(TargetBase, GenBase):
target_snapshot = self.settings["portdir"] + "/ " + mytmp + "/%s/" % self.settings["repo_name"]
cmd("rsync -a --no-o --no-g --delete --exclude /packages/ --exclude /distfiles/ " +
"--exclude /local/ --exclude CVS/ --exclude .svn --filter=H_**/files/digest-* " +
- target_snapshot,
- "Snapshot failure", env=self.env)
+ target_snapshot, env=self.env)
log.notice('Compressing Portage snapshot tarball ...')
compressor = CompressMap(self.settings["compress_definitions"],
diff --git a/catalyst/targets/tinderbox.py b/catalyst/targets/tinderbox.py
index c9ed9b8..f7895de 100644
--- a/catalyst/targets/tinderbox.py
+++ b/catalyst/targets/tinderbox.py
@@ -25,7 +25,7 @@ class tinderbox(StageBase):
try:
if os.path.exists(self.settings["controller_file"]):
cmd(self.settings["controller_file"]+" run "+\
- list_bashify(self.settings["tinderbox/packages"]),"run script failed.",env=self.env)
+ list_bashify(self.settings["tinderbox/packages"]),env=self.env)
except CatalystError:
self.unbind()
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/
@ 2016-05-22 3:34 Mike Frysinger
0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2016-05-22 3:34 UTC (permalink / raw
To: gentoo-commits
commit: 70aa9439819c3b659c8aa3c1460b6ed2e46b7350
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 05:34:19 2016 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri May 20 05:34:19 2016 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=70aa9439
cmd: add support for running commands directly
Very few of the commands we execute actually need to be run through a
shell. Extend the cmd helper to take an argv and convert the majority
of calls over to that.
catalyst/base/stagebase.py | 94 +++++++++++++++++++------------------------
catalyst/support.py | 48 +++++++++++-----------
catalyst/targets/grp.py | 9 +++--
catalyst/targets/netboot.py | 28 ++++++-------
catalyst/targets/netboot2.py | 14 +++----
catalyst/targets/snapshot.py | 14 +++++--
catalyst/targets/tinderbox.py | 6 +--
7 files changed, 104 insertions(+), 109 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 0b25516..78e5b94 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -13,7 +13,7 @@ from catalyst import log
from catalyst.defaults import (SOURCE_MOUNT_DEFAULTS, TARGET_MOUNT_DEFAULTS,
PORT_LOGDIR_CLEAN)
from catalyst.support import (CatalystError, file_locate, normpath,
- cmd, list_bashify, read_makeconf, ismount, file_check)
+ cmd, read_makeconf, ismount, file_check)
from catalyst.base.targetbase import TargetBase
from catalyst.base.clearbase import ClearBase
from catalyst.base.genbase import GenBase
@@ -648,7 +648,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
killcmd = normpath(self.settings["sharedir"] +
self.settings["shdir"] + "/support/kill-chroot-pids.sh")
if os.path.exists(killcmd):
- cmd(killcmd, env=self.env)
+ cmd([killcmd], env=self.env)
def mount_safety_check(self):
"""
@@ -873,10 +873,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
clear_path(self.settings['chroot_path'] +
self.settings['port_conf'] + '/make.profile')
ensure_dirs(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",
+ cmd(['ln', '-sf',
+ '../..' + self.settings['portdir'] + '/profiles/' + self.settings['target_profile'],
+ self.settings['chroot_path'] + self.settings['port_conf'] + '/make.profile'],
env=self.env)
self.resume.enable("config_profile_link")
@@ -892,7 +891,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
# The trailing slashes on both paths are important:
# We want to make sure rsync copies the dirs into each
# other and not as subdirs.
- cmd('rsync -a %s/ %s/' % (self.settings['portage_confdir'], dest),
+ cmd(['rsync', '-a', self.settings['portage_confdir'] + '/', dest + '/'],
env=self.env)
self.resume.enable("setup_confdir")
@@ -914,7 +913,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
"/root_overlay"]:
if os.path.exists(x):
log.info('Copying root_overlay: %s', x)
- cmd('rsync -a ' + x + '/ ' + self.settings['chroot_path'],
+ cmd(['rsync', '-a', x + '/', self.settings['chroot_path']],
env=self.env)
def base_dirs(self):
@@ -922,7 +921,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
def bind(self):
for x in self.mounts:
- _cmd = ''
log.debug('bind(); x = %s', x)
target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
ensure_dirs(target, mode=0o755)
@@ -935,23 +933,25 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.debug('bind(); src = %s', src)
if "snapcache" in self.settings["options"] and x == "portdir":
self.snapcache_lock.read_lock()
+ _cmd = None
if os.uname()[0] == "FreeBSD":
if src == "/dev":
- _cmd = "mount -t devfs none " + target
+ _cmd = ['mount', '-t', 'devfs', 'none', target]
else:
- _cmd = "mount_nullfs " + src + " " + target
+ _cmd = ['mount_nullfs', src, target]
else:
if src == "tmpfs":
if "var_tmpfs_portage" in self.settings:
- _cmd = "mount -t tmpfs -o size=" + \
- self.settings["var_tmpfs_portage"] + "G " + \
- src + " " + target
+ _cmd = ['mount', '-t', 'tmpfs',
+ '-o', 'size=' + self.settings['var_tmpfs_portage'] + 'G',
+ src, target]
elif src == "shmfs":
- _cmd = "mount -t tmpfs -o noexec,nosuid,nodev shm " + target
+ _cmd = ['mount', '-t', 'tmpfs', '-o', 'noexec,nosuid,nodev', 'shm', target]
else:
- _cmd = "mount --bind " + src + " " + target
- log.debug('bind(); _cmd = %s', _cmd)
- cmd(_cmd, env=self.env, fail_func=self.unbind)
+ _cmd = ['mount', '--bind', src, target]
+ if _cmd:
+ log.debug('bind(); _cmd = %s', _cmd)
+ cmd(_cmd, env=self.env, fail_func=self.unbind)
log.debug('bind(); finished :D')
def unbind(self):
@@ -1134,7 +1134,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
if "fsscript" in self.settings:
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings['controller_file'] + ' fsscript',
+ cmd([self.settings['controller_file'], 'fsscript'],
env=self.env)
self.resume.enable("fsscript")
@@ -1144,7 +1144,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Resume point detected, skipping rcupdate operation...')
else:
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings["controller_file"]+" rc-update",\
+ cmd([self.settings['controller_file'], 'rc-update'],
env=self.env)
self.resume.enable("rcupdate")
@@ -1178,12 +1178,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
# Clean up old and obsoleted files in /etc
if os.path.exists(self.settings["stage_path"]+"/etc"):
- cmd("find "+self.settings["stage_path"]+\
- "/etc -maxdepth 1 -name \"*-\" | xargs rm -f",\
+ cmd(['find', self.settings['stage_path'] + '/etc',
+ '-maxdepth', '1', '-name', '*-', '-delete'],
env=self.env)
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings['controller_file'] + ' clean', env=self.env)
+ cmd([self.settings['controller_file'], 'clean'], env=self.env)
self.resume.enable("clean")
def empty(self):
@@ -1224,7 +1224,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
clear_path(self.settings["chroot_path"] + x)
try:
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings['controller_file'] + ' clean',
+ cmd([self.settings['controller_file'], 'clean'],
env=self.env)
self.resume.enable("remove")
except:
@@ -1238,7 +1238,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
try:
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings['controller_file'] + ' preclean',
+ cmd([self.settings['controller_file'], 'preclean'],
env=self.env)
self.resume.enable("preclean")
@@ -1295,7 +1295,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
try:
if os.path.exists(self.settings["controller_file"]):
log.info('run_local() starting controller script...')
- cmd(self.settings["controller_file"]+" run",\
+ cmd([self.settings['controller_file'], 'run'],
env=self.env)
self.resume.enable("run_local")
else:
@@ -1422,19 +1422,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
if isinstance(self.settings[self.settings['spec_prefix']+'/unmerge'], str):
self.settings[self.settings["spec_prefix"]+"/unmerge"]=\
[self.settings[self.settings["spec_prefix"]+"/unmerge"]]
- myunmerge=\
- self.settings[self.settings["spec_prefix"]+"/unmerge"][:]
-
- for x in range(0,len(myunmerge)):
- # Surround args with quotes for passing to bash, allows
- # things like "<" to remain intact
- myunmerge[x]="'"+myunmerge[x]+"'"
- myunmerge = ' '.join(myunmerge)
# Before cleaning, unmerge stuff
try:
- cmd(self.settings['controller_file'] +
- ' unmerge ' + myunmerge, env=self.env)
+ cmd([self.settings['controller_file'], 'unmerge'] +
+ self.settings[self.settings['spec_prefix'] + '/unmerge'],
+ env=self.env)
log.info('unmerge shell script')
except CatalystError:
self.unbind()
@@ -1447,9 +1440,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Resume point detected, skipping target_setup operation...')
else:
log.notice('Setting up filesystems per filesystem type')
- cmd(self.settings["controller_file"]+\
- " target_image_setup "+ self.settings["target_path"],\
- env=self.env)
+ cmd([self.settings['controller_file'], 'target_image_setup',
+ self.settings['target_path']], env=self.env)
self.resume.enable("target_setup")
def setup_overlay(self):
@@ -1460,7 +1452,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if self.settings["spec_prefix"]+"/overlay" in self.settings:
for x in self.settings[self.settings["spec_prefix"]+"/overlay"]:
if os.path.exists(x):
- cmd('rsync -a ' + x + '/ ' + self.settings['target_path'],
+ cmd(['rsync', '-a', x + '/', self.settings['target_path']],
env=self.env)
self.resume.enable("setup_overlay")
@@ -1471,8 +1463,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
else:
# Create the ISO
if "iso" in self.settings:
- cmd(self.settings["controller_file"]+" iso "+\
- self.settings['iso'],
+ cmd([self.settings['controller_file'], 'iso', self.settings['iso']],
env=self.env)
self.gen_contents_file(self.settings["iso"])
self.gen_digest_file(self.settings["iso"])
@@ -1492,12 +1483,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
and self.resume.is_enabled("build_packages"):
log.notice('Resume point detected, skipping build_packages operation...')
else:
- mypack=\
- list_bashify(self.settings[self.settings["spec_prefix"]\
- +"/packages"])
try:
- cmd(self.settings["controller_file"]+\
- " build_packages "+mypack,\
+ cmd([self.settings['controller_file'], 'build_packages'] +
+ self.settings[self.settings["spec_prefix"] + '/packages'],
env=self.env)
fileutils.touch(build_packages_resume)
self.resume.enable("build_packages")
@@ -1518,7 +1506,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
if isinstance(mynames, str):
mynames=[mynames]
# Execute the script that sets up the kernel build environment
- cmd(self.settings['controller_file'] + ' pre-kmerge',
+ cmd([self.settings['controller_file'], 'pre-kmerge'],
env=self.env)
for kname in mynames:
self._build_kernel(kname=kname)
@@ -1556,7 +1544,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self._copy_initramfs_overlay(kname=kname)
# Execute the script that builds the kernel
- cmd(self.settings['controller_file'] + ' kernel ' + kname,
+ cmd([self.settings['controller_file'], 'kernel', kname],
env=self.env)
if "boot/kernel/"+kname+"/initramfs_overlay" in self.settings:
@@ -1566,7 +1554,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
self.resume.is_enabled("build_kernel_"+kname)
# Execute the script that cleans up the kernel build environment
- cmd(self.settings['controller_file'] + ' post-kmerge',
+ cmd([self.settings['controller_file'], 'post-kmerge'],
env=self.env)
def _copy_kernel_config(self, kname):
@@ -1604,8 +1592,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Resume point detected, skipping bootloader operation...')
else:
try:
- cmd(self.settings["controller_file"]+\
- " bootloader " + self.settings["target_path"].rstrip('/'),\
+ cmd([self.settings['controller_file'], 'bootloader',
+ self.settings['target_path'].rstrip('/')],
env=self.env)
self.resume.enable("bootloader")
except CatalystError:
@@ -1618,7 +1606,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Resume point detected, skipping build_packages operation...')
else:
try:
- cmd(self.settings['controller_file'] + ' livecd-update',
+ cmd([self.settings['controller_file'], 'livecd-update'],
env=self.env)
self.resume.enable("livecd_update")
diff --git a/catalyst/support.py b/catalyst/support.py
index 0ce49d2..f2ae5bb 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -12,18 +12,6 @@ from catalyst.defaults import valid_config_file_values
BASH_BINARY = "/bin/bash"
-def list_bashify(mylist):
- if isinstance(mylist, str):
- mypack=[mylist]
- else:
- mypack=mylist[:]
- for x in range(0,len(mypack)):
- # surround args with quotes for passing to bash,
- # allows things like "<" to remain intact
- mypack[x]="'"+mypack[x]+"'"
- return ' '.join(mypack)
-
-
class CatalystError(Exception):
def __init__(self, message, print_traceback=False):
if message:
@@ -31,26 +19,38 @@ class CatalystError(Exception):
def cmd(mycmd, env=None, debug=False, fail_func=None):
- if env is None:
- env = {}
+ """Run the external |mycmd|.
+
+ If |mycmd| is a string, then it's assumed to be a bash snippet and will
+ be run through bash. Otherwise, it's a standalone command line and will
+ be run directly.
+ """
log.debug('cmd: %r', mycmd)
sys.stdout.flush()
- args=[BASH_BINARY]
- if "BASH_ENV" not in env:
+
+ if env is None:
+ env = {}
+ if 'BASH_ENV' not in env:
env = env.copy()
- env["BASH_ENV"] = "/etc/spork/is/not/valid/profile.env"
- if debug:
- args.append("-x")
- args.append("-c")
- args.append(mycmd)
+ env['BASH_ENV'] = '/etc/spork/is/not/valid/profile.env'
+
+ args = []
+ if isinstance(mycmd, str):
+ args.append(BASH_BINARY)
+ if debug:
+ args.append('-x')
+ args.extend(['-c', mycmd])
+ else:
+ args.extend(mycmd)
log.debug('args: %r', args)
proc = Popen(args, env=env)
- if proc.wait() != 0:
+ ret = proc.wait()
+ if ret:
if fail_func:
- log.error('CMD(), NON-Zero command return. Running fail_func().')
+ log.error('cmd(%r) exited %s; running fail_func().', args, ret)
fail_func()
- raise CatalystError("cmd() NON-zero return value from: %s" % args,
+ raise CatalystError('cmd(%r) exited %s' % (args, ret),
print_traceback=False)
diff --git a/catalyst/targets/grp.py b/catalyst/targets/grp.py
index c1bd2dd..049bc55 100644
--- a/catalyst/targets/grp.py
+++ b/catalyst/targets/grp.py
@@ -7,7 +7,7 @@ import os
import glob
from catalyst import log
-from catalyst.support import (CatalystError, normpath, cmd, list_bashify)
+from catalyst.support import (CatalystError, normpath, cmd)
from catalyst.base.stagebase import StageBase
@@ -41,10 +41,11 @@ class grp(StageBase):
def run_local(self):
for pkgset in self.settings["grp"]:
# example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
- mypackages=list_bashify(self.settings["grp/"+pkgset+"/packages"])
try:
- cmd(self.settings["controller_file"]+" run "+self.settings["grp/"+pkgset+"/type"]\
- +" "+pkgset+" "+mypackages,env=self.env)
+ cmd([self.settings['controller_file'], 'run',
+ self.settings['grp/' + pkgset + '/type'],
+ pkgset] + self.settings['grp/' + pkgset + '/packages'],
+ env=self.env)
except CatalystError:
self.unbind()
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index 5285c05..161300d 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -7,7 +7,7 @@ import os
from catalyst import log
from catalyst.support import (CatalystError, normpath,
- cmd, list_bashify, file_locate)
+ cmd, file_locate)
from catalyst.base.stagebase import StageBase
@@ -62,22 +62,22 @@ class netboot(StageBase):
# def build_packages(self):
# # build packages
# if "netboot/packages" in self.settings:
-# mypack=list_bashify(self.settings["netboot/packages"])
-# try:
-# cmd(self.settings["controller_file"]+" packages "+mypack,env=self.env)
-# except CatalystError:
-# self.unbind()
-# raise CatalystError("netboot build aborting due to error.",
-# print_traceback=True)
+# try:
+# cmd([self.settings['controller_file'], 'packages'] +
+# self.settings['netboot/packages'], env=self.env)
+# except CatalystError:
+# self.unbind()
+# raise CatalystError('netboot build aborting due to error.',
+# print_traceback=True)
def build_busybox(self):
# build busybox
if "netboot/busybox_config" in self.settings:
- mycmd = self.settings["netboot/busybox_config"]
+ mycmd = [self.settings['netboot/busybox_config']]
else:
- mycmd = ""
+ mycmd = []
try:
- cmd(self.settings["controller_file"]+" busybox "+ mycmd,env=self.env)
+ cmd([self.settings['controller_file'], 'busybox'] + mycmd, env=self.env)
except CatalystError:
self.unbind()
raise CatalystError("netboot build aborting due to error.",
@@ -106,8 +106,8 @@ class netboot(StageBase):
myfiles.append(self.settings["netboot/extra_files"])
try:
- cmd(self.settings["controller_file"]+\
- " image " + list_bashify(myfiles),env=self.env)
+ cmd([self.settings['controller_file'], 'image'] + myfiles,
+ env=self.env)
except CatalystError:
self.unbind()
raise CatalystError("netboot build aborting due to error.",
@@ -116,7 +116,7 @@ class netboot(StageBase):
def create_netboot_files(self):
# finish it all up
try:
- cmd(self.settings["controller_file"]+" finish",env=self.env)
+ cmd([self.settings['controller_file'], 'finish'], env=self.env)
except CatalystError:
self.unbind()
raise CatalystError("netboot build aborting due to error.",
diff --git a/catalyst/targets/netboot2.py b/catalyst/targets/netboot2.py
index 568b791..da856ba 100644
--- a/catalyst/targets/netboot2.py
+++ b/catalyst/targets/netboot2.py
@@ -8,7 +8,7 @@ import shutil
from stat import ST_UID, ST_GID, ST_MODE
from catalyst import log
-from catalyst.support import (CatalystError, normpath, cmd, list_bashify)
+from catalyst.support import (CatalystError, normpath, cmd)
from catalyst.fileops import ensure_dirs, clear_path
from catalyst.base.stagebase import StageBase
@@ -89,8 +89,8 @@ class netboot2(StageBase):
myfiles.append(self.settings["netboot2/extra_files"])
try:
- cmd(self.settings["controller_file"]+\
- " image " + list_bashify(myfiles),env=self.env)
+ cmd([self.settings['controller_file'], 'image'] +
+ myfiles, env=self.env)
except CatalystError:
self.unbind()
raise CatalystError("Failed to copy files to image!",
@@ -106,8 +106,9 @@ class netboot2(StageBase):
if "netboot2/overlay" in self.settings:
for x in self.settings["netboot2/overlay"]:
if os.path.exists(x):
- cmd("rsync -a "+x+"/ "+\
- self.settings["chroot_path"] + self.settings["merge_path"], env=self.env)
+ cmd(['rsync', '-a', x + '/',
+ self.settings['chroot_path'] + self.settings['merge_path']],
+ env=self.env)
self.resume.enable("setup_overlay")
def move_kernels(self):
@@ -115,8 +116,7 @@ class netboot2(StageBase):
# no auto resume here as we always want the
# freshest images moved
try:
- cmd(self.settings["controller_file"]+\
- " final",env=self.env)
+ cmd([self.settings['controller_file'], 'final'], env=self.env)
log.notice('Netboot Build Finished!')
except CatalystError:
self.unbind()
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index 196166a..7ba94b2 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -56,10 +56,16 @@ class snapshot(TargetBase, GenBase):
mytmp=self.settings["tmp_path"]
ensure_dirs(mytmp)
- target_snapshot = self.settings["portdir"] + "/ " + mytmp + "/%s/" % self.settings["repo_name"]
- cmd("rsync -a --no-o --no-g --delete --exclude /packages/ --exclude /distfiles/ " +
- "--exclude /local/ --exclude CVS/ --exclude .svn --filter=H_**/files/digest-* " +
- target_snapshot, env=self.env)
+ cmd(['rsync', '-a', '--no-o', '--no-g', '--delete',
+ '--exclude=/packages/',
+ '--exclude=/distfiles/',
+ '--exclude=/local/',
+ '--exclude=CVS/',
+ '--exclude=.svn',
+ '--filter=H_**/files/digest-*',
+ self.settings['portdir'] + '/',
+ mytmp + '/' + self.settings['repo_name'] + '/'],
+ env=self.env)
log.notice('Compressing Portage snapshot tarball ...')
compressor = CompressMap(self.settings["compress_definitions"],
diff --git a/catalyst/targets/tinderbox.py b/catalyst/targets/tinderbox.py
index f7895de..85a939f 100644
--- a/catalyst/targets/tinderbox.py
+++ b/catalyst/targets/tinderbox.py
@@ -5,7 +5,7 @@ Tinderbox target
import os
-from catalyst.support import cmd, list_bashify, CatalystError
+from catalyst.support import cmd, CatalystError
from catalyst.base.stagebase import StageBase
@@ -24,8 +24,8 @@ class tinderbox(StageBase):
# example call: "grp.sh run xmms vim sys-apps/gleep"
try:
if os.path.exists(self.settings["controller_file"]):
- cmd(self.settings["controller_file"]+" run "+\
- list_bashify(self.settings["tinderbox/packages"]),env=self.env)
+ cmd([self.settings['controller_file'], 'run'] +
+ self.settings['tinderbox/packages'], env=self.env)
except CatalystError:
self.unbind()
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/
2021-01-28 2:09 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/, catalyst/base/ Matt Turner
@ 2021-01-28 2:41 ` Matt Turner
0 siblings, 0 replies; 7+ messages in thread
From: Matt Turner @ 2021-01-28 2:41 UTC (permalink / raw
To: gentoo-commits
commit: 50ba8aadf5f7096e9079eafec9182d526956cd49
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 24 02:43:47 2021 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Jan 28 02:06:46 2021 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=50ba8aad
catalyst: Clean up exception handling
Use 'raise from' where sensible, but a lot of the CatalystErrors are
just trading one CatalystError for another, so remove them.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/base/stagebase.py | 110 ++++++++++++++------------------------
catalyst/main.py | 4 +-
catalyst/support.py | 4 +-
catalyst/targets/livecd_stage2.py | 4 +-
catalyst/targets/netboot.py | 33 ++++--------
catalyst/targets/snapshot.py | 2 +-
6 files changed, 57 insertions(+), 100 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 28ff8fd2..46cb1fda 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -906,7 +906,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
fstype=fstype, options=options)
cxt.mount()
except Exception as e:
- raise CatalystError(f"Couldn't mount: {source}, {e}")
+ raise CatalystError(f"Couldn't mount: {source}, {e}") from e
def chroot_setup(self):
self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] +
@@ -978,7 +978,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
except OSError as e:
raise CatalystError('Could not write %s: %s' % (
normpath(self.settings["chroot_path"] +
- self.settings["make_conf"]), e))
+ self.settings["make_conf"]), e)) from e
self.resume.enable("chroot_setup")
def write_make_conf(self, setup=True):
@@ -1206,13 +1206,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
# operations, so we get easy glob handling.
log.notice('%s: removing %s', self.settings["spec_prefix"], x)
clear_path(self.settings["stage_path"] + x)
- try:
- if os.path.exists(self.settings["controller_file"]):
- cmd([self.settings['controller_file'], 'clean'],
- env=self.env)
- self.resume.enable("remove")
- except:
- raise
+
+ if os.path.exists(self.settings["controller_file"]):
+ cmd([self.settings['controller_file'], 'clean'],
+ env=self.env)
+ self.resume.enable("remove")
def preclean(self):
if "autoresume" in self.settings["options"] \
@@ -1278,19 +1276,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.notice('Resume point detected, skipping run_local operation...')
return
- try:
- if os.path.exists(self.settings["controller_file"]):
- log.info('run_local() starting controller script...')
- cmd([self.settings['controller_file'], 'run'],
- env=self.env)
- self.resume.enable("run_local")
- else:
- log.info('run_local() no controller_file found... %s',
- self.settings['controller_file'])
-
- except CatalystError:
- raise CatalystError("Stage build aborting due to error.",
- print_traceback=False)
+ if os.path.exists(self.settings["controller_file"]):
+ log.info('run_local() starting controller script...')
+ cmd([self.settings['controller_file'], 'run'],
+ env=self.env)
+ self.resume.enable("run_local")
+ else:
+ log.info('run_local() no controller_file found... %s',
+ self.settings['controller_file'])
def setup_environment(self):
log.debug('setup_environment(); settings = %r', self.settings)
@@ -1382,13 +1375,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
[self.settings[self.settings["spec_prefix"] + "/unmerge"]]
# Before cleaning, unmerge stuff
- try:
- cmd([self.settings['controller_file'], 'unmerge'] +
- self.settings[self.settings['spec_prefix'] + '/unmerge'],
- env=self.env)
- log.info('unmerge shell script')
- except CatalystError:
- raise
+ cmd([self.settings['controller_file'], 'unmerge'] +
+ self.settings[self.settings['spec_prefix'] + '/unmerge'],
+ env=self.env)
+ log.info('unmerge shell script')
self.resume.enable("unmerge")
def target_setup(self):
@@ -1457,14 +1447,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
command.append(self.settings[target_pkgs])
else:
command.extend(self.settings[target_pkgs])
- try:
- cmd(command, env=self.env)
- fileutils.touch(build_packages_resume)
- self.resume.enable("build_packages")
- except CatalystError:
- raise CatalystError(
- self.settings["spec_prefix"] +
- "build aborting due to error.")
+ cmd(command, env=self.env)
+ fileutils.touch(build_packages_resume)
+ self.resume.enable("build_packages")
def build_kernel(self):
'''Build all configured kernels'''
@@ -1475,19 +1460,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
return
if "boot/kernel" in self.settings:
- try:
- mynames = self.settings["boot/kernel"]
- if isinstance(mynames, str):
- mynames = [mynames]
- # Execute the script that sets up the kernel build environment
- cmd([self.settings['controller_file'], 'pre-kmerge'], env=self.env)
- for kname in [sanitize_name(name) for name in mynames]:
- self._build_kernel(kname=kname)
- self.resume.enable("build_kernel")
- except CatalystError:
- raise CatalystError(
- "build aborting due to kernel build error.",
- print_traceback=True)
+ mynames = self.settings["boot/kernel"]
+ if isinstance(mynames, str):
+ mynames = [mynames]
+ # Execute the script that sets up the kernel build environment
+ cmd([self.settings['controller_file'], 'pre-kmerge'], env=self.env)
+ for kname in [sanitize_name(name) for name in mynames]:
+ self._build_kernel(kname=kname)
+ self.resume.enable("build_kernel")
def _build_kernel(self, kname):
"Build a single configured kernel by name"
@@ -1531,12 +1511,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
raise CatalystError("Can't find kernel config: %s" %
self.settings[key])
- try:
- shutil.copy(self.settings[key],
- self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
-
- except IOError:
- raise
+ shutil.copy(self.settings[key],
+ self.settings['chroot_path'] + '/var/tmp/' + kname + '.config')
def _copy_initramfs_overlay(self, kname):
key = 'boot/kernel/' + kname + '/initramfs_overlay'
@@ -1560,13 +1536,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
'Resume point detected, skipping bootloader operation...')
return
- try:
- cmd([self.settings['controller_file'], 'bootloader',
- self.settings['target_path'].rstrip('/')],
- env=self.env)
- self.resume.enable("bootloader")
- except CatalystError:
- raise CatalystError("Script aborting due to error.")
+ cmd([self.settings['controller_file'], 'bootloader',
+ self.settings['target_path'].rstrip('/')],
+ env=self.env)
+ self.resume.enable("bootloader")
def livecd_update(self):
if "autoresume" in self.settings["options"] \
@@ -1575,14 +1548,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
'Resume point detected, skipping build_packages operation...')
return
- try:
- cmd([self.settings['controller_file'], 'livecd-update'],
- env=self.env)
- self.resume.enable("livecd_update")
-
- except CatalystError:
- raise CatalystError(
- "build aborting due to livecd_update error.")
+ cmd([self.settings['controller_file'], 'livecd-update'],
+ env=self.env)
+ self.resume.enable("livecd_update")
@staticmethod
def _debug_pause_():
diff --git a/catalyst/main.py b/catalyst/main.py
index b0d9015f..0de1040f 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -77,10 +77,10 @@ def build_target(addlargs):
target = addlargs["target"].replace('-', '_')
module = import_module(target)
target = getattr(module, target)(conf_values, addlargs)
- except AttributeError:
+ except AttributeError as e:
raise CatalystError(
"Target \"%s\" not available." % target,
- print_traceback=True)
+ print_traceback=True) from e
except CatalystError:
return False
return target.run()
diff --git a/catalyst/support.py b/catalyst/support.py
index fa652987..fc50fa34 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -140,9 +140,9 @@ def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
return read_bash_dict(mymakeconffile, sourcing_command="source")
- except Exception:
+ except Exception as e:
raise CatalystError("Could not parse make.conf file " +
- mymakeconffile, print_traceback=True)
+ mymakeconffile, print_traceback=True) from e
else:
makeconf = {}
return makeconf
diff --git a/catalyst/targets/livecd_stage2.py b/catalyst/targets/livecd_stage2.py
index e90e9f53..ff4ea62a 100644
--- a/catalyst/targets/livecd_stage2.py
+++ b/catalyst/targets/livecd_stage2.py
@@ -79,11 +79,11 @@ class livecd_stage2(StageBase):
"livecd/modblacklist"].split()
for x in self.settings["livecd/modblacklist"]:
myf.write("\nblacklist "+x)
- except:
+ except Exception as e:
raise CatalystError("Couldn't open " +
self.settings["chroot_path"] +
"/etc/modprobe.d/blacklist.conf.",
- print_traceback=True)
+ print_traceback=True) from e
def set_action_sequence(self):
self.build_sequence.extend([
diff --git a/catalyst/targets/netboot.py b/catalyst/targets/netboot.py
index a2a9fcb3..38d0cb45 100644
--- a/catalyst/targets/netboot.py
+++ b/catalyst/targets/netboot.py
@@ -30,17 +30,14 @@ class netboot(StageBase):
])
def __init__(self, spec, addlargs):
- try:
- if "netboot/packages" in addlargs:
- if isinstance(addlargs['netboot/packages'], str):
- loopy = [addlargs["netboot/packages"]]
- else:
- loopy = addlargs["netboot/packages"]
+ if "netboot/packages" in addlargs:
+ if isinstance(addlargs['netboot/packages'], str):
+ loopy = [addlargs["netboot/packages"]]
+ else:
+ loopy = addlargs["netboot/packages"]
- for x in loopy:
- self.valid_values |= {"netboot/packages/"+x+"/files"}
- except:
- raise CatalystError("configuration error in netboot/packages.")
+ for x in loopy:
+ self.valid_values |= {"netboot/packages/"+x+"/files"}
StageBase.__init__(self, spec, addlargs)
self.settings["merge_path"] = normpath("/tmp/image/")
@@ -89,12 +86,8 @@ class netboot(StageBase):
else:
myfiles.append(self.settings["netboot/extra_files"])
- try:
- cmd([self.settings['controller_file'], 'image'] +
- myfiles, env=self.env)
- except CatalystError:
- raise CatalystError("Failed to copy files to image!",
- print_traceback=True)
+ cmd([self.settings['controller_file'], 'image'] +
+ myfiles, env=self.env)
self.resume.enable("copy_files_to_image")
@@ -116,12 +109,8 @@ class netboot(StageBase):
# we're done, move the kernels to builds/*
# no auto resume here as we always want the
# freshest images moved
- try:
- cmd([self.settings['controller_file'], 'final'], env=self.env)
- log.notice('Netboot Build Finished!')
- except CatalystError:
- raise CatalystError("Failed to move kernel images!",
- print_traceback=True)
+ cmd([self.settings['controller_file'], 'final'], env=self.env)
+ log.notice('Netboot Build Finished!')
def remove(self):
if "autoresume" in self.settings["options"] \
diff --git a/catalyst/targets/snapshot.py b/catalyst/targets/snapshot.py
index 7732312c..6b727600 100644
--- a/catalyst/targets/snapshot.py
+++ b/catalyst/targets/snapshot.py
@@ -73,7 +73,7 @@ class snapshot(TargetBase):
except subprocess.CalledProcessError as e:
raise CatalystError(f'{e.cmd} failed with return code'
f'{e.returncode}\n'
- f'{e.output}\n')
+ f'{e.output}\n') from e
def run(self):
if self.settings['snapshot_treeish'] == 'stable':
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-01-28 2:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-23 20:31 [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2021-01-28 2:09 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/targets/, catalyst/, catalyst/base/ Matt Turner
2021-01-28 2:41 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/targets/, catalyst/base/ Matt Turner
2016-05-22 3:34 Mike Frysinger
2016-05-20 4:06 Mike Frysinger
2016-05-20 4:06 Mike Frysinger
2015-10-24 6:58 Mike Frysinger
2015-10-09 21:06 Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox