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
38 changes: 25 additions & 13 deletions scripts/aur/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# AUR packaging

Arch Linux packaging for mcpp. Two packages, same runtime layout:
Arch Linux packaging for mcpp. Three packages, same runtime layout:

| Package | What it installs | Pick it when |
| --- | --- | --- |
| [`mcpp-bin`](mcpp-bin/) | the **prebuilt** release binary (what [`install.sh`](../../install.sh) downloads) | you just want mcpp, fast |
| [`mcpp-m`](mcpp-m/) | mcpp **built from source**, bootstrapped with `mcpp-bin` | you want a from-source build |
| [`mcpp-m`](mcpp-m/) | mcpp **built from source**, bootstrapped with `mcpp-bin` | you want a from-source build of a release |
| [`mcpp-git`](mcpp-git/) | mcpp **built from the git master**, bootstrapped with `mcpp-bin` | you want to track master (rolling) and never lag the index floor |

```sh
yay -S mcpp-bin # prebuilt
yay -S mcpp-m # from source (pulls mcpp-bin as a build dep)
yay -S mcpp-git # from git master (pulls mcpp-bin as a build dep)
```

The two `conflict` with each other, so only one can be installed at a time.
The three `conflict` with each other, so only one can be installed at a time.
Supported architectures: `x86_64`, `aarch64`.

### Why not just `mcpp`?

The name `mcpp` is already taken by **`extra/mcpp`** — Matsui's C preprocessor,
an unrelated long-standing official Arch package that owns `/usr/bin/mcpp`. The
AUR refuses to host any package whose `pkgname` (or `provides`) collides with an
official-repo package, so our packages are `mcpp-bin` / `mcpp-m`. They still
install the `mcpp` command at `/usr/bin/mcpp`, so both `conflicts=('mcpp')` with
that preprocessor — you can have our mcpp or the preprocessor, not both.
official-repo package, so our packages are `mcpp-bin` / `mcpp-m` / `mcpp-git`.
They still install the `mcpp` command at `/usr/bin/mcpp`, so all three
`conflicts=('mcpp')` with that preprocessor — you can have our mcpp or the
preprocessor, not both.

## Layout & why the wrapper exists

Expand Down Expand Up @@ -52,30 +55,39 @@ user already exported, so a custom home or xlings still works.
First `mcpp build`/`mcpp run` bootstraps the sandbox (downloads ninja, patchelf
and the default toolchain into `~/.mcpp`) — expected, and only once per user.

### How the `mcpp-m` source package builds
### How the `mcpp-m` / `mcpp-git` source packages build

mcpp is self-hosting. The `mcpp-m` PKGBUILD uses the installed `mcpp-bin` as the
bootstrap compiler and runs `mcpp build --target <arch>-linux-musl` — the same
mcpp is self-hosting. Both source PKGBUILDs use the installed `mcpp-bin` as the
bootstrap compiler and run `mcpp build --target <arch>-linux-musl` — the same
path [`release.yml`](../../.github/workflows/release.yml) ships. mcpp downloads
its own pinned toolchain (it does **not** use the host gcc), so the build needs
network access, like the upstream release build.

`mcpp-m` builds a pinned release tarball; `mcpp-git` checks out `master` from
the official repo (`source = mcpp::git+…`, `sha256sums = SKIP`) and derives a
monotonic `pkgver` from `git describe` (tag + commit distance). Because it
tracks master, `mcpp-git` can never lag the index floor the way `mcpp-bin` does
between releases — at the cost of tracking bleeding-edge master.

## Files

```
scripts/aur/
README.md this file
update.sh bump BOTH packages to a release version
update.sh bump the release-pinned packages (mcpp-bin, mcpp-m)
mcpp-bin/{PKGBUILD, .SRCINFO, mcpp.sh}
mcpp-m/{PKGBUILD, .SRCINFO, mcpp.sh}
mcpp-git/{PKGBUILD, .SRCINFO, mcpp.sh}
```

`mcpp.sh` is identical in both dirs (each AUR repo must be self-contained);
`update.sh` keeps them in sync.
`mcpp.sh` is identical in all three dirs (each AUR repo must be self-contained);
`update.sh` keeps `mcpp-bin`/`mcpp-m` in sync. `mcpp-git` has no checksums to
bump (VCS source) and is not touched by `update.sh`.

## Releasing a new version

After a GitHub release is published (and mirrored), bump both packages:
After a GitHub release is published (and mirrored), bump the release-pinned
packages (`mcpp-bin`, `mcpp-m`; `mcpp-git` tracks master and needs no bump):

```sh
scripts/aur/update.sh # uses [package].version from mcpp.toml
Expand Down
10 changes: 5 additions & 5 deletions scripts/aur/mcpp-bin/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pkgbase = mcpp-bin
pkgdesc = Modern C++ build & package management tool (prebuilt binary)
pkgver = 0.0.65
pkgver = 2026.8.8.4
pkgrel = 1
url = https://github.com/mcpp-community/mcpp
arch = x86_64
Expand All @@ -12,9 +12,9 @@ pkgbase = mcpp-bin
options = !strip
source = mcpp.sh
sha256sums = SKIP
source_x86_64 = mcpp-0.0.65-linux-x86_64.tar.gz::https://github.com/mcpp-community/mcpp/releases/download/v0.0.65/mcpp-0.0.65-linux-x86_64.tar.gz
sha256sums_x86_64 = 0d1d16aae05e4d7c59a00a2621abc4b99421b9821d2145c139fabf95fcf93409
source_aarch64 = mcpp-0.0.65-linux-aarch64.tar.gz::https://github.com/mcpp-community/mcpp/releases/download/v0.0.65/mcpp-0.0.65-linux-aarch64.tar.gz
sha256sums_aarch64 = 20dd7a8be657bf2e32dcffcf10b758e34fe740fcdb1ceb374822d5ee25cb4a52
source_x86_64 = mcpp-2026.8.8.4-linux-x86_64.tar.gz::https://github.com/mcpp-community/mcpp/releases/download/v2026.8.8.4/mcpp-2026.8.8.4-linux-x86_64.tar.gz
sha256sums_x86_64 = a8f30fc73fae75381cdd734d204e6c04a24c55365cdf8bb6da07c3aa663c8f9f
source_aarch64 = mcpp-2026.8.8.4-linux-aarch64.tar.gz::https://github.com/mcpp-community/mcpp/releases/download/v2026.8.8.4/mcpp-2026.8.8.4-linux-aarch64.tar.gz
sha256sums_aarch64 = e0d63de0f6e0111f47df00e9135baf437aed2bcdb883dbb658880d9ee4418e27

pkgname = mcpp-bin
6 changes: 3 additions & 3 deletions scripts/aur/mcpp-bin/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# how this is published to the AUR and how to bump it (scripts/aur/update.sh).

pkgname=mcpp-bin
pkgver=0.0.65
pkgver=2026.8.8.4
pkgrel=1
pkgdesc="Modern C++ build & package management tool (prebuilt binary)"
arch=('x86_64' 'aarch64')
Expand All @@ -28,8 +28,8 @@ source_aarch64=("mcpp-${pkgver}-linux-aarch64.tar.gz::${_relbase}/mcpp-${pkgver}
source=("mcpp.sh")

sha256sums=('SKIP')
sha256sums_x86_64=('0d1d16aae05e4d7c59a00a2621abc4b99421b9821d2145c139fabf95fcf93409')
sha256sums_aarch64=('20dd7a8be657bf2e32dcffcf10b758e34fe740fcdb1ceb374822d5ee25cb4a52')
sha256sums_x86_64=('a8f30fc73fae75381cdd734d204e6c04a24c55365cdf8bb6da07c3aa663c8f9f')
sha256sums_aarch64=('e0d63de0f6e0111f47df00e9135baf437aed2bcdb883dbb658880d9ee4418e27')

package() {
local _src="${srcdir}/mcpp-${pkgver}-linux-${CARCH}"
Expand Down
21 changes: 21 additions & 0 deletions scripts/aur/mcpp-git/.SRCINFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pkgbase = mcpp-git
pkgdesc = Modern C++ build & package management tool (git master)
pkgver = 2026.8.8.4
pkgrel = 1
url = https://github.com/mcpp-community/mcpp
arch = x86_64
arch = aarch64
license = Apache-2.0
makedepends = mcpp-bin
makedepends = git
depends = git
conflicts = mcpp-bin
conflicts = mcpp-m
conflicts = mcpp
options = !strip
source = mcpp::git+https://github.com/mcpp-community/mcpp.git
source = mcpp.sh
sha256sums = SKIP
sha256sums = SKIP

pkgname = mcpp-git
96 changes: 96 additions & 0 deletions scripts/aur/mcpp-git/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Maintainer: mcpp-community <x.d2learn.org@gmail.com>
#
# mcpp-git — mcpp built from the upstream git repository (rolling master),
# bootstrapped with the prebuilt `mcpp-bin`. Same self-hosted build as
# `mcpp-m`, but tracks master instead of a pinned release — so it can never
# lag the index floor (E0006) the way `mcpp-bin` does between releases.
#
# Rolling master is bleeding-edge: prefer `mcpp-bin` for stable use.
#
# NB: the AUR/official name `mcpp` is taken by Matsui's C preprocessor
# (extra/mcpp), so this package is `mcpp-git`. It still installs the `mcpp`
# command at /usr/bin/mcpp, hence the conflict with that preprocessor.
# See scripts/aur/README.md.

pkgname=mcpp-git
# Static seed only — real builds override it via pkgver() below. Kept at the
# current release so the AUR listing doesn't look ancient; actual version is
# whatever master reports at build time.
pkgver=2026.8.8.4
pkgrel=1
pkgdesc="Modern C++ build & package management tool (git master)"
arch=('x86_64' 'aarch64')
url="https://github.com/mcpp-community/mcpp"
license=('Apache-2.0')
# mcpp/xlings are statically linked; git is used for package-index sync.
depends=('git')
# mcpp-bin is the bootstrap compiler; it also supplies the bundled xlings we
# ship at runtime. git is needed for toolchain/index sync during the build.
makedepends=('mcpp-bin' 'git')
# mcpp-bin / mcpp-m = the same tool (mutually exclusive); mcpp = the C
# preprocessor that also owns /usr/bin/mcpp.
conflicts=('mcpp-bin' 'mcpp-m' 'mcpp')
# We strip the built ELF ourselves; don't let makepkg re-strip the vendored
# xlings binary (a prebuilt third-party artifact).
options=('!strip')

source=("mcpp::git+https://github.com/mcpp-community/mcpp.git"
"mcpp.sh")
sha256sums=('SKIP'
'SKIP')

# Rolling master has no stable release number. Pacman only needs a
# monotonically increasing pkgver, so derive one from the closest tag plus the
# commit distance (AUR -git convention): v2026.8.8.4-5-g<hash> →
# 2026.8.8.4.5.g<hash>. The binary's own version comes from the checked-out
# source (src/version.cppm), independent of pkgver.
pkgver() {
cd "${srcdir}/mcpp"
git describe --long --tags | sed 's/^v//; s/-/./g'
}

# mcpp downloads its own pinned toolchain (gcc/ninja/patchelf) into the build
# sandbox — it does not use the host gcc. This needs network access at build
# time, like the upstream release build.
build() {
cd "${srcdir}/mcpp"

case "$CARCH" in
x86_64) _target=x86_64-linux-musl ;;
aarch64) _target=aarch64-linux-musl ;;
*) echo "unsupported CARCH: $CARCH" >&2; return 1 ;;
esac

# Bootstrap with mcpp-bin's real binary (not its /usr/bin wrapper, which
# would force MCPP_HOME into the user's home). Keep the build sandbox
# self-contained under $srcdir and reuse mcpp-bin's bundled xlings.
export MCPP_HOME="${srcdir}/.mcpp-home"
export MCPP_VENDORED_XLINGS="/opt/mcpp/registry/bin/xlings"

/opt/mcpp/bin/mcpp build --target "$_target"

_artifact=$(find "target/${_target}" -type f -name mcpp | head -1)
test -n "$_artifact" || { echo "build produced no mcpp binary" >&2; return 1; }
file "$_artifact" | grep -q 'statically linked'
# Debug info on a static ELF balloons it ~7×; strip with the native tool.
strip "$_artifact"

# Stash artifact + the vendored xlings for package() (which has no /opt
# guarantees beyond makedepends being installed).
install -Dm755 "$_artifact" "${srcdir}/stage/bin/mcpp"
install -Dm755 /opt/mcpp/registry/bin/xlings "${srcdir}/stage/registry/bin/xlings"
}

package() {
# Same /opt + wrapper layout as mcpp-bin / mcpp-m (see scripts/aur/README.md
# for why the per-user wrapper exists instead of a /usr/bin symlink).
install -Dm755 "${srcdir}/stage/bin/mcpp" "${pkgdir}/opt/mcpp/bin/mcpp"
install -Dm755 "${srcdir}/stage/registry/bin/xlings" "${pkgdir}/opt/mcpp/registry/bin/xlings"

install -Dm755 "${srcdir}/mcpp.sh" "${pkgdir}/usr/bin/mcpp"

install -Dm644 "${srcdir}/mcpp/LICENSE" \
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
install -Dm644 "${srcdir}/mcpp/README.md" \
"${pkgdir}/usr/share/doc/${pkgname}/README.md"
}
27 changes: 27 additions & 0 deletions scripts/aur/mcpp-git/mcpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# mcpp launcher (Arch / AUR mcpp-bin package).
#
# The AUR package installs mcpp's self-contained tree read-only under
# /opt/mcpp (shared by every user). But mcpp WRITES its registry sandbox,
# BMI/metadata caches, logs and downloaded toolchains into MCPP_HOME at
# runtime — that has to be a per-user, writable location, never /opt.
#
# mcpp resolves MCPP_HOME from the binary's real path (/proc/self/exe, which
# resolves symlinks), so a plain /usr/bin symlink would make MCPP_HOME land in
# the root-owned /opt tree and every command would fail to write. This wrapper
# fixes that by pinning the two env knobs the binary honors:
#
# MCPP_HOME — per-user home (default ~/.mcpp, same as install.sh)
# MCPP_VENDORED_XLINGS — the bundled xlings under /opt, which mcpp copies
# into $MCPP_HOME/registry/bin/xlings on first run
#
# Both respect a value the user already exported, so power users can still
# point mcpp at a custom home or xlings.
set -eu

MCPP_OPT="/opt/mcpp"

export MCPP_HOME="${MCPP_HOME:-$HOME/.mcpp}"
export MCPP_VENDORED_XLINGS="${MCPP_VENDORED_XLINGS:-$MCPP_OPT/registry/bin/xlings}"

exec "$MCPP_OPT/bin/mcpp" "$@"
4 changes: 2 additions & 2 deletions scripts/aur/mcpp-m/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pkgbase = mcpp-m
pkgdesc = Modern C++ build & package management tool (built from source)
pkgver = 0.0.65
pkgver = 2026.8.8.4
pkgrel = 1
url = https://github.com/mcpp-community/mcpp
arch = x86_64
Expand All @@ -12,7 +12,7 @@ pkgbase = mcpp-m
conflicts = mcpp-bin
conflicts = mcpp
options = !strip
source = mcpp-0.0.65.tar.gz::https://github.com/mcpp-community/mcpp/archive/v0.0.65.tar.gz
source = mcpp-2026.8.8.4.tar.gz::https://github.com/mcpp-community/mcpp/archive/v2026.8.8.4.tar.gz
source = mcpp.sh
sha256sums = 07f8233d3f18565c52607816a82c9facda3a7ed11c67d3772e42bd84cb54476a
sha256sums = SKIP
Expand Down
2 changes: 1 addition & 1 deletion scripts/aur/mcpp-m/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# See scripts/aur/README.md.

pkgname=mcpp-m
pkgver=0.0.65
pkgver=2026.8.8.4
pkgrel=1
pkgdesc="Modern C++ build & package management tool (built from source)"
arch=('x86_64' 'aarch64')
Expand Down
Loading
Loading