diff --git a/.github/CI.md b/.github/CI.md index 1c9f6160..be8ad4f6 100644 --- a/.github/CI.md +++ b/.github/CI.md @@ -33,5 +33,30 @@ QEMU jobs retain serial logs and result records. Select **CI result** as the required branch check. It reports every required job and treats a missing or failed result as a failure. -Production publishing is performed separately following the release -guide, using a complete signed RPR snapshot and the matching media. + +## Production Pages and RPR + +A successful CI result for a push to `main` triggers the production publisher. +To retry from Actions, run **ReliefOS CI** on `main` with **publish_pages** +enabled. The workflow builds the verified commit, serializes production +deployments, and skips commits already deployed or superseded on `main`. + +Configure the `github-pages` environment for `main` deployments. Set the +`RPR_SIGNING_FINGERPRINT` Actions variable to the primary fingerprint from +`packages/arch/reliefos-keyring/production-fingerprint`. Set the +`RPR_SIGNING_KEY_B64` Actions secret to a base64-encoded OpenPGP secret-subkey +export that can sign in batch mode. Retain the primary secret key and its +revocation certificate in project-controlled backup storage. + +The default repository is `https://reliefosproject.github.io/ReliefOS/rpr`. +The build uses the selected snapshot key to verify local packages. ISO and disk +images configured for the default URL trust the packaged production public key +for online installation and updates. Override `RPR_SERVER_URL` to use a +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. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0ee6d42..06ace8d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,11 @@ on: push: branches: [main, rewrite/new-os] workflow_dispatch: + inputs: + publish_pages: + description: Publish the verified main commit to GitHub Pages and RPR + type: boolean + default: false permissions: contents: read @@ -84,6 +89,7 @@ jobs: tests/integration/arch-rpr-{testing,pacman}.sh \ tests/integration/arch-{kernel-prune,kernel-prune-container,systemd-boot,systemd-entry}.sh \ tests/integration/arch-kernel-upgrade{,-build}.sh + shellcheck scripts/ci/{restore-rpr,publish-pages}.sh /usr/bin/python3 -m unittest discover -s tools/tests -p 'test_ci*.py' -v documentation: @@ -292,3 +298,13 @@ jobs: env: NEEDS_JSON: ${{ toJSON(needs) }} run: python3 tools/ci.py summary + + publish: + name: Publish production Pages and RPR + needs: ci + if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish_pages)) + permissions: + contents: write + pages: write + id-token: write + uses: ./.github/workflows/publish-pages.yml diff --git a/.github/workflows/publish-pages.yml b/.github/workflows/publish-pages.yml new file mode 100644 index 00000000..5cd34956 --- /dev/null +++ b/.github/workflows/publish-pages.yml @@ -0,0 +1,103 @@ +name: Publish ReliefOS Pages + +on: + workflow_call: + +concurrency: + group: reliefos-production-pages + cancel-in-progress: false + +jobs: + production: + name: Sign RPR, publish installer and deploy Pages + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-24.04 + timeout-minutes: 90 + permissions: + contents: write + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + env: + ARCH_BASE_REGISTRY: docker.io + ARCH_JOBS: '2' + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + submodules: recursive + persist-credentials: false + - name: Skip superseded runs + id: current + shell: bash + run: | + ref=$(git ls-remote --exit-code origin refs/heads/main) + if [[ ${ref%%$'\t'*} == "$GITHUB_SHA" ]]; then + echo 'publish=true' >> "$GITHUB_OUTPUT" + else + echo 'This CI run has been superseded by a newer main commit.' + fi + - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 + if: steps.current.outputs.publish == 'true' + id: pages + - name: Check production configuration + if: steps.current.outputs.publish == 'true' + shell: bash + env: + PAGES_BASE_URL: ${{ steps.pages.outputs.base_url }} + RPR_SIGNING_FINGERPRINT: ${{ vars.RPR_SIGNING_FINGERPRINT }} + RPR_SIGNING_KEY_B64: ${{ secrets.RPR_SIGNING_KEY_B64 }} + run: | + repository=$(> "$GITHUB_ENV" + echo "RPR_SIGNING_FINGERPRINT=$RPR_SIGNING_FINGERPRINT" >> "$GITHUB_ENV" + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + if: steps.current.outputs.publish == 'true' + with: + python-version: '3.12' + cache: pip + cache-dependency-path: Documentation/requirements.txt + - name: Install Sphinx and build release packages + if: steps.current.outputs.publish == 'true' + shell: bash + run: | + python -m pip install -r Documentation/requirements.txt 'Sphinx==9.*' + bash scripts/ci/arch-host.sh ubuntu-24.04 out/production-pages + - name: Sign the repository with the production subkey + if: steps.current.outputs.publish == 'true' + id: signed + env: + RPR_SIGNING_KEY_B64: ${{ secrets.RPR_SIGNING_KEY_B64 }} + run: bash scripts/ci/publish-pages.sh sign out/production-pages + - name: Assemble the production installer and Pages site + if: steps.signed.outputs.publish == 'true' + run: bash scripts/ci/publish-pages.sh assemble out/production-pages + - name: Check that this is still the latest main commit + if: steps.signed.outputs.publish == 'true' + id: ready + shell: bash + run: | + ref=$(git ls-remote --exit-code origin refs/heads/main) + if [[ ${ref%%$'\t'*} == "$GITHUB_SHA" ]]; then + echo 'publish=true' >> "$GITHUB_OUTPUT" + else + echo 'A newer main commit will publish its own release.' + fi + - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 + if: steps.ready.outputs.publish == 'true' + with: + path: out/production-pages/pages + - name: Publish the matching ISO to GitHub Releases + if: steps.ready.outputs.publish == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: bash scripts/ci/publish-pages.sh upload out/production-pages + - name: Deploy the signed RPR and download links together + if: steps.ready.outputs.publish == 'true' + id: deployment + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 diff --git a/Documentation/kbuild/building.rst b/Documentation/kbuild/building.rst index b1afca39..f2078a42 100644 --- a/Documentation/kbuild/building.rst +++ b/Documentation/kbuild/building.rst @@ -174,7 +174,7 @@ testing RPR 收录当前版本化内核包、固定名称的更新包,以及 ` 客户端必须先通过独立可信渠道取得发布者的完整指纹。在 Arch 测试环境中,可用 ``bash tools/build/arch-rpr-trust.sh PUBLIC_KEY FINGERPRINT PACMAN_GPGDIR`` 初始化一个 -新的 pacman 信任目录。已签名的 ``reliefos-testing-keyring`` 包保存公开信任数据, +新的 pacman 信任目录。已签名的 ``reliefos-keyring`` 包保存公开信任数据, 不能替代首次指纹核验。让 ``[rpr]`` 指向所选快照,仓库使用 ``SigLevel = Required TrustedOnly``;testing 环境之外使用 HTTPS。此入口不配置 系统 pacman,也不安装或切换系统组件。 @@ -220,7 +220,8 @@ ReliefOS 的 XDM 覆盖配置、会话选择和 IceWM 自启动规则见 :doc:`. 已校验的持久内核载荷进入归档,供离线磁盘装配和安装后的启动更新使用。 载荷发布锁文件在归档前删除。 -必须用 ``RPR_SERVER_URL`` 指定目标系统使用的在线仓库地址。开发测试应指定测试服务器。目标系统的 +默认在线仓库为 ``https://reliefosproject.github.io/ReliefOS/rpr``,镜像使用内置的正式 RPR 公钥。 +开发测试可用 ``RPR_SERVER_URL`` 指定其他仓库,并使用所选快照的签名公钥。目标系统的 ``/etc/pacman.d/reliefos-rpr.conf`` 将该地址配置为 ``[rpr]``,包和数据库均须通过 可信签名验证。首次启动时 ``reliefos-pacman-init.service`` 使用已安装的 Arch 和 ReliefOS 公钥初始化独立的 pacman 信任目录,后续密钥包升级会更新 ReliefOS 信任数据。 diff --git a/Documentation/locale/en/LC_MESSAGES/kbuild/building.po b/Documentation/locale/en/LC_MESSAGES/kbuild/building.po index 5b63e5eb..746a2dcc 100644 --- a/Documentation/locale/en/LC_MESSAGES/kbuild/building.po +++ b/Documentation/locale/en/LC_MESSAGES/kbuild/building.po @@ -399,14 +399,14 @@ msgstr "" msgid "" "客户端必须先通过独立可信渠道取得发布者的完整指纹。在 Arch 测试环境中,可用 ``bash tools/build/arch-rpr-" "trust.sh PUBLIC_KEY FINGERPRINT PACMAN_GPGDIR`` 初始化一个 新的 pacman 信任目录。已签名的" -" ``reliefos-testing-keyring`` 包保存公开信任数据, 不能替代首次指纹核验。让 ``[rpr]`` " +" ``reliefos-keyring`` 包保存公开信任数据, 不能替代首次指纹核验。让 ``[rpr]`` " "指向所选快照,仓库使用 ``SigLevel = Required TrustedOnly``;testing 环境之外使用 " "HTTPS。此入口不配置 系统 pacman,也不安装或切换系统组件。" msgstr "" "Clients must first obtain the publisher’s full fingerprint through an " "independent trusted channel. In an Arch test environment, run ``bash " "tools/build/arch-rpr-trust.sh PUBLIC_KEY FINGERPRINT PACMAN_GPGDIR`` to " -"initialize a new pacman trust directory. The signed ``reliefos-testing-" +"initialize a new pacman trust directory. The signed ``reliefos-" "keyring`` package carries public trust data but cannot replace the " "initial fingerprint check. Point ``[rpr]`` at the chosen snapshot and use" " ``SigLevel = Required TrustedOnly`` for the repository. Use HTTPS " @@ -522,14 +522,13 @@ msgstr "" " before archiving." msgid "" -"必须用 ``RPR_SERVER_URL`` 指定目标系统使用的在线仓库地址。开发测试应指定测试服务器。目标系统的 " +"默认在线仓库为 ``https://reliefosproject.github.io/ReliefOS/rpr``,镜像使用内置的正式 RPR 公钥。 开发测试可用 ``RPR_SERVER_URL`` 指定其他仓库,并使用所选快照的签名公钥。目标系统的 " "``/etc/pacman.d/reliefos-" "rpr.conf`` 将该地址配置为 ``[rpr]``,包和数据库均须通过 可信签名验证。首次启动时 ``reliefos-pacman-" "init.service`` 使用已安装的 Arch 和 ReliefOS 公钥初始化独立的 pacman 信任目录,后续密钥包升级会更新 " "ReliefOS 信任数据。" msgstr "" -"Set ``RPR_SERVER_URL`` to the target system's online repository URL. Use " -"the testing server for development. The target's ``/etc/pacman.d/reliefos-" +"The default online repository is ``https://reliefosproject.github.io/ReliefOS/rpr``. Images use the embedded production RPR public key. Set ``RPR_SERVER_URL`` for development to use another repository and the selected snapshot's signing key. The target's ``/etc/pacman.d/reliefos-" "rpr.conf`` configures this URL under ``[rpr]``. Both packages and the " "database must have trusted signatures. On first boot, ``reliefos-pacman-" "init.service`` initializes a dedicated pacman trust directory from the " diff --git a/Documentation/locale/ja/LC_MESSAGES/kbuild/building.po b/Documentation/locale/ja/LC_MESSAGES/kbuild/building.po index dfaef3a1..3de9edef 100644 --- a/Documentation/locale/ja/LC_MESSAGES/kbuild/building.po +++ b/Documentation/locale/ja/LC_MESSAGES/kbuild/building.po @@ -333,13 +333,13 @@ msgstr "" msgid "" "客户端必须先通过独立可信渠道取得发布者的完整指纹。在 Arch 测试环境中,可用 ``bash tools/build/arch-rpr-" "trust.sh PUBLIC_KEY FINGERPRINT PACMAN_GPGDIR`` 初始化一个 新的 pacman 信任目录。已签名的" -" ``reliefos-testing-keyring`` 包保存公开信任数据, 不能替代首次指纹核验。让 ``[rpr]`` " +" ``reliefos-keyring`` 包保存公开信任数据, 不能替代首次指纹核验。让 ``[rpr]`` " "指向所选快照,仓库使用 ``SigLevel = Required TrustedOnly``;testing 环境之外使用 " "HTTPS。此入口不配置 系统 pacman,也不安装或切换系统组件。" msgstr "" "クライアントは、配布元の完全なフィンガープリントを事前に独立した信頼できる経路で取得してください。 Arch のテスト環境では、``bash " "tools/build/arch-rpr-trust.sh PUBLIC_KEY FINGERPRINT PACMAN_GPGDIR`` で新しい" -" pacman の信頼ディレクトリを初期化できます。署名済みの ``reliefos-testing-keyring`` " +" pacman の信頼ディレクトリを初期化できます。署名済みの ``reliefos-keyring`` " "パッケージには公開の信頼情報が含まれますが、初回のフィンガープリント照合の代わりにはなりません。 ``[rpr]`` " "の参照先を対象のスナップショットに設定し、リポジトリには ``SigLevel = Required TrustedOnly`` " "を指定します。テスト環境以外では HTTPS を使用してください。 この手順でシステムの pacman " @@ -437,14 +437,13 @@ msgstr "" "信頼ディレクトリを含めません。検証済みの永続カーネルペイロードは、オフラインのディスク組み立てとインストール後の起動更新に使用するため含めます。ペイロード公開ロックファイルはアーカイブ前に削除します。" msgid "" -"必须用 ``RPR_SERVER_URL`` 指定目标系统使用的在线仓库地址。开发测试应指定测试服务器。目标系统的 " +"默认在线仓库为 ``https://reliefosproject.github.io/ReliefOS/rpr``,镜像使用内置的正式 RPR 公钥。 开发测试可用 ``RPR_SERVER_URL`` 指定其他仓库,并使用所选快照的签名公钥。目标系统的 " "``/etc/pacman.d/reliefos-" "rpr.conf`` 将该地址配置为 ``[rpr]``,包和数据库均须通过 可信签名验证。首次启动时 ``reliefos-pacman-" "init.service`` 使用已安装的 Arch 和 ReliefOS 公钥初始化独立的 pacman 信任目录,后续密钥包升级会更新 " "ReliefOS 信任数据。" msgstr "" -"``RPR_SERVER_URL`` にインストール先システムが使うオンラインリポジトリの URL を指定してください。" -"開発テストではテストサーバーを指定します。インストール先の " +"既定のオンラインリポジトリは ``https://reliefosproject.github.io/ReliefOS/rpr`` です。イメージは組み込みの正式 RPR 公開鍵を使用します。開発テストで ``RPR_SERVER_URL`` を設定すると、別のリポジトリと選択したスナップショットの署名鍵を使用できます。インストール先の " "``/etc/pacman.d/reliefos-rpr.conf`` はこの URL を ``[rpr]`` " "に設定し、パッケージとデータベースの両方に信頼済みの署名を要求します。初回起動時に ``reliefos-pacman-" "init.service`` がインストール済みの Arch と ReliefOS 公開鍵から専用の pacman " diff --git a/packages/arch/reliefos-keyring/PKGBUILD b/packages/arch/reliefos-keyring/PKGBUILD new file mode 100644 index 00000000..779e9b4c --- /dev/null +++ b/packages/arch/reliefos-keyring/PKGBUILD @@ -0,0 +1,50 @@ +# The repository publisher supplies only the selected public key and trust data. +pkgname=reliefos-keyring +pkgver=1 +pkgrel=2 +pkgdesc='Public OpenPGP trust data for the ReliefOS package repository' +arch=('any') +url='https://github.com/ReliefOSProject/ReliefOS' +license=('Apache-2.0') +depends=('pacman') +makedepends=('gnupg') +provides=('reliefos-testing-keyring') +conflicts=('reliefos-testing-keyring') +replaces=('reliefos-testing-keyring') +options=('!debug') +source=('reliefos-pacman-init.service' 'reliefos-pacman-keyring' 'reliefos-keyring-update.hook' + 'reliefos-rpr-keyring' 'production-url' 'production-fingerprint' 'production-key.pub') +sha256sums=('30f39fdb8c2642b1a30ca49746a981ed6a6814831f9254223497207a71fc2554' + 'fcd8edcd93aceea9524f5ec62159534316df79bf6f9d73a55eb19ae291601df3' + '074f6a51e422b03dcb0630b62ab8831e84ab97bb15bdc11e9c194418eedb7a77' + '8ed06f68a7286f4ba8dfedcd02de278259dfff108739c1897bee7a6a0ee5edda' + 'c513a7e52e0afcd9a8831e18d3016e3aa2ef8f9b92567572206fead34563f2e5' + '02867c18145974c1f37d86c25fd0f9f7216ef365a264b7321f06ac9ded9783ba' + '663ccb5e93cb20f32542137bc9b7dc4d61ff7a1809b043a70f5fdd3cc6e3bcbe') + +package() { + local keyring=${RELIEFOS_KEYRING_DIR:?build via make arch-rpr-testing} + local production_dir=$pkgdir/usr/share/pacman/keyrings + local gpg_home=$srcdir/rpr-gnupg + local -a gpg=(gpg --no-options --batch --homedir "$gpg_home") + local fingerprint found + install -dm700 -- "$gpg_home" + fingerprint=$(<"$srcdir/production-fingerprint") + found=$("${gpg[@]}" --with-colons --show-keys "$srcdir/production-key.pub" | + awk -F: '$1 == "pub" {primary = 1} $1 == "fpr" && primary {print $10; primary = 0}') + [[ $fingerprint =~ ^[0-9A-F]{40}$ && $found == "$fingerprint" ]] || return 1 + install -Dm644 -t "$pkgdir/usr/share/pacman/keyrings" \ + "$keyring/reliefos.gpg" "$keyring/reliefos-trusted" \ + "$keyring/reliefos-revoked" + "${gpg[@]}" --dearmor --output "$production_dir/reliefos-production.gpg" "$srcdir/production-key.pub" + printf '%s:4:\n' "$fingerprint" > "$production_dir/reliefos-production-trusted" + : > "$production_dir/reliefos-production-revoked" + install -Dm644 "$srcdir/production-url" "$pkgdir/usr/share/reliefos/rpr-production-url" + install -Dm755 "$srcdir/reliefos-rpr-keyring" "$pkgdir/usr/libexec/reliefos/rpr-keyring" + install -Dm644 "$srcdir/reliefos-pacman-init.service" \ + "$pkgdir/usr/lib/systemd/system/reliefos-pacman-init.service" + install -Dm755 "$srcdir/reliefos-pacman-keyring" \ + "$pkgdir/usr/libexec/reliefos/pacman-keyring" + install -Dm644 "$srcdir/reliefos-keyring-update.hook" \ + "$pkgdir/usr/share/libalpm/hooks/reliefos-keyring-update.hook" +} diff --git a/packages/arch/reliefos-keyring/production-fingerprint b/packages/arch/reliefos-keyring/production-fingerprint new file mode 100644 index 00000000..d1aef26a --- /dev/null +++ b/packages/arch/reliefos-keyring/production-fingerprint @@ -0,0 +1 @@ +6697F82A4B84BAD8D19A2C7867DA313B6C201C57 diff --git a/packages/arch/reliefos-keyring/production-key.pub b/packages/arch/reliefos-keyring/production-key.pub new file mode 100644 index 00000000..3ada43b4 --- /dev/null +++ b/packages/arch/reliefos-keyring/production-key.pub @@ -0,0 +1,15 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mDMEaxF0SRYJKwYBBAHaRw8BAQdAF0MPc4BsQznQEeoZMPf6MfSpsGk87zddX01X +5N+NiQq0DFJlbGllZk9TIFJQUoiQBBMWCgA4FiEEZpf4KkuEutjRmix4Z9oxO2wg +HFcFAmsRdEkCGwEFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQZ9oxO2wgHFeD +lQD/dCKKb06VqnAhEaWO/PuRIU6bCDPvU4mDWnCD4GGZ2wMBAPSdlP75Lns43Kgq +b5P4PnyFrv+PKuNZnUZTFETqQg4BuDMEaxF0SRYJKwYBBAHaRw8BAQdAMly91ceZ +/WOfDail+OvYmjAFCjC1AwIF6nsMBsgY4+6I9QQYFgoAJhYhBGaX+CpLhLrY0Zos +eGfaMTtsIBxXBQJrEXRJAhsCBQkDwmcAAIEJEGfaMTtsIBxXdiAEGRYKAB0WIQQz +eyT8Ke/P13Ltz9eaPahVvCiaiwUCaxF0SQAKCRCaPahVvCiai/NOAQDLEC9CFKbE +cQNc9mTWbRBU02ahQApzvg808QOaiPuK8gD/Yv7mmiOhDOJDxw2fpdxmiPqepFrH +/17ZV/B3eO+ivwzwxgEAq70UJDD7F/BbwQkyObWwXTsbE4QsI7/+yuZeUaj2T2gA +/1AUDCrEm8fSuV4WlAJ6H8pEFlfn+RA7vqk1fZi6euoM +=2Sy7 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/packages/arch/reliefos-keyring/production-url b/packages/arch/reliefos-keyring/production-url new file mode 100644 index 00000000..6e3a17f1 --- /dev/null +++ b/packages/arch/reliefos-keyring/production-url @@ -0,0 +1 @@ +https://reliefosproject.github.io/ReliefOS/rpr diff --git a/packages/arch/reliefos-testing-keyring/reliefos-keyring-update.hook b/packages/arch/reliefos-keyring/reliefos-keyring-update.hook similarity index 86% rename from packages/arch/reliefos-testing-keyring/reliefos-keyring-update.hook rename to packages/arch/reliefos-keyring/reliefos-keyring-update.hook index 21077bf0..4fa7fbd1 100644 --- a/packages/arch/reliefos-testing-keyring/reliefos-keyring-update.hook +++ b/packages/arch/reliefos-keyring/reliefos-keyring-update.hook @@ -2,7 +2,7 @@ Operation = Install Operation = Upgrade Type = Package -Target = reliefos-testing-keyring +Target = reliefos-keyring [Action] Description = Updating the ReliefOS package signing trust diff --git a/packages/arch/reliefos-testing-keyring/reliefos-pacman-init.service b/packages/arch/reliefos-keyring/reliefos-pacman-init.service similarity index 100% rename from packages/arch/reliefos-testing-keyring/reliefos-pacman-init.service rename to packages/arch/reliefos-keyring/reliefos-pacman-init.service diff --git a/packages/arch/reliefos-testing-keyring/reliefos-pacman-keyring b/packages/arch/reliefos-keyring/reliefos-pacman-keyring similarity index 65% rename from packages/arch/reliefos-testing-keyring/reliefos-pacman-keyring rename to packages/arch/reliefos-keyring/reliefos-pacman-keyring index 58cd29bb..783c5b87 100644 --- a/packages/arch/reliefos-testing-keyring/reliefos-pacman-keyring +++ b/packages/arch/reliefos-keyring/reliefos-pacman-keyring @@ -5,13 +5,15 @@ ready=/var/lib/reliefos/pacman-keyring.ready case ${1:-initialize} in initialize) [ ! -e "$ready" ] || exit 0 + keyring=$(/usr/libexec/reliefos/rpr-keyring) pacman-key --init - pacman-key --populate archlinux reliefos-testing + pacman-key --populate archlinux "$keyring" install -Dm644 /dev/null "$ready" ;; --if-initialized) [ -e "$ready" ] || exit 0 - pacman-key --populate reliefos-testing + keyring=$(/usr/libexec/reliefos/rpr-keyring) + pacman-key --populate "$keyring" ;; *) printf 'usage: %s [--if-initialized]\n' "$0" >&2 diff --git a/packages/arch/reliefos-keyring/reliefos-rpr-keyring b/packages/arch/reliefos-keyring/reliefos-rpr-keyring new file mode 100644 index 00000000..a27a6fd7 --- /dev/null +++ b/packages/arch/reliefos-keyring/reliefos-rpr-keyring @@ -0,0 +1,13 @@ +#!/bin/sh +# Select the trust root for the configured RPR, including an optional sysroot. +set -eu +root=${1:-} +production=$(cat -- "$root/usr/share/reliefos/rpr-production-url") +configuration=$root/etc/pacman.d/reliefos-rpr.conf +[ -n "$production" ] +[ -r "$configuration" ] +if grep -Fxq -- "Server = $production" "$configuration"; then + printf '%s\n' reliefos-production +else + printf '%s\n' reliefos +fi diff --git a/packages/arch/reliefos-testing-keyring/PKGBUILD b/packages/arch/reliefos-testing-keyring/PKGBUILD deleted file mode 100644 index f05b4039..00000000 --- a/packages/arch/reliefos-testing-keyring/PKGBUILD +++ /dev/null @@ -1,27 +0,0 @@ -# The testing publisher supplies only the selected public key and trust data. -pkgname=reliefos-testing-keyring -pkgver=1 -pkgrel=2 -pkgdesc='Public OpenPGP trust data for the ReliefOS testing package repository' -arch=('any') -url='https://github.com/ReliefOSProject/ReliefOS' -license=('Apache-2.0') -depends=('pacman') -options=('!debug') -source=('reliefos-pacman-init.service' 'reliefos-pacman-keyring' 'reliefos-keyring-update.hook') -sha256sums=('30f39fdb8c2642b1a30ca49746a981ed6a6814831f9254223497207a71fc2554' - '8e2f954c30946a2771460f26385855e862ddc361d26a2db5d5d0bc14c905c2eb' - '0b7945a29c08c33623b67448e132964347d7c010c6fee60b7c649bc7244c080e') - -package() { - local keyring=${RELIEFOS_TESTING_KEYRING_DIR:?build via make arch-rpr-testing} - install -Dm644 -t "$pkgdir/usr/share/pacman/keyrings" \ - "$keyring/reliefos-testing.gpg" "$keyring/reliefos-testing-trusted" \ - "$keyring/reliefos-testing-revoked" - install -Dm644 "$srcdir/reliefos-pacman-init.service" \ - "$pkgdir/usr/lib/systemd/system/reliefos-pacman-init.service" - install -Dm755 "$srcdir/reliefos-pacman-keyring" \ - "$pkgdir/usr/libexec/reliefos/pacman-keyring" - install -Dm644 "$srcdir/reliefos-keyring-update.hook" \ - "$pkgdir/usr/share/libalpm/hooks/reliefos-keyring-update.hook" -} diff --git a/scripts/ci/publish-pages.sh b/scripts/ci/publish-pages.sh new file mode 100644 index 00000000..03ee6125 --- /dev/null +++ b/scripts/ci/publish-pages.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# Sign an existing build, then prepare and publish its public release artifacts. +set -euo pipefail +operation=${1:?sign, assemble or upload required} +output=$(realpath -e -- "${2:?build output required}") +iso=$output/images/reliefos-installer.iso +tag_file=$output/ci/installer-release-tag +fingerprint=${RPR_SIGNING_FINGERPRINT:-} +export RPR_SIGNING_FINGERPRINT=${fingerprint^^} +[[ $RPR_SIGNING_FINGERPRINT =~ ^[0-9A-F]{40}$ ]] || { + echo 'Set RPR_SIGNING_FINGERPRINT in GitHub environment github-pages' >&2; exit 1 +} + +case $operation in + sign) + : "${RPR_SIGNING_KEY_B64:?set the GitHub environment secret RPR_SIGNING_KEY_B64}" + sh tools/build/reliefnt-release-guard.sh "$PWD" "$PWD/kernel/reliefnt" kernel/reliefnt + export RPR_GNUPGHOME + RPR_GNUPGHOME=$(mktemp -d "${RUNNER_TEMP:-/tmp}/rpr-key.XXXXXXXX") + trap 'gpgconf --homedir "$RPR_GNUPGHOME" --kill all; rm -rf -- "$RPR_GNUPGHOME"' EXIT + printf '%s' "$RPR_SIGNING_KEY_B64" | base64 --decode | + gpg --no-options --batch --homedir "$RPR_GNUPGHOME" --import + unset RPR_SIGNING_KEY_B64 + bash scripts/ci/restore-rpr.sh restore "$output" + if [[ -f $output/ci/previous-rpr ]]; then + previous=$(<"$output/ci/previous-rpr") + [[ $previous =~ ^[a-f0-9]{64}$ ]] + if [[ $(<"$output/rpr-testing/$previous/source-commit") == "$GITHUB_SHA" ]]; then + echo 'This source commit is already deployed.' + exit 0 + fi + fi + make O="$output" rpr-testing + echo 'publish=true' >> "$GITHUB_OUTPUT" + ;; + assemble) + snapshot=$(<"$output/rpr-testing/current-$RPR_SIGNING_FINGERPRINT") + [[ $snapshot =~ ^[a-f0-9]{64}$ ]] + tag=rpr-$snapshot + mkdir -p -- "$output/ci" + printf '%s\n' "$tag" > "$tag_file" + export PAGES_INSTALLER_URL="https://github.com/$GITHUB_REPOSITORY/releases/download/$tag/reliefos-installer.iso" + make O="$output" installer + make O="$output" pages + bash scripts/ci/restore-rpr.sh retain "$output" + [[ $(<"$output/pages/rpr/source-commit") == "$GITHUB_SHA" ]] + [[ $(stat -c %s -- "$iso") -lt 2147483648 ]] || { echo 'Installer exceeds the GitHub Release asset limit' >&2; exit 1; } + size=$(du --apparent-size --bytes -s -- "$output/pages") + [[ ${size%%[[:space:]]*} -le 1000000000 ]] || { echo 'Production site exceeds the GitHub Pages 1 GB limit' >&2; exit 1; } + ;; + upload) + tag=$(<"$tag_file") + [[ $tag =~ ^rpr-[a-f0-9]{64}$ ]] + digest=$(sha256sum -- "$iso") + if ! gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then + notes=$output/ci/installer-release.md + printf 'Online installer for signed RPR snapshot %s built from ReliefOS %s.\n\nSHA-256 %s\n' \ + "${tag#rpr-}" "$GITHUB_SHA" "${digest%% *}" > "$notes" + gh release create "$tag" "$iso" --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" \ + --title "ReliefOS rolling installer ${GITHUB_SHA:0:12}" --notes-file "$notes" --latest=false + fi + published=$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$tag" \ + --jq '.assets[] | select(.name == "reliefos-installer.iso" and .state == "uploaded") | .digest') + [[ $published == "sha256:${digest%% *}" ]] || { echo 'Release installer checksum mismatch' >&2; exit 1; } + ;; + *) echo "Unknown publication operation: $operation" >&2; exit 2 ;; +esac diff --git a/scripts/ci/restore-rpr.sh b/scripts/ci/restore-rpr.sh new file mode 100644 index 00000000..4e60eb99 --- /dev/null +++ b/scripts/ci/restore-rpr.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# Seed the publisher with the previous public snapshot and retain its package URLs. +set -euo pipefail +export LC_ALL=C +operation=${1:?restore or retain required} +output=${2:?build output required} +fingerprint=${RPR_SIGNING_FINGERPRINT:?production fingerprint required} +fingerprint=${fingerprint^^} +[[ $fingerprint =~ ^[0-9A-F]{40}$ ]] +history=$output/ci/previous-rpr +parent=$output/rpr-testing + +fail() { printf 'RPR history: %s\n' "$*" >&2; exit 1; } + +case $operation in + restore) + url=${RPR_SERVER_URL:?production RPR URL required} + url=${url%/} + [[ $url == https://?* ]] || fail 'expected an HTTPS repository URL' + mkdir -p -- "$parent" "$output/ci" + work=$(mktemp -d "$parent/.previous.XXXXXXXX") + trap 'rm -rf -- "$work"' EXIT + curl_options=(--silent --show-error --location --proto '=https' --proto-redir '=https' + --connect-timeout 15 --max-time 300 --retry 3) + manifest=$work/SHA256SUMS + code=$(curl "${curl_options[@]}" --output "$manifest" --write-out '%{http_code}' "$url/SHA256SUMS") + if [[ $code == 404 ]]; then + code=$(curl "${curl_options[@]}" --head --output /dev/null --write-out '%{http_code}' "$url/rpr.db") + [[ $code == 404 ]] || fail 'published database exists without its checksum manifest' + printf 'No previous pacman repository at %s\n' "$url" + exit 0 + fi + [[ $code == 200 ]] || fail "could not fetch the published manifest (HTTP $code)" + entry='^[a-f0-9]{64} \./(source-commit|rpr\.gpg|rpr\.(db|files)(\.sig)?|[A-Za-z0-9._+-]+\.pkg\.tar\.zst(\.sig)?)$' + declare -A members=() + while IFS= read -r line; do + [[ $line =~ $entry ]] || fail 'published checksum manifest contains an invalid entry' + member=${BASH_REMATCH[1]} + [[ ! ${members[$member]+seen} ]] || fail "duplicate entry: $member" + members[$member]=1 + done < "$manifest" + for member in source-commit rpr.gpg rpr.db rpr.db.sig rpr.files rpr.files.sig; do + [[ ${members[$member]+seen} ]] || fail "missing manifest entry: $member" + done + for member in "${!members[@]}"; do + curl "${curl_options[@]}" --fail --output "$work/$member" "$url/$member" + done + (cd -- "$work" && sha256sum --strict --quiet -c SHA256SUMS) + gpg_home=$(mktemp -d "${RUNNER_TEMP:-/tmp}/rpr-verify.XXXXXXXX") + trap 'rm -rf -- "$work" "$gpg_home"' EXIT + found=$(gpg --no-options --homedir "$gpg_home" --batch --with-colons --show-keys "$work/rpr.gpg" | + awk -F: '$1 == "pub" {primary = 1} $1 == "fpr" && primary {print $10; primary = 0}') + [[ $found == "$fingerprint" ]] || fail 'published public key does not match the production fingerprint' + for index in rpr.db rpr.files; do + gpgv --homedir "$gpg_home" --keyring "$work/rpr.gpg" -- "$work/$index.sig" "$work/$index" + done + snapshot=$(sha256sum -- "$manifest") + snapshot=${snapshot%% *} + mv -T -- "$work" "$parent/$snapshot" + printf '%s\n' "$snapshot" > "$parent/current-$fingerprint" + printf '%s\n' "$snapshot" > "$history" + ;; + retain) + [[ -f $history ]] || exit 0 + snapshot=$(<"$history") + [[ $snapshot =~ ^[a-f0-9]{64}$ ]] || fail 'invalid previous snapshot identity' + previous=$parent/$snapshot + current=$output/pages/rpr + [[ -d $current && -f $current/rpr.db ]] || fail 'assemble the new Pages snapshot first' + shopt -s nullglob + for package in "$previous"/*.pkg.tar.zst; do + name=${package##*/} + if [[ -e $current/$name ]]; then + cmp -s -- "$package" "$current/$name" || fail "package changed without a new filename: $name" + continue + fi + gpgv --keyring "$previous/rpr.gpg" -- "$package.sig" "$package" + cp -- "$package" "$package.sig" "$current/" + done + ;; + *) fail "unknown operation: $operation" ;; +esac diff --git a/tests/build/test-site-i18n.py b/tests/build/test-site-i18n.py index bf7f9064..6a886ea5 100644 --- a/tests/build/test-site-i18n.py +++ b/tests/build/test-site-i18n.py @@ -109,6 +109,8 @@ def test_routes_language_navigation_and_shared_artifacts(self): self.assertIn("pacman -Syu", "".join(page.text)) if logical == "download/index.html": self.assertIn(hashlib.sha256(self.iso.read_bytes()).hexdigest(), "".join(page.text)) + download, = [item["href"] for _, item in page.anchors if item.get("class") == "button"] + self.assertEqual(self.resolve(current, download), "download/reliefos-installer.iso") def test_generators_preserve_repository_and_download_checksum(self): for name, contents in self.before.items(): diff --git a/tests/integration/arch-rpr-pacman.sh b/tests/integration/arch-rpr-pacman.sh index fe9dec38..cad7bfb4 100644 --- a/tests/integration/arch-rpr-pacman.sh +++ b/tests/integration/arch-rpr-pacman.sh @@ -4,7 +4,7 @@ set -euo pipefail export LC_ALL=C fingerprint=$1 repo=rpr -keyring=reliefos-testing +keyring=reliefos work=$(mktemp -d /tmp/reliefos-rpr-client.XXXXXXXX) served=$work/served mkdir -p "$served" "$work/root" "$work/db" "$work/cache" "$work/hooks" diff --git a/tests/integration/arch-rpr-testing.sh b/tests/integration/arch-rpr-testing.sh index 19ce2367..e55b8daa 100644 --- a/tests/integration/arch-rpr-testing.sh +++ b/tests/integration/arch-rpr-testing.sh @@ -219,7 +219,7 @@ docker run --rm --pull=never --read-only --network none \ history=$scratch/history # shellcheck source=/dev/null source "$source_root/tools/build/arch-guest-packages.sh" -glibc_only_packages=() +declare -a application_packages=() glibc_only_packages=() reliefos_application_packages app_packages=("${application_packages[@]}") declare -A glibc_only @@ -427,7 +427,7 @@ cp -- "$output/packages/arch/$app_archive" "$history/packages/arch/$app_archive" printf 'testing RPR: kernel history retained, repeated and rejected conflicting or older releases\n' if [[ ${2:-} == --with-rootfs ]]; then - repository_url=${RPR_SERVER_URL:-https://rpr.example.invalid/testing} + repository_url=${RPR_SERVER_URL:-$(<"$source_root/packages/arch/reliefos-keyring/production-url")} repository_url=${repository_url%/} ARCH_DESKTOP=icewm RPR_SNAPSHOT=$snapshot RPR_SERVER_URL=$repository_url \ make -C "$source_root" O="$output" arch-rootfs @@ -478,6 +478,8 @@ work=$(mktemp -d) trap 'rm -rf -- "$work"' EXIT tar --zstd -xf /rootfs.tar.zst -C "$work" \ ./etc/resolv.conf ./etc/pacman.conf ./etc/pacman.d/reliefos-rpr.conf \ + ./usr/libexec/reliefos/rpr-keyring ./usr/share/reliefos/rpr-production-url \ + ./usr/share/pacman/keyrings/reliefos-production.gpg \ ./etc/pacman.d/mirrorlist ./usr/share/reliefos/pacman/mirrorlist \ ./etc/systemd/system/multi-user.target.wants/reliefos-pacman-init.service \ ./etc/systemd/system/multi-user.target.wants/systemd-networkd.service \ @@ -491,6 +493,12 @@ tar --zstd -xf /rootfs.tar.zst -C "$work" \ grep -Fxq '[rpr]' "$work/etc/pacman.d/reliefos-rpr.conf" grep -Fxq 'SigLevel = Required TrustedOnly' "$work/etc/pacman.d/reliefos-rpr.conf" grep -Fxq "Server = $repository_url" "$work/etc/pacman.d/reliefos-rpr.conf" +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" ]] +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" grep -Fxq 'DisableSandboxFilesystem' "$work/etc/pacman.conf" diff --git a/tools/build/arch-guest-packages.sh b/tools/build/arch-guest-packages.sh index 2d67a5fb..e6fb9ef4 100644 --- a/tools/build/arch-guest-packages.sh +++ b/tools/build/arch-guest-packages.sh @@ -23,7 +23,7 @@ reliefos_application_packages() { reliefos_guest_packages() { local desktop=$1 name - local_packages=(reliefos-filesystem libreliefos paru reliefos-testing-keyring reliefos-kernel reliefos-boot) + local_packages=(reliefos-filesystem libreliefos paru reliefos-keyring reliefos-kernel reliefos-boot) official_packages=(core/base core/systemd core/systemd-sysvcompat core/dbus-broker-units extra/dracut) case $desktop in icewm|xfce) diff --git a/tools/build/arch-installer-build.sh b/tools/build/arch-installer-build.sh index d43b831c..c1573ed8 100644 --- a/tools/build/arch-installer-build.sh +++ b/tools/build/arch-installer-build.sh @@ -51,7 +51,8 @@ rm -rf -- "$root/.reliefos/kernel-bundles" "$root/install/esp/reliefos/"{version install -Dm644 /dev/null "$root/etc/reliefos/online-installer" # The live session only verifies downloads. Seal the public verification # state into the ISO so boot does not generate a pacman signing key. -keyring=$root/usr/share/pacman/keyrings/reliefos-testing +keyring_name=$("$root/usr/libexec/reliefos/rpr-keyring" "$root") +keyring=$root/usr/share/pacman/keyrings/$keyring_name fingerprint=$(cut -d: -f1 "$keyring-trusted") verification=$work/gnupg bash "$source_root/tools/build/arch-rpr-trust.sh" "$keyring.gpg" "$fingerprint" "$verification" diff --git a/tools/build/arch-root.sh b/tools/build/arch-root.sh index 84985559..8ec8d19a 100644 --- a/tools/build/arch-root.sh +++ b/tools/build/arch-root.sh @@ -112,7 +112,6 @@ fi if [[ $operation == all || $operation == release ]]; then : "${RPR_GNUPGHOME:?set a dedicated signing home, or use make build for unsigned packages}" : "${RPR_SIGNING_FINGERPRINT:?select an explicit full signing fingerprint}" - : "${RPR_SERVER_URL:?set the guest-visible repository URL for the installation media}" fi recipe_id=$(sha256sum "$recipe") diff --git a/tools/build/arch-rootfs.sh b/tools/build/arch-rootfs.sh index 6718a1ab..7ae97c87 100644 --- a/tools/build/arch-rootfs.sh +++ b/tools/build/arch-rootfs.sh @@ -18,7 +18,7 @@ esac source "$source_root/tools/build/arch-rpr-selection.sh" snapshot='' fingerprint='' reliefos_rpr_selection "$output" || fail 'select a signed snapshot and its pinned fingerprint' -repository_url=${RPR_SERVER_URL:-} +repository_url=${RPR_SERVER_URL:-$(<"$source_root/packages/arch/reliefos-keyring/production-url")} case $repository_url in http://?*|https://?*) ;; *) fail 'set RPR_SERVER_URL to the guest-visible HTTP or HTTPS repository directory' ;; diff --git a/tools/build/arch-rpr-sign.sh b/tools/build/arch-rpr-sign.sh index 347ef380..b72844a5 100644 --- a/tools/build/arch-rpr-sign.sh +++ b/tools/build/arch-rpr-sign.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Stage one downloadable testing snapshot. Only host GnuPG sees private keys. +# Stage one downloadable signed snapshot. Only host GnuPG sees private keys. set -euo pipefail export LC_ALL=C source_root=$1 @@ -7,7 +7,7 @@ output=$2 image=$3 identity=$4 repo=rpr -keyring=reliefos-testing +keyring=reliefos fail() { printf 'arch-rpr-testing: %s\n' "$*" >&2; exit 1; } source_commit=$(git -C "$source_root" rev-parse --verify 'HEAD^{commit}') || @@ -15,6 +15,7 @@ source_commit=$(git -C "$source_root" rev-parse --verify 'HEAD^{commit}') || for tool in gpg gpgv; do command -v "$tool" >/dev/null || fail "missing host tool: $tool" done +fixed_archives=("${archives[@]}") home=$(realpath -e -- "${RPR_GNUPGHOME:?use a dedicated GnuPG signing home}") fingerprint=${RPR_SIGNING_FINGERPRINT:?set the full primary signing-key fingerprint} fingerprint=${fingerprint^^} @@ -53,7 +54,7 @@ archives+=("$runtime") # shellcheck source=/dev/null source "$source_root/tools/build/arch-guest-packages.sh" -glibc_only_packages=() +declare -a application_packages=() glibc_only_packages=() reliefos_application_packages || fail 'invalid application package manifest' app_packages=("${application_packages[@]}") declare -A app_archives app_versions previous_app_versions glibc_only @@ -117,6 +118,7 @@ mkdir -p -- "$parent" pointer=$parent/current-$fingerprint previous_update= previous_runtime= +previous= kernel_archives=() if [[ -e $pointer || -L $pointer ]]; then [[ -f $pointer && ! -L $pointer ]] || fail 'kernel history pointer is not a regular file' @@ -198,7 +200,7 @@ arch() { --cap-drop=ALL --security-opt=no-new-privileges --user "$identity" \ --tmpfs /tmp:rw,nosuid,nodev,mode=1777 --env HOME=/tmp \ --mount "type=bind,src=$work,dst=/rpr-work,bind-recursive=disabled" \ - --mount "type=bind,src=$source_root/packages/arch/reliefos-testing-keyring,dst=/keyring,readonly,bind-recursive=disabled" \ + --mount "type=bind,src=$source_root/packages/arch/reliefos-keyring,dst=/keyring,readonly,bind-recursive=disabled" \ --mount "type=bind,src=$source_root/tools/build/arch-rpr-kernel-check.sh,dst=/kernel-check.sh,readonly" \ --workdir /rpr-work/site "$image" "$@" } @@ -262,13 +264,21 @@ if [[ $boot_arch == x86_64 ]]; then [[ $comparison != -1 ]] || fail 'boot package requires a newer runtime' fi arch env "SOURCE_DATE_EPOCH=$(git -C "$source_root" show -s --format=%ct "$source_commit")" \ - RELIEFOS_TESTING_KEYRING_DIR=/rpr-work \ + RELIEFOS_KEYRING_DIR=/rpr-work \ makepkg --dir /keyring --nocolor --nosign \ SRCDEST=/rpr-work BUILDDIR=/rpr-work/build PKGDEST=/rpr-work/site -keyrings=("$site"/reliefos-testing-keyring-*-any.pkg.tar.zst) +keyrings=("$site"/reliefos-keyring-*-any.pkg.tar.zst) [[ ${#keyrings[@]} == 1 ]] || fail 'keyring packaging did not produce one archive' archives+=("${keyrings[0]##*/}") +if [[ -n $previous ]]; then + # Keep published bytes for recipes with manually managed package versions. + for file in "${fixed_archives[@]}" "${keyrings[0]##*/}"; do + [[ -f $previous/$file ]] || continue + gpgv --homedir "$work/verify" --keyring "$public" -- "$previous/$file.sig" "$previous/$file" + cp -- "$previous/$file" "$site/$file" + done +fi arch repo-add --nocolor "$repo.db.tar.gz" "${archives[@]}" # Publish ordinary files so static HTTP hosts need not support symlink aliases. for kind in db files; do diff --git a/tools/build/download-page.sh b/tools/build/download-page.sh index f9985928..faab9aa8 100755 --- a/tools/build/download-page.sh +++ b/tools/build/download-page.sh @@ -4,8 +4,7 @@ # The page is a static build artifact: the ISO hash, size and version are # computed here from the file that will actually be published, so what the page # shows can never disagree with the downloadable file (plan §28, §46.B). The -# ISO download link is a bare relative "reliefos-installer.iso", so it works at -# whatever base path Pages serves the site from (plan §25). +# Local builds use a relative link. Pages can link to the same ISO on GitHub Releases. set -eu [ "$#" = 3 ] || exit 2 iso=$1 build=$2 output=$3 @@ -23,6 +22,14 @@ printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { echo 'invali mkdir -p "$site/download" name=${iso##*/} +if [ -n "${PAGES_INSTALLER_URL:-}" ]; then + case $PAGES_INSTALLER_URL in + *[!a-zA-Z0-9.:/_-]*) echo 'invalid external installer URL' >&2; exit 1 ;; + esac + printf '%s\n' "$PAGES_INSTALLER_URL" | grep -Eq '^https://[a-zA-Z0-9./_-]+/reliefos-installer\.iso$' || { + echo 'invalid external installer URL' >&2; exit 1 + } +fi size=$(stat -c %s "$iso") iso_hash=$(sha256sum "$iso" | cut -d' ' -f1) # SHA256SUMS lists the bare filename so `sha256sum -c` runs inside download/. @@ -34,6 +41,7 @@ for language in zh-CN en ja; do mkdir -p "$(dirname "$page")" { site_page_begin download/index.html "$(site_message download_title)" "$(site_message download_title)" + download_href=${PAGES_INSTALLER_URL:-$(site_href "download/$name")} printf '

%s · %s %s · x86_64

\n' \ "$(site_text latest_release)" "$(site_text version)" "$(printf '%s' "$version" | site_html_escape)" cat <$(site_text size)
$(site_bytes_human "$size")
SHA256
$(printf '%s' "$iso_hash" | site_html_escape)
-

$(site_text download)

+

$(site_text download)

SHA256SUMS — $(site_text checksum_help)

sha256sum -c SHA256SUMS
diff --git a/tools/build/site.sh b/tools/build/site.sh index 7a81cb97..8b7d1c8a 100755 --- a/tools/build/site.sh +++ b/tools/build/site.sh @@ -8,6 +8,7 @@ iso=$output/images/reliefos-installer.iso fail() { printf 'pages: %s\n' "$*" >&2; exit 1; } # shellcheck source=/dev/null source "$source_root/tools/build/arch-rpr-selection.sh" +snapshot='' fingerprint='' reliefos_rpr_selection "$output" || fail 'expected a signed RPR snapshot and pinned fingerprint' [[ -f $iso && ! -L $iso && -s $iso ]] || fail 'build the online installer before Pages' [[ $(<"$iso.rpr-snapshot") == "${snapshot##*/}" ]] || fail 'the installer ISO was assembled with another snapshot' @@ -24,9 +25,10 @@ gpgv --homedir "$work/gpg" --keyring "$snapshot/rpr.gpg" -- "$snapshot/rpr.files manifest_digest=$(sha256sum "$snapshot/SHA256SUMS") [[ ${manifest_digest%% *} == "${snapshot##*/}" ]] || fail 'snapshot manifest digest mismatch' if [[ -e $snapshot/source-commit || -L $snapshot/source-commit ]]; then - [[ -f $snapshot/source-commit && ! -L $snapshot/source-commit ]] && - grep -Eq '^[0-9a-f]{64} \./source-commit$' "$snapshot/SHA256SUMS" || + if [[ ! -f $snapshot/source-commit || -L $snapshot/source-commit ]] || + ! grep -Eq '^[0-9a-f]{64} \./source-commit$' "$snapshot/SHA256SUMS"; then fail 'source commit is not a regular, checksummed snapshot member' + fi fi (cd "$snapshot" && sha256sum --strict --quiet -c SHA256SUMS) @@ -34,11 +36,13 @@ pages=$work/pages mkdir -p "$pages"/{rpr,css,download} cp -a -- "$snapshot/." "$pages/rpr/" cp -- "$source_root/resources/pages/css/reliefos.css" "$pages/css/" -cp --reflink=auto -- "$iso" "$pages/download/" +if [[ -z ${PAGES_INSTALLER_URL:-} ]]; then + cp --reflink=auto -- "$iso" "$pages/download/" +fi version=$(sed -n 's/^release_version=\([0-9.]*\)$/\1/p' "$source_root/configs/build-version") [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || fail 'invalid release version' printf '#define RELIEFOS_KERNEL_VERSION "%s"\n' "$version" > "$work/build_info.h" -sh "$source_root/tools/build/download-page.sh" "$pages/download/${iso##*/}" "$work/build_info.h" "$pages" +sh "$source_root/tools/build/download-page.sh" "$iso" "$work/build_info.h" "$pages" sh "$source_root/tools/build/home-page.sh" "$work/build_info.h" "$pages" sh "$source_root/tools/build/docs-page.sh" "$source_root/Documentation" \ "$source_root/kernel/reliefnt/Documentation" "$pages/docs" diff --git a/tools/tests/test_ci_arch_root.py b/tools/tests/test_ci_arch_root.py index cfcc6ffc..1ddea7ad 100644 --- a/tools/tests/test_ci_arch_root.py +++ b/tools/tests/test_ci_arch_root.py @@ -24,7 +24,8 @@ def setUp(self): for name in ("Makefile", "Kconfig", "scripts/reliefos/Makefile.product", "tools/build/arch-root.Dockerfile", "tools/build/arch-root.sh", "tools/build/arch-image.sh", "tools/build/arch-rootfs.sh", - "tools/build/arch-rpr-selection.sh", "packages/arch/reliefos-filesystem/mirrorlist"): + "tools/build/arch-rpr-selection.sh", "packages/arch/reliefos-filesystem/mirrorlist", + "packages/arch/reliefos-keyring/production-url"): path = self.source / name path.parent.mkdir(parents=True, exist_ok=True) shutil.copyfile(ROOT / name, path) @@ -284,9 +285,9 @@ def test_rootfs_records_selected_online_rpr_and_rejects_invalid_url(self): "dst=/guest-mirrorlist,readonly", run) result, calls = self.make("rootfs", **options) - self.assertNotEqual(result.returncode, 0) - self.assertIn("RPR_SERVER_URL", result.stderr) - self.assertNotIn("run", [call[0] for call in calls]) + self.assertEqual(result.returncode, 0, result.stderr) + run, = [call for call in calls if call[0] == "run"] + self.assertEqual(run[-1], "https://reliefosproject.github.io/ReliefOS/rpr") result, calls = self.make("rootfs", **options, RPR_SERVER_URL="https://testing.example/rpr\n[extra]") diff --git a/userland/apps/installer/arch-online-install.sh b/userland/apps/installer/arch-online-install.sh index f7c2330f..c448ba30 100644 --- a/userland/apps/installer/arch-online-install.sh +++ b/userland/apps/installer/arch-online-install.sh @@ -107,7 +107,7 @@ declare -a guest_packages local_packages reliefos_guest_packages "$desktop" rpr_config=/etc/pacman.d/reliefos-rpr.conf -rpr_key=/usr/share/pacman/keyrings/reliefos-testing.gpg +rpr_key=/usr/share/pacman/keyrings/$(/usr/libexec/reliefos/rpr-keyring).gpg root=${5-} zone=$7 case $zone in ''|/*|*..*|*[!a-zA-Z0-9_+/-]*) fail 'invalid time zone' ;; esac