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 os
import sys import sys
from lxcbuild.app import App 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') parser = argparse.ArgumentParser(description='VM application builder and packager')
group = parser.add_mutually_exclusive_group() group = parser.add_mutually_exclusive_group()

View File

@ -3,19 +3,12 @@
import os import os
import sys import sys
from enum import Enum
from lxcmgr import lxcmgr from lxcmgr import lxcmgr
from .imagebuilder import ImageBuilder, ImageExistsError, ImageNotFoundError from .imagebuilder import BuildType, ImageBuilder, ImageExistsError, ImageNotFoundError
from .imagepacker import ImagePacker from .imagepacker import ImagePacker
from .packer import PackageExistsError from .packer import PackageExistsError
class BuildType(Enum):
NORMAL = 1
FORCE = 2
SCRATCH = 3
METADATA = 4
class Image: class Image:
def __init__(self): def __init__(self):
self.name = None self.name = None

View File

@ -5,18 +5,23 @@ import shutil
import subprocess import subprocess
import sys import sys
from enum import Enum
from lxcmgr import lxcmgr from lxcmgr import lxcmgr
from lxcmgr.paths import LXC_STORAGE_DIR from lxcmgr.paths import LXC_STORAGE_DIR
from lxcmgr.pkgmgr import PkgMgr from lxcmgr.pkgmgr import PkgMgr
from .image import BuildType
class ImageExistsError(Exception): class ImageExistsError(Exception):
pass pass
class ImageNotFoundError(Exception): class ImageNotFoundError(Exception):
pass pass
class BuildType(Enum):
NORMAL = 1
FORCE = 2
SCRATCH = 3
METADATA = 4
class ImageBuilder: class ImageBuilder:
def __init__(self, image): def __init__(self, image):
self.image = image self.image = image
@ -86,6 +91,9 @@ class ImageBuilder:
# Set name and first (topmost) layer of the image # Set name and first (topmost) layer of the image
self.image.name = name self.image.name = name
self.image.conf['layers'] = [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) image_path = self.get_layer_path(name)
if os.path.exists(image_path): if os.path.exists(image_path):
if self.image.build_type in (BuildType.FORCE, BuildType.SCRATCH): if self.image.build_type in (BuildType.FORCE, BuildType.SCRATCH):