forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 55
ci: install LLVM from a mirrored GitHub release instead of apt.llvm.org #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| name: Mirror LLVM debs | ||
|
|
||
| # Rebuilds the llvm-<version>-debs release that the Dockerfiles install LLVM | ||
| # from. Run it when the LLVM version changes or apt.llvm.org ships a build | ||
| # worth picking up, then pin the printed SHA-256s in the Dockerfiles. | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| llvm_version: | ||
| description: 'LLVM major version to mirror' | ||
| type: string | ||
| default: '21' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| mirror: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
| with: | ||
| sparse-checkout: scripts | ||
| - name: Mirror | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| LLVM_VERSION: ${{ inputs.llvm_version }} | ||
| OUT: ${{ runner.temp }}/llvm-debs | ||
| run: bash scripts/mirror-llvm-debs.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| #!/usr/bin/env bash | ||
| # Mirror the LLVM .debs that the Dockerfiles install from apt.llvm.org to a | ||
| # GitHub release on oven-sh/WebKit, so the docker builds stop depending on | ||
| # apt.llvm.org being reachable. Same idea as scripts/mirror-gcc13-debs.sh. | ||
| # | ||
| # One tarball per (Ubuntu release, arch) the Dockerfiles build on: | ||
| # focal amd64, arm64 -> Dockerfile (llvm.sh $LLVM_VERSION all) | ||
| # noble amd64 -> Dockerfile.{android,freebsd,macos,windows} | ||
| # (llvm.sh $LLVM_VERSION) | ||
| # Only packages served from apt.llvm.org go in; their Ubuntu-archive | ||
| # dependencies are resolved by `apt-get install ./*.deb` at image build time | ||
| # as before. apt verifies every download against the signed repo index. | ||
| # | ||
| # Needs docker and gh. Run .github/workflows/mirror-llvm-debs.yml to do this | ||
| # on a runner. Afterwards paste the printed SHA-256s into the Dockerfiles. | ||
| set -euo pipefail | ||
|
|
||
| REPO="${REPO:-oven-sh/WebKit}" | ||
| LLVM_VERSION="${LLVM_VERSION:-21}" | ||
| TAG="${TAG:-llvm-${LLVM_VERSION}-debs}" | ||
| OUT="${OUT:-/tmp/llvm-debs}" | ||
| V="$LLVM_VERSION" | ||
|
|
||
| # What `llvm.sh $V` and `llvm.sh $V all` install (see PKG= in llvm.sh). | ||
| BASE_PKGS="clang-$V lldb-$V lld-$V clangd-$V" | ||
| ALL_PKGS="$BASE_PKGS clang-tidy-$V clang-format-$V clang-tools-$V llvm-$V-dev \ | ||
| llvm-$V-tools libomp-$V-dev libc++-$V-dev libc++abi-$V-dev \ | ||
| libclang-common-$V-dev libclang-$V-dev libclang-cpp$V-dev liblldb-$V-dev \ | ||
| libunwind-$V-dev libclang-rt-$V-dev libpolly-$V-dev" | ||
|
|
||
| rm -rf "$OUT" && mkdir -p "$OUT" | ||
|
|
||
| # mirror <distro> <image> <pkgs> <arch>... | ||
| mirror() { | ||
| local distro="$1" image="$2" pkgs="$3"; shift 3 | ||
| local arches="$*" | ||
| mkdir -p "$OUT/$distro" | ||
| docker run --rm -v "$OUT/$distro":/out -e V="$V" -e DISTRO="$distro" \ | ||
| -e PKGS="$pkgs" -e ARCHES="$arches" "$image" bash -euo pipefail -c ' | ||
| export DEBIAN_FRONTEND=noninteractive | ||
| apt-get update -qq | ||
| apt-get install -y -qq ca-certificates curl gnupg >/dev/null | ||
| mkdir -p /etc/apt/keyrings | ||
| curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /etc/apt/keyrings/llvm.gpg | ||
| native=$(dpkg --print-architecture) | ||
| for a in $ARCHES; do | ||
| [ "$a" = "$native" ] || dpkg --add-architecture "$a" | ||
| done | ||
| # Keep the Ubuntu archive native-only: the foreign arch is served from | ||
| # ports.ubuntu.com and we only need its apt.llvm.org debs. | ||
| if [ -f /etc/apt/sources.list ]; then | ||
| sed -i "s|^deb |deb [arch=$native] |" /etc/apt/sources.list | ||
| fi | ||
| if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then | ||
| sed -i "/^Types:/a Architectures: $native" /etc/apt/sources.list.d/ubuntu.sources | ||
| fi | ||
| echo "deb [arch=$(echo $ARCHES | tr " " ,) signed-by=/etc/apt/keyrings/llvm.gpg] https://apt.llvm.org/$DISTRO/ llvm-toolchain-$DISTRO-$V main" \ | ||
| > /etc/apt/sources.list.d/llvm.list | ||
| apt-get update -qq | ||
| # Resolve the install set on the native arch and keep the names that come | ||
| # from apt.llvm.org; the same names exist for every arch in that repo. | ||
| names=$(apt-get install -y -qq --print-uris $PKGS \ | ||
| | grep -o "https://apt.llvm.org/[^ '"'"']*\.deb" | xargs -n1 basename | cut -d_ -f1 | sort -u) | ||
| echo "$(echo "$names" | wc -l) packages from apt.llvm.org" | ||
| for a in $ARCHES; do | ||
| mkdir -p /out/$a && cd /out/$a | ||
| for n in $names; do | ||
| apt-get download -qq "$n:$a" | ||
| done | ||
| ls *.deb | wc -l | ||
| done | ||
| ' | ||
| } | ||
|
|
||
| mirror focal ubuntu:20.04 "$ALL_PKGS" amd64 arm64 | ||
| mirror noble ubuntu:24.04 "$BASE_PKGS" amd64 | ||
|
|
||
| NOTES="$OUT/notes.md" | ||
| { | ||
| echo "LLVM $V .debs from apt.llvm.org, mirrored so the Dockerfiles do not depend on apt.llvm.org at build time. Regenerate with scripts/mirror-llvm-debs.sh (or the mirror-llvm-debs workflow)." | ||
| echo | ||
| echo "| tarball | clang-$V version | files | sha256 |" | ||
| echo "|---|---|---|---|" | ||
| } > "$NOTES" | ||
| ASSETS=() | ||
| for dir in "$OUT"/*/*/; do | ||
| distro=$(basename "$(dirname "$dir")"); arch=$(basename "$dir") | ||
| ls "$dir"/clang-${V}_*.deb >/dev/null || { echo "!! $distro/$arch missing clang-$V"; exit 1; } | ||
| tarball="$OUT/llvm-$V-$distro-$arch.tar.gz" | ||
| # Sorted names + fixed mtime/owner so the SHA-256 is reproducible. | ||
| tar --sort=name --mtime='UTC 2020-01-01' --owner=0 --group=0 --numeric-owner \ | ||
| -czf "$tarball" -C "$dir" . | ||
| sha=$(sha256sum "$tarball" | cut -d' ' -f1) | ||
| ver=$(dpkg-deb -f "$(ls "$dir"/clang-${V}_*.deb)" Version) | ||
| echo "| llvm-$V-$distro-$arch.tar.gz | $ver | $(ls "$dir" | wc -l) | \`$sha\` |" >> "$NOTES" | ||
| echo "LLVM_DEBS_SHA256_${distro}_${arch}=$sha ($(du -h "$tarball" | cut -f1))" | ||
| ASSETS+=("$tarball") | ||
| done | ||
|
|
||
| if gh release view "$TAG" -R "$REPO" >/dev/null 2>&1; then | ||
| gh release upload "$TAG" -R "$REPO" --clobber "${ASSETS[@]}" | ||
| gh release edit "$TAG" -R "$REPO" --notes-file "$NOTES" | ||
| else | ||
| gh release create "$TAG" -R "$REPO" --title "LLVM $V .debs (mirror of apt.llvm.org)" \ | ||
| --notes-file "$NOTES" "${ASSETS[@]}" | ||
| fi | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Pin the LLVM archive signing-key fingerprint.
Line 44 accepts any key returned by the endpoint. If the key download is substituted, APT accepts a matching attacker-signed repository index. The workflow can then publish those packages as trusted release assets.
Verify a repository-pinned expected fingerprint after import and fail before
apt-get update.🤖 Prompt for AI Agents