Skip to content

Commit

Permalink
Support HCK installer as ISO
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Chulak <[email protected]>
  • Loading branch information
Jedoku committed Mar 26, 2024
1 parent d14e165 commit 0936be1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
31 changes: 19 additions & 12 deletions lib/engines/hckinstall/hckinstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def init_config
end

def studio_platform(kit)
res = @kit_info
res = @kit_info['studio_platform']
@logger.info("Loading studio platform for kit: #{kit}")
@logger.fatal("Kit studio platform for kit #{kit} does not exist") unless res['studio_platform']
res['studio_platform'] || raise(InvalidConfigFile, "Kit studio platform for kit #{kit} does not exist")
@logger.fatal("Kit studio platform for kit #{kit} does not exist") unless res
res || raise(InvalidConfigFile, "Kit studio platform for kit #{kit} does not exist")
end

def client_platform
Expand Down Expand Up @@ -234,12 +234,11 @@ def run_first(studio:, client:)
if studio
prepare_studio_drives

iso_list = [@setup_studio_iso, @studio_iso_info['path']]
iso_list << @kit_path if @kit_is_iso
vms << [
'studio',
run_studio(scope, [
@setup_studio_iso,
@studio_iso_info['path']
], keep_alive: false, snapshot: false)
run_studio(scope, iso_list, keep_alive: false, snapshot: false)
]
end

Expand Down Expand Up @@ -285,16 +284,23 @@ def prepare_setup_scripts_config
"#{kit_type}#{kit_version}", @hck_setup_scripts_path)
end

check_installers(kit_type, kit_version)

create_setup_scripts_config(@hck_setup_scripts_path, config)
end

def check_installers(kit_type, kit_version)
installers = [
"#{@hck_setup_scripts_path}/Kits/#{kit_type}#{kit_version}Setup.exe",
"#{@hck_setup_scripts_path}/Kits/#{kit_type}#{kit_version}/#{kit_type}Setup.exe"
"#{@hck_setup_scripts_path}/Kits/#{kit_type}#{kit_version}/#{kit_type}Setup.exe",
"#{@hck_setup_scripts_path}/Kits/#{kit_type}#{kit_version}Setup.iso"
]

raise unless (file = installers.find { File.exist? _1 })
raise unless (@kit_path = installers.find { File.exist? _1 })

@logger.info("HLK installer #{file} was found")
@kit_is_iso = @kit_path.end_with?('.iso')

create_setup_scripts_config(@hck_setup_scripts_path, config)
@logger.info("HLK installer #{@kit_path} was found")
end

def product_key_xml(product_key)
Expand Down Expand Up @@ -354,7 +360,8 @@ def prepare_studio_drives
file_gsub(build_studio_answer_file_path(file),
@hck_setup_scripts_path + "/#{file}", replacement_list)
end
create_iso(@setup_studio_iso, [@hck_setup_scripts_path])

create_iso(@setup_studio_iso, [@hck_setup_scripts_path], @kit_is_iso ? ['Kits'] : [])

@project.setup_manager.create_studio_image
end
Expand Down
1 change: 0 additions & 1 deletion lib/engines/hckinstall/kit.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@
"studio_platform": "Win2012R2x64"
}
}

13 changes: 12 additions & 1 deletion lib/engines/hckinstall/setup_scripts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ def validate_setup_scripts_config(config)

def download_kit_installer(url, kit, hck_setup_scripts_path)
dw = Downloader.new(@logger)
dw.download(url, "#{hck_setup_scripts_path}/Kits/#{kit}Setup.exe")

kit_setup_path = "#{hck_setup_scripts_path}/Kits/#{kit}Setup"
return if File.exist?("#{kit_setup_path}.iso")

dw.download(url, "#{kit_setup_path}.tmp")
if File.read("#{kit_setup_path}.tmp", 2) == 'MZ'
FileUtils.mv("#{kit_setup_path}.tmp",
"#{kit_setup_path}.exe")
else
FileUtils.mv("#{kit_setup_path}.tmp",
"#{kit_setup_path}.iso")
end
end

def copy_extra_software(hck_setup_scripts_path, extra_software_path, sw_names)
Expand Down

0 comments on commit 0936be1

Please sign in to comment.