Skip to content

Commit 4cd070f

Browse files
committed
Add ability to unsign driver before packaging
Use --package-with-driver=unsigned to remove signature from the driver before including. Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
1 parent f608877 commit 4cd070f

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

lib/cli.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class CliTestOptions < T::Struct
7979
prop :drivers, T::Array[String], default: []
8080
prop :driver_path, T.nilable(String)
8181
prop :supplemental_path, T.nilable(String)
82-
prop :package_with_driver, T::Boolean, default: false
82+
prop :package_with_driver, Symbol, default: :none
8383
prop :commit, T.nilable(String)
8484
prop :svvp, T::Boolean, default: false
8585
prop :dump, T::Boolean, default: false
@@ -129,9 +129,12 @@ def define_options(parser)
129129
'Path to the supplemental content folder (e.g. for README)',
130130
&method(:supplemental_path=))
131131

132-
parser.on('--package-with-driver', TrueClass,
132+
parser.on('--package-with-driver [package_action]', %i[keep unsigned],
133133
'Include driver files in HLKX package (requires --driver-path)',
134-
&method(:package_with_driver=))
134+
'Use --package-with-driver or --package-with-driver=keep to include driver with original signature',
135+
'Use --package-with-driver=unsigned to remove signature from the driver before including') do |pa|
136+
self.package_with_driver = pa || :keep
137+
end
135138

136139
parser.on('-c', '--commit <commit_hash>', String,
137140
'Commit hash for CI status update',

lib/engines/hcktest/tests.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def upload_package_asset(type, path)
646646

647647
sig { returns(T.nilable(String)) }
648648
def prepare_package_driver_content
649-
return unless @project.options.test.package_with_driver
649+
return if @project.options.test.package_with_driver == :none
650650

651651
upload_package_asset('Driver', @project.options.test.driver_path)
652652
end
@@ -656,14 +656,28 @@ def prepare_package_supplemental_content
656656
upload_package_asset('Supplemental', @project.options.test.supplemental_path)
657657
end
658658

659+
def print_project_package_results(res)
660+
messages = (res['messages'] || []).map { " -- #{_1}\n" }.join
661+
if res['iserror'] == false
662+
@logger.info('Project package successfully created')
663+
@logger.debug("Project package creation result:\n#{messages}")
664+
else
665+
@logger.warn('Project package creation got an error. Check the logs for details.')
666+
@logger.warn("Project package creation result:\n#{messages}")
667+
end
668+
end
669+
659670
def create_project_package
660-
package_playlist = @playlist.playlist if @project.options.test.package_with_playlist
671+
test_options = @project.options.test
672+
package_playlist = @playlist.playlist if test_options.package_with_playlist
661673

662674
remote_driver_path = prepare_package_driver_content
663675
remote_supplemental_path = prepare_package_supplemental_content
664676

665-
res = @tools.create_project_package(@tag, package_playlist, nil, remote_driver_path, remote_supplemental_path)
666-
@logger.info('Results package successfully created')
677+
res = @tools.create_project_package(@tag, package_playlist, nil, remote_driver_path, remote_supplemental_path,
678+
remove_driver_signatures: test_options.package_with_driver == :unsigned)
679+
print_project_package_results(res)
680+
667681
r_name = @tag + File.extname(res['hostprojectpackagepath'])
668682
@project.result_uploader.upload_file(res['hostprojectpackagepath'], r_name)
669683
end

lib/engines/hcktest/tools.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,13 @@ def zip_test_result_logs(...)
378378
retry
379379
end
380380

381-
def create_project_package(project, playlist = nil, handler = nil, driver_path = nil, supplemental_path = nil) # rubocop:disable Metrics/ParameterLists
381+
def create_project_package(project, playlist = nil, handler = nil, driver_path = nil, supplemental_path = nil, # rubocop:disable Metrics/ParameterLists
382+
remove_driver_signatures: false)
382383
retry_tools_command(__method__) do
383-
act_with_tools { _1.create_project_package(project, playlist, handler, driver_path, supplemental_path) }
384+
act_with_tools do |tools|
385+
tools.create_project_package(project, playlist, handler, driver_path, supplemental_path,
386+
remove_driver_signatures:)
387+
end
384388
end
385389
end
386390

0 commit comments

Comments
 (0)