Fix desktop update lifecycle and retain readable transaction progress
This commit is contained in:
parent
c4ec833595
commit
361cd67b3c
3 changed files with 71 additions and 4 deletions
|
|
@ -19,5 +19,9 @@ gcc -shared -fPIC -O2 -Wall -Werror=implicit-function-declaration \
|
|||
-DG_LOG_DOMAIN=\"GsPluginArchipelago\" /source/gs-plugin-archipelago.c \
|
||||
-o /output/libgs_plugin_archipelago.so $(pkg-config --cflags --libs gnome-software json-glib-1.0)
|
||||
sha256sum /source/gs-plugin-archipelago.c /output/libgs_plugin_archipelago.so > /output/SHA256SUMS
|
||||
gcc -O2 -Wall -Werror=implicit-function-declaration \
|
||||
-DG_LOG_DOMAIN=\"GsPluginArchipelago\" /source/test-plugin.c \
|
||||
-o /output/test-plugin $(pkg-config --cflags --libs gnome-software json-glib-1.0)
|
||||
/output/test-plugin > /output/plugin-contract.log 2>&1
|
||||
pacman -Q > /output/packages.txt
|
||||
'
|
||||
|
|
|
|||
57
pipeline/flatpak-relay.sh
Normal file
57
pipeline/flatpak-relay.sh
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
# Download on the explicitly selected relay; import only a verified immutable export.
|
||||
set -euo pipefail
|
||||
source_root=$1
|
||||
local_cache=$2
|
||||
bootstrap=$3
|
||||
packages=$4
|
||||
refresh=$5
|
||||
variant=$6
|
||||
initial=$7
|
||||
relay=$8
|
||||
[[ $variant == gnome || $variant == kde ]]
|
||||
[[ $relay == root@tall-bridge ]]
|
||||
mkdir -p "$local_cache"
|
||||
exec 9>"$local_cache/refresh.lock"
|
||||
flock -n 9
|
||||
stamp=$(date -u +%Y%m%dT%H%M%SZ)-$$
|
||||
remote_source=/opt/archipelago/flatpak-relay/$stamp
|
||||
remote_cache=/opt/archipelago/cache/flatpak/$variant
|
||||
# Use verified SSH host keys; never disable host verification for the relay.
|
||||
ssh -o BatchMode=yes "$relay" "mkdir -p $remote_source; test -f '$bootstrap'; test \"\$(df -PB1 /opt/archipelago | awk 'NR==2 {print \$4}')\" -ge 8000000000"
|
||||
tar -C "$source_root" -cf - builder/adapters/prepare-flatpak-seed.sh \
|
||||
infrastructure/pipeline/flatpak-cache.sh "purposes/proposals/$variant-flatpak-apps.json" |
|
||||
ssh -o BatchMode=yes "$relay" "tar -xf - -C $remote_source"
|
||||
ssh -o BatchMode=yes -o ServerAliveInterval=15 "$relay" \
|
||||
"systemd-run --wait --pipe --unit=archipelago-flatpak-relay-$stamp --property=RuntimeMaxSec=$((initial + 300)) bash $remote_source/infrastructure/pipeline/flatpak-cache.sh $remote_source $remote_cache '$bootstrap' '$packages' '$refresh' '$variant' '$initial'"
|
||||
mkdir -p "$local_cache/exports" "$local_cache/runs/$stamp"
|
||||
destination="$local_cache/exports/relay-$stamp"
|
||||
partial="$local_cache/exports/.relay-$stamp.partial"
|
||||
mkdir "$partial"
|
||||
trap 'rm -rf "$partial"' EXIT
|
||||
link=()
|
||||
if [[ -f $local_cache/current/SHA256SUMS ]]; then link=(--link-dest="$(realpath -e "$local_cache/current")"); fi
|
||||
rsync -a --copy-links "${link[@]}" "$relay:$remote_cache/current/" "$partial/"
|
||||
cmp "$source_root/purposes/proposals/$variant-flatpak-apps.json" "$partial/policy.json"
|
||||
(cd "$partial"; sha256sum --quiet -c SHA256SUMS)
|
||||
mv "$partial" "$destination"
|
||||
rsync -a "$relay:$remote_cache/status.json" "$local_cache/runs/$stamp/relay-status.json"
|
||||
ln -s "exports/relay-$stamp" "$local_cache/current.next"
|
||||
mv -Tf "$local_cache/current.next" "$local_cache/current"
|
||||
python3 - "$local_cache" "$stamp" "$relay" <<'PY'
|
||||
import hashlib,json,shutil,sys
|
||||
from pathlib import Path
|
||||
cache=Path(sys.argv[1]); stamp=sys.argv[2]
|
||||
status=json.loads((cache/'runs'/stamp/'relay-status.json').read_text())
|
||||
status.update(download_worker=sys.argv[3],export=str((cache/'current').resolve()),
|
||||
manifest_sha256=hashlib.sha256((cache/'current/SHA256SUMS').read_bytes()).hexdigest())
|
||||
temporary=cache/'status.tmp'
|
||||
temporary.write_text(json.dumps(status,indent=2)+'\n')
|
||||
temporary.replace(cache/'status.json')
|
||||
exports=sorted((p for p in (cache/'exports').iterdir() if p.is_dir() and not p.name.startswith('.')),key=lambda p:p.stat().st_mtime,reverse=True)
|
||||
current=(cache/'current').resolve()
|
||||
keep={current,*[p for p in exports if p != current][:2]}
|
||||
for old in exports:
|
||||
if old not in keep: shutil.rmtree(old)
|
||||
print(json.dumps(status))
|
||||
PY
|
||||
|
|
@ -220,9 +220,12 @@ find {remote_root}/probes -type f -name '*.py' -exec sha256sum {{}} + >> {remote
|
|||
kde_cache = config['kde_flatpak_cache']
|
||||
if Path(kde_cache) == Path(config['flatpak_cache']):
|
||||
raise ValueError('KDE must use a separate Flatpak cache')
|
||||
remote(shlex.join(['bash', remote_root + '/source/src/infrastructure/pipeline/flatpak-cache.sh',
|
||||
relay = config.get('kde_flatpak_download_worker')
|
||||
adapter = 'flatpak-relay.sh' if relay else 'flatpak-cache.sh'
|
||||
remote(shlex.join(['bash', remote_root + '/source/src/infrastructure/pipeline/' + adapter,
|
||||
remote_root + '/source/src', kde_cache, config['bootstrap'],
|
||||
config['build_environment']['ARCHIPELAGO_PACKAGE_CACHE'], str(refresh), 'kde', str(initial_fill)]) +
|
||||
config['build_environment']['ARCHIPELAGO_PACKAGE_CACHE'], str(refresh), 'kde', str(initial_fill)] +
|
||||
([relay] if relay else [])) +
|
||||
' > ' + shlex.quote(remote_root + '/flatpak-kde.log') + ' 2>&1', initial_fill + 600)
|
||||
call(['rsync', '-a', f'{worker}:{kde_cache}/status.json', str(run / 'flatpak-kde-status.json')])
|
||||
state['flatpak_kde'] = json.loads((run / 'flatpak-kde-status.json').read_text())
|
||||
|
|
@ -241,13 +244,14 @@ find {remote_root}/probes -type f -name '*.py' -exec sha256sum {{}} + >> {remote
|
|||
if 'kde' in desktops:
|
||||
phase('building-discover-adapter')
|
||||
remote(shlex.join(['bash', remote_root + '/source/src/infrastructure/pipeline/build-discover-adapter.sh',
|
||||
remote_root + '/source/src', config['kde_flatpak_cache'] + '/tools/root.x86_64',
|
||||
remote_root + '/source/src', config['flatpak_cache'] + '/tools/root.x86_64',
|
||||
config['build_environment']['ARCHIPELAGO_PACKAGE_CACHE'], remote_root + '/discover-adapter']) +
|
||||
' > ' + shlex.quote(remote_root + '/discover-adapter.log') + ' 2>&1', 3600)
|
||||
call(['rsync', '-a', f'{worker}:{remote_root}/discover-adapter/', str(run / 'discover-adapter') + '/'])
|
||||
phase('building-core')
|
||||
builds = {v: remote_root + '/' + v + '/build' for v in variants}
|
||||
build_env = dict(config['build_environment'], ARCHIPELAGO_SOFTWARE_PLUGIN=remote_root + '/software-adapter/libgs_plugin_archipelago.so')
|
||||
build_env = dict(config['build_environment'], ARCHIPELAGO_SOFTWARE_PLUGIN=remote_root + '/software-adapter/libgs_plugin_archipelago.so',
|
||||
ARCHIPELAGO_LOG_DIR=remote_root + '/cli-logs')
|
||||
if 'kde' in desktops and build_env.get('ARCHIPELAGO_UPDATE_PROFILE'):
|
||||
original_profile = build_env['ARCHIPELAGO_UPDATE_PROFILE']
|
||||
generated_profile = remote_root + '/update.json'
|
||||
|
|
@ -328,6 +332,8 @@ rm -rf {builds['core']}/iso-work {builds['core']}/profile {builds['core']}/extra
|
|||
state['artifacts_archived'] = True
|
||||
call(['rsync', '-a', f'{worker}:{remote_root}/inputs.sha256', str(run) + '/'])
|
||||
call(['rsync', '-a', f'{worker}:{remote_root}/source.tar', f'{worker}:{remote_root}/archipelago', str(run) + '/'])
|
||||
if not args.existing:
|
||||
call(['rsync', '-a', f'{worker}:{remote_root}/cli-logs/', str(run / 'cli-logs') + '/'])
|
||||
phase('preparing-publication')
|
||||
core_summaries = list((run / 'core/vms').glob('*/summary.json'))
|
||||
if len(core_summaries) != 1:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue