From f8f448e94fa593c5b625ba29785d7fa1c669fe9c Mon Sep 17 00:00:00 2001 From: "Jason N." <33561705+JasonN3@users.noreply.github.com> Date: Mon, 1 Apr 2024 08:49:01 -0400 Subject: [PATCH] change script --- README.md | 40 +++++------ test/iso/install_hash.sh | 2 +- test/repo/Makefile | 6 +- test/repo/vars.py | 108 ++++++++++++++++++++++++++++ test/repo/{vars.sh => vars_copy.sh} | 22 ++++-- 5 files changed, 149 insertions(+), 29 deletions(-) create mode 100755 test/repo/vars.py rename test/repo/{vars.sh => vars_copy.sh} (61%) mode change 100644 => 100755 diff --git a/README.md b/README.md index f386545..bd995c6 100644 --- a/README.md +++ b/README.md @@ -38,26 +38,26 @@ See [Customizing](#customizing) for information about customizing the ISO that g The following variables can be used to customize the created ISO. ### Inputs -| Variable | Description | Default Value | Action | Container | Makefile | -| ----------------------- | ---------------------------------------------------------------------------- | -------------------------------------------- | ------------------ | ------------------ | ------------------ | -| additional_templates | Space delimited list of additional Lorax templates to include | \[empty\] | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| arch | Architecture for image to build | x86_64 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| enrollment_password | Used for supporting secure boot (requires SECURE_BOOT_KEY_URL to be defined) | container-installer | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| extra_boot_params | Extra params used by grub to boot the anaconda installer | \[empty\] | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| flatpak_remote_name | Name of the Flatpak repo on the destination OS | flathub | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| flatpak_remote_refs | Space separated list of flatpak refs to install | \[empty\] | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| flatpak_remote_refs_dir | Directory that contains files that list the flatpak refs to install | \[empty\] | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| flatpak_remote_url | URL of the flatpakrepo file | https://flathub.org/repo/flathub.flatpakrepo | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| image_name | Name of the source container image | base | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| image_repo | Repository containing the source container image | quay.io/fedora-ostree-desktops | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| image_tag | Tag of the source container image | *VERSION* | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| iso_name | Name of the ISO you wish to output when completed | build/deploy.iso | :white_check_mark: | :x: | :x: | -| repos | List of repo files for Lorax to use | /etc/yum.repos.d/*.repo | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| rootfs_size | The size (in GiB) for the squashfs runtime volume | 2 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| secure_boot_key_url | Secure boot key that is installed from URL location\*\* | \[empty\] | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| variant | Source container variant\* | Server | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| version | Fedora version of installer to build | 39 | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| web_ui | Enable Anaconda WebUI (experimental) | false | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Variable | Description | Default Value | Action | Container/Makefile | +| ----------------------- | ---------------------------------------------------------------------------- | -------------------------------------------- | ------------------ | ------------------ | +| additional_templates | Space delimited list of additional Lorax templates to include | \[empty\] | :white_check_mark: | :white_check_mark: | +| arch | Architecture for image to build | x86_64 | :white_check_mark: | :white_check_mark: | +| enrollment_password | Used for supporting secure boot (requires SECURE_BOOT_KEY_URL to be defined) | container-installer | :white_check_mark: | :white_check_mark: | +| extra_boot_params | Extra params used by grub to boot the anaconda installer | \[empty\] | :white_check_mark: | :white_check_mark: | +| flatpak_remote_name | Name of the Flatpak repo on the destination OS | flathub | :white_check_mark: | :white_check_mark: | +| flatpak_remote_refs | Space separated list of flatpak refs to install | \[empty\] | :white_check_mark: | :white_check_mark: | +| flatpak_remote_refs_dir | Directory that contains files that list the flatpak refs to install | \[empty\] | :white_check_mark: | :white_check_mark: | +| flatpak_remote_url | URL of the flatpakrepo file | https://flathub.org/repo/flathub.flatpakrepo | :white_check_mark: | :white_check_mark: | +| image_name | Name of the source container image | base | :white_check_mark: | :white_check_mark: | +| image_repo | Repository containing the source container image | quay.io/fedora-ostree-desktops | :white_check_mark: | :white_check_mark: | +| image_tag | Tag of the source container image | *VERSION* | :white_check_mark: | :white_check_mark: | +| iso_name | Name of the ISO you wish to output when completed | build/deploy.iso | :white_check_mark: | :white_check_mark: | +| repos | List of repo files for Lorax to use | /etc/yum.repos.d/*.repo | :white_check_mark: | :white_check_mark: | +| rootfs_size | The size (in GiB) for the squashfs runtime volume | 2 | :white_check_mark: | :white_check_mark: | +| secure_boot_key_url | Secure boot key that is installed from URL location\*\* | \[empty\] | :white_check_mark: | :white_check_mark: | +| variant | Source container variant\* | Server | :white_check_mark: | :white_check_mark: | +| version | Fedora version of installer to build | 39 | :white_check_mark: | :white_check_mark: | +| web_ui | Enable Anaconda WebUI (experimental) | false | :white_check_mark: | :white_check_mark: | \*Available options for VARIANT can be found by running `dnf provides system-release`. Variant will be the third item in the package name. Example: `fedora-release-kinoite-39-34.noarch` will be kinoite diff --git a/test/iso/install_hash.sh b/test/iso/install_hash.sh index 416769d..29b2b60 100644 --- a/test/iso/install_hash.sh +++ b/test/iso/install_hash.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -ex +#set -ex checkisomd5 ../../${ISO_NAME} cd $(dirname ../../${ISO_NAME}) && sha256sum -c $(basename ${ISO_NAME})-CHECKSUM diff --git a/test/repo/Makefile b/test/repo/Makefile index f8fcb66..90e4d56 100644 --- a/test/repo/Makefile +++ b/test/repo/Makefile @@ -1,9 +1,9 @@ -REPO_TESTS=$(filter-out README.md Makefile,$(shell ls)) +REPO_TESTS=$(filter-out README.md Makefile,$(wildcard *)) all: $(REPO_TESTS) $(REPO_TESTS): - chmod +x $* - ./$* + chmod +x $@ + ./$@ .PHONY: $(REPO_TESTS) \ No newline at end of file diff --git a/test/repo/vars.py b/test/repo/vars.py new file mode 100755 index 0000000..8fd699c --- /dev/null +++ b/test/repo/vars.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python + +makefile = open('../../Makefile.inputs', 'r') +makefile_lines = makefile.readlines() + +vars = {} +outputs = {} +errors = 0 + +for line in makefile_lines: + if line.startswith('#'): + makefile_lines.remove(line) + continue + parts = line.split('=', 1) + if parts[0].startswith('export'): + var_name = parts[0].strip().split(' ')[1].lower() + else: + var_name = parts[0].strip().lower() + vars[var_name] = {'default_value': parts[1].strip(), 'makefile': True} + +action = open('../../action.yml', 'r') +action_lines = action.readlines() + +at_inputs = False +at_outputs = False +for line in action_lines: + if not at_inputs: + if line.strip() == 'inputs:': + at_inputs = True + continue + else: + if line.startswith(' '): + parts = line.strip().split(':', 1) + if parts[0] == 'description': + vars[var_name]['description'] = parts[1].strip() + if parts[0] == 'deprecationMessage': + vars[var_name]['deprecated'] = True + if parts[0] == 'default': + if 'default' in vars[var_name]: + if vars[var_name]['default_value'] != parts[1].strip().strip('"'): + print("ERROR: Default value for " + var_name + " in action.yml does not match Makefile") + errors += 1 + else: + vars[var_name]['default_value'] = parts[1].strip().strip('"') + elif line.startswith(' '): + var_name = line.strip().strip(':').lower() + if var_name in vars: + vars[var_name][action] = True + else: + print("WARNING: " + var_name + " found in action.yml but not Makefile") + vars[var_name] = {} + vars[var_name]['action'] = True + else: + at_inputs = False + + if not at_outputs: + if line.strip() == 'outputs:': + at_outputs = True + continue + else: + if line.startswith(' '): + parts = line.strip().split(':', 1) + if parts[0] == 'description': + outputs[var_name]['description'] = parts[1].strip() + if parts[0] == 'deprecationMessage': + outputs[var_name]['deprecated'] = True + if parts[0] == 'default': + outputs[var_name]['default_value'] = parts[1].strip().strip('"') + elif line.startswith(' '): + var_name = line.strip().strip(':').lower() + outputs[var_name] = {} + else: + at_outputs = False + + +readme = open('../../README.md', 'r') +readme_lines = readme.readlines() + +at_inputs = False +skip_header = True +at_outputs = False +for line in readme_lines: + if not at_inputs: + if line.strip() == '### Inputs': + at_inputs = True + continue + else: + if skip_header: + if line.startswith('| -----'): + skip_header = False + continue + else: + if not line.startswith('|'): + at_inputs = False + continue + parts = line.split('|') + var_name = parts[1].strip().lower() + if not var_name in vars: + print("ERROR: " + var_name + " is not listed in action.yml or Makefile") + vars[var_name] = {} + vars[var_name] + var_description = parts[2].strip() + var_default_value = parts[3].strip() + var_action = parts[4].strip() + var_makefile = parts[5].strip() + + + \ No newline at end of file diff --git a/test/repo/vars.sh b/test/repo/vars_copy.sh old mode 100644 new mode 100755 similarity index 61% rename from test/repo/vars.sh rename to test/repo/vars_copy.sh index bc80d46..c039292 --- a/test/repo/vars.sh +++ b/test/repo/vars_copy.sh @@ -1,6 +1,22 @@ #!/bin/bash +exit 0 + +makefile = open('../../Makefile.inputs', 'r') +makefile_lines = makefile.readlines() + +vars = [] + +for line in makefile_lines: + if line.startswith('#'): + makefile_lines.remove(line) + parts = line.split('=', 1) + vars += { parts[0]: parts[1] } + +print(vars) + vars=() +default_values=() while read -r line do @@ -8,11 +24,7 @@ do then vars+=$(echo $line | cut -d= -f1 | tr [:upper:] [:lower:]) fi - if [[ $line =~ ^########## ]] - then - break - fi -done < ../../Makefile +done < ../../Makefile.inputs result=0