Import bundled Flatpak applications into installed persistent storage
This commit is contained in:
parent
1334f01294
commit
bdfdbdb1d2
2 changed files with 44 additions and 0 deletions
37
adapters/flatpak-import.sh
Normal file
37
adapters/flatpak-import.sh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
# Prototype: called from live installation, after OSTree deployment.
|
||||
# The seed is ISO content; no seed repository is retained in immutable /usr.
|
||||
set -euo pipefail
|
||||
seed=$1
|
||||
destination=$2
|
||||
test "$EUID" = 0
|
||||
test -d "$seed/.ostree/repo"
|
||||
test -f "$seed/SHA256SUMS"
|
||||
(cd "$seed"; sha256sum --quiet --check SHA256SUMS)
|
||||
test ! -e "$destination" || { echo 'Flatpak destination must be fresh' >&2; exit 1; }
|
||||
mkdir -p /etc/flatpak/installations.d
|
||||
name=archipelago-installer-$$
|
||||
config=/etc/flatpak/installations.d/$name.conf
|
||||
trap 'rm -f "$config"' EXIT
|
||||
printf '[Installation "%s"]\nPath=%s\nDisplayName=Archipelago installation target\n' "$name" "$destination" > "$config"
|
||||
chmod 0600 "$config"
|
||||
# Namespace isolation makes this a local-media import, not a network fallback.
|
||||
unshare --net /bin/bash -euo pipefail -s -- "$name" "$seed" <<'IMPORT'
|
||||
name=$1
|
||||
seed=$2
|
||||
flatpak --installation="$name" remote-add flathub "$seed/flathub.flatpakrepo"
|
||||
flatpak --installation="$name" remote-modify --collection-id=org.flathub.Stable flathub
|
||||
flatpak --installation="$name" config --set languages '*'
|
||||
mapfile -t apps < <(python3 - "$seed/policy.json" <<'PY'
|
||||
import json,sys
|
||||
p=json.load(open(sys.argv[1]))
|
||||
assert p['delivery']=='installation-media'
|
||||
for ref in p['applications']:
|
||||
assert ref.startswith('app/org.gnome.') and ref.endswith('/x86_64/stable')
|
||||
print(ref)
|
||||
PY
|
||||
)
|
||||
test "${#apps[@]}" -gt 0
|
||||
flatpak --installation="$name" install --noninteractive --assumeyes --sideload-repo="$seed/.ostree/repo" flathub "${apps[@]}"
|
||||
for ref in "${apps[@]}"; do flatpak --installation="$name" info "$ref"; done
|
||||
IMPORT
|
||||
|
|
@ -10,6 +10,9 @@ size=$(blockdev --getsize64 "$device")
|
|||
echo "Erasing selected disk $device ($size bytes), GPT: 1 GiB ESP, remaining ext4 root"
|
||||
exec 9>/run/archipelago-install.lock
|
||||
flock -n 9
|
||||
if ostree --repo=/usr/share/archipelago/repo cat core /usr/lib/archipelago/purpose 2>/dev/null | grep -qx purpose/desktop/gnome; then
|
||||
test -f /usr/share/archipelago/flatpak-seed/SHA256SUMS || { echo 'GNOME installation media lacks its application seed' >&2; exit 1; }
|
||||
fi
|
||||
sgdisk --zap-all "$device"
|
||||
sgdisk -n 1:0:+1G -t 1:ef00 -c 1:ARCHIPELAGO-ESP -n 2:0:0 -t 2:8300 -c 2:ARCHIPELAGO-ROOT "$device"
|
||||
partprobe "$device"
|
||||
|
|
@ -42,5 +45,9 @@ bootctl --esp-path="$target/efi" --no-variables install
|
|||
cp -aL "$target/boot/loader/entries" "$target/efi/loader/"
|
||||
cp -a "$target/boot/ostree" "$target/efi/"
|
||||
printf 'timeout 3\ndefault ostree-*\n' > "$target/efi/loader/loader.conf"
|
||||
if [[ -d /usr/share/archipelago/flatpak-seed ]]; then
|
||||
bash /usr/share/archipelago/flatpak-import.sh /usr/share/archipelago/flatpak-seed \
|
||||
"$target/ostree/deploy/archipelago/var/lib/flatpak"
|
||||
fi
|
||||
sync
|
||||
echo 'ARCHIPELAGO_INSTALL_COMPLETE: shut down and boot this disk without the ISO'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue