Skip to content

Commit 087c5f3

Browse files
authored
0.23.0: dist-deb and dist-rpm, the staged tree as a Debian or RPM package (#56)
* 0.23.0: dist-deb and dist-rpm, the staged tree as a Debian or RPM package Both members install the tree mcpp pack stages under /opt/<name>, with a launcher in /usr/bin, a desktop entry and an icon, and take the control fields from [package]. They share mcpp.dist.linux_package and write either format with nfpm from the xim:nfpm payload, asked for only when a pack needs it, so no host needs dpkg-deb or rpmbuild. Every staged file is listed with an explicit mode and time, so repacking an unchanged tree gives the same bytes. tests/linux-package-consumer packs both, compares their contents, installs the deb and runs the program. * 0.23.0: the in-source version, and dist-deb and dist-rpm compiled on every host The collection states its version in src/plugins.cppm as well as mcpp.toml, and tests/all-rules-compile names every member that carries sources, so both new members' plans are compiled and asserted silent on macOS and Windows.
1 parent 6f5308a commit 087c5f3

15 files changed

Lines changed: 636 additions & 6 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,53 @@ jobs:
12831283
# the compiled build program's actual behaviour under the exact
12841284
# environment contract `--target aarch64-ios-sim --format app` and the
12851285
# device row would set, run directly rather than through mcpp.
1286+
- name: dist-deb and dist-rpm produce packages that carry the program, reproducibly
1287+
working-directory: tests/linux-package-consumer
1288+
run: |
1289+
# A plain build has no distribution edge, yet both formats are known.
1290+
"$MCPP" build
1291+
if find target -name '*.deb' -o -name '*.rpm' | grep -q .; then
1292+
echo "FAIL: a plain build produced a package"; exit 1
1293+
fi
1294+
set +e
1295+
se=$("$MCPP" pack --pkg-format bogus 2>&1 >/dev/null)
1296+
set -e
1297+
grep -qE 'available in this build: .*\bdeb\b' <<<"$se" && grep -qE 'available in this build: .*\brpm\b' <<<"$se" \
1298+
|| { echo "FAIL: the refusal does not name deb and rpm"; echo "$se"; exit 1; }
1299+
1300+
"$MCPP" pack --pkg-format deb | tee pack-deb.log
1301+
"$MCPP" pack --pkg-format rpm | tee pack-rpm.log
1302+
deb=$(find target -name 'linux-package-consumer_0.4.0_*.deb' | head -1)
1303+
rpm=$(find target -name 'linux-package-consumer-0.4.0-1.*.rpm' | head -1)
1304+
test -n "$deb" && test -n "$rpm" || { echo "FAIL: no package was produced"; exit 1; }
1305+
1306+
# The control fields come from [package], and the dependency the project stated is recorded.
1307+
dpkg-deb --field "$deb" Package Version Maintainer Depends | tee fields.log
1308+
grep -q '^Maintainer: mcpp-community <' fields.log && grep -q '^Depends: bash' fields.log \
1309+
|| { echo "FAIL: the deb's control fields"; exit 1; }
1310+
rpm -qp --requires "$rpm" | grep -qx bash || { echo "FAIL: the rpm does not require bash"; exit 1; }
1311+
1312+
# The same files in both, and the installed program runs through /usr/bin.
1313+
dpkg-deb --contents "$deb" | awk '{print $6}' | sed 's|^\./|/|' | grep -v '/$' | sort > deb-files.txt
1314+
rpm -qlp "$rpm" | sort > rpm-files.txt
1315+
diff deb-files.txt rpm-files.txt || { echo "FAIL: deb and rpm carry different files"; exit 1; }
1316+
for f in /usr/bin/linux-package-consumer /usr/share/applications/linux-package-consumer.desktop \
1317+
/usr/share/icons/hicolor/scalable/apps/linux-package-consumer.svg; do
1318+
grep -qx "$f" deb-files.txt || { echo "FAIL: $f is not in the package"; exit 1; }
1319+
done
1320+
sudo dpkg -i "$deb"
1321+
linux-package-consumer | tee run.log
1322+
grep -q '^linux-package-consumer ok' run.log || { echo "FAIL: the installed program did not run"; exit 1; }
1323+
sudo dpkg -r linux-package-consumer
1324+
1325+
# Re-staging an unchanged program gives the same bytes.
1326+
before=$(sha256sum "$deb" "$rpm")
1327+
touch src/main.cpp
1328+
"$MCPP" pack --pkg-format deb > /dev/null
1329+
"$MCPP" pack --pkg-format rpm > /dev/null
1330+
[ "$before" = "$(sha256sum "$deb" "$rpm")" ] || { echo "FAIL: repacking changed the packages"; exit 1; }
1331+
echo "ok: deb and rpm"
1332+
12861333
- name: dist-apple's iOS row, checked at the plan level
12871334
working-directory: tests/ios-app-consumer
12881335
run: MCPP="$MCPP" ./check-ios-plan.sh

‎README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module name the member declares, and configures it there.
99

1010
```toml
1111
[build-dependencies.mcpp]
12-
plugins = { version = "0.22.1", features = ["rules-spirv"], host-module = true }
12+
plugins = { version = "0.23.0", features = ["rules-spirv"], host-module = true }
1313
```
1414

1515
```cpp
@@ -76,6 +76,8 @@ mcpp 2026.11.7.1 or later; cross configuration requires CMake 3.19 or later.
7676
| `tools-embed` | `mcpp.tools.embed` | 2026.9.5.4 | Writes a data file into a header the program compiles in. | [tools-embed](docs/tools-embed.md) |
7777
| `tools-island` | `mcpp.tools.island` | 2026.9.7.1 | Generates the `extern "C"` boundary and the C++ module of a code island. | [tools-island](docs/tools-island.md) |
7878
| `dist-appimage` | `mcpp.dist.appimage` | 2026.10.1.3 | Turns the tree `mcpp pack` stages into an AppImage (Linux). | [dist](docs/dist.md#dist-appimage) |
79+
| `dist-deb` | `mcpp.dist.deb` | 2026.10.30.1 | Installs the staged tree under `/opt/<name>` with a launcher, a desktop entry and an icon, as a Debian package (Linux targets). | [dist](docs/dist.md#dist-deb-and-dist-rpm) |
80+
| `dist-rpm` | `mcpp.dist.rpm` | 2026.10.30.1 | The same installation as an RPM package (Linux targets). | [dist](docs/dist.md#dist-deb-and-dist-rpm) |
7981
| `dist-wix` | `mcpp.dist.wix` | 2026.10.1.3 | Builds an MSI of the staged tree, and a Burn bundle chaining it (Windows). | [dist](docs/dist.md#dist-wix) |
8082
| `dist-apple` | `mcpp.dist.apple` | 2026.9.14.2 | Lays out a macOS or iOS application bundle, signs it and writes a disk image. | [dist-apple](docs/dist-apple.md) |
8183
| `dist-web` | `mcpp.dist.web` | 2026.9.13.1 | Copies a `wasm32-emscripten` program and its files into a web directory with an `index.html`. | [dist](docs/dist.md#dist-web) |

‎dist/deb.cppm‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// mcpp.dist.deb -- a staged program becomes a Debian package for Debian, Ubuntu, and their derivatives.
2+
//
3+
// The layout and the writer are shared with the other Linux package format in
4+
// `mcpp.dist.linux_package`: the staged closure under `/opt/<name>`, a
5+
// launcher in `/usr/bin`, a desktop entry and an icon, written by nfpm from
6+
// the `xim:nfpm` payload, so the host needs no `dpkg-deb`.
7+
8+
export module mcpp.dist.deb;
9+
10+
import std;
11+
export import mcpp.dist.linux_package;
12+
13+
export namespace mcpp::dist::deb {
14+
15+
using options = mcpp::dist::linux_package::options;
16+
using plan = mcpp::dist::linux_package::plan;
17+
18+
// What `generate` would submit for `mcpp pack --format deb`, without submitting it.
19+
inline plan plan_for(options opt = {}) {
20+
return mcpp::dist::linux_package::plan_for("deb", std::move(opt));
21+
}
22+
23+
inline bool submit(const plan& p) {
24+
return mcpp::dist::linux_package::submit(p);
25+
}
26+
27+
// The one call a build program makes: declares the `deb` format in every pass
28+
// and submits the package action when `mcpp pack --format deb` asked for it.
29+
inline bool generate(options opt = {}) {
30+
return mcpp::dist::linux_package::generate("deb", std::move(opt));
31+
}
32+
33+
} // namespace mcpp::dist::deb

0 commit comments

Comments
 (0)