Refine Vagrantfile location

Read from script directory if run from Git checkout and from /usr/share/
if run from a packaged installation.

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2023-05-21 00:28:38 +02:00
parent c0af9d8a68
commit 7024eb6fae
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57

View File

@ -40,6 +40,14 @@ vmprefix = 'scullery'
cwd = os.getcwd() cwd = os.getcwd()
sshfile='{}/.scullery_ssh'.format(cwd) sshfile='{}/.scullery_ssh'.format(cwd)
envfile='{}/.scullery_env'.format(cwd) envfile='{}/.scullery_env'.format(cwd)
vagfile='Vagrantfile-Template'
# replaced in scullery.spec
is_packaged = False
if is_packaged:
vagfile='/usr/share/scullery/{}'.format(vagfile)
else:
vagfile='{}/{}'.format(os.path.abspath(os.path.dirname(__file__)), vagfile)
def _abort(msg): def _abort(msg):
log.error(msg) log.error(msg)
@ -163,7 +171,7 @@ def main_interactive():
_abort('Suite referencs an undefined box') _abort('Suite referencs an undefined box')
box_name = boxconf.get('name', None) box_name = boxconf.get('name', None)
box_image = boxconf.get('image', None) box_image = boxconf.get('image', None)
box_file = boxconf.get('file', '{}/Vagrantfile-Template'.format(os.path.abspath(os.path.dirname(__file__)))) box_file = boxconf.get('file', vagfile)
if None in [box_name, box_image, box_file]: if None in [box_name, box_image, box_file]:
_abort('Box configuration is incomplete') _abort('Box configuration is incomplete')
box_bootstrap = boxconf.get('bootstrap', None) box_bootstrap = boxconf.get('bootstrap', None)