-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lorax-embed-flatpaks.tmpl
44 lines (39 loc) · 1.9 KB
/
lorax-embed-flatpaks.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## 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
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
%for ref in 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}