general fixes

This commit is contained in:
Jason N. 2024-02-16 23:40:48 +00:00
parent 70bc2264ba
commit c48c28120b
13 changed files with 357 additions and 173 deletions

View File

@ -0,0 +1,16 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
// "build": {
// "context": "..",
// "dockerfile": "../Containerfile",
// "args": {
// "version": "39"
// }
// },
"image": "ghcr.io/ublue-os/isogenerator:latest",
"overrideCommand": true,
"shutdownAction": "stopContainer",
"privileged": true
}

View File

@ -1,5 +1,5 @@
---
name: isogenerator-image
name: Create Container
on:
pull_request:
branches:
@ -21,15 +21,9 @@ jobs:
push-image:
name: Build and push image
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
steps:
# Checkout push-to-registry action GitHub repository
- name: Checkout Push to Registry action

View File

@ -1,87 +0,0 @@
name: Create and publish an ISO
on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
workflow_dispatch:
workflow_call:
inputs:
ARCH:
required: true
type: string
IMAGE_NAME:
required: true
type: string
IMAGE_REPO:
required: true
type: string
IMAGE_TAG:
required: true
type: string
VARIANT:
required: true
type: string
VERSION:
required: true
type: string
WEB_UI:
required: true
type: string
BUILD_REPO:
required: false
type: string
default: ublue-os/isogenerator
BUILD_REF:
required: false
type: string
default: main
env:
ARCH: ${{ inputs.ARCH || 'x86_64' }}
IMAGE_NAME: ${{ inputs.IMAGE_NAME || 'base-main' }}
IMAGE_REPO: ${{ inputs.IMAGE_REPO || 'ghcr.io/ublue-os' }}
IMAGE_TAG: ${{ inputs.IMAGE_TAG || 'latest' }}
VARIANT: ${{ inputs.VARIANT || 'Kinoite' }}
VERSION: ${{ inputs.VERSION || '39' }}
WEB_UI: ${{ inputs.WEB_UI || 'false' }}
CURR_REPO: ${{ inputs.BUILD_REPO || github.repository }}
CURR_REF: ${{ inputs.BUILD_REF || github.ref }}
jobs:
build-and-push-iso:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Build ISO
shell: bash
run: |
set -eo pipefail
mkdir -p output
docker run \
--rm --privileged \
-v ./output:/isogenerator/output \
-e ARCH="${{ env.ARCH }}" \
-e IMAGE_NAME="${{ env.IMAGE_NAME }}" \
-e IMAGE_REPO="${{ env.IMAGE_REPO }}" \
-e IMAGE_TAG="${{ env.IMAGE_TAG }}" \
-e VARIANT="${{ env.VARIANT }}" \
-e VERSION="${{ env.VERSION }}" \
-e WEB_UI="${{ env.WEB_UI }}" \
ghcr.io/ublue-os/isogenerator:latest
- name: Upload ISO as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.IMAGE_NAME }}-${{ env.IMAGE_TAG }}.iso
path: output/*.iso
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true

43
.github/workflows/test-iso.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Test Generate ISO
on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
env:
ARCH: ${{ inputs.ARCH || 'x86_64' }}
IMAGE_NAME: ${{ inputs.IMAGE_NAME || 'base-main' }}
IMAGE_REPO: ${{ inputs.IMAGE_REPO || 'ghcr.io/ublue-os' }}
IMAGE_TAG: ${{ inputs.IMAGE_TAG || 'latest' }}
VARIANT: ${{ inputs.VARIANT || 'Kinoite' }}
VERSION: ${{ inputs.VERSION || '39' }}
WEB_UI: ${{ inputs.WEB_UI || 'false' }}
CURR_REPO: ${{ inputs.BUILD_REPO || github.repository }}
CURR_REF: ${{ inputs.BUILD_REF || github.ref }}
jobs:
build-and-push-iso:
runs-on: ubuntu-latest
container:
image: fedora:39
options: "--privileged"
permissions:
contents: read
packages: write
steps:
- name: Build ISO
uses: ublue-os/isogenerator
with:
ARCH: 'x86_64'
IMAGE_NAME: 'base-main'
IMAGE_REPO: 'ghcr.io/ublue-os'
IMAGE_TAG: 'latest'
VARIANT: 'Kinoite'
VERSION: '39'
WEB_UI: 'false'
CURR_REPO: ${{ github.repository }}
CURR_REF: ${{ github.ref }}

2
.gitignore vendored
View File

@ -8,5 +8,5 @@
/original-pkgsizes.txt
/final-pkgsizes.txt
/lorax.conf
/*.iso
/output
/*.log

2
CODEOWNERS Normal file
View File

@ -0,0 +1,2 @@
# Default owner of code within this repo
* @JasonN3

21
Containerfile Normal file
View File

@ -0,0 +1,21 @@
ARG version=39
FROM fedora:${version}
ENV ARCH="x86_64"
ENV IMAGE_NAME="base-main"
ENV IMAGE_REPO="ghcr.io/ublue-os"
ENV IMAGE_TAG="${version}"
ENV VARIANT="Kinoite"
ENV VERSION="${version}"
ENV WEB_UI="false"
COPY / /isogenerator
WORKDIR /isogenerator
RUN dnf install -y make && make install-deps
VOLUME /isogenerator/output
ENTRYPOINT ["make" ]
CMD [ "ARCH=${ARCH}", "VERSION=${VERSION}", "IMAGE_REPO=${IMAGE_REPO}", "IMAGE_NAME=${IMAGE_NAME}", "IMAGE_TAG=${IMAGE_TAG}", "VARIANT=${VARIANT}", "WEB_UI=${WEB_UI}"]

View File

@ -1,18 +0,0 @@
FROM fedora:latest
ENV ARCH="x86_64"
ENV IMAGE_NAME="base-main"
ENV IMAGE_REPO="ghcr.io/ublue-os"
ENV IMAGE_TAG="$(version)"
ENV VARIANT="Kinoite"
ENV VERSION="39"
ENV WEB_UI="false"
WORKDIR /isogenerator
RUN dnf install -y make git && \
git clone https://github.com/ublue-os/isogenerator.git . && \
make install-deps
ENTRYPOINT ["make", "arch=${ARCH}", "version=${VERSION}", "image_repo=${IMAGE_REPO}", "image_name=${IMAGE_NAME}", "image_tag=${IMAGE_TAG}", "variant=${VARIANT}", "web_ui=${WEB_UI}"]

122
Makefile
View File

@ -1,85 +1,97 @@
arch = x86_64
version = 39
base_dir = $(shell pwd)
image_repo = ghcr.io/ublue-os
image_name = base-main
image_tag = $(version)
variant = Silverblue
web_ui = false
# Configuration vars
## Formatting = UPPERCASE
ARCH = x86_64
VERSION = 39
IMAGE_REPO = ghcr.io/ublue-os
IMAGE_NAME = base-main
IMAGE_TAG = $(version)
VARIANT = Silverblue
WEB_UI = false
image_repo_escaped = $(subst /,\/,$(image_repo))
image_repo_double_escaped = $(subst \,\\\,$(image_repo_escaped))
# Generated vars
## Formatting = _UPPERCASE
_BASE_DIR = $(shell pwd)
_IMAGE_REPO_ESCAPED = $(subst /,\/,$(IMAGE_REPO))
_IMAGE_REPO_DOUBLE_ESCAPED = $(subst \,\\\,$(_IMAGE_REPO_ESCAPED))
ifeq ($(variant),'Server')
lorax_args = --macboot --noupgrade
ifeq ($(VARIANT),'Server')
_LORAX_ARGS = --macboot --noupgrade
else
lorax_args = --nomacboot
_LORAX_ARGS = --nomacboot
endif
ifeq ($(web_ui),true)
lorax_args += -i anaconda-webui
ifeq ($(WEB_UI),true)
_LORAX_ARGS += -i anaconda-webui
endif
$(image_name)-$(version).iso: boot.iso container/$(image_name)-$(image_tag) xorriso/input.txt
xorriso -dialog on < $(base_dir)/xorriso/input.txt
# Step 6: Build end ISO file
## Default action
$(IMAGE_NAME)-$(IMAGE_TAG).iso: boot.iso container/$(IMAGE_NAME)-$(IMAGE_TAG) xorriso/input.txt
mkdir $(_BASE_DIR)/output
xorriso -dialog on < $(_BASE_DIR)/xorriso/input.txt
# Step 2: Build boot.iso using Lorax
boot.iso: lorax_templates/set_installer.tmpl lorax_templates/configure_upgrades.tmpl
rm -Rf $(base_dir)/results
lorax -p $(image_name) -v $(version) -r $(version) -t $(variant) \
--isfinal --buildarch=$(arch) --volid=$(image_name)-$(arch)-$(version) \
$(lorax_args) \
rm -Rf $(_BASE_DIR)/results
lorax -p $(IMAGE_NAME) -v $(VERSION) -r $(VERSION) -t $(VARIANT) \
--isfinal --buildarch=$(ARCH) --volid=$(IMAGE_NAME)-$(ARCH)-$(VERSION) \
$(_LORAX_ARGS) \
--repo /etc/yum.repos.d/fedora.repo \
--repo /etc/yum.repos.d/fedora-updates.repo \
--add-template $(base_dir)/lorax_templates/set_installer.tmpl \
--add-template $(base_dir)/lorax_templates/configure_upgrades.tmpl \
$(base_dir)/results/
mv $(base_dir)/results/images/boot.iso $(base_dir)/
--add-template $(_BASE_DIR)/lorax_templates/set_installer.tmpl \
--add-template $(_BASE_DIR)/lorax_templates/configure_upgrades.tmpl \
$(_BASE_DIR)/results/
mv $(_BASE_DIR)/results/images/boot.iso $(_BASE_DIR)/
container/$(image_name)-$(image_tag):
# Step 3: Download container image
container/$(IMAGE_NAME)-$(IMAGE_TAG):
mkdir container
podman pull $(image_repo)/$(image_name):$(image_tag)
podman save --format oci-dir -o $(base_dir)/container/$(image_name)-$(image_tag) $(image_repo)/$(image_name):$(image_tag)
podman rmi $(image_repo)/$(image_name):$(image_tag)
podman pull $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)
podman save --format oci-dir -o $(_BASE_DIR)/container/$(IMAGE_NAME)-$(IMAGE_TAG) $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)
podman rmi $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)
install-deps:
dnf install -y lorax xorriso podman git rpm-ostree
# Step 1: Generate Lorax Templates
lorax_templates/%.tmpl: lorax_templates/%.tmpl.in
sed 's/@IMAGE_NAME@/$(image_name)/' $(base_dir)/lorax_templates/$*.tmpl.in > $(base_dir)/lorax_templates/$*.tmpl
sed 's/@IMAGE_REPO@/$(image_repo_escaped)/' $(base_dir)/lorax_templates/$*.tmpl > $(base_dir)/lorax_templates/$*.tmpl.tmp
mv $(base_dir)/lorax_templates/$*.tmpl{.tmp,}
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,}
sed 's/@IMAGE_NAME@/$(IMAGE_NAME)/' $(_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 5: Generate xorriso input
xorriso/input.txt: xorriso/gen_input.sh
bash $(base_dir)/xorriso/gen_input.sh | tee $(base_dir)/xorriso/input.txt
bash $(_BASE_DIR)/xorriso/gen_input.sh | tee $(_BASE_DIR)/xorriso/input.txt
# Step 4: Generate xorriso script
xorriso/%.sh: xorriso/%.sh.in
sed 's/@IMAGE_NAME@/$(image_name)/' $(base_dir)/xorriso/$*.sh.in > $(base_dir)/xorriso/$*.sh.in2
sed 's/@IMAGE_TAG@/$(image_tag)/' $(base_dir)/xorriso/$*.sh.in2 > $(base_dir)/xorriso/$*.sh
sed 's/@VERSION@/$(version)/' $(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,}
sed 's/@IMAGE_NAME@/$(IMAGE_NAME)/' $(_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,}
clean:
rm -Rf $(base_dir)/container || true
rm -Rf $(base_dir)/debugdata || true
rm -Rf $(base_dir)/pkglists || true
rm -Rf $(base_dir)/results || true
rm -f $(base_dir)/lorax_templates/*.tmpl || true
rm -f $(base_dir)/xorriso/input.txt || true
rm -f $(base_dir)/xorriso/*.sh || true
rm -f $(base_dir)/{original,final}-pkgsizes.txt || true
rm -f $(base_dir)/lorax.conf || true
rm -f $(base_dir)/*.iso || true
rm -f $(base_dir)/*.log || true
rm -Rf $(_BASE_DIR)/container || true
rm -Rf $(_BASE_DIR)/debugdata || true
rm -Rf $(_BASE_DIR)/pkglists || true
rm -Rf $(_BASE_DIR)/results || true
rm -f $(_BASE_DIR)/lorax_templates/*.tmpl || true
rm -f $(_BASE_DIR)/xorriso/input.txt || true
rm -f $(_BASE_DIR)/xorriso/*.sh || true
rm -f $(_BASE_DIR)/{original,final}-pkgsizes.txt || true
rm -f $(_BASE_DIR)/lorax.conf || true
rm -f $(_BASE_DIR)/*.iso || true
rm -f $(_BASE_DIR)/*.log || true

View File

@ -1,2 +1,92 @@
# container-installer
Creates an ISO for installing a container image as an OS
# UBlueOS ISO Generator
This action is used to generate the ISO images for UBlueOS.
## Makefile
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.
See [Customizing](#customizing) for information about customizing the image that gets created.
## Container
A container with the necessary tools already installed is provided at `ghcr.io/ublue-os/isogenerator:latest`
To use the container file, run `docker --privileged --volume .:/isogenerator/output ghcr.io/ublue-os/isogenerator`
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:
Environment Variable
```bash
docker --privileged --volume .:/isogenerator/output -e VERSION=39 ghcr.io/ublue-os/isogenerator
```
Command Argument
```bash
docker --privileged --volume .:/isogenerator/output ghcr.io/ublue-os/isogenerator VERSION=39
```
## Customizing
The following variables can be used to customize the create image.
- ARCH
Architecture for image to build
Default Value: x86_64
- VERSION
Fedora version of installer to build
Default Value: 39
- IMAGE_REPO
Repository containing the source container image
Default Value: ghcr.io/ublue-os
- IMAGE_NAME
Name of the source container image
Default Value: base-main
- IMAGE_TAG
Tag of the source container image
Default Value: *VERSION*
- VARIANT
Source container variant
Silverblue
- WEB_UI
Enable Anaconda WebUI
false
## 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/ublue-os/isogenerator`, 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/isogenerator` once the container has started.
Privileged is required for access to loop devices for lorax.
Use existing image
```json
{
"name": "Existing Dockerfile",
// "build": {
// "context": "..",
// "dockerfile": "../Containerfile",
// "args": {
// "version": "39"
// }
// },
"image": "ghcr.io/ublue-os/isogenerator:latest",
"overrideCommand": true,
"shutdownAction": "stopContainer",
"privileged": true
}
```
Build a new image
```json
{
"name": "Existing Dockerfile",
"build": {
"context": "..",
"dockerfile": "../Containerfile",
"args": {
"version": "39"
}
},
//"image": "ghcr.io/ublue-os/isogenerator:latest",
"overrideCommand": true,
"shutdownAction": "stopContainer",
"privileged": true
}
```

112
action.yml Normal file
View File

@ -0,0 +1,112 @@
name: Generate ISO
description: Creates an ISO for installing an OSTree container
inputs:
ARCH:
description: Architecture for image to build
required: true
default: x86_64
IMAGE_NAME:
description: Name of the source container image
required: true
default: base-main
IMAGE_REPO:
description: Repository containing the source container image
required: true
default: ghcr.io/ublue-os
IMAGE_TAG:
description: Tag of the source container image
required: true
default: ${{ inputs.VERSION }}
VARIANT:
description: Source container variant
required: true
default: Kinoite
VERSION:
description: Fedora version of installer to build
required: true
default: "39"
WEB_UI:
description: Enable Anaconda WebUI
required: true
default: "false"
BUILD_REPO:
description: Repository with the build tool
required: false
default: ${{ github.repository }}
BUILD_REF:
description: Repository ref for the build tool
required: false
default: ${{ github.ref }}
runs:
using: composite
steps:
- name: Install make and git
shell: bash
run: dnf install -y make git
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: ${{ inputs.BUILD_REPO }}
ref: ${{ inputs.BUILD_REF }}
submodules: recursive
- name: Install dependencies
shell: bash
run: make install-deps
- name: Lowercase Registry
id: registry_case
uses: ASzc/change-string-case-action@v6
with:
string: ${{ inputs.IMAGE_REPO }}
- name: Download image
shell: bash
run: |
make container/${{ inputs.IMAGE_NAME }}-${{ inputs.IMAGE_TAG }} \
ARCH=${{ inputs.ARCH }} \
IMAGE_NAME=${{ inputs.IMAGE_NAME }} \
IMAGE_REPO=${{ steps.registry_case.outputs.lowercase }} \
IMAGE_TAG=${{ inputs.IMAGE_TAG }} \
VARIANT=${{ inputs.VARIANT }} \
VERSION=${{ inputs.VERSION }} \
WEB_UI=${{ inputs.WEB_UI }}
- name: Create boot.iso
shell: bash
run: |
make boot.iso \
ARCH=${{ inputs.ARCH }} \
IMAGE_NAME=${{ inputs.IMAGE_NAME }} \
IMAGE_REPO=${{ steps.registry_case.outputs.lowercase }} \
IMAGE_TAG=${{ inputs.IMAGE_TAG }} \
VARIANT=${{ inputs.VARIANT }} \
VERSION=${{ inputs.VERSION }} \
WEB_UI=${{ inputs.WEB_UI }}
- name: Create deploy.iso
shell: bash
run: |
make ${IMAGE_NAME}-${IMAGE_VERSION}.iso \
ARCH=${{ inputs.ARCH }} \
IMAGE_NAME=${{ inputs.IMAGE_NAME }} \
IMAGE_REPO=${{ steps.registry_case.outputs.lowercase }} \
IMAGE_TAG=${{ inputs.IMAGE_TAG }} \
VARIANT=${{ inputs.VARIANT }} \
VERSION=${{ inputs.VERSION }} \
WEB_UI=${{ inputs.WEB_UI }}
mkdir end_iso
mv output/${IMAGE_NAME}-${IMAGE_TAG}.iso end_iso/
- name: Upload ISO as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.IMAGE_NAME }}-${{ inputs.IMAGE_VERSION }}.iso
path: end_iso/*.iso
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true

View File

@ -1 +0,0 @@
Final ISO gets output in this directory

View File

@ -1,9 +1,9 @@
#!/bin/bash
echo "-indev $(pwd)/boot.iso"
echo "-outdev $(pwd)/output/@IMAGE_NAME@-@VERSION@.iso"
echo "-outdev $(pwd)/output/@IMAGE_NAME@-@IMAGE_TAG@.iso"
echo "-boot_image any replay"
echo "-volid @IMAGE_NAME@-@ARCH@-@VERSION@"
echo "-volid @IMAGE_NAME@-@ARCH@-@IMAGE_TAG@"
echo "-joliet on"
echo "-compliance joliet_long_names"
cd container