|
27 | 27 | unless ENV['MODULE_provision'] == 'no'
|
28 | 28 | agents.each do |agent|
|
29 | 29 | # Emit CommonProgramFiles environment variable
|
30 |
| - program_files = agent.get_env_var('ProgramFiles').split('=')[1] |
31 |
| - agent.add_env_var('CommonProgramFiles', "#{program_files}\\Common Files") |
| 30 | + common_program_files = agent.get_env_var('CommonProgramFiles') |
| 31 | + |
| 32 | + # Workarounds due to BKR-914 |
| 33 | + # - newline chars indicate matching more than one env var |
| 34 | + # - env var key matching is very loose. e.g. CommonProgramFiles(x86) can be returned |
| 35 | + common_program_files = "" if common_program_files.include?("\n") |
| 36 | + common_program_files = "" unless common_program_files.start_with?("CommonProgramFiles=") |
| 37 | + # If the env var is not found use a workaround to inject regex into the grep call |
| 38 | + common_program_files = agent.get_env_var('^CommonProgramFiles=') if common_program_files == "" |
| 39 | + |
| 40 | + if common_program_files == "" |
| 41 | + program_files = agent.get_env_var('PROGRAMFILES') |
| 42 | + |
| 43 | + # Workarounds due to BKR-914 |
| 44 | + # - newline chars indicate matching more than one env var |
| 45 | + # - env var key matching is very loose. e.g. ProgramFiles(x86) can be returned |
| 46 | + program_files = "" if program_files.include?("\n") |
| 47 | + program_files = "" unless program_files.start_with?("PROGRAMFILES=") |
| 48 | + # If the env var is not found use a workaround to inject regex into the grep call |
| 49 | + program_files = agent.get_env_var('^PROGRAMFILES=') if program_files == "" |
| 50 | + |
| 51 | + program_files = program_files.split('=')[1] |
| 52 | + agent.add_env_var('CommonProgramFiles', "#{program_files}\\Common Files") |
| 53 | + end |
32 | 54 |
|
33 | 55 | # Install Forge certs to allow for PMT installation.
|
34 | 56 | install_ca_certs(agent)
|
|
0 commit comments