Compare commits

..

No commits in common. "856675180980c9cae51a92a4d4eaccea2e1a2d6d" and "4d2439c25072b638b6abd7a97c5fd6c082527633" have entirely different histories.

1 changed files with 8 additions and 8 deletions

View File

@ -16,17 +16,14 @@ except:
from .utils import _
DATASET_PATH = '/usr/share/risotto/'
DATASET_PATH = ''
TMP_DIRECTORY = '/tmp'
PACKER_TMP_DIRECTORY = join(TMP_DIRECTORY, 'packer')
PACKER_FILE_NAME = 'recipe.json'
IMAGES_DIRECTORY = join(TMP_DIRECTORY, 'images')
FUNCTIONS = b"""try:
from tiramisu3 import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value
except:
from tiramisu import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value
FUNCTIONS = b"""from tiramisu import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value
# =============================================================
# fork of risotto-setting/src/risotto_setting/config/config.py
def get_password(**kwargs):
@ -171,6 +168,7 @@ class Image:
if not isdir(funcs_dir):
continue
for func in listdir(funcs_dir):
print(join(funcs_dir, func))
with open(join(funcs_dir, func), 'rb') as fh:
functions += fh.read()
func_name = join(packer_tmp_directory, 'func.py')
@ -253,12 +251,14 @@ class Image:
def build_image(self,
packer_dst_filename: str,
tmp_directory: str,
packer_tmp_directory: str,
packer_configuration: dict,
) -> None:
tmp_directory = join(packer_tmp_directory, 'tmp')
makedirs(tmp_directory)
packer_configuration['tmp_directory'] = tmp_directory
recipe = {'variables': packer_configuration}
packer_filename = join(tmp_directory, PACKER_FILE_NAME)
packer_filename = join(packer_tmp_directory, PACKER_FILE_NAME)
with open(packer_filename, 'r') as recipe_fd:
for key, value in jload(recipe_fd).items():
recipe[key] = value
@ -271,7 +271,7 @@ class Image:
)
proc.wait()
if proc.returncode:
raise Exception(_(f'cannot build {packer_dst_filename} with {packer_filename}'))
raise Exception(_(f'cannot build {application} with {packer_filename}'))
move(join(tmp_directory, 'image.img'), packer_dst_filename)
move(join(tmp_directory, 'image.sha256'), f'{packer_dst_filename}.sha256')
rmtree(tmp_directory)