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
48 changes: 48 additions & 0 deletions .github/scripts/pacman-build-context.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
set -euo pipefail

recipes=$1
architecture=$2
shift 2
targets=("$@")
export LC_ALL=C
shopt -s nullglob
metadata=("$recipes"/*/.SRCINFO)
if (( ${#metadata[@]} == 0 )); then
printf 'No .SRCINFO files found under %s\n' "$recipes" >&2
exit 1
fi

dependencies=$(awk -v arch="$architecture" '
function package_name(requirement) {
sub(/[<=>].*$/, "", requirement)
return requirement
}

$2 != "=" { next }
$1 == "pkgname" || $1 == "provides" || $1 == "provides_" arch {
local_packages[package_name($3)] = 1
}
$1 ~ /^(depends|makedepends|checkdepends)$/ ||
$1 ~ "^(depends|makedepends|checkdepends)_" arch "$" {
requirements[$3] = 1
}
END {
for (requirement in requirements)
if (!(package_name(requirement) in local_packages))
print requirement
}
' "${metadata[@]}" | sort)

while IFS= read -r dependency; do
if [[ -n $dependency ]]; then
targets+=("$dependency")
fi
done <<< "$dependencies"

# Resolve the whole dependency tree, including libraries already installed in the CI image.
database=$(mktemp -d)
trap 'rm -rf -- "$database"' EXIT
sync_database=$(pacman-conf DBPath)
ln -s -- "$sync_database/sync" "$database/sync"
pacman --dbpath "$database" --sync --print-format '%n %v' --quiet --noconfirm -- "${targets[@]}" | sort -u
119 changes: 91 additions & 28 deletions .github/workflows/build-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,44 @@ on:
pull_request:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
inputs:
rebuild_all:
description: Rebuild every package
type: boolean
default: false

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

env:
PACMAN_BUILDER_REPO: LizardByte/pacman-repo-builder

defaults:
run:
shell: bash

jobs:
resolve-builder-release:
name: Resolve latest Pacman Repo Builder release
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.release.outputs.tag }}
steps:
- name: Read latest release tag
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag=$(gh api "repos/$PACMAN_BUILDER_REPO/releases/latest" --jq '.tag_name')
printf 'tag=%s\n' "$tag" >> "$GITHUB_OUTPUT"

build-pacman-repo:
name: Build (${{ matrix.distribution }}, ${{ matrix.channel }})
needs: resolve-builder-release
permissions:
contents: read
runs-on: ubuntu-latest
Expand All @@ -29,6 +55,7 @@ jobs:
env:
DISPLAY: ":1"
CONTAINER_DIR: pkgbuilds
PACMAN_BUILDER_TAG: ${{ needs.resolve-builder-release.outputs.tag }}
_use_cuda: "true"
_run_unit_tests: "true"
_support_headless_testing: "true"
Expand Down Expand Up @@ -93,42 +120,50 @@ jobs:
cmake \
cuda \
git \
github-cli \
jq \
wget \
xorg-server-xvfb
pacman -Scc --noconfirm

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set Up Pacman Repo Builder
env:
DISTRIBUTION: ${{ matrix.distribution }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "${DISTRIBUTION}" == "manjaro" ]]; then
# The published builder links to Arch's glibc/libalpm. Build it against Manjaro's libraries.
gh release download "$PACMAN_BUILDER_TAG" \
--repo "$PACMAN_BUILDER_REPO" \
--pattern build-pacman-repo \
--output "$RUNNER_TEMP/build-pacman-repo"
install -Dm755 "$RUNNER_TEMP/build-pacman-repo" /usr/bin/build-pacman-repo

if [[ $DISTRIBUTION == manjaro ]] && ! build-pacman-repo --help >/dev/null; then
# Manjaro can carry a different libalpm ABI from the Arch build host.
pacman -S --disable-download-timeout --needed --noconfirm rustup
builder_tag=$(
curl --fail --silent --show-error \
https://api.github.com/repos/LizardByte/pacman-repo-builder/releases/latest | jq -er '.tag_name'
)
builder_dir="${RUNNER_TEMP}/pacman-repo-builder"
git clone --depth 1 --branch "${builder_tag}" \
https://github.com/LizardByte/pacman-repo-builder.git "${builder_dir}"
pushd "${builder_dir}"
# rustup uses the toolchain pinned in the builder's rust-toolchain.toml.
builder_dir="$RUNNER_TEMP/pacman-repo-builder"
git clone --depth 1 --branch "$PACMAN_BUILDER_TAG" \
"https://github.com/$PACMAN_BUILDER_REPO.git" "$builder_dir"
pushd "$builder_dir"
cargo build --locked --release
install -Dm755 target/release/build-pacman-repo /usr/bin/build-pacman-repo
popd
else
builder_url="https://github.com/LizardByte/pacman-repo-builder/releases/latest/download/build-pacman-repo"
# GitHub's latest-release URL requires two redirects to the release asset
wget --max-redirect=2 "${builder_url}" -O /usr/bin/build-pacman-repo # NOSONAR (githubactions:S6506)
chmod +x /usr/bin/build-pacman-repo
fi

# patch makepkg to allow running as root
build-pacman-repo patch-makepkg --replace

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Download the published repository snapshot
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ matrix.release_name }}
REPO_NAME: ${{ matrix.repo }}
run: |
gh api -H 'Accept: application/vnd.github.raw+json' \
"repos/$PACMAN_BUILDER_REPO/contents/ci/github-actions/fetch-repo.sh?ref=$PACMAN_BUILDER_TAG" \
> "$RUNNER_TEMP/fetch-pacman-repo.sh"
bash "$RUNNER_TEMP/fetch-pacman-repo.sh" "$GITHUB_REPOSITORY" "$RELEASE_TAG" "$REPO_NAME" previous

- name: Configure Git directory
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
Expand Down Expand Up @@ -217,6 +252,8 @@ jobs:
env:
GH_BOT_NAME: ${{ vars.GH_BOT_NAME }}
GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
REBUILD_ALL: ${{ inputs.rebuild_all || 'false' }}
PACKAGE_ARCH: x86_64
run: |
source /etc/profile # ensure cuda is in the PATH

Expand All @@ -230,9 +267,9 @@ jobs:
--with-install-missing-dependencies true \
--with-clean-before-build false \
--with-clean-after-build false \
--with-force-rebuild true \
--with-force-rebuild "$REBUILD_ALL" \
--with-pacman pacman \
--with-arch-filter x86_64 \
--with-arch-filter "$PACKAGE_ARCH" \
--with-check inherit \
--with-packager "${GH_BOT_NAME} <${GH_BOT_EMAIL}>" \
--with-allow-failure false \
Expand All @@ -244,8 +281,8 @@ jobs:
echo "::warning:: .SRCINFO files mismatch" >> "${GITHUB_STEP_SUMMARY}" && \
build-pacman-repo sync-srcinfo -u

# build the packages and create the repo
build-pacman-repo build
build_context=$(bash .github/scripts/pacman-build-context.sh "$CONTAINER_DIR" "$PACKAGE_ARCH" base-devel cuda)
build-pacman-repo build --previous previous --build-context "$build_context"

# ensure files are present in the repo
repo_files=$(ls repo)
Expand All @@ -264,15 +301,19 @@ jobs:

verify-and-release-pacman-repo:
name: Verify and Release (${{ matrix.distribution }}, ${{ matrix.channel }})
needs: build-pacman-repo
needs:
- build-pacman-repo
- resolve-builder-release
# Verify successful artifacts even when another distribution/channel failed to build.
if: ${{ !cancelled() }}
if: ${{ !cancelled() && needs.resolve-builder-release.result == 'success' }}
permissions:
contents: read
runs-on: ubuntu-latest
container:
image: ${{ matrix.runtime_image }}
strategy: *repository-strategy
env:
PACMAN_BUILDER_TAG: ${{ needs.resolve-builder-release.outputs.tag }}
steps:
# Use a fresh container so build dependencies cannot hide missing runtime dependencies.
- *configure-distribution
Expand Down Expand Up @@ -312,13 +353,35 @@ jobs:
fi
/usr/bin/sunshine --version

- name: Prepare release assets
if: >-
github.event_name != 'pull_request' &&
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
id: sign
env:
REPO_NAME: ${{ matrix.repo }}
PACMAN_SIGNING_FINGERPRINT: ${{ vars.PACMAN_SIGNING_FINGERPRINT }}
PACMAN_SIGNING_PRIVATE_KEY: ${{ secrets.PACMAN_SIGNING_PRIVATE_KEY }}
PACMAN_SIGNING_PASSPHRASE: ${{ secrets.PACMAN_SIGNING_PASSPHRASE }}
run: |
directory=repo
if [[ -n $PACMAN_SIGNING_FINGERPRINT || -n $PACMAN_SIGNING_PRIVATE_KEY ]]; then
directory=signed
curl --fail --silent --show-error --output "$RUNNER_TEMP/sign-pacman-repo.sh" \
"https://raw.githubusercontent.com/$PACMAN_BUILDER_REPO/$PACMAN_BUILDER_TAG/src/cmd/sign-repo.sh"
bash "$RUNNER_TEMP/sign-pacman-repo.sh" "$REPO_NAME" repo "$directory"
fi
printf 'directory=%s\n' "$directory" >> "$GITHUB_OUTPUT"

- name: Create/Update GitHub Release
if: github.event_name == 'schedule' || github.event_name == 'push'
if: >-
github.event_name != 'pull_request' &&
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: repo/*
artifacts: ${{ steps.sign.outputs.directory }}/*
bodyFile: README.md
commit: master
makeLatest: ${{ matrix.release_name == 'stable' || false }}
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,27 @@ sudo pacman -S lizardbyte-manjaro-beta/sunshine-git

## Considerations

- To account for changes to any dependencies, packages in this repo are rebuilt once per day.
- The daily build reuses packages whose recipes and archives match the published snapshot for that channel.
- Arch Linux and Manjaro packages use the same PKGBUILDs, built separately against each distribution's libraries.
- Packages are installed and checked for unresolved libraries in a fresh matching container before publishing.
- Packages may have optional run time dependencies, you can review the PKGBUILD files for more information.

## Repository maintenance

Each channel rebuilds automatically when packages in its resolved dependency
tree change. CI uses the runtime, build, and test dependencies declared by the
recipes, plus the `base-devel` and CUDA build environment, to resolve package
versions from the matching distribution. It also checks runtime library
resolution before publishing. Run **Build Pacman Repo** manually with
`rebuild_all` for changes outside the dependency tree. Increment `pkgrel` for
changed packages at the same upstream version so Pacman can upgrade existing installs.

To sign future releases, set the repository variable `PACMAN_SIGNING_FINGERPRINT`
and the secret `PACMAN_SIGNING_PRIVATE_KEY`. Set `PACMAN_SIGNING_PASSPHRASE` for an
encrypted signing key. The stable and beta release names stay the same. Releases
include the public signing key for users who verify its fingerprint with the
maintainers and import it into their Pacman keyring.

## License

This repository is licensed under the [MIT License](LICENSE); however, individual packages may have their own licenses.
Expand Down