From 3566e7eddf48cde46f334f3ce24c3f5daedc6cc1 Mon Sep 17 00:00:00 2001 From: madomado Date: Wed, 1 Jan 2025 04:23:45 +0800 Subject: [PATCH] feat(ci)!: switch to rpmbuild (#2792) * feat(ci)!: switch to rpmbuild * fix: support extra_repos * let's try this instead * fix the funny condition * fix: disable gpgcheck This should be fine because checksum is checked for the repomd and the packages too --- .github/workflows/autobuild.yml | 24 ++++++++--------- .github/workflows/bootstrap.yml | 12 +++++---- .github/workflows/build.yml | 15 +++++------ .github/workflows/json-build.yml | 20 +++++++------- .../games/prismlauncher-nightly/ci_setup.rhai | 2 ++ anda/games/prismlauncher/ci_setup.rhai | 2 ++ andax/ci/extra_repos.rhai | 26 +++++++++++++++++++ 7 files changed, 66 insertions(+), 35 deletions(-) create mode 100644 anda/games/prismlauncher-nightly/ci_setup.rhai create mode 100644 anda/games/prismlauncher/ci_setup.rhai create mode 100644 andax/ci/extra_repos.rhai diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 26be284080..6f1903ecb0 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -52,26 +52,26 @@ jobs: with: fetch-depth: 0 - - name: Checkout latest Mock configs - uses: actions/checkout@v4 - with: - fetch-depth: 0 - repository: terrapkg/mock-configs - path: mock-configs - - name: Set up git repository run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - - name: Include custom build template instead of package default + - name: CI Setup Script + run: | + dir=$(dirname ${{ matrix.pkg.pkg }}) + if [ -f $dir/ci_setup.rhai ]; then + anda run $dir/ci_setup.rhai --labels script_path=$dir/ci_setup.rhai + fi + + - name: Install Build Dependencies run: | - cp -v mock-configs/terra.tpl /etc/mock/templates/terra.tpl + dir=$(dirname ${{ matrix.pkg.pkg }}) + dnf5 builddep -y ${dir}/*.spec - name: Build with Andaman - run: anda build ${{ matrix.pkg.pkg }} --package rpm -c mock-configs/terra-${{ matrix.version }}-${{ matrix.pkg.arch }}.cfg + run: anda build ${{ matrix.pkg.pkg }} -rrpmbuild - name: Build with Andaman (alternate arch) - if: | - matrix.pkg.arch == 'x86_64' && matrix.pkg.labels['multilib'] + if: matrix.pkg.arch == 'x86_64' && matrix.pkg.labels['multilib'] run: anda build ${{ matrix.pkg.pkg }} --package rpm -c mock-configs/terra-${{ matrix.version }}-i386.cfg - name: Generating artifact name diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml index e78df7b691..6923a87c40 100644 --- a/.github/workflows/bootstrap.yml +++ b/.github/workflows/bootstrap.yml @@ -16,7 +16,9 @@ jobs: options: --cap-add=SYS_ADMIN --privileged steps: - name: Install repositories - run: dnf5 install -y --setopt=install_weak_deps=False mock curl wget git-core openssl-devel cargo podman fuse-overlayfs + run: | + dnf5 install -y --setopt=install_weak_deps=False curl wget git-core openssl-devel cargo podman fuse-overlayfs + dnf5 builddep -y anda/terra/{mock-configs,srpm-macros}/*.spec anda/tools/buildsys/{anda,subatomic}/*.spec - name: Install Anda run: cargo install anda @@ -30,20 +32,20 @@ jobs: echo "PATH=$PATH:/github/home/.cargo/bin" >> $GITHUB_ENV export PATH=$PATH:/github/home/.cargo/bin git config --global --add safe.directory "$GITHUB_WORKSPACE" - anda build -c fedora-${{ matrix.version }}-${{ matrix.arch }} anda/terra/mock-configs/pkg -p rpm + anda build -rrpmbuild anda/terra/mock-configs/pkg - name: Install terra-mock-configs run: dnf5 install -y anda-build/rpm/rpms/terra-mock-configs*.rpm - name: Build anda-srpm-macros - run: anda build -c terra-${{ matrix.version }}-${{ matrix.arch }} anda/terra/srpm-macros/pkg + run: anda build -rrpmbuild anda/terra/srpm-macros/pkg - name: Build Subatomic - run: anda build -c terra-${{ matrix.version }}-${{ matrix.arch }} anda/tools/buildsys/subatomic/pkg + run: anda build -rrpmbuild anda/tools/buildsys/subatomic/pkg - name: Install Subatomic run: dnf5 install -y ./anda-build/rpm/rpms/subatomic-*.rpm - name: Build Andaman - run: anda build -c terra-${{ matrix.version }}-${{ matrix.arch }} anda/tools/buildsys/anda/pkg + run: anda build -rrpmbuild anda/tools/buildsys/anda/pkg - name: Upload packages to subatomic run: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8322b7b656..936178690d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,21 +57,18 @@ jobs: with: fetch-depth: 0 - - name: Checkout latest Mock configs - uses: actions/checkout@v4 - with: - repository: terrapkg/mock-configs - path: mock-configs - - name: Set up git repository run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - - name: Include custom build template instead of package default + - name: CI Setup Script run: | - cp -v mock-configs/terra.tpl /etc/mock/templates/terra.tpl + dir=${{ matrix.pkg }} + if [ -f $dir/ci_setup.rhai ]; then + anda run $dir/ci_setup.rhai --labels script_path=$dir/ci_setup.rhai + fi - name: Build with Andaman - run: anda build anda/${{ matrix.pkg }}pkg --package rpm -c mock-configs/terra-${{ matrix.version }}-${{ matrix.arch }}.cfg + run: anda build -rrpmbuild anda/${{ matrix.pkg }}pkg - name: Generating artifact name id: art diff --git a/.github/workflows/json-build.yml b/.github/workflows/json-build.yml index 6f4a37e76b..faf88abe41 100644 --- a/.github/workflows/json-build.yml +++ b/.github/workflows/json-build.yml @@ -23,21 +23,23 @@ jobs: with: fetch-depth: 0 - - name: Checkout latest Mock configs - uses: actions/checkout@v4 - with: - repository: terrapkg/mock-configs - path: mock-configs - - name: Set up git repository run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - - name: Include custom build template instead of package default + - name: CI Setup Script + run: | + dir=$(dirname ${{ matrix.pkg.pkg }}) + if [ -f $dir/ci_setup.rhai ]; then + anda run $dir/ci_setup.rhai --labels script_path=$dir/ci_setup.rhai + fi + + - name: Install Build Dependencies run: | - cp -v mock-configs/terra.tpl /etc/mock/templates/terra.tpl + dir=$(dirname ${{ matrix.pkg.pkg }}) + dnf5 builddep -y ${dir}/*.spec - name: Build with Andaman - run: anda build ${{ matrix.pkg.pkg }} --package rpm -c mock-configs/terra-${{ matrix.version }}-${{ matrix.pkg.arch }}.cfg + run: anda build ${{ matrix.pkg.pkg }} -rrpmbuild - name: Generating artifact name id: art diff --git a/anda/games/prismlauncher-nightly/ci_setup.rhai b/anda/games/prismlauncher-nightly/ci_setup.rhai new file mode 100644 index 0000000000..92de03460a --- /dev/null +++ b/anda/games/prismlauncher-nightly/ci_setup.rhai @@ -0,0 +1,2 @@ +import "andax/ci/extra_repos.rhai" as extra_repos; +extra_repos::install(labels); diff --git a/anda/games/prismlauncher/ci_setup.rhai b/anda/games/prismlauncher/ci_setup.rhai new file mode 100644 index 0000000000..92de03460a --- /dev/null +++ b/anda/games/prismlauncher/ci_setup.rhai @@ -0,0 +1,2 @@ +import "andax/ci/extra_repos.rhai" as extra_repos; +extra_repos::install(labels); diff --git a/andax/ci/extra_repos.rhai b/andax/ci/extra_repos.rhai new file mode 100644 index 0000000000..8fc353a502 --- /dev/null +++ b/andax/ci/extra_repos.rhai @@ -0,0 +1,26 @@ +import "anda::cfg" as cfg; + +fn install(labels) { + if labels.script_path == () { + print("fatal: labels.script_path is empty"); + terminate(); + } + let releasever = sh("rpm -E '%fedora'", #{"stdout": "piped"}).ctx.stdout; + releasever.trim(); + let basearch = sh("rpm -E '%_arch'", #{"stdout": "piped"}).ctx.stdout; + basearch.trim(); + let hcl = cfg::load_file(sub(`(.+/)[^.]+\.rhai`, "${1}anda.hcl", labels.script_path)); + for repo in hcl.project.pkg.rpm.extra_repos { + repo = sub(`\$releasever`, releasever, repo); + repo = sub(`\$basearch`, basearch, repo); + let filename = sub(`\W`, "_", repo); + let file = open_file(`/etc/yum.repos.d/${filename}.repo`); + file.write(` +[filename] +name=${filename} +baseurl=${repo} +enabled=1 +gpgcheck=0 +`); + } +}