1
0
Fork 0
mirror of https://github.com/JasonN3/build-container-installer.git synced 2025-12-25 10:57:55 +01:00

Merge branch 'main' into test_qemu

This commit is contained in:
Jason N 2024-02-28 16:41:08 -05:00 committed by GitHub
commit 8af60fb525
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 105 additions and 108 deletions

View file

@ -4,7 +4,7 @@
"name": "Existing Dockerfile", "name": "Existing Dockerfile",
// "build": { // "build": {
// "context": "..", // "context": "..",
// "dockerfile": "../Dockerfile", // "dockerfile": "../Containerfile",
// "args": { // "args": {
// "version": "39" // "version": "39"
// } // }
@ -14,3 +14,4 @@
"shutdownAction": "stopContainer", "shutdownAction": "stopContainer",
"privileged": true "privileged": true
} }

View file

@ -124,7 +124,7 @@ jobs:
image_repo: ${{ env.IMAGE_REPO}} image_repo: ${{ env.IMAGE_REPO}}
version: ${{ env.VERSION }} version: ${{ env.VERSION }}
variant: ${{ env.VARIANT }} variant: ${{ env.VARIANT }}
action_version: ${{ steps.meta.outputs.tags }} action_version: ${{ steps.meta.outputs.tags || 'latest' }}
- name: Rename ISO - name: Rename ISO
run: | run: |

View file

@ -1,34 +0,0 @@
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Create Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: "Release ${{ github.ref_name }}"
draft: true
prerelease: false
#- uses: actions/upload-release-asset@v1.0.1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./my-artifact.zip
# asset_name: my-artifact.zip
# asset_content_type: application/zip
- uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}

2
.gitignore vendored
View file

@ -1,6 +1,7 @@
/debugdata /debugdata
/build /build
/pkglists /pkglists
/repos
/results /results
/lorax_templates/*.tmpl /lorax_templates/*.tmpl
/xorriso/input.txt /xorriso/input.txt
@ -10,3 +11,4 @@
/lorax.conf /lorax.conf
/output /output
/*.log /*.log

View file

@ -23,3 +23,4 @@ RUN dnf install -y make && make install-deps
VOLUME /build-container-installer/build VOLUME /build-container-installer/build
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]

View file

@ -9,6 +9,7 @@ VARIANT = Server
WEB_UI = false WEB_UI = false
REPOS = /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora-updates.repo REPOS = /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora-updates.repo
ADDITIONAL_TEMPLATES = "" ADDITIONAL_TEMPLATES = ""
ROOTFS_SIZE = 4
# Generated vars # Generated vars
## Formatting = _UPPERCASE ## Formatting = _UPPERCASE
@ -16,9 +17,10 @@ _BASE_DIR = $(shell pwd)
_IMAGE_REPO_ESCAPED = $(subst /,\/,$(IMAGE_REPO)) _IMAGE_REPO_ESCAPED = $(subst /,\/,$(IMAGE_REPO))
_IMAGE_REPO_DOUBLE_ESCAPED = $(subst \,\\\,$(_IMAGE_REPO_ESCAPED)) _IMAGE_REPO_DOUBLE_ESCAPED = $(subst \,\\\,$(_IMAGE_REPO_ESCAPED))
_VOLID = $(firstword $(subst -, ,$(IMAGE_NAME)))-$(ARCH)-$(IMAGE_TAG) _VOLID = $(firstword $(subst -, ,$(IMAGE_NAME)))-$(ARCH)-$(IMAGE_TAG)
_REPO_FILES = $(notdir $(REPOS)) _REPO_FILES = $(subst /etc/yum.repos.d,repos,$(REPOS))
_LORAX_TEMPLATES = $(subst .in,,$(shell ls lorax_templates/*.tmpl.in))
ifeq ($(VARIANT),'Server') ifeq ($(VARIANT),Server)
_LORAX_ARGS = --macboot --noupgrade _LORAX_ARGS = --macboot --noupgrade
else else
_LORAX_ARGS = --nomacboot _LORAX_ARGS = --nomacboot
@ -33,33 +35,35 @@ endif
build/deploy.iso: boot.iso container/$(IMAGE_NAME)-$(IMAGE_TAG) xorriso/input.txt build/deploy.iso: boot.iso container/$(IMAGE_NAME)-$(IMAGE_TAG) xorriso/input.txt
mkdir $(_BASE_DIR)/build || true mkdir $(_BASE_DIR)/build || true
xorriso -dialog on < $(_BASE_DIR)/xorriso/input.txt xorriso -dialog on < $(_BASE_DIR)/xorriso/input.txt
implantisomd5 build/deploy.iso
# Step 1: Generate Lorax Templates # Step 1: Generate Lorax Templates
lorax_templates/%.tmpl: lorax_templates/%.tmpl.in lorax_templates/%.tmpl: lorax_templates/%.tmpl.in
sed 's/@IMAGE_NAME@/$(IMAGE_NAME)/' $(_BASE_DIR)/lorax_templates/$*.tmpl.in > $(_BASE_DIR)/lorax_templates/$*.tmpl $(eval _VARS = IMAGE_NAME IMAGE_TAG _IMAGE_REPO_DOUBLE_ESCAPED)
$(foreach var,$(_VARS),$(var)=$($(var))) envsubst '$(foreach var,$(_VARS),$$$(var))' < $(_BASE_DIR)/lorax_templates/$*.tmpl.in > $(_BASE_DIR)/lorax_templates/$*.tmpl
sed 's/@IMAGE_TAG@/$(IMAGE_TAG)/' $(_BASE_DIR)/lorax_templates/$*.tmpl > $(_BASE_DIR)/lorax_templates/$*.tmpl.tmp
mv $(_BASE_DIR)/lorax_templates/$*.tmpl{.tmp,}
sed 's/@IMAGE_REPO_ESCAPED@/$(_IMAGE_REPO_DOUBLE_ESCAPED)/' $(_BASE_DIR)/lorax_templates/$*.tmpl > $(_BASE_DIR)/lorax_templates/$*.tmpl.tmp
mv $(_BASE_DIR)/lorax_templates/$*.tmpl{.tmp,}
# Step 2: Replace vars in repo files # Step 2: Replace vars in repo files
%.repo: /etc/yum.repos.d/%.repo repos/%.repo: /etc/yum.repos.d/%.repo
cp /etc/yum.repos.d/$*.repo $(_BASE_DIR)/$*.repo mkdir repos || true
sed -i "s/\$$releasever/${VERSION}/g" $(_BASE_DIR)/$*.repo cp /etc/yum.repos.d/$*.repo $(_BASE_DIR)/repos/$*.repo
sed -i "s/\$$basearch/${ARCH}/g" $(_BASE_DIR)/$*.repo sed -i "s/\$$releasever/${VERSION}/g" $(_BASE_DIR)/repos/$*.repo
sed -i "s/\$$basearch/${ARCH}/g" $(_BASE_DIR)/repos/$*.repo
# Don't do anything for custom repos
%.repo:
# Step 3: Build boot.iso using Lorax # Step 3: Build boot.iso using Lorax
boot.iso: lorax_templates/set_installer.tmpl lorax_templates/configure_upgrades.tmpl $(_REPO_FILES) boot.iso: $(_LORAX_TEMPLATES) $(_REPO_FILES)
rm -Rf $(_BASE_DIR)/results rm -Rf $(_BASE_DIR)/results || true
rm /etc/rpm/macros.image-language-conf || true
lorax -p $(IMAGE_NAME) -v $(VERSION) -r $(VERSION) -t $(VARIANT) \ lorax -p $(IMAGE_NAME) -v $(VERSION) -r $(VERSION) -t $(VARIANT) \
--isfinal --buildarch=$(ARCH) --volid=$(_VOLID) \ --isfinal --squashfs-only --buildarch=$(ARCH) --volid=$(_VOLID) \
$(_LORAX_ARGS) \ $(_LORAX_ARGS) \
$(foreach file,$(_REPO_FILES),--repo $(_BASE_DIR)/$(file)) \ $(foreach file,$(_REPO_FILES),--repo $(_BASE_DIR)/$(file)) \
--add-template $(_BASE_DIR)/lorax_templates/set_installer.tmpl \ $(foreach file,$(_LORAX_TEMPLATES),--add-template $(_BASE_DIR)/$(file)) \
--add-template $(_BASE_DIR)/lorax_templates/configure_upgrades.tmpl \
$(foreach file,$(ADDITIONAL_TEMPLATES),--add-template $(file)) \ $(foreach file,$(ADDITIONAL_TEMPLATES),--add-template $(file)) \
--rootfs-size $(ROOTFS_SIZE) \
$(_BASE_DIR)/results/ $(_BASE_DIR)/results/
mv $(_BASE_DIR)/results/images/boot.iso $(_BASE_DIR)/ mv $(_BASE_DIR)/results/images/boot.iso $(_BASE_DIR)/
@ -72,13 +76,8 @@ container/$(IMAGE_NAME)-$(IMAGE_TAG):
# Step 5: Generate xorriso script # Step 5: Generate xorriso script
xorriso/%.sh: xorriso/%.sh.in xorriso/%.sh: xorriso/%.sh.in
sed 's/@IMAGE_NAME@/$(IMAGE_NAME)/' $(_BASE_DIR)/xorriso/$*.sh.in > $(_BASE_DIR)/xorriso/$*.sh $(eval _VARS = IMAGE_NAME IMAGE_TAG ARCH VERSION)
$(foreach var,$(_VARS),$(var)=$($(var))) envsubst '$(foreach var,$(_VARS),$$$(var))' < $(_BASE_DIR)/xorriso/$*.sh.in > $(_BASE_DIR)/xorriso/$*.sh
sed 's/@IMAGE_TAG@/$(IMAGE_TAG)/' $(_BASE_DIR)/xorriso/$*.sh > $(_BASE_DIR)/xorriso/$*.sh.tmp
mv $(_BASE_DIR)/xorriso/$*.sh{.tmp,}
sed 's/@ARCH@/$(ARCH)/' $(_BASE_DIR)/xorriso/$*.sh > $(_BASE_DIR)/xorriso/$*.sh.tmp
mv $(_BASE_DIR)/xorriso/$*.sh{.tmp,}
# Step 6: Generate xorriso input # Step 6: Generate xorriso input
xorriso/input.txt: xorriso/gen_input.sh xorriso/input.txt: xorriso/gen_input.sh
@ -86,11 +85,12 @@ xorriso/input.txt: xorriso/gen_input.sh
clean: clean:
rm -Rf $(_BASE_DIR)/build || true
rm -Rf $(_BASE_DIR)/container || true rm -Rf $(_BASE_DIR)/container || true
rm -Rf $(_BASE_DIR)/debugdata || true rm -Rf $(_BASE_DIR)/debugdata || true
rm -Rf $(_BASE_DIR)/pkglists || true rm -Rf $(_BASE_DIR)/pkglists || true
rm -Rf $(_BASE_DIR)/repos || true
rm -Rf $(_BASE_DIR)/results || true rm -Rf $(_BASE_DIR)/results || true
rm -Rf $(_BASE_DIR)/build || true
rm -f $(_BASE_DIR)/lorax_templates/*.tmpl || true rm -f $(_BASE_DIR)/lorax_templates/*.tmpl || true
rm -f $(_BASE_DIR)/xorriso/input.txt || true rm -f $(_BASE_DIR)/xorriso/input.txt || true
rm -f $(_BASE_DIR)/xorriso/*.sh || true rm -f $(_BASE_DIR)/xorriso/*.sh || true
@ -103,3 +103,4 @@ install-deps:
dnf install -y lorax xorriso podman dnf install -y lorax xorriso podman
.PHONY: clean install-deps .PHONY: clean install-deps

View file

@ -1,35 +1,26 @@
![Build status](https://github.com/jasonn3/build-container-installer/actions/workflows/build-and-test.yml/badge.svg??event=push) ![Build status](https://github.com/jasonn3/build-container-installer/actions/workflows/build-and-test.yml/badge.svg??event=push)
# Bulid Container Installer Action # Build Container Installer Action
This action is used to generate an ISO for installing OSTrees stored in a container. This utilizes the anaconda command `ostreecontainer` This action is used to enerate an ISO for installing an OSTree stored in a container image. This utilizes the anaconda command `ostreecontainer`
## Makefile ## Usage
A Makefile is provided for ease of use. There are separate targets for each file generated, however `make` can be used to generate the final image and `make clean` can be used to clean up the workspace. The resulting ISO will be stored in the `build` directory. This action is designed to be called from a GitHub workflow using the following format
```yaml
See [Customizing](#customizing) for information about customizing the image that gets created. - name: Build ISO
uses: jasonn3/build-container-installer/v1.0.0
## Container with:
A container with the necessary tools already installed is provided at `ghcr.io/jasonn3/build-container-installer:latest` arch: ${{ env.ARCH}}
image_name: ${{ env.IMAGE_NAME}}
To use the container file, run `docker run --privileged --volume .:/build-container-installer/build ghcr.io/jasonn3/build-container-installer:latest`. image_repo: ${{ env.IMAGE_REPO}}
version: ${{ env.VERSION }}
This will create an ISO with the baked in defaults of the container image. variant: ${{ env.VARIANT }}
action_version: v1.0.0
See [Customizing](#customizing) for information about customizing the image that gets created. The variable can either be defined as environment variables or as command arguments.
Examples:
Building an ISO to install Fedora 38
```bash
docker run --rm --privileged --volume .:/build-container-installer/build -e VERSION=38 -e IMAGE_NAME=base -e IMAGE_TAG=38 -e VARIANT=Server ghcr.io/jasonn3/build-container-installer:latest
``` ```
Building an ISO to install Fedora 39 See [Customizing](#customizing) for information about customizing the ISO that gets created using `with`
```bash
docker run --rm --privileged --volume .:/build-container-installer/build -e VERSION=39 -e IMAGE_NAME=base -e IMAGE_TAG=39 -e VARIANT=Server ghcr.io/jasonn3/build-container-installer:latest
```
## Customizing ## Customizing
The following variables can be used to customize the create image. The following variables can be used to customize the created ISO.
| Variable | Description | Default Value | | Variable | Description | Default Value |
| ----------------- | -------------------------------------------------------- | ------------------------------ | | ----------------- | -------------------------------------------------------- | ------------------------------ |
@ -45,20 +36,48 @@ The following variables can be used to customize the create image.
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
## VSCode Dev Container ## Development
### Makefile
The Makefile contains all of the commands that are run in the action. There are separate targets for each file generated, however `make` can be used to generate the final image and `make clean` can be used to clean up the workspace. The resulting ISO will be stored in the `build` directory.
`make install-deps` can be used to install the necessary packages
See [Customizing](#customizing) for information about customizing the ISO that gets created.
### Container
A container with `make install-deps` already run is provided at `ghcr.io/jasonn3/build-container-installer:latest`
To use the container file, run `docker run --privileged --volume .:/build-container-installer/build ghcr.io/jasonn3/build-container-installer:latest`.
This will create an ISO with the baked in defaults of the container image.
See [Customizing](#customizing) for information about customizing the ISO that gets created. The variable can either be defined as environment variables.
Examples:
Building an ISO to install Fedora 38
```bash
docker run --rm --privileged --volume .:/build-container-installer/build -e VERSION=38 -e IMAGE_NAME=base -e IMAGE_TAG=38 -e VARIANT=Server ghcr.io/jasonn3/build-container-installer:latest
```
Building an ISO to install Fedora 39
```bash
docker run --rm --privileged --volume .:/build-container-installer/build -e VERSION=39 -e IMAGE_NAME=base -e IMAGE_TAG=39 -e VARIANT=Server ghcr.io/jasonn3/build-container-installer:latest
```
### VSCode Dev Container
There is a dev container configuration provided for development. By default it will use the existing container image available at `ghcr.io/jasonn3/build-container-installer:latest`, however, you can have it build a new image by editing `.devcontainer/devcontainer.json` and replacing `image` with `build`. `Ctrl+/` can be used to comment and uncomment blocks of code within VSCode. There is a dev container configuration provided for development. By default it will use the existing container image available at `ghcr.io/jasonn3/build-container-installer:latest`, however, you can have it build a new image by editing `.devcontainer/devcontainer.json` and replacing `image` with `build`. `Ctrl+/` can be used to comment and uncomment blocks of code within VSCode.
The code from VSCode will be available at `/workspaces/build-container-installer` once the container has started. The code from VSCode will be available at `/workspaces/build-container-installer` once the container has started.
Privileged is required for access to loop devices for lorax. Privileged is required for access to loop devices for lorax.
Use existing image Use existing container image:
```json ```
{ {
"name": "Existing Dockerfile", "name": "Existing Dockerfile",
// "build": { // "build": {
// "context": "..", // "context": "..",
// "dockerfile": "../Dockerfile", // "dockerfile": "../Containerfile",
// "args": { // "args": {
// "version": "39" // "version": "39"
// } // }
@ -70,13 +89,13 @@ Use existing image
} }
``` ```
Build a new image Build a new container image:
```json ```
{ {
"name": "Existing Dockerfile", "name": "Existing Dockerfile",
"build": { "build": {
"context": "..", "context": "..",
"dockerfile": "../Dockerfile", "dockerfile": "../Containerfile",
"args": { "args": {
"version": "39" "version": "39"
} }
@ -87,3 +106,4 @@ Build a new image
"privileged": true "privileged": true
} }
``` ```

View file

@ -1,5 +1,5 @@
name: Build Contianer Installer name: Build Container Installer
description: generate an ISO for installing OSTrees stored in a container description: Generates an ISO for installing an OSTree stored in a container image
inputs: inputs:
arch: arch:
@ -52,3 +52,4 @@ runs:
IMAGE_TAG=${{ inputs.image_tag || inputs.version }} \ IMAGE_TAG=${{ inputs.image_tag || inputs.version }} \
WEB_UI=${{ inputs.web_ui }} \ WEB_UI=${{ inputs.web_ui }} \
"ADDITIONAL_TEMPLATES=${{ inputs.additional_templates }}" "ADDITIONAL_TEMPLATES=${{ inputs.additional_templates }}"

View file

@ -22,3 +22,4 @@ mkdir /github/workspace/build || true
# Copy resulting iso to github workspace and fix permissions # Copy resulting iso to github workspace and fix permissions
cp build/deploy.iso /github/workspace/build cp build/deploy.iso /github/workspace/build
chmod -R ugo=rwX /github/workspace/build chmod -R ugo=rwX /github/workspace/build

View file

@ -1,7 +1,8 @@
append usr/share/anaconda/interactive-defaults.ks "%post --erroronfail" append usr/share/anaconda/interactive-defaults.ks "%post --erroronfail"
append usr/share/anaconda/interactive-defaults.ks "sed -i 's/container-image-reference=.*/container-image-reference=ostree-image-signed:docker:\/\/@IMAGE_REPO_ESCAPED@\/@IMAGE_NAME@:@IMAGE_TAG@/' /ostree/deploy/default/deploy/*.origin" append usr/share/anaconda/interactive-defaults.ks "sed -i 's/container-image-reference=.*/container-image-reference=ostree-image-signed:docker:\/\/${_IMAGE_REPO_DOUBLE_ESCAPED}\/${IMAGE_NAME}:${IMAGE_TAG}/' /ostree/deploy/default/deploy/*.origin"
append usr/share/anaconda/interactive-defaults.ks "%end" append usr/share/anaconda/interactive-defaults.ks "%end"
append usr/share/anaconda/post-scripts/configure_upgrades.ks "%post --erroronfail" append usr/share/anaconda/post-scripts/configure_upgrades.ks "%post --erroronfail"
append usr/share/anaconda/post-scripts/configure_upgrades.ks "sed -i 's/container-image-reference=.*/container-image-reference=ostree-image-signed:docker:\/\/@IMAGE_REPO_ESCAPED@\/@IMAGE_NAME@:@IMAGE_TAG@/' /ostree/deploy/default/deploy/*.origin" append usr/share/anaconda/post-scripts/configure_upgrades.ks "sed -i 's/container-image-reference=.*/container-image-reference=ostree-image-signed:docker:\/\/${_IMAGE_REPO_DOUBLE_ESCAPED}\/${IMAGE_NAME}:${IMAGE_TAG}/' /ostree/deploy/default/deploy/*.origin"
append usr/share/anaconda/post-scripts/configure_upgrades.ks "%end" append usr/share/anaconda/post-scripts/configure_upgrades.ks "%end"

View file

@ -1 +1,2 @@
append usr/share/anaconda/interactive-defaults.ks "ostreecontainer --url=/run/install/repo/@IMAGE_NAME@-@VERSION@ --transport=oci --no-signature-verification" append usr/share/anaconda/interactive-defaults.ks "ostreecontainer --url=/run/install/repo/${IMAGE_NAME}-${IMAGE_TAG} --transport=oci --no-signature-verification"

View file

@ -5,10 +5,12 @@ echo "-outdev $(pwd)/build/deploy.iso"
echo "-boot_image any replay" echo "-boot_image any replay"
echo "-joliet on" echo "-joliet on"
echo "-compliance joliet_long_names" echo "-compliance joliet_long_names"
cd container pushd container > /dev/null
for file in $(find @IMAGE_NAME@-@IMAGE_TAG@) for file in $(find ${IMAGE_NAME}-${IMAGE_TAG})
do do
echo "-map $(pwd)/${file} ${file}" echo "-map $(pwd)/${file} ${file}"
echo "-chmod 0444 ${file}" echo "-chmod 0444 ${file}"
done done
popd > /dev/null
echo "-end" echo "-end"