Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically determine Flatpak dependencies #86

Merged
merged 45 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
af1cf3f
add step to pull in dependencies
JasonN3 Mar 21, 2024
c7445bd
debug
JasonN3 Mar 21, 2024
a13a9ea
spelling
JasonN3 Mar 21, 2024
042f5c0
not tty
JasonN3 Mar 21, 2024
75c0973
add dir_refs
JasonN3 Mar 21, 2024
cf2dd03
test hard code
noelmiller Mar 21, 2024
9d8f2d1
debug
noelmiller Mar 21, 2024
0b0b048
debug env
noelmiller Mar 21, 2024
7d026e6
set to system flatpaks to resolve root issue
noelmiller Mar 21, 2024
f531c18
remove sudo, create directory
noelmiller Mar 21, 2024
de6abbb
readd sudo...
noelmiller Mar 21, 2024
c466551
removed dependencies and new lines
noelmiller Mar 21, 2024
20008f4
hardcode for now
noelmiller Mar 21, 2024
99dcb34
add privileged
noelmiller Mar 21, 2024
127ec7f
use script
JasonN3 Mar 21, 2024
77029aa
remove -i
JasonN3 Mar 21, 2024
37d35d6
use system
JasonN3 Mar 21, 2024
9b8ee65
don't use volume
JasonN3 Mar 21, 2024
8646f5f
copy out
JasonN3 Mar 21, 2024
6d94571
ensure ref collection works
JasonN3 Mar 22, 2024
5a6770b
save location
JasonN3 Mar 22, 2024
74e7e40
fix dir name
JasonN3 Mar 22, 2024
1292edf
delete image when done
JasonN3 Mar 22, 2024
13d4cbf
delete container when done running
JasonN3 Mar 25, 2024
e99ecbb
add flatpaks to iso
JasonN3 Mar 25, 2024
396323c
only one flatpak method at a time
JasonN3 Mar 25, 2024
632055d
missing :
JasonN3 Mar 25, 2024
f857b5f
add flatpak_dir to list
JasonN3 Mar 25, 2024
f81a3b9
fix dir
JasonN3 Mar 25, 2024
b2dba5d
free up space
JasonN3 Mar 25, 2024
8fb95e2
fix condition
JasonN3 Mar 25, 2024
72b9575
move dir
JasonN3 Mar 25, 2024
de7f101
fix dir
JasonN3 Mar 25, 2024
5de8d24
should be /flatpak/repo
JasonN3 Mar 26, 2024
2b41ee6
copy to ostree
JasonN3 Mar 26, 2024
4f3fbc9
build-update-repo
JasonN3 Mar 26, 2024
d7cf451
debug
JasonN3 Mar 26, 2024
447ff59
debug
JasonN3 Mar 26, 2024
c22a86d
debug
JasonN3 Mar 26, 2024
a075fbd
escape $
JasonN3 Mar 26, 2024
6ee7d5e
more escaping
JasonN3 Mar 26, 2024
16a6ef0
debug
JasonN3 Mar 26, 2024
9e9246c
remove random quote
JasonN3 Mar 26, 2024
d3d8542
more random quotes
JasonN3 Mar 26, 2024
c906ec4
remove debug echo
JasonN3 Mar 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/build_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ jobs:
build-container:
if: >
github.event_name == 'push' ||
github.event_name == 'issue_comment' ||
( github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'auto-test') )
github.event_name == 'issue_comment' ||
github.event_name == 'workflow_dispatch'
name: Build Container Image
env:
JOB_NAME: Build Container Image
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/build_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ jobs:
sha: ${{ env.sha }}
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
id: registry_case
uses: ASzc/change-string-case-action@v6
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/lorax.conf
/output
/*.log

/cache
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ FLATPAK_REMOTE_NAME = flathub
FLATPAK_REMOTE_URL = https://flathub.org/repo/flathub.flatpakrepo
FLATPAK_REMOTE_REFS =
FLATPAK_REMOTE_REFS_DIR =
FLATPAK_DIR =
# Secure boot
ENROLLMENT_PASSWORD =
SECURE_BOOT_KEY_URL =
Expand Down Expand Up @@ -121,6 +122,13 @@ _LORAX_TEMPLATES += $(call get_templates,cache)
_TEMPLATE_VARS += DNF_CACHE
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),)
COLLECTED_REFS = $(foreach file,$(shell ls $(FLATPAK_REMOTE_REFS_DIR)/*),$(shell cat $(file)))
FLATPAK_REMOTE_REFS += $(sort $(COLLECTED_REFS))
Expand All @@ -132,10 +140,11 @@ _FLATPAK_REPO_URL = $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^URL=' | cu
_LORAX_ARGS += -i flatpak-libs
_LORAX_TEMPLATES += $(call get_templates,flatpak) \
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


ifneq ($(SECURE_BOOT_KEY_URL),)
_LORAX_TEMPLATES += $(call get_templates,secureboot)
_TEMPLATE_VARS += ENROLLMENT_PASSWORD
Expand Down Expand Up @@ -200,7 +209,7 @@ container/$(IMAGE_NAME)-$(IMAGE_TAG):
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/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

# Step 6: Generate xorriso input
Expand Down
41 changes: 41 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inputs:
description: Whether to enable caching for skopeo
required: false
default: "false"
enable_flatpak_dependencies:
description: Whether to enable automatically determining Flatpak dependencies
required: false
default: "true"
enrollment_password:
description: Used for supporting secure boot (requires secure_boot_key_url to be defined)
required: false
Expand Down Expand Up @@ -130,6 +134,42 @@ runs:
mkdir /cache/dnf_new || 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
env:
ACTION_REPO: ${{ github.action_repository }}
Expand Down Expand Up @@ -183,6 +223,7 @@ runs:
FLATPAK_REMOTE_NAME="${{ inputs.flatpak_remote_name }}" \
${vars} \
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_REPO="${{ inputs.image_repo }}" \
IMAGE_TAG="${{ inputs.image_tag || inputs.version }}" \
Expand Down
4 changes: 0 additions & 4 deletions flatpak_refs/Firefox
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
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 change: 0 additions & 1 deletion flatpak_refs/VLC
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
app/org.videolan.VLC/x86_64/stable
runtime/org.kde.Platform/x86_64/5.15-23.08
5 changes: 5 additions & 0 deletions lorax_templates/flatpak_link.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%page args="flatpak_dir"/>

%if flatpak_dir != "":
symlink /run/install/repo/flatpak /flatpak
%endif
11 changes: 11 additions & 0 deletions xorriso/gen_input.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ echo "-chmod 0444 boot/grub2/grub.cfg"
echo "-map $(pwd)/results/EFI/BOOT/grub.cfg 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 ]
then
echo "-map $(pwd)/sb_pubkey.der sb_pubkey.der"
Expand Down
Loading