Commit b7d9b425 authored by Sébastien Luttringer's avatar Sébastien Luttringer

Payload directory is not mandatory

execpt if there is build directory
parent 3afabe8c
......@@ -31,7 +31,7 @@ class ISException(Exception):
Base exception class
def __init__(self, message="", exception=None):
def __init__(self, message=u"", exception=None):
self.message = unicode(message)
self.exception = None if exception is None else sys.exc_info()
......@@ -71,6 +71,7 @@ class ISException(Exception):
# reset color
out("#R#", fd=fd, endl="")
class ISError(ISException):
Installsystems error; this exception will stop execution
......@@ -81,3 +82,12 @@ class ISWarning(ISException):
Installsystems warning; this exception do not stop execution
class InvalidSourceImage(ISError):
Invalid source image errors
def __init(self, message=u"", exception=None):
ISException(self, u"Invalid source image: " + message, exception)
......@@ -336,22 +336,26 @@ class SourceImage(Image):
def check_source_image(self):
Check if we are a valid SourceImage directories
# setup and payload are the only needed dirs
# setup are mandatory to do something
# payload directory is needed because build script chroot into payload directory
for d in (self.setup_path, self.payload_path):
if not os.path.exists(d):
raise ISError(u"Invalid source image: directory %s is missing" % d)
A vaild SourceImage contains at least a description and a setup directory.
Payload directory is mandatory is build scripts are present
# Ensure setup_path exists
if not os.path.exists(self.setup_path):
raise InvalidSourceImage(u"setup directory is missing.")
# Ensure description exists
if not os.path.exists(os.path.join(self.base_path, u"description")):
raise InvalidSourceImage(u"no description file.")
# Ensure payload directory exists if there is build directory
if not os.path.exists(self.payload_path) and os.path.exists(self.build_path):
raise InvalidSourceImage(u"payload directory is mandatory with a build directory.")
# Ensure directories are directories and accessible
for d in (self.base_path, self.build_path, self.parser_path,
self.setup_path, self.payload_path, self.lib_path):
if os.path.exists(d):
if not os.path.isdir(d):
raise ISError(u"Invalid source image: %s is not a directory" % d)
raise InvalidSourceImage(u"%s is not a directory." % d)
if not os.access(d, os.R_OK|os.X_OK):
raise ISError(u"Invalid source image: unable to access to %s" % d)
if not os.path.exists(os.path.join(self.base_path, "description")):
raise ISError("Invalid source image: no description file")
raise InvalidSourceImage(u"unable to access to %s." % d)
def build(self, force=False, force_payload=False, check=True, script=True):
......@@ -450,6 +454,8 @@ class SourceImage(Image):
Return a generator on image payloads
if not os.path.isdir(self.payload_path):
raise StopIteration()
for payname in os.listdir(self.payload_path):
yield payname
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment