mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 10:57:55 +01:00
Fix post scripts and use multiple OS versions in tests (#70)
This commit is contained in:
parent
10524ae6ea
commit
3dc05c0efc
4 changed files with 59 additions and 50 deletions
31
.github/workflows/build-and-test.yml
vendored
31
.github/workflows/build-and-test.yml
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
name: Create and publish an ISO
|
name: Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -26,6 +26,7 @@ env:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-container:
|
build-container:
|
||||||
|
name: Build Container Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
@ -67,6 +68,7 @@ jobs:
|
||||||
password: ${{ github.token }}
|
password: ${{ github.token }}
|
||||||
|
|
||||||
build-and-push-iso:
|
build-and-push-iso:
|
||||||
|
name: Build ISO
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- build-container
|
- build-container
|
||||||
|
|
@ -110,13 +112,13 @@ jobs:
|
||||||
arch: ${{ env.ARCH}}
|
arch: ${{ env.ARCH}}
|
||||||
image_name: ${{ env.IMAGE_NAME}}
|
image_name: ${{ env.IMAGE_NAME}}
|
||||||
image_repo: ${{ env.IMAGE_REPO}}
|
image_repo: ${{ env.IMAGE_REPO}}
|
||||||
image_tag: ${{ env.IMAGE_TAG }}
|
image_tag: ${{ matrix.version }}
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
variant: ${{ env.VARIANT }}
|
variant: ${{ env.VARIANT }}
|
||||||
flatpak_remote_refs_dir: ${{ env.FLATPAK_REMOTE_REFS_DIR }}
|
flatpak_remote_refs_dir: ${{ env.FLATPAK_REMOTE_REFS_DIR }}
|
||||||
secure_boot_key_url: ${{ env.SECURE_BOOT_KEY_URL }}
|
secure_boot_key_url: ${{ env.SECURE_BOOT_KEY_URL }}
|
||||||
enrollment_password: ${{ env.ENROLLMENT_PASSWORD }}
|
enrollment_password: ${{ env.ENROLLMENT_PASSWORD }}
|
||||||
iso_name: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_TAG }}-${{ matrix.version }}.iso
|
iso_name: ${{ env.IMAGE_NAME }}-${{ matrix.version }}-${{ matrix.version }}.iso
|
||||||
|
|
||||||
- name: Save output
|
- name: Save output
|
||||||
id: save_output
|
id: save_output
|
||||||
|
|
@ -138,6 +140,7 @@ jobs:
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
|
||||||
test-qemu:
|
test-qemu:
|
||||||
|
name: Test ISO
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- build-and-push-iso
|
- build-and-push-iso
|
||||||
|
|
@ -158,10 +161,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Ensure qemu is installed
|
- name: Install test tools
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat socat jq isomd5sum ansible make coreutils
|
sudo apt-get install -y make
|
||||||
|
sudo make install-test-deps PACKAGE_MANAGER=apt-get
|
||||||
|
|
||||||
- name: Create disk
|
- name: Create disk
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -184,7 +188,7 @@ jobs:
|
||||||
ARCH=${{ env.ARCH}} \
|
ARCH=${{ env.ARCH}} \
|
||||||
IMAGE_NAME=${{ env.IMAGE_NAME}} \
|
IMAGE_NAME=${{ env.IMAGE_NAME}} \
|
||||||
IMAGE_REPO=${{ env.IMAGE_REPO}} \
|
IMAGE_REPO=${{ env.IMAGE_REPO}} \
|
||||||
IMAGE_TAG=${{ env.IMAGE_TAG }} \
|
IMAGE_TAG=${{ matrix.version }} \
|
||||||
VERSION=${{ matrix.version }} \
|
VERSION=${{ matrix.version }} \
|
||||||
VARIANT=${{ env.VARIANT }} \
|
VARIANT=${{ env.VARIANT }} \
|
||||||
FLATPAK_REMOTE_REFS_DIR=${{ env.FLATPAK_REMOTE_REFS_DIR }} \
|
FLATPAK_REMOTE_REFS_DIR=${{ env.FLATPAK_REMOTE_REFS_DIR }} \
|
||||||
|
|
@ -250,7 +254,7 @@ jobs:
|
||||||
timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done"
|
timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done"
|
||||||
(tail -f vm.stdin | nc localhost 4321 | tee vm.stdout) &
|
(tail -f vm.stdin | nc localhost 4321 | tee vm.stdout) &
|
||||||
|
|
||||||
timeout 30m bash -c "while ! (grep 'login:' vm.stdout); do sleep 1; done"
|
timeout 30m bash -c "while ! (echo > /dev/tcp/${VM_IP}/${VM_PORT}); do sleep 1; done"
|
||||||
|
|
||||||
if ! (echo > /dev/tcp/${VM_IP}/${VM_PORT})
|
if ! (echo > /dev/tcp/${VM_IP}/${VM_PORT})
|
||||||
then
|
then
|
||||||
|
|
@ -258,17 +262,6 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "VM ready for tests at IP ${VM_IP}:${VM_PORT}"
|
echo "VM ready for tests at IP ${VM_IP}:${VM_PORT}"
|
||||||
echo "Creating Ansible inventory"
|
|
||||||
cat << EOF > ansible_inventory
|
|
||||||
ungrouped:
|
|
||||||
hosts:
|
|
||||||
vm:
|
|
||||||
ansible_host: ${VM_IP}
|
|
||||||
ansible_port: ${VM_PORT}
|
|
||||||
ansible_user: ${VM_USER}
|
|
||||||
ansible_password: ${VM_PASS}
|
|
||||||
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
|
|
||||||
EOF
|
|
||||||
|
|
||||||
#make test-vm
|
make test-vm VM_IP=${VM_IP} VM_PORT=${VM_PORT} VM_USER=${VM_USER} VM_PASS=${VM_PASS}
|
||||||
kill $QEMU_PID
|
kill $QEMU_PID
|
||||||
|
|
|
||||||
38
Makefile
38
Makefile
|
|
@ -23,6 +23,8 @@ SECURE_BOOT_KEY_URL =
|
||||||
# Cache
|
# Cache
|
||||||
DNF_CACHE =
|
DNF_CACHE =
|
||||||
|
|
||||||
|
PACKAGE_MANAGER = dnf
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
## Formatting = lowercase
|
## Formatting = lowercase
|
||||||
# Get a list of templates for the feature
|
# Get a list of templates for the feature
|
||||||
|
|
@ -75,7 +77,7 @@ _LORAX_ARGS =
|
||||||
_LORAX_TEMPLATES = $(call get_templates,install)
|
_LORAX_TEMPLATES = $(call get_templates,install)
|
||||||
_REPO_FILES = $(subst /etc/yum.repos.d,repos,$(REPOS))
|
_REPO_FILES = $(subst /etc/yum.repos.d,repos,$(REPOS))
|
||||||
_TEMP_DIR = $(shell mktemp -d)
|
_TEMP_DIR = $(shell mktemp -d)
|
||||||
_TEMPLATE_VARS = ARCH IMAGE_NAME IMAGE_REPO _IMAGE_REPO_DOUBLE_ESCAPED _IMAGE_REPO_ESCAPED IMAGE_TAG REPOS _RHEL VARIANT VERSION WEB_UI
|
_TEMPLATE_VARS = ARCH _BASE_DIR IMAGE_NAME IMAGE_REPO _IMAGE_REPO_DOUBLE_ESCAPED _IMAGE_REPO_ESCAPED IMAGE_TAG REPOS _RHEL VARIANT VERSION WEB_UI
|
||||||
_VOLID = $(firstword $(subst -, ,$(IMAGE_NAME)))-$(ARCH)-$(IMAGE_TAG)
|
_VOLID = $(firstword $(subst -, ,$(IMAGE_NAME)))-$(ARCH)-$(IMAGE_TAG)
|
||||||
|
|
||||||
ifeq ($(findstring redhat.repo,$(REPOS)),redhat.repo)
|
ifeq ($(findstring redhat.repo,$(REPOS)),redhat.repo)
|
||||||
|
|
@ -136,11 +138,7 @@ external/lorax/branch-$(VERSION):
|
||||||
|
|
||||||
# Step 1: Generate Lorax Templates
|
# Step 1: Generate Lorax Templates
|
||||||
lorax_templates/post_%.tmpl: lorax_templates/scripts/post/%
|
lorax_templates/post_%.tmpl: lorax_templates/scripts/post/%
|
||||||
# Support interactive-defaults.ks
|
$(call convert_post_to_tmpl,$*,usr/share/anaconda/post-scripts/$*.ks,true)
|
||||||
([ ${_RHEL} == false ] && [ $(VERSION) -le 38 ]) && ($(call convert_post_to_tmpl,$*,usr/share/anaconda/interactive-defaults.ks,true)) || true
|
|
||||||
|
|
||||||
# Support new Anaconda method
|
|
||||||
([ ${_RHEL} == true ] || [ $(VERSION) -ge 39 ]) && ($(call convert_post_to_tmpl,$*,usr/share/anaconda/post-scripts/$*.sh,true)) || true
|
|
||||||
|
|
||||||
repos: $(_REPO_FILES)
|
repos: $(_REPO_FILES)
|
||||||
|
|
||||||
|
|
@ -209,7 +207,13 @@ clean:
|
||||||
rm -f $(_BASE_DIR)/*.log || true
|
rm -f $(_BASE_DIR)/*.log || true
|
||||||
|
|
||||||
install-deps:
|
install-deps:
|
||||||
dnf install -y lorax xorriso skopeo flatpak dbus-daemon ostree coreutils gettext git
|
if [ "$(PACKAGE_MANAGER)" =~ apt.* ]; then $(PACKAGE_MANAGER) update; fi
|
||||||
|
$(PACKAGE_MANAGER) install -y lorax xorriso skopeo flatpak dbus-daemon ostree coreutils gettext git
|
||||||
|
|
||||||
|
install-test-deps:
|
||||||
|
if [ "$(PACKAGE_MANAGER)" =~ apt.* ]; then $(PACKAGE_MANAGER) update; fi
|
||||||
|
$(PACKAGE_MANAGER) install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat socat jq isomd5sum ansible make coreutils squashfs-tools
|
||||||
|
|
||||||
|
|
||||||
test: test-iso test-vm
|
test: test-iso test-vm
|
||||||
|
|
||||||
|
|
@ -217,8 +221,6 @@ test-iso:
|
||||||
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/iso)))
|
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/iso)))
|
||||||
$(eval _VARS = VERSION FLATPAK_REMOTE_NAME _FLATPAK_REPO_URL)
|
$(eval _VARS = VERSION FLATPAK_REMOTE_NAME _FLATPAK_REPO_URL)
|
||||||
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y squashfs-tools
|
|
||||||
sudo modprobe loop
|
sudo modprobe loop
|
||||||
sudo mkdir /mnt/iso /mnt/install
|
sudo mkdir /mnt/iso /mnt/install
|
||||||
sudo mount -o loop deploy.iso /mnt/iso
|
sudo mount -o loop deploy.iso /mnt/iso
|
||||||
|
|
@ -245,9 +247,21 @@ test-iso:
|
||||||
sudo umount /mnt/install
|
sudo umount /mnt/install
|
||||||
sudo umount /mnt/iso
|
sudo umount /mnt/iso
|
||||||
|
|
||||||
test-vm:
|
ansible_inventory:
|
||||||
|
echo "ungrouped:" > ansible_inventory
|
||||||
|
echo " hosts:" >> ansible_inventory
|
||||||
|
echo " vm:" >> ansible_inventory
|
||||||
|
echo " ansible_host: ${VM_IP}" >> ansible_inventory
|
||||||
|
echo " ansible_port: ${VM_PORT}" >> ansible_inventory
|
||||||
|
echo " ansible_user: ${VM_USER}" >> ansible_inventory
|
||||||
|
echo " ansible_password: ${VM_PASS}" >> ansible_inventory
|
||||||
|
echo " ansible_become_pass: ${VM_PASS}" >> ansible_inventory
|
||||||
|
echo " ansible_ssh_common_args: '-o StrictHostKeyChecking=no'" >> ansible_inventory
|
||||||
|
|
||||||
|
test-vm: ansible_inventory
|
||||||
|
ansible -i ansible_inventory -m ansible.builtin.wait_for_connection vm
|
||||||
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/vm)))
|
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/vm)))
|
||||||
chmod +x $(foreach test,$(_TESTS),tests/vm/$(test))
|
chmod +x $(foreach test,$(_TESTS),tests/vm/$(test))
|
||||||
for test in $(_TESTS); do ./tests/vm/$${test} deploy.iso; done
|
for test in $(_TESTS); do ./tests/vm/$${test}; done
|
||||||
|
|
||||||
.PHONY: clean install-deps test test-iso test-vm
|
.PHONY: clean install-deps install-test-deps test test-iso test-vm
|
||||||
|
|
|
||||||
36
README.md
36
README.md
|
|
@ -38,24 +38,24 @@ See [Customizing](#customizing) for information about customizing the ISO that g
|
||||||
The following variables can be used to customize the created ISO.
|
The following variables can be used to customize the created ISO.
|
||||||
|
|
||||||
### Inputs
|
### Inputs
|
||||||
| Variable | Description | Default Value |
|
| Variable | Description | Default Value | Action | Container | Makefile |
|
||||||
| ---------------------- | ---------------------------------------------------------------------------- | -------------------------------------------- |
|
| ----------------------- | ---------------------------------------------------------------------------- | -------------------------------------------- | ------------------ | ------------------ | ------------------ |
|
||||||
| additional_templates | Space delimited list of additional Lorax templates to include | \[empty\] |
|
| 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 |
|
| 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 |
|
| 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\] |
|
| 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 |
|
| 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\] |
|
| 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\] |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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* |
|
| 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 |
|
| iso_name | Name of the ISO you wish to output when completed | build/deploy.iso | :white_check_mark: | :x: | :x: |
|
||||||
| secure_boot_key_url | Secure boot key that is installed from URL location\*\* | \[empty\] |
|
| 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 |
|
| variant | Source container variant\* | Server | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| version | Fedora version of installer to build | 39 |
|
| version | Fedora version of installer to build | 39 | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| web_ui | Enable Anaconda WebUI (experimental) | false |
|
| web_ui | Enable Anaconda WebUI (experimental) | false | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
|
|
||||||
\*Available options for VARIANT can be found by running `dnf provides system-release`.
|
\*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
|
Variant will be the third item in the package name. Example: `fedora-release-kinoite-39-34.noarch` will be kinoite
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
# Verifies that the GPG key is functional
|
||||||
- name: Test updating flatpak packages
|
- name: Test updating flatpak packages
|
||||||
|
become: true
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: /usr/bin/flatpak update -y
|
cmd: /usr/bin/flatpak update -y --noninteractive
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue