Compare commits

..

2 Commits

Author SHA1 Message Date
Emmanuel Garette 8566751809 Merge branch 'develop' into dist/risotto/risotto-2.8.0/develop 2021-05-24 16:53:58 +02:00
Emmanuel Garette 9d4644bedf fix 2021-05-24 16:53:50 +02:00
1 changed files with 8 additions and 8 deletions

View File

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