@@ -206,10 +206,10 @@ def prepare_config(args):
206206 config .update (profile_config )
207207
208208 packer_tmpl = prepare_packer_template (config , args )
209-
210209 # merge/update with template config
211210 with open (packer_tmpl , 'r' ) as f :
212- config .update (json .loads (f .read ()))
211+ a = f .read ()
212+ config .update (json .loads (a ))
213213
214214 return config , packer_tmpl
215215
@@ -331,10 +331,14 @@ def run_packer(packer_tmpl, args):
331331 return 254
332332
333333 # run packer with relevant config minified
334+ # (removes "profiles" as packer do not support arrays in var-file)
334335 configfile = os .path .join (DIRS .user_config_dir , 'config.js' )
335336 with open (configfile , 'r' ) as config :
337+ config = json .loads (jsmin (config .read ()))
338+ if "profile_config" in config .keys ():
339+ del config ["profile_config" ]
336340 f = create_cachefd ('packer_var_file.json' )
337- f .write (jsmin ( config . read () ))
341+ f .write (json . dumps ( config ))
338342 f .close ()
339343
340344 flags = ['-var-file={}' .format (f .name )]
@@ -486,6 +490,8 @@ def prepare_profile(config, args):
486490
487491 profile = load_profile (profile_name )
488492
493+ config ["profile_config" ] = profile
494+
489495 fd = create_cachefd ('profile-{}.ps1' .format (profile_name ))
490496
491497 if "registry" in profile :
@@ -500,9 +506,9 @@ def prepare_profile(config, args):
500506 for doc_mod in profile ["document" ]:
501507 document (profile_name , doc_mod ["modtype" ], doc_mod ["docpath" ], fd )
502508
503- if "package " in profile :
504- for package_mod in profile ["package " ]:
505- package (profile_name , package_mod [ "package" ] , fd )
509+ if "packages " in profile :
510+ for pkg in profile ["packages " ]:
511+ package (profile_name , pkg , fd )
506512
507513 if "packer" in profile :
508514 packer = profile ["packer" ]
@@ -560,7 +566,7 @@ def directory(profile_name, modtype, dirpath, fd):
560566
561567def package (profile_name , package_name , fd ):
562568 """ Adds a package to install with Chocolatey."""
563- line = "choco install {} -y \r \n " .format (package_name )
569+ line = "choco install -y {} \r \n " .format (package_name )
564570 print ("Adding Chocolatey package: {}" .format (package_name ))
565571
566572 fd .write (line )
0 commit comments