mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Set env. var YNH_APP_ARG_xxx for each manifest argument during install
This commit is contained in:
parent
eaf0fabc7f
commit
e20ec39cb2
2 changed files with 7 additions and 2 deletions
|
@ -468,6 +468,11 @@ def app_install(auth, app, label=None, args=None):
|
|||
args_list = args_odict.values()
|
||||
args_list.append(app_id)
|
||||
|
||||
# Prepare env. var. to pass to script
|
||||
env_dict = {}
|
||||
for arg_name, arg_value in args_odict.items():
|
||||
env_dict[ "YNH_APP_ARG_%s" % arg_name ] = arg_value
|
||||
|
||||
# Create app directory
|
||||
app_setting_path = os.path.join(apps_setting_path, app_id)
|
||||
if os.path.exists(app_setting_path):
|
||||
|
@ -497,7 +502,7 @@ def app_install(auth, app, label=None, args=None):
|
|||
os.system('cp %s/manifest.json %s' % (app_tmp_folder, app_setting_path))
|
||||
os.system('cp -R %s/scripts %s' % (app_tmp_folder, app_setting_path))
|
||||
try:
|
||||
if hook_exec(app_tmp_folder + '/scripts/install', args_list) == 0:
|
||||
if hook_exec(app_tmp_folder + '/scripts/install', args=args_list, env=env_dict) == 0:
|
||||
# Store app status
|
||||
with open(app_setting_path + '/status.json', 'w+') as f:
|
||||
json.dump(status, f)
|
||||
|
|
|
@ -307,7 +307,7 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False, env=None):
|
|||
cmd_args = '"{:s}"'.format('" "'.join(str(s) for s in args))
|
||||
|
||||
envcli = ''
|
||||
if env is not None and isinstance(env, dict):
|
||||
if env is not None:
|
||||
envcli = ' '.join([ '{key}="{val}"'.format(key=key, val=val) for key,val in env.items()])
|
||||
|
||||
# Construct command to execute
|
||||
|
|
Loading…
Add table
Reference in a new issue