Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 10 additions & 4 deletions .github/CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ self-hosted snapshot and its own key.

Pages serves the signed pacman repository, manuals, and a checksummed ISO
download page. The ISO is an asset of a snapshot-specific GitHub Release
because it exceeds the Pages site limit. The publisher verifies the previous
signed snapshot, preserves its package URLs during the handover, and reuses
already published package bytes for unchanged fixed package versions. Bump
the PKGBUILD version or release when changing one of those packages.
because it exceeds the Pages site limit. After successful deployment, the
publisher keeps the live rolling ISO and one previous installer and prunes
older generated rolling Releases and tags.

The RPR page lists packages from the signed sync database, with installation
commands, dependencies, and recent source commits up to each package's build
date. The publisher verifies the previous signed snapshot, preserves its package
URLs during the handover, and reuses already published package bytes for unchanged
fixed package versions. Bump the PKGBUILD version or release when changing one
of those packages.
5 changes: 5 additions & 0 deletions .github/workflows/publish-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,8 @@ jobs:
if: steps.ready.outputs.publish == 'true'
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1
- name: Prune older rolling installer releases
if: steps.deployment.outcome == 'success' || steps.signed.outputs.deployed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/ci/prune-rpr-releases.py out/production-pages
15 changes: 15 additions & 0 deletions resources/pages/css/reliefos.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,21 @@ dl.meta dd {
clear: both;
}

.rpr-package {
padding: 8px 0;
border-bottom: 1px solid #d7dde5;
overflow-wrap: break-word;
}

.rpr-package summary {
cursor: pointer;
color: #1a4f8a;
}

.rpr-package[open] summary {
margin-bottom: 10px;
}

/* A plain button-like link for the primary Download action, no gradient or
animation, just a solid blue block. */
a.button {
Expand Down
5 changes: 5 additions & 0 deletions resources/pages/i18n/en.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ site_message() {
rpr_summary) printf '%s' 'The Remote Package Repository.' ;;
rpr_source_commit) printf '%s' 'Git commit at repository generation' ;;
rpr_source_commit_missing) printf '%s' 'Not recorded' ;;
rpr_download_size) printf '%s' 'Download size' ;;
rpr_dependencies) printf '%s' 'Dependencies' ;;
rpr_optional_dependencies) printf '%s' 'Optional dependencies' ;;
rpr_changes) printf '%s' 'Recent source changes' ;;
rpr_no_changes) printf '%s' 'No source changes recorded for this package.' ;;
download_summary) printf '%s' 'Installer ISO with checksums.' ;;
source) printf '%s' 'Source' ;;
source_summary) printf '%s' 'Project source repository.' ;;
Expand Down
5 changes: 5 additions & 0 deletions resources/pages/i18n/ja.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ site_message() {
rpr_summary) printf '%s' 'リモートパッケージリポジトリ。' ;;
rpr_source_commit) printf '%s' 'リポジトリ生成時の Git コミット' ;;
rpr_source_commit_missing) printf '%s' '記録なし' ;;
rpr_download_size) printf '%s' 'ダウンロードサイズ' ;;
rpr_dependencies) printf '%s' '依存パッケージ' ;;
rpr_optional_dependencies) printf '%s' '任意の依存パッケージ' ;;
rpr_changes) printf '%s' '最近のソース変更' ;;
rpr_no_changes) printf '%s' 'このパッケージの変更履歴は記録されていません。' ;;
download_summary) printf '%s' 'インストール ISO とチェックサム。' ;;
source) printf '%s' 'ソースコード' ;;
source_summary) printf '%s' 'プロジェクトのソースリポジトリ。' ;;
Expand Down
5 changes: 5 additions & 0 deletions resources/pages/i18n/zh-CN.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ site_message() {
rpr_summary) printf '%s' '远程软件包仓库。' ;;
rpr_source_commit) printf '%s' '仓库生成时的 Git 提交' ;;
rpr_source_commit_missing) printf '%s' '未记录' ;;
rpr_download_size) printf '%s' '下载大小' ;;
rpr_dependencies) printf '%s' '依赖' ;;
rpr_optional_dependencies) printf '%s' '可选依赖' ;;
rpr_changes) printf '%s' '近期更新日志' ;;
rpr_no_changes) printf '%s' '暂无此软件包的源码变更记录。' ;;
download_summary) printf '%s' '安装 ISO 镜像及校验和。' ;;
source) printf '%s' '源码' ;;
source_summary) printf '%s' '项目源码仓库。' ;;
Expand Down
64 changes: 64 additions & 0 deletions scripts/ci/prune-rpr-releases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
"""Keep the live rolling installer and one fallback after Pages deployment."""

import argparse
import json
import os
from pathlib import Path
import re
import subprocess


def is_rolling_installer(release):
return (
re.fullmatch(r"rpr-[0-9a-f]{64}", release["tag_name"])
and re.fullmatch(r"ReliefOS rolling installer [0-9a-f]{12}", release["name"] or "")
and not release["draft"]
and not release["prerelease"]
and [asset["name"] for asset in release["assets"]] == ["reliefos-installer.iso"]
and release["assets"][0]["state"] == "uploaded"
)


def installers_to_prune(releases, active, previous):
ordered = sorted(filter(is_rolling_installer, releases),
key=lambda release: (release["published_at"], release["id"]), reverse=True)
tags = [release["tag_name"] for release in ordered]
if active not in tags:
raise ValueError(f"Deployed installer {active} is missing from the release list")

# The signed previous Pages snapshot takes precedence over unpublished attempts.
keep = {active}
if previous and previous != active and previous in tags:
keep.add(previous)
else:
index = tags.index(active)
keep.update(tags[index + 1:index + 2])
return [tag for tag in tags if tag not in keep]


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("output", type=Path)
args = parser.parse_args()
state = args.output / "ci"
repository = os.environ["GITHUB_REPOSITORY"]
active = (state / "installer-release-tag").read_text().strip()
previous_snapshot = state / "previous-rpr"
previous = f"rpr-{previous_snapshot.read_text().strip()}" if previous_snapshot.exists() else None

raw = subprocess.check_output(["gh", "api", "--paginate", "--slurp",
f"repos/{repository}/releases?per_page=100"], text=True)
releases = [release for page in json.loads(raw) for release in page]
try:
obsolete = installers_to_prune(releases, active, previous)
except ValueError as error:
parser.exit(1, f"RPR release retention: {error}\n")
for tag in obsolete:
print(f"Pruning superseded rolling installer {tag}", flush=True)
subprocess.run(["gh", "release", "delete", tag, "--repo", repository,
"--yes", "--cleanup-tag"], check=True)


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions scripts/ci/publish-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ case $operation in
[[ $previous =~ ^[a-f0-9]{64}$ ]]
if [[ $(<"$output/rpr-testing/$previous/source-commit") == "$GITHUB_SHA" ]]; then
echo 'This source commit is already deployed.'
printf 'rpr-%s\n' "$previous" > "$tag_file"
echo 'deployed=true' >> "$GITHUB_OUTPUT"
exit 0
fi
fi
Expand Down
65 changes: 65 additions & 0 deletions tests/build/test-site-i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"""Exercise translated Pages against the pacman repository layout."""
import hashlib
from html.parser import HTMLParser
import io
import os
from pathlib import Path
import runpy
import shutil
import subprocess
import tarfile
import tempfile
import unittest
from urllib.parse import urljoin, urlsplit
Expand All @@ -18,6 +22,20 @@
SOURCE_COMMIT = "a14fa1e18ae96847e7315a56b455c2b2c8adb930"


def write_database(path):
with tarfile.open(path, "w:gz") as archive:
for name, size, extra in (
("reliefos-packages", 1048576,
"%DESC%\nPackage manager <desktop>\n\n%DEPENDS%\nlibreliefos>=5.3.4\n\n%OPTDEPENDS%\nparu: install from AUR\n\n"),
("libreliefos", 8192, ""),
):
metadata = (f"%NAME%\n{name}\n\n%VERSION%\n5.3.4-1.42\n\n%CSIZE%\n{size}\n\n"
f"%BUILDDATE%\n1700000000\n\n{extra}").encode()
entry = tarfile.TarInfo(f"{name}-5.3.4-1.42/desc")
entry.size = len(metadata)
archive.addfile(entry, io.BytesIO(metadata))


class Page(HTMLParser):
def __init__(self, path):
super().__init__(convert_charrefs=True)
Expand Down Expand Up @@ -60,6 +78,7 @@ def setUpClass(cls):
(cls.site / directory).mkdir(parents=True)
for name in REPOSITORY_FILES:
(cls.site / "rpr" / name).write_bytes((name + " fixture\n").encode())
write_database(cls.site / "rpr/rpr.db")
(cls.site / "rpr/source-commit").write_text(SOURCE_COMMIT + "\n")
shutil.copyfile(ROOT / "resources/pages/css/reliefos.css", cls.site / "css/reliefos.css")
cls.iso = cls.site / "download/reliefos-installer.iso"
Expand Down Expand Up @@ -128,11 +147,57 @@ def test_rpr_links_the_snapshot_commit_in_all_languages(self):

def test_rpr_does_not_guess_an_older_snapshot_commit(self):
with tempfile.TemporaryDirectory() as directory:
(Path(directory) / "rpr").mkdir()
shutil.copyfile(self.site / "rpr/rpr.db", Path(directory) / "rpr/rpr.db")
subprocess.run(["sh", str(SCRIPTS / "rpr-index.sh"), directory, FINGERPRINT], check=True)
page = Page(Path(directory) / "en/rpr/index.html")
self.assertIn("Not recorded", "".join(page.text))
self.assertFalse(any("/commit/" in anchor["href"] for _, anchor in page.anchors))

def test_catalog_describes_packages_in_all_languages(self):
headings = {"zh-CN": "近期更新日志", "en": "Recent source changes", "ja": "最近のソース変更"}
for language, prefix in LANGUAGES.items():
html = (self.site / prefix / "rpr/index.html").read_text()
with self.subTest(language=language):
self.assertLess(html.index('id="package-libreliefos"'), html.index('id="package-reliefos-packages"'))
for entry in ("5.3.4-1.42", "1.0 MiB", "8.0 KiB", headings[language],
"Package manager &lt;desktop&gt;", "libreliefos&gt;=5.3.4",
"paru: install from AUR", "pacman -S rpr/reliefos-packages"):
self.assertIn(entry, html)

def test_changelog_respects_the_package_sources_and_build_date(self):
scripts = runpy.run_path(str(SCRIPTS / "rpr-packages.py"))
packages = scripts["read_packages"](self.site / "rpr/rpr.db")
with tempfile.TemporaryDirectory() as directory:
source = Path(directory)
manifest = source / "tools/build/arch-applications.list"
manifest.parent.mkdir(parents=True)
manifest.write_text("reliefpackages reliefos-packages desktop\n")
app = source / "userland/apps/reliefpackages/README"
app.parent.mkdir(parents=True)
unrelated = source / "unrelated.txt"

def git(*arguments, time=1700000000):
return subprocess.check_output(
["git", "-C", source, "-c", "user.name=RPR Test", "-c", "user.email=rpr@example.invalid", *arguments],
env={**os.environ, "GIT_AUTHOR_DATE": f"{time} +0000", "GIT_COMMITTER_DATE": f"{time} +0000"},
text=True,
).strip()

git("init", "-q")
app.write_text("initial\n")
git("add", ".")
git("commit", "-qm", "First package update")
published = git("rev-parse", "HEAD")
unrelated.write_text("unrelated\n")
git("add", ".")
git("commit", "-qm", "Unrelated change")
app.write_text("future update\n")
git("add", ".")
git("commit", "-qm", "Future package update", time=1700000001)
changes = scripts["package_changes"](packages, source, git("rev-parse", "HEAD"))
self.assertEqual(changes["reliefos-packages"], [[published, "First package update"]])


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion tests/integration/arch-rpr-testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ expected_keyring=reliefos
if [[ $repository_url == "$(<"$work/usr/share/reliefos/rpr-production-url")" ]]; then
expected_keyring=reliefos-production
fi
[[ $("$work/usr/libexec/reliefos/rpr-keyring" "$work") == "$expected_keyring" ]]
[[ $(sh "$work/usr/libexec/reliefos/rpr-keyring" "$work") == "$expected_keyring" ]]
test -s "$work/usr/share/pacman/keyrings/reliefos-production.gpg"
cmp -- "$work/etc/pacman.d/mirrorlist" "$work/usr/share/reliefos/pacman/mirrorlist"
grep -Fxq 'ParallelDownloads = 10' "$work/etc/pacman.conf"
Expand Down
10 changes: 9 additions & 1 deletion tools/build/rpr-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# Render human entry points next to the unchanged pacman repository URLs.
set -eu
output=$1 fingerprint=$2
scripts=$(dirname "$0")
# shellcheck source=/dev/null
. "$(dirname "$0")/site-common.sh"
. "$scripts/site-common.sh"
source_commit=
if [ -f "$output/rpr/source-commit" ]; then
source_commit=$(cat "$output/rpr/source-commit")
Expand Down Expand Up @@ -34,6 +35,13 @@ for language in zh-CN en ja; do
printf '<li><a href="%s">%s</a></li>\n' "$(site_href "rpr/$member")" "$member"
done
printf '</ul><p><code>pacman -Syu</code></p>\n'
python3 "$scripts/rpr-packages.py" "$output/rpr/rpr.db" "$source_commit" \
--title "$(site_message packages)" \
--download-size "$(site_message rpr_download_size)" \
--dependencies "$(site_message rpr_dependencies)" \
--optional-dependencies "$(site_message rpr_optional_dependencies)" \
--changelog "$(site_message rpr_changes)" \
--no-changes "$(site_message rpr_no_changes)"
site_page_end
} > "$page"
done
Loading