diff --git a/build/usr/bin/lxcbuild b/build/usr/bin/lxcbuild index 437d59e..06b00e1 100755 --- a/build/usr/bin/lxcbuild +++ b/build/usr/bin/lxcbuild @@ -5,7 +5,8 @@ import argparse import os import sys from lxcbuild.app import App -from lxcbuild.image import BuildType, Image +from lxcbuild.image import Image +from lxcbuild.imagebuilder import BuildType parser = argparse.ArgumentParser(description='VM application builder and packager') group = parser.add_mutually_exclusive_group() diff --git a/build/usr/lib/python3.6/lxcbuild/image.py b/build/usr/lib/python3.6/lxcbuild/image.py index d903e63..c07e293 100644 --- a/build/usr/lib/python3.6/lxcbuild/image.py +++ b/build/usr/lib/python3.6/lxcbuild/image.py @@ -3,19 +3,12 @@ import os import sys -from enum import Enum from lxcmgr import lxcmgr -from .imagebuilder import ImageBuilder, ImageExistsError, ImageNotFoundError +from .imagebuilder import BuildType, ImageBuilder, ImageExistsError, ImageNotFoundError from .imagepacker import ImagePacker from .packer import PackageExistsError -class BuildType(Enum): - NORMAL = 1 - FORCE = 2 - SCRATCH = 3 - METADATA = 4 - class Image: def __init__(self): self.name = None diff --git a/build/usr/lib/python3.6/lxcbuild/imagebuilder.py b/build/usr/lib/python3.6/lxcbuild/imagebuilder.py index ba65188..d368adc 100644 --- a/build/usr/lib/python3.6/lxcbuild/imagebuilder.py +++ b/build/usr/lib/python3.6/lxcbuild/imagebuilder.py @@ -5,18 +5,23 @@ import shutil import subprocess import sys +from enum import Enum from lxcmgr import lxcmgr from lxcmgr.paths import LXC_STORAGE_DIR from lxcmgr.pkgmgr import PkgMgr -from .image import BuildType - class ImageExistsError(Exception): pass class ImageNotFoundError(Exception): pass +class BuildType(Enum): + NORMAL = 1 + FORCE = 2 + SCRATCH = 3 + METADATA = 4 + class ImageBuilder: def __init__(self, image): self.image = image @@ -86,6 +91,9 @@ class ImageBuilder: # Set name and first (topmost) layer of the image self.image.name = name self.image.conf['layers'] = [name] + if self.image.build_type == BuildType.METADATA: + # Don't check or create any directories if we're building just metadata + return image_path = self.get_layer_path(name) if os.path.exists(image_path): if self.image.build_type in (BuildType.FORCE, BuildType.SCRATCH):