mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 02:47:56 +01:00
Automatically determine Flatpak dependencies (#86)
Co-authored-by: Noel Miller <noelmiller@protonmail.com>
This commit is contained in:
parent
f2305bbaf8
commit
b5c953d8d3
9 changed files with 88 additions and 12 deletions
5
.github/workflows/build_container.yml
vendored
5
.github/workflows/build_container.yml
vendored
|
|
@ -12,9 +12,8 @@ jobs:
|
||||||
build-container:
|
build-container:
|
||||||
if: >
|
if: >
|
||||||
github.event_name == 'push' ||
|
github.event_name == 'push' ||
|
||||||
github.event_name == 'issue_comment' ||
|
github.event_name == 'issue_comment' ||
|
||||||
( github.event_name == 'pull_request' &&
|
github.event_name == 'workflow_dispatch'
|
||||||
contains(github.event.pull_request.labels.*.name, 'auto-test') )
|
|
||||||
name: Build Container Image
|
name: Build Container Image
|
||||||
env:
|
env:
|
||||||
JOB_NAME: Build Container Image
|
JOB_NAME: Build Container Image
|
||||||
|
|
|
||||||
16
.github/workflows/build_iso.yml
vendored
16
.github/workflows/build_iso.yml
vendored
|
|
@ -81,6 +81,22 @@ jobs:
|
||||||
sha: ${{ env.sha }}
|
sha: ${{ env.sha }}
|
||||||
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
targetUrl: ${{ steps.jobs.outputs.html_url }}
|
||||||
|
|
||||||
|
- name: Free Disk Space (Ubuntu)
|
||||||
|
uses: jlumbroso/free-disk-space@main
|
||||||
|
with:
|
||||||
|
# this might remove tools that are actually needed,
|
||||||
|
# if set to "true" but frees about 6 GB
|
||||||
|
tool-cache: false
|
||||||
|
|
||||||
|
# all of these default to true, but feel free to set to
|
||||||
|
# "false" if necessary for your workflow
|
||||||
|
android: true
|
||||||
|
dotnet: true
|
||||||
|
haskell: true
|
||||||
|
large-packages: true
|
||||||
|
docker-images: true
|
||||||
|
swap-storage: true
|
||||||
|
|
||||||
- name: Lowercase Registry
|
- name: Lowercase Registry
|
||||||
id: registry_case
|
id: registry_case
|
||||||
uses: ASzc/change-string-case-action@v6
|
uses: ASzc/change-string-case-action@v6
|
||||||
|
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -11,4 +11,4 @@
|
||||||
/lorax.conf
|
/lorax.conf
|
||||||
/output
|
/output
|
||||||
/*.log
|
/*.log
|
||||||
|
/cache
|
||||||
15
Makefile
15
Makefile
|
|
@ -17,6 +17,7 @@ FLATPAK_REMOTE_NAME = flathub
|
||||||
FLATPAK_REMOTE_URL = https://flathub.org/repo/flathub.flatpakrepo
|
FLATPAK_REMOTE_URL = https://flathub.org/repo/flathub.flatpakrepo
|
||||||
FLATPAK_REMOTE_REFS =
|
FLATPAK_REMOTE_REFS =
|
||||||
FLATPAK_REMOTE_REFS_DIR =
|
FLATPAK_REMOTE_REFS_DIR =
|
||||||
|
FLATPAK_DIR =
|
||||||
# Secure boot
|
# Secure boot
|
||||||
ENROLLMENT_PASSWORD =
|
ENROLLMENT_PASSWORD =
|
||||||
SECURE_BOOT_KEY_URL =
|
SECURE_BOOT_KEY_URL =
|
||||||
|
|
@ -121,6 +122,13 @@ _LORAX_TEMPLATES += $(call get_templates,cache)
|
||||||
_TEMPLATE_VARS += DNF_CACHE
|
_TEMPLATE_VARS += DNF_CACHE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(FLATPAK_DIR),)
|
||||||
|
_FLATPAK_REPO_GPG = $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^GPGKey=' | cut -d= -f2)
|
||||||
|
_FLATPAK_REPO_URL = $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^URL=' | cut -d= -f2)
|
||||||
|
_LORAX_ARGS += -i flatpak-libs
|
||||||
|
_LORAX_TEMPLATES += $(call get_templates,flatpak)
|
||||||
|
_TEMPLATE_VARS += FLATPAK_DIR FLATPAK_REMOTE_NAME FLATPAK_REMOTE_REFS FLATPAK_REMOTE_URL _FLATPAK_REPO_GPG _FLATPAK_REPO_URL
|
||||||
|
else
|
||||||
ifneq ($(FLATPAK_REMOTE_REFS_DIR),)
|
ifneq ($(FLATPAK_REMOTE_REFS_DIR),)
|
||||||
COLLECTED_REFS = $(foreach file,$(shell ls $(FLATPAK_REMOTE_REFS_DIR)/*),$(shell cat $(file)))
|
COLLECTED_REFS = $(foreach file,$(shell ls $(FLATPAK_REMOTE_REFS_DIR)/*),$(shell cat $(file)))
|
||||||
FLATPAK_REMOTE_REFS += $(sort $(COLLECTED_REFS))
|
FLATPAK_REMOTE_REFS += $(sort $(COLLECTED_REFS))
|
||||||
|
|
@ -132,9 +140,10 @@ _FLATPAK_REPO_URL = $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^URL=' | cu
|
||||||
_LORAX_ARGS += -i flatpak-libs
|
_LORAX_ARGS += -i flatpak-libs
|
||||||
_LORAX_TEMPLATES += $(call get_templates,flatpak) \
|
_LORAX_TEMPLATES += $(call get_templates,flatpak) \
|
||||||
external/fedora-lorax-templates/ostree-based-installer/lorax-embed-flatpaks.tmpl
|
external/fedora-lorax-templates/ostree-based-installer/lorax-embed-flatpaks.tmpl
|
||||||
_TEMPLATE_VARS += FLATPAK_REMOTE_NAME FLATPAK_REMOTE_REFS FLATPAK_REMOTE_URL _FLATPAK_REPO_GPG _FLATPAK_REPO_URL
|
_TEMPLATE_VARS += FLATPAK_DIR FLATPAK_REMOTE_NAME FLATPAK_REMOTE_REFS FLATPAK_REMOTE_URL _FLATPAK_REPO_GPG _FLATPAK_REPO_URL
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifneq ($(SECURE_BOOT_KEY_URL),)
|
ifneq ($(SECURE_BOOT_KEY_URL),)
|
||||||
_LORAX_TEMPLATES += $(call get_templates,secureboot)
|
_LORAX_TEMPLATES += $(call get_templates,secureboot)
|
||||||
|
|
@ -200,7 +209,7 @@ container/$(IMAGE_NAME)-$(IMAGE_TAG):
|
||||||
xorriso/%.sh: xorriso/%.sh.in
|
xorriso/%.sh: xorriso/%.sh.in
|
||||||
sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' results/boot/grub2/grub.cfg
|
sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' results/boot/grub2/grub.cfg
|
||||||
sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' results/EFI/BOOT/grub.cfg
|
sed -i 's/quiet/quiet $(EXTRA_BOOT_PARAMS)/g' results/EFI/BOOT/grub.cfg
|
||||||
$(eval _VARS = IMAGE_NAME IMAGE_TAG ARCH VERSION)
|
$(eval _VARS = FLATPAK_DIR 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
|
$(foreach var,$(_VARS),$(var)=$($(var))) envsubst '$(foreach var,$(_VARS),$$$(var))' < $(_BASE_DIR)/xorriso/$*.sh.in > $(_BASE_DIR)/xorriso/$*.sh
|
||||||
|
|
||||||
# Step 6: Generate xorriso input
|
# Step 6: Generate xorriso input
|
||||||
|
|
|
||||||
41
action.yml
41
action.yml
|
|
@ -24,6 +24,10 @@ inputs:
|
||||||
description: Whether to enable caching for skopeo
|
description: Whether to enable caching for skopeo
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
|
enable_flatpak_dependencies:
|
||||||
|
description: Whether to enable automatically determining Flatpak dependencies
|
||||||
|
required: false
|
||||||
|
default: "true"
|
||||||
enrollment_password:
|
enrollment_password:
|
||||||
description: Used for supporting secure boot (requires secure_boot_key_url to be defined)
|
description: Used for supporting secure boot (requires secure_boot_key_url to be defined)
|
||||||
required: false
|
required: false
|
||||||
|
|
@ -130,6 +134,42 @@ runs:
|
||||||
mkdir /cache/dnf_new || true
|
mkdir /cache/dnf_new || true
|
||||||
mkdir /cache/skopeo || true
|
mkdir /cache/skopeo || true
|
||||||
|
|
||||||
|
- name: Determine Flatpak dependencies
|
||||||
|
if: inputs.enable_flatpak_dependencies == 'true'
|
||||||
|
id: flatpak_dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
image="${{ inputs.image_repo }}/${{ inputs.image_name }}:${{ inputs.image_tag }}"
|
||||||
|
# Make temp space
|
||||||
|
FLATPAK_DIR=$(basename $(mktemp -d -p ${{ github.workspace }} flatpak.XXX))
|
||||||
|
# Get list of refs from directory
|
||||||
|
sudo mkdir /github || true
|
||||||
|
sudo ln -s ${{ github.workspace }} /github/workspace
|
||||||
|
DIR_REFS=$(cat ${{ inputs.flatpak_remote_refs_dir }}/* | tr '\n' ' ' )
|
||||||
|
# Generate install script
|
||||||
|
cat << EOF > ${{ github.workspace }}/${FLATPAK_DIR}/script.sh
|
||||||
|
cat /flatpak_dir/script.sh
|
||||||
|
mkdir -p /flatpak/flatpak /flatpak/triggers
|
||||||
|
mkdir /var/tmp || true
|
||||||
|
chmod -R 1777 /var/tmp
|
||||||
|
flatpak config --system --set languages "*"
|
||||||
|
flatpak remote-add --system ${{ inputs.flatpak_remote_name }} ${{ inputs.flatpak_remote_url }}
|
||||||
|
flatpak install --system -y ${{ inputs.flatpak_remote_refs }} ${DIR_REFS}
|
||||||
|
ostree init --repo=/flatpak_dir/repo --mode=archive-z2
|
||||||
|
for i in \$(ostree refs --repo=\${FLATPAK_SYSTEM_DIR}/repo | grep '^deploy/' | sed 's/^deploy\///g')
|
||||||
|
do
|
||||||
|
echo "Copying \${i}..."
|
||||||
|
ostree --repo=/flatpak_dir/repo pull-local \${FLATPAK_SYSTEM_DIR}/repo \$(ostree --repo=\${FLATPAK_SYSTEM_DIR}/repo rev-parse ${{ inputs.flatpak_remote_name }}/\${i})
|
||||||
|
mkdir -p \$(dirname /flatpak_dir/repo/refs/heads/\${i})
|
||||||
|
ostree --repo=\${FLATPAK_SYSTEM_DIR}/repo rev-parse ${{ inputs.flatpak_remote_name }}/\${i} > /flatpak_dir/repo/refs/heads/\${i}
|
||||||
|
done
|
||||||
|
flatpak build-update-repo /flatpak_dir/repo
|
||||||
|
ostree refs --repo=/flatpak_dir/repo
|
||||||
|
EOF
|
||||||
|
docker run --rm --privileged --entrypoint bash -e FLATPAK_SYSTEM_DIR=/flatpak/flatpak -e FLATPAK_TRIGGERSDIR=/flatpak/triggers --volume ${{ github.workspace }}/${FLATPAK_DIR}:/flatpak_dir ${image} /flatpak_dir/script.sh
|
||||||
|
echo "flatpak_dir=${FLATPAK_DIR}" >> $GITHUB_OUTPUT
|
||||||
|
docker rmi ${image}
|
||||||
|
|
||||||
- name: Run docker image
|
- name: Run docker image
|
||||||
env:
|
env:
|
||||||
ACTION_REPO: ${{ github.action_repository }}
|
ACTION_REPO: ${{ github.action_repository }}
|
||||||
|
|
@ -183,6 +223,7 @@ runs:
|
||||||
FLATPAK_REMOTE_NAME="${{ inputs.flatpak_remote_name }}" \
|
FLATPAK_REMOTE_NAME="${{ inputs.flatpak_remote_name }}" \
|
||||||
${vars} \
|
${vars} \
|
||||||
FLATPAK_REMOTE_URL="${{ inputs.flatpak_remote_url }}" \
|
FLATPAK_REMOTE_URL="${{ inputs.flatpak_remote_url }}" \
|
||||||
|
FLATPAK_DIR="${{ steps.flatpak_dependencies.outputs.flatpak_dir && format('/github/workspace/{0}', steps.flatpak_dependencies.outputs.flatpak_dir) || '' }}" \
|
||||||
IMAGE_NAME="${{ inputs.image_name }}" \
|
IMAGE_NAME="${{ inputs.image_name }}" \
|
||||||
IMAGE_REPO="${{ inputs.image_repo }}" \
|
IMAGE_REPO="${{ inputs.image_repo }}" \
|
||||||
IMAGE_TAG="${{ inputs.image_tag || inputs.version }}" \
|
IMAGE_TAG="${{ inputs.image_tag || inputs.version }}" \
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1 @@
|
||||||
app/org.mozilla.firefox/x86_64/stable
|
app/org.mozilla.firefox/x86_64/stable
|
||||||
|
|
||||||
runtime/org.mozilla.firefox.Locale/x86_64/stable
|
|
||||||
runtime/org.freedesktop.Platform/x86_64/23.08
|
|
||||||
runtime/org.freedesktop.Platform.Locale/x86_64/23.08
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
app/org.videolan.VLC/x86_64/stable
|
app/org.videolan.VLC/x86_64/stable
|
||||||
runtime/org.kde.Platform/x86_64/5.15-23.08
|
|
||||||
5
lorax_templates/flatpak_link.tmpl
Normal file
5
lorax_templates/flatpak_link.tmpl
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<%page args="flatpak_dir"/>
|
||||||
|
|
||||||
|
%if flatpak_dir != "":
|
||||||
|
symlink /run/install/repo/flatpak /flatpak
|
||||||
|
%endif
|
||||||
|
|
@ -10,6 +10,17 @@ echo "-chmod 0444 boot/grub2/grub.cfg"
|
||||||
echo "-map $(pwd)/results/EFI/BOOT/grub.cfg EFI/BOOT/grub.cfg"
|
echo "-map $(pwd)/results/EFI/BOOT/grub.cfg EFI/BOOT/grub.cfg"
|
||||||
echo "-chmod 0444 EFI/BOOT/grub.cfg"
|
echo "-chmod 0444 EFI/BOOT/grub.cfg"
|
||||||
|
|
||||||
|
if [[ -n "${FLATPAK_DIR}" ]]
|
||||||
|
then
|
||||||
|
pushd ${FLATPAK_DIR} > /dev/null
|
||||||
|
for file in $(find *)
|
||||||
|
do
|
||||||
|
echo "-map $(pwd)/${file} flatpak/${file}"
|
||||||
|
echo "-chmod 0444 flatpak/${file}"
|
||||||
|
done
|
||||||
|
popd > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f $(pwd)/sb_pubkey.der ]
|
if [ -f $(pwd)/sb_pubkey.der ]
|
||||||
then
|
then
|
||||||
echo "-map $(pwd)/sb_pubkey.der sb_pubkey.der"
|
echo "-map $(pwd)/sb_pubkey.der sb_pubkey.der"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue