mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 10:57:55 +01:00
use found_refs
This commit is contained in:
parent
1b0319ae83
commit
f89846e64f
2 changed files with 49 additions and 1 deletions
1
Makefile
1
Makefile
|
|
@ -25,7 +25,6 @@ _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 = $(subst /etc/yum.repos.d,repos,$(REPOS))
|
_REPO_FILES = $(subst /etc/yum.repos.d,repos,$(REPOS))
|
||||||
_LORAX_TEMPLATES = $(subst .in,,$(shell ls lorax_templates/*.tmpl.in)) $(foreach file,$(shell ls lorax_templates/scripts/post),lorax_templates/post_$(file).tmpl)
|
_LORAX_TEMPLATES = $(subst .in,,$(shell ls lorax_templates/*.tmpl.in)) $(foreach file,$(shell ls lorax_templates/scripts/post),lorax_templates/post_$(file).tmpl)
|
||||||
_FLATPAK_TEMPLATES = $(_BASE_DIR)/external/fedora-lorax-templates/ostree-based-installer/lorax-embed-flatpaks.tmpl
|
|
||||||
_FLATPAK_REPO_URL = $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^URL=' | cut -d= -f2)
|
_FLATPAK_REPO_URL = $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^URL=' | cut -d= -f2)
|
||||||
_FLATPAK_REPO_GPG = $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^GPGKey=' | cut -d= -f2)
|
_FLATPAK_REPO_GPG = $(shell curl -L $(FLATPAK_REMOTE_URL) | grep -i '^GPGKey=' | cut -d= -f2)
|
||||||
_TEMPLATE_VARS = ARCH VERSION IMAGE_REPO IMAGE_NAME IMAGE_TAG VARIANT WEB_UI REPOS _IMAGE_REPO_ESCAPED _IMAGE_REPO_DOUBLE_ESCAPED FLATPAK_REMOTE_NAME FLATPAK_REMOTE_URL FLATPAK_REMOTE_REFS _FLATPAK_REPO_URL _FLATPAK_REPO_GPG ENROLLMENT_PASSWORD
|
_TEMPLATE_VARS = ARCH VERSION IMAGE_REPO IMAGE_NAME IMAGE_TAG VARIANT WEB_UI REPOS _IMAGE_REPO_ESCAPED _IMAGE_REPO_DOUBLE_ESCAPED FLATPAK_REMOTE_NAME FLATPAK_REMOTE_URL FLATPAK_REMOTE_REFS _FLATPAK_REPO_URL _FLATPAK_REPO_GPG ENROLLMENT_PASSWORD
|
||||||
|
|
|
||||||
49
lorax_templates/download_flatpaks.tmpl.in
Normal file
49
lorax_templates/download_flatpaks.tmpl.in
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
## Lorax template to embed Flatpaks into the installer.iso
|
||||||
|
|
||||||
|
## Args:
|
||||||
|
## - root - the root directory of the iso tree
|
||||||
|
## - flatpak_remote_name - the name for the flaptak remote to fetch from
|
||||||
|
## - flatpak_remote_url - the url for the remote
|
||||||
|
## - flatpak_remote_refs - refs to fetch from the remote (whitespace separated)
|
||||||
|
|
||||||
|
<%page args="root, flatpak_remote_name, flatpak_remote_url, flatpak_remote_refs"/>
|
||||||
|
<%
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import tempfile
|
||||||
|
import subprocess
|
||||||
|
from pylorax.executils import runcmd_output, setenv
|
||||||
|
from pylorax.sysutils import joinpaths
|
||||||
|
|
||||||
|
dest_repo=joinpaths(root, "flatpak/repo")
|
||||||
|
refs=re.split(r"\s+", flatpak_remote_refs)
|
||||||
|
|
||||||
|
# the temporary Flatpak directory is a sibling of the install tree
|
||||||
|
flatpak_dir=joinpaths(os.path.dirname(root), "flatpak")
|
||||||
|
setenv("FLATPAK_USER_DIR", flatpak_dir)
|
||||||
|
flatpak_repo=joinpaths(flatpak_dir, "repo")
|
||||||
|
# suppress executing triggers by using an empty directory
|
||||||
|
triggers_dir = tempfile.mkdtemp(prefix='flatpak-triggers-')
|
||||||
|
setenv("FLATPAK_TRIGGERSDIR", triggers_dir)
|
||||||
|
%>
|
||||||
|
|
||||||
|
runcmd flatpak config --user --set languages "*"
|
||||||
|
runcmd flatpak remote-add --user ${flatpak_remote_name} ${flatpak_remote_url}
|
||||||
|
%if len(refs) > 0:
|
||||||
|
# We have to run a DBus session here, because Flatpak wants to talk to
|
||||||
|
# flatpak-oci-authenticator for OCI remotes - even ones that don't require
|
||||||
|
# authentication
|
||||||
|
runcmd dbus-run-session flatpak install -y --user ${flatpak_remote_name} ${flatpak_remote_refs}
|
||||||
|
%endif
|
||||||
|
runcmd mkdir -p ${root}/flatpak
|
||||||
|
runcmd ostree init --repo=${dest_repo} --mode=archive-z2
|
||||||
|
<%
|
||||||
|
cmd_result = subprocess.run(['ostree', 'refs', '--repo={0}'.format(${flatpak_repo})])
|
||||||
|
found_refs = cmd_result.stdout.decode('utf-8').trim().split('\n')
|
||||||
|
%>
|
||||||
|
%for ref in found_refs:
|
||||||
|
runcmd sh -c "ostree --repo=${dest_repo} pull-local ${flatpak_repo} $(ostree --repo=${flatpak_repo} rev-parse ${flatpak_remote_name}/${ref})"
|
||||||
|
runcmd sh -c "mkdir -p $(dirname ${dest_repo}/refs/heads/${ref})"
|
||||||
|
runcmd sh -c "ostree --repo=${flatpak_repo} rev-parse ${flatpak_remote_name}/${ref} > ${dest_repo}/refs/heads/${ref}"
|
||||||
|
%endfor
|
||||||
|
runcmd flatpak build-update-repo ${dest_repo}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue