Move BuildType to imagebuilder to prevent dependency conflicts

This commit is contained in:
Disassembler 2019-11-30 16:02:31 +01:00
parent e794ced82a
commit c22d2c7393
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
3 changed files with 13 additions and 11 deletions

View File

@ -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()

View File

@ -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

View File

@ -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):