diff --git a/schema.json b/schema.json index 9de945a..1ed4eba 100644 --- a/schema.json +++ b/schema.json @@ -72,7 +72,8 @@ "enum": [ "2020.03.02", "2020.04.30", - "2022.07.25" + "2022.07.25", + "2023.02.16" ] } }, @@ -119,6 +120,27 @@ "properties": { "type": "object", "properties": { + "platform": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "object", + "properties": { + "architecture": { + "type": "string", + "enum": [ + "x86_64", + "aarch64" + ] + } + }, + "required": [ + "architecture" + ], + "additionalProperties": false + } + }, "packages": { "type": "object", "properties": { diff --git a/userenvs/fedora36-ci.json b/userenvs/fedora36-ci.json index f40c749..3b16fee 100644 --- a/userenvs/fedora36-ci.json +++ b/userenvs/fedora36-ci.json @@ -1,7 +1,7 @@ { "workshop": { "schema": { - "version": "2020.03.02" + "version": "2023.02.16" } }, "userenv": { @@ -12,6 +12,14 @@ "tag": "36" }, "properties": { + "platform": [ + { + "architecture": "x86_64" + }, + { + "architecture": "aarch64" + } + ], "packages": { "type": "rpm", "manager": "dnf" diff --git a/workshop.pl b/workshop.pl index 2996cec..b602924 100755 --- a/workshop.pl +++ b/workshop.pl @@ -148,6 +148,8 @@ sub get_exit_code { 'no_label' => 92, 'package_remove' => 93, 'group_remove' => 94, + 'architecture_query_failed' => 95, + 'unsupported_platform_architecture' => 96 ); if (exists($reasons{$exit_reason})) { @@ -579,6 +581,43 @@ sub delete_proto { } } +if (exists $userenv_json->{'userenv'}{'properties'}{'platform'}) { + # the userenv has platform information that indicates what type of + # system architecture(s) it supports so validate that what we are + # about to build is supported + my $my_architecture; + logger('info', "performing userenv platform validation...\n", 1); + ($command, $command_output, $rc) = run_command("uname -m"); + if ($rc == 0) { + command_logger('verbose', $command, $rc, $command_output); + $command_output = filter_output($command_output); + chomp($command_output); + $my_architecture = $command_output; + logger('info', "found current system architecture is " . $my_architecture . "\n", 2); + } else { + logger('info', "failed\n", 2); + command_logger('error', $command, $rc, $command_output); + logger('error', "Failed to obtain the current system architecture!\n"); + exit(get_exit_code('architecture_query_failed')); + } + + my $supported = 0; + # loop through the supported platforms and see if our architecture matches one of them + foreach my $platform (@{$userenv_json->{'userenv'}{'properties'}{'platform'}}) { + if ($platform->{'architecture'} eq $my_architecture) { + $supported = 1; + } + } + + if ($supported) { + logger('info', "succeeded...the userenv is supported for my architecture.\n", 2); + } else { + logger('info', "failed...the userenv is not supported for my architecture.\n", 2); + logger('error', "The userenv is not supported for my architecure.\n"); + exit(get_exit_code('unsupported_platform_architecture')); + } +} + if (!defined $args{'proj'}) { if (defined $args{'label'}) { # Support default behavior before --proj was introduced