[215] Cycles: Bau (CI Linux/macOS) und Auslieferung (Tauri, Electron)
check / check (push) Has been cancelled
check / licenses (push) Has been cancelled
check / e2e (push) Has been cancelled
macos / native (push) Has been cancelled
cycles / linux (push) Has been cancelled
cycles / macos (push) Has been cancelled

cycles.yml baut Cycles je Plattform (Linux x86_64, macOS arm64) und legt das Paket als Artefakt und am Gitea-Release cycles-<version> ab;
release.yml lädt es vor dem App-Bau (get.sh). Mitgeliefert: Electron extraResources (resources/cycles), Tauri externalBin + resources
(tauri.cycles.conf.json). Fassade src/native/cyclesRuntime.ts (cyclesAvailable, runCycles mit Fortschritt und Abbruch), Hauptprozess und
Rust (cycles.rs) prüfen die Argumente und starten nur das Paketprogramm. build-macos.sh fertig, Lizenztexte im Paket, NOTICE, doc/CYCLES.md.
Geprüft: vitest, rustc --test, AppImage mit Linux-Paket (test:linux-app, Fall Cycles). Nicht geprüft: Workflows, Mac, Tauri-Befehle.
This commit is contained in:
Claude committed 2026-11-16 17:01:38 +00:00
1 parent e3fcfb0e3c
commit d0ba3f17ae
35 files changed
+1785 -58

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
Dossier — mitgeliefertes Cycles-Paket: Bestandteile und Lizenzen ([215], [51])
=================================================================================
Dieses Paket (Ordner `cycles/`) liegt der App bei und wird als eigenes Programm gestartet (`cycles --background …`). Es
enthält nur Software unter permissiven Lizenzen — kein GPL, kein LGPL. Die Lizenztexte stehen in diesem Ordner
(`Apache-2.0.txt`, `*-license.txt`, `Cycles-LICENSE.txt`, `debian/<paket>.copyright`, `OpenImageIO-*`, `libtiff-*`).
Programm
Cycles (Blender Foundation u. a.), Standalone-Fassung, Version siehe Datei VERSION Apache-2.0
Quelle: https://projects.blender.org/blender/cycles (Tag v<VERSION>); Änderung: scripts/cycles/patches/no-ocio.patch
(OpenColorIO optional, bei uns aus). In der Quelle enthalten: Nishita-Himmel, Hosek-Wilkie-Himmel, mikktspace (Zlib),
atomic_ops (BSD-3-Clause), Teile unter MIT — Texte: Apache2-license.txt, BSD-3-Clause-license.txt, MIT-license.txt, Zlib-license.txt
Bibliotheken (lib/)
Embree 4 (Intel) libembree4 Apache-2.0
Open Image Denoise 2.5 (Intel; enthält libOpenImageDenoise* Apache-2.0
oneDNN, Apache-2.0, und trainierte Netze)
OpenImageIO 2.4 (eigener schlanker Bau) libOpenImageIO* BSD-3-Clause
OpenEXR / Imath / Iex / IlmThread 3.1 libOpenEXR*, libI* BSD-3-Clause
oneTBB libtbb Apache-2.0
libtiff 4.5 (eigener Bau, ohne jbig) libtiff libtiff-Lizenz (BSD-artig)
libpng libpng16 libpng-Lizenz
libjpeg-turbo libjpeg IJG / BSD-3-Clause / Zlib
zlib libz Zlib
libdeflate libdeflate MIT
Zstandard libzstd BSD-3-Clause
pugixml libpugixml MIT
Boost (filesystem, thread) libboost_* BSL-1.0
macOS (arm64) zusätzlich: die Blender-Vorbau-Bibliotheken (lib-macos_arm64) in derselben Auswahl; die Metal-Kernel-Quellen
(`source/`, Apache-2.0, Teil von Cycles).
Das System liefert libc, libstdc++, libm (nicht Teil des Pakets).
+1
View File
@@ -0,0 +1 @@
5.3.0
+21 -3
View File
@@ -14,10 +14,10 @@
# Cloud-Container gesperrt und wird NICHT gebraucht.
set -euo pipefail
CYCLES_TAG="${CYCLES_TAG:-v5.3.0}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CYCLES_TAG="${CYCLES_TAG:-v$(tr -d ' \n' < "$HERE/VERSION")}"
OIIO_VERSION="${OIIO_VERSION:-2.4.17.0+dfsg}"
JOBS="${JOBS:-3}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORK="$(mkdir -p "${1:-$HOME/cycles-build}" && cd "${1:-$HOME/cycles-build}" && pwd)"
OUT="$WORK/dist"
echo "== Arbeitsordner: $WORK"
@@ -104,6 +104,7 @@ ninja -C "$WORK/build-cycles" -j"$JOBS"
rm -rf "$OUT"; mkdir -p "$OUT/lib"
cp "$WORK/build-cycles/bin/cycles" "$OUT/cycles"
export LD_LIBRARY_PATH="$OIDN/lib:$OIIO/lib:$TIFF/lib"
LIBS_SRC="$WORK/libs.txt"
ldd "$OUT/cycles" | awk '/=>/ {print $3}' | grep -Ev '/(libc|libm|libdl|libpthread|librt|libstdc\+\+|libgcc_s|libresolv|ld-linux[^/]*)\.so' | sort -u > "$WORK/libs.txt"
while read -r l; do cp -L "$l" "$OUT/lib/$(basename "$l")"; done < "$WORK/libs.txt"
# OIDN lädt die Geräte-Bibliothek zur Laufzeit neben sich
@@ -111,5 +112,22 @@ cp -L "$OIDN/lib/libOpenImageDenoise_device_cpu.so.2.5.0" "$OUT/lib/"
strip --strip-unneeded "$OUT/cycles" "$OUT/lib/"*.so* 2>/dev/null || true
patchelf --set-rpath '$ORIGIN/lib' "$OUT/cycles"
for f in "$OUT"/lib/*.so*; do patchelf --set-rpath '$ORIGIN' "$f" 2>/dev/null || true; done
cp "$WORK/src/cycles/LICENSE" "$OUT/LICENSE-cycles.txt"
# (7) Lizenztexte. Debian-Pakete: /usr/share/doc/<paket>/copyright (über dpkg -S vom Bibliothekspfad); eigene Builds und
# der OIDN-Vorbau: aus den Quellordnern. Fehlt ein Text, bricht der Bau ab (sonst lieferten wir Bibliotheken ohne Lizenz aus).
LIC="$OUT/licenses"; mkdir -p "$LIC/debian"
cp "$WORK/src/cycles/LICENSE" "$LIC/Cycles-LICENSE.txt"
cp "$WORK/src/cycles/src/doc/license/"*-license.txt "$LIC/" # Apache-2.0, BSD-3-Clause, MIT, Zlib (Teile von Cycles, SPDX-Kopfzeilen)
cp /usr/share/common-licenses/Apache-2.0 "$LIC/Apache-2.0.txt"
cp "$HERE/THIRD-PARTY.txt" "$LIC/README.txt"
for cand in LICENSE.md LICENSE; do [ -f "$WORK/src/oiio/$cand" ] && cp "$WORK/src/oiio/$cand" "$LIC/OpenImageIO-$cand.txt" && break; done
for cand in LICENSE.md COPYRIGHT; do [ -f "$WORK/src/tiff/$cand" ] && cp "$WORK/src/tiff/$cand" "$LIC/libtiff-$cand.txt" && break; done
# OIDN (Apache-2.0): Vorbau liefert keinen eigenen Text; Apache-2.0.txt oben gilt (Quelle: github.com/RenderKit/oidn, Copyright Intel).
while read -r l; do
pkg="$(dpkg -S "$(readlink -f "$l")" 2>/dev/null | head -1 | cut -d: -f1 || true)"
[ -n "$pkg" ] && [ -f "/usr/share/doc/$pkg/copyright" ] && cp "/usr/share/doc/$pkg/copyright" "$LIC/debian/$pkg.copyright"
done < "$LIBS_SRC"
ls "$LIC" "$LIC/debian"
for need in Cycles-LICENSE.txt Apache-2.0.txt; do [ -s "$LIC/$need" ] || { echo "FEHLT: licenses/$need"; exit 1; }; done
printf '%s\n' "${CYCLES_TAG#v}" > "$OUT/VERSION"
echo "== fertig: $OUT"; du -sh "$OUT" "$OUT/lib"; ls -la "$OUT/cycles"; "$OUT/cycles" --version
+95 -25
View File
@@ -1,50 +1,120 @@
#!/usr/bin/env bash
# [215] ENTWURF — Cycles-Standalone für macOS arm64 (Apple Silicon, Metal-GPU + CPU). NICHT AUSGEFÜHRT:
# im Linux-Container gibt es weder Xcode noch Metal. Der Maintainer prüft das auf dem Mac; Abweichungen in
# doc/CYCLES.md nachtragen.
# [215] Cycles-Standalone für macOS arm64 (Apple Silicon, Metal-GPU + CPU) bauen — Ergebnis in $WORK/dist, danach
# scripts/cycles/pack.sh <dist> macos arm64. STAND: für den CI-Lauf (macos-14, .github/workflows/cycles.yml) geschrieben,
# im Linux-Container NICHT ausgeführt (kein Xcode/Metal). Der erste echte Lauf zeigt die Abweichungen; in doc/CYCLES.md nachtragen.
#
# scripts/cycles/build-macos.sh [Arbeitsordner] (Standard: $HOME/cycles-build)
#
# Voraussetzungen: Xcode (nicht nur Command Line Tools: Metal-Header/SDK >= 12), `brew install cmake ninja git git-lfs`.
# Weg A (hier): die offiziellen vorgebauten Bibliotheken von Blender (Submodul lib/macos_arm64, per git-lfs,
# nur dieser eine Ordner; OpenImageIO, OpenColorIO, Embree, OIDN, TBB, OpenEXR … in einer fixen, geprüften Kombination).
# Das ist der Weg, den auch das Blender-Projekt für seine Mac-Builds nutzt. Weg B (Homebrew-Pakete) wäre
# schneller eingerichtet, zieht aber ffmpeg/GDAL … (wie unter Linux) und wechselt mit jeder brew-Version.
# Voraussetzungen: Xcode (nicht nur Command Line Tools), `brew install cmake ninja git git-lfs`.
# Weg A (hier): Blenders vorgebaute Bibliotheken (`make update` holt lib/macos_arm64 per git-lfs: OpenImageIO, Embree, OIDN,
# TBB, OpenEXR … in einer fixen, geprüften Kombination). Weg B (Homebrew) zieht ffmpeg/GDAL … und wechselt mit jeder Version.
#
# Metal: Cycles übersetzt die GPU-Kernel zur Laufzeit aus den Quellen im Ordner `source/` neben dem Programm
# (install/source/kernel/…) und legt sie im Benutzer-Cache ab — der erste Render braucht ein paar Minuten, danach
# lädt es sofort. Der Ordner `source/` muss deshalb in die App (Sidecar-Ressource) und die Kernel-Cache-Ablage
# muss beschreibbar sein (Cycles: path_cache_get → ~/Library/Caches bzw. --cache-Ordner der App).
# Layout des Pakets (Wurzel `cycles/` im Archiv):
# cycles Programm; RPATH @executable_path/lib (Paket, lokal) UND @executable_path/../Resources/cycles/lib (in der App)
# lib/*.dylib nur Nicht-System-Bibliotheken; Kennung @rpath/<name>, eigener RPATH @loader_path
# source/ Metal-Kernel-Quellen: Cycles übersetzt die GPU-Kernel zur Laufzeit daraus (erster GPU-Render einige Minuten,
# Ergebnis im Benutzer-Cache). Der Pfad lässt sich per Umgebungsvariable CYCLES_KERNEL_PATH setzen — die App
# setzt sie beim Start (src-tauri/src/cycles.rs, scripts/electron-cycles.cjs), `source/` muss also nicht neben dem Programm liegen.
# licenses/, VERSION
# Alles bekommt eine Ad-hoc-Signatur (arm64 verlangt eine); die Developer-ID-Signatur setzt der App-Bau (release.yml).
set -euo pipefail
CYCLES_TAG="${CYCLES_TAG:-v5.3.0}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CYCLES_TAG="${CYCLES_TAG:-v$(tr -d ' \n' < "$HERE/VERSION")}"
WORK="$(mkdir -p "${1:-$HOME/cycles-build}" && cd "${1:-$HOME/cycles-build}" && pwd)"
SRC="$WORK/src/cycles"
INSTALL="$WORK/install"
OUT="$WORK/dist"
[ "$(uname -s)" = Darwin ] && [ "$(uname -m)" = arm64 ] || { echo "nur macOS arm64"; exit 1; }
xcrun --sdk macosx --show-sdk-path >/dev/null || { echo "Xcode fehlt"; exit 1; }
for t in cmake ninja git git-lfs python3 install_name_tool otool codesign; do command -v "$t" >/dev/null || { echo "fehlt: $t (brew install cmake ninja git git-lfs)"; exit 1; }; done
git lfs install --skip-repo
mkdir -p "$WORK/src"
[ -d "$WORK/src/cycles" ] || git clone --depth 1 --branch "$CYCLES_TAG" https://projects.blender.org/blender/cycles.git "$WORK/src/cycles"
cd "$WORK/src/cycles"
[ -d "$SRC" ] || git clone --depth 1 --branch "$CYCLES_TAG" https://projects.blender.org/blender/cycles.git "$SRC"
cd "$SRC"
make update # holt lib/macos_arm64 (git-lfs, mehrere GB, einmalig)
# Standard-Konfiguration des Projekts, aber ohne unnötiges: kein OSL/USD/Hydra/Alembic/OpenVDB/OpenSubdiv.
# WITH_CYCLES_DEVICE_METAL ist auf dem Mac Standard (AN). OIDN läuft mit den Blender-Bibliotheken auf CPU/GPU.
# Kein OSL/USD/Hydra/Alembic/OpenVDB/OpenSubdiv/GUI. WITH_CYCLES_DEVICE_METAL ist auf dem Mac Standard (hier ausdrücklich AN).
cmake -G Ninja -S . -B "$WORK/build-cycles" -DCMAKE_BUILD_TYPE=Release \
-DWITH_CYCLES_OSL=OFF -DWITH_CYCLES_USD=OFF -DWITH_CYCLES_HYDRA_RENDER_DELEGATE=OFF -DWITH_CYCLES_ALEMBIC=OFF \
-DWITH_CYCLES_OPENVDB=OFF -DWITH_CYCLES_NANOVDB=OFF -DWITH_CYCLES_OPENSUBDIV=OFF -DWITH_CYCLES_STANDALONE_GUI=OFF \
-DWITH_CYCLES_DEVICE_METAL=ON -DWITH_CYCLES_EMBREE=ON -DWITH_CYCLES_OPENIMAGEDENOISE=ON \
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DCMAKE_INSTALL_PREFIX="$OUT"
-DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DCMAKE_INSTALL_PREFIX="$INSTALL"
cmake --build "$WORK/build-cycles" --target install -j"$(sysctl -n hw.ncpu)"
# Ergebnis prüfen: Programm, mitinstallierte Bibliotheken (install/lib), Kernel-Quellen (install/source)
ls -la "$OUT" "$OUT/lib" 2>/dev/null | head -40
du -sh "$OUT" "$OUT/source" 2>/dev/null || true
BIN="$(find "$INSTALL" -maxdepth 2 -type f -name cycles -perm -u+x | head -1)"
[ -n "$BIN" ] || { echo "installiertes cycles nicht gefunden in $INSTALL"; find "$INSTALL" -maxdepth 2 | head -30; exit 1; }
SRCDIR="$(find "$INSTALL" -maxdepth 2 -type d -name source | head -1)"
[ -n "$SRCDIR" ] || { echo "Metal-Kernel-Quellen (install/source) fehlen"; exit 1; }
# --- Auslieferordner ---
rm -rf "$OUT"; mkdir -p "$OUT/lib" "$OUT/licenses"
cp "$BIN" "$OUT/cycles"
cp -R "$SRCDIR" "$OUT/source"
# Index aller Bibliotheken des Vorbaus: Name → Pfad (für @rpath-Abhängigkeiten, die otool nur als @rpath/<name> nennt)
INDEX="$WORK/dylib-index.txt"
{ find "$SRC/lib/macos_arm64" "$INSTALL" -name '*.dylib' 2>/dev/null; } | while read -r p; do echo "$(basename "$p") $p"; done | sort -u -k1,1 > "$INDEX"
is_system() { case "$1" in /usr/lib/*|/System/*) return 0 ;; *) return 1 ;; esac; }
deps_of() { otool -L "$1" | tail -n +2 | awk '{print $1}'; }
# Abhängigkeiten rekursiv einsammeln
queue=("$OUT/cycles"); seen=" "
while [ ${#queue[@]} -gt 0 ]; do
f="${queue[0]}"; queue=("${queue[@]:1}")
for d in $(deps_of "$f"); do
is_system "$d" && continue
name="$(basename "$d")"
case "$seen" in *" $name "*) continue ;; esac
seen="$seen$name "
path="$(awk -v n="$name" '$1==n {print $2; exit}' "$INDEX")"
[ -n "$path" ] || { echo "Bibliothek nicht gefunden: $d (von $f)"; exit 1; }
cp -L "$path" "$OUT/lib/$name"; chmod u+w "$OUT/lib/$name"
queue+=("$OUT/lib/$name")
done
done
# OIDN lädt seine Gerätebibliotheken (Metal, CPU) zur Laufzeit neben sich
for f in $(awk '$1 ~ /^libOpenImageDenoise_device/ {print $2}' "$INDEX"); do cp -L "$f" "$OUT/lib/$(basename "$f")"; chmod u+w "$OUT/lib/$(basename "$f")"; done
# Kennungen, Abhängigkeiten und RPATHs auf @rpath/@loader_path umschreiben
for l in "$OUT"/lib/*.dylib; do
install_name_tool -id "@rpath/$(basename "$l")" "$l"
for d in $(deps_of "$l"); do is_system "$d" || [ "$(basename "$d")" = "$(basename "$l")" ] || install_name_tool -change "$d" "@rpath/$(basename "$d")" "$l"; done
install_name_tool -add_rpath @loader_path "$l" 2>/dev/null || true
done
for d in $(deps_of "$OUT/cycles"); do is_system "$d" || install_name_tool -change "$d" "@rpath/$(basename "$d")" "$OUT/cycles"; done
# alte RPATHs des Bauordners entfernen, unsere setzen
for rp in $(otool -l "$OUT/cycles" | awk '/LC_RPATH/ {getline; getline; print $2}'); do install_name_tool -delete_rpath "$rp" "$OUT/cycles" 2>/dev/null || true; done
install_name_tool -add_rpath @executable_path/lib "$OUT/cycles"
install_name_tool -add_rpath @executable_path/../Resources/cycles/lib "$OUT/cycles"
strip -x "$OUT/cycles" 2>/dev/null || true
for f in "$OUT/cycles" "$OUT"/lib/*.dylib; do codesign --force --sign - "$f"; done
# --- Lizenzen: Cycles + dessen Teile; je Vorbau-Bibliothek, was der Ordner an Lizenzdateien mitbringt ---
LIC="$OUT/licenses"
cp "$SRC/LICENSE" "$LIC/Cycles-LICENSE.txt"
cp "$SRC/src/doc/license/"*-license.txt "$LIC/"
cp "$SRC/src/doc/license/Apache2-license.txt" "$LIC/Apache-2.0.txt"
cp "$HERE/THIRD-PARTY.txt" "$LIC/README.txt"
: > "$LIC/macos-libs.txt"
for l in "$OUT"/lib/*.dylib; do
name="$(basename "$l")"; p="$(awk -v n="$name" '$1==n {print $2; exit}' "$INDEX")"
# Wurzel der Bibliothek im Vorbau: lib/macos_arm64/<paket>/…
pkg="$(echo "$p" | sed -n 's|.*/lib/macos_arm64/\([^/]*\)/.*|\1|p')"
echo "$name ${pkg:-?}" >> "$LIC/macos-libs.txt"
if [ -n "$pkg" ] && [ -d "$SRC/lib/macos_arm64/$pkg" ]; then
find "$SRC/lib/macos_arm64/$pkg" -maxdepth 3 \( -iname 'LICENSE*' -o -iname 'COPYING*' -o -iname 'NOTICE*' -o -iname 'COPYRIGHT*' \) -type f 2>/dev/null \
| while read -r lf; do mkdir -p "$LIC/$pkg"; cp "$lf" "$LIC/$pkg/$(basename "$lf")"; done
fi
done
printf '%s\n' "${CYCLES_TAG#v}" > "$OUT/VERSION"
# --- Ergebnis prüfen ---
du -sh "$OUT" "$OUT/lib" "$OUT/source"
otool -L "$OUT/cycles" | head -30
"$OUT/cycles" --version
"$OUT/cycles" --list-devices # erwartet: CPU + Apple-GPU (Metal)
# Danach (für die App, nicht Teil dieses Skripts): strip, `codesign --options runtime --timestamp` aller Mach-O-Dateien
# mit der Developer-ID der App, Eintrag in tauri.conf.json (bundle.externalBin: cycles-aarch64-apple-darwin + resources: source/**).
"$OUT/cycles" --list-devices || true # erwartet: CPU (+ Apple-GPU/Metal, wenn der Rechner eine hat; gehostete CI-Runner haben keine)
echo "== fertig: $OUT — Weiter: scripts/cycles/pack.sh $OUT macos arm64"
+57
View File
@@ -0,0 +1,57 @@
// [215] Cycles-Pakete: Namen, Release-Tag, Download-Adresse — reine Funktionen ohne Netz (getestet in
// src/native/cyclesPackage.test.ts). Benutzt von fetch.mjs (App-Bau lädt das fertige Paket) und upload-gitea.mjs (cycles.yml
// legt es ab). Das Paket wird in `.github/workflows/cycles.yml` gebaut und als Asset am Gitea-Release `cycles-<version>`
// (git.openbureau.ch/karim/dossier) abgelegt, damit die App-Builds Cycles nicht jedes Mal neu bauen.
const fs = require("node:fs");
const path = require("node:path");
const { HOST, REPO } = require("../release-gitea-lib.cjs");
const OSES = ["linux", "macos"];
const ARCHES = ["x86_64", "arm64"];
/** Cycles-Version aus `scripts/cycles/VERSION` (z. B. "5.3.0"). */
function cyclesVersion(dir = __dirname) {
const v = fs.readFileSync(path.join(dir, "VERSION"), "utf8").trim();
if (!/^\d+\.\d+\.\d+$/.test(v)) throw new Error(`scripts/cycles/VERSION: keine Version: ${v}`);
return v;
}
/** Release-Tag auf Gitea: "5.3.0" → "cycles-5.3.0". */
function releaseTag(version) {
if (!/^\d+\.\d+\.\d+$/.test(version)) throw new Error(`keine Cycles-Version: ${version}`);
return `cycles-${version}`;
}
/** Name des Pakets (Asset und Artefakt), wie `pack.sh` ihn schreibt. */
function assetName(os, arch, version) {
if (!OSES.includes(os)) throw new Error(`unbekanntes Betriebssystem: ${os}`);
if (!ARCHES.includes(arch)) throw new Error(`unbekannte Architektur: ${arch}`);
releaseTag(version);
return `cycles-${os}-${arch}-${version}.tar.xz`;
}
/** Name des Actions-Artefakts (ohne Endung), z. B. "cycles-linux-x86_64-5.3.0". */
function artifactName(os, arch, version) {
return assetName(os, arch, version).replace(/\.tar\.xz$/, "");
}
/** Download-Adresse des Pakets am Gitea-Release. */
function downloadUrl(os, arch, version) {
return `${HOST}/${REPO}/releases/download/${releaseTag(version)}/${encodeURIComponent(assetName(os, arch, version))}`;
}
/** Plattform des laufenden Rechners im Namensschema des Pakets. */
function hostPlatform(platform = process.platform, arch = process.arch) {
const os = platform === "darwin" ? "macos" : platform === "linux" ? "linux" : null;
const a = arch === "x64" ? "x86_64" : arch === "arm64" ? "arm64" : null;
if (!os || !a) throw new Error(`keine Cycles-Pakete für ${platform}/${arch}`);
return { os, arch: a };
}
/** Erste Zeile `<sha256> <name>` einer `.sha256`-Datei → Hex, sonst null. */
function parseSha256(txt) {
const m = /^([0-9a-f]{64})\s/.exec(String(txt).trim());
return m ? m[1] : null;
}
module.exports = { OSES, ARCHES, cyclesVersion, releaseTag, assetName, artifactName, downloadUrl, hostPlatform, parseSha256 };
+73
View File
@@ -0,0 +1,73 @@
#!/usr/bin/env node
// [215] Fertiges Cycles-Paket laden und auspacken (für den App-Bau in release.yml und für Entwickler):
//
// node scripts/cycles/fetch.mjs [--os linux|macos] [--arch x86_64|arm64] [--out build/cycles] [--version 5.3.0]
//
// Quelle: Asset `cycles-<os>-<arch>-<version>.tar.xz` am Gitea-Release `cycles-<version>` (git.openbureau.ch/karim/dossier),
// mit Prüfsumme aus `<asset>.sha256`, falls vorhanden. GITEA_TOKEN ist nur nötig, wenn das Repository nicht öffentlich lesbar ist.
// Ausgang: 0 = ausgepackt nach --out (Ordner enthält `cycles`, `lib/`, `licenses/`); 3 = Paket gibt es dort nicht (404) — der
// Workflow weicht dann auf das Artefakt von cycles.yml aus; 1 = anderer Fehler.
import { createHash } from "node:crypto";
import { createRequire } from "node:module";
import { mkdirSync, mkdtempSync, readdirSync, renameSync, rmSync, writeFileSync, existsSync } from "node:fs";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { spawnSync } from "node:child_process";
const lib = createRequire(import.meta.url)("./cycles-lib.cjs");
const args = process.argv.slice(2);
const opt = (name, dflt) => {
const i = args.indexOf(`--${name}`);
return i >= 0 && args[i + 1] && !args[i + 1].startsWith("--") ? args[i + 1] : dflt;
};
const host = lib.hostPlatform();
const os = opt("os", host.os);
const arch = opt("arch", host.arch);
const version = opt("version", lib.cyclesVersion());
const out = resolve(opt("out", join(import.meta.dirname, "..", "..", "build", "cycles")));
const token = process.env.GITEA_TOKEN;
const headers = token && token !== "proxy-injected" ? { Authorization: `token ${token}` } : {};
const url = lib.downloadUrl(os, arch, version);
console.log(`cycles: lade ${url}`);
const res = await fetch(url, { headers });
if (res.status === 404) {
console.error(`cycles: Paket nicht am Release ${lib.releaseTag(version)} (404) — erst cycles.yml laufen lassen oder dessen Artefakt nehmen.`);
process.exit(3);
}
if (!res.ok) {
console.error(`cycles: ${res.status} ${await res.text().catch(() => "")}`);
process.exit(1);
}
const data = Buffer.from(await res.arrayBuffer());
const sumRes = await fetch(`${url}.sha256`, { headers });
if (sumRes.ok) {
const want = lib.parseSha256(await sumRes.text());
const got = createHash("sha256").update(data).digest("hex");
if (want && want !== got) {
console.error(`cycles: Prüfsumme stimmt nicht (${got} statt ${want})`);
process.exit(1);
}
console.log(`cycles: Prüfsumme ok (${got.slice(0, 12)}…)`);
} else {
console.log("cycles: keine .sha256 am Release — ohne Prüfsumme weiter");
}
const tmp = mkdtempSync(join(tmpdir(), "dossier-cycles-"));
try {
const tarball = join(tmp, "cycles.tar.xz");
writeFileSync(tarball, data);
const t = spawnSync("tar", ["-xJf", tarball, "-C", tmp], { stdio: "inherit" });
if (t.status !== 0) throw new Error("tar -xJf fehlgeschlagen (xz installiert?)");
const inner = join(tmp, "cycles");
if (!existsSync(join(inner, "cycles"))) throw new Error(`Paket hat nicht den erwarteten Aufbau (cycles/cycles fehlt): ${readdirSync(tmp).join(", ")}`);
rmSync(out, { recursive: true, force: true });
mkdirSync(resolve(out, ".."), { recursive: true });
renameSync(inner, out);
console.log(`cycles: ausgepackt nach ${out}`);
} catch (e) {
console.error(`cycles: ${e.message}`);
process.exit(1);
} finally {
rmSync(tmp, { recursive: true, force: true });
}
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# [215] Cycles-Paket für die App holen: zuerst vom Gitea-Release `cycles-<version>`, sonst aus dem Artefakt des letzten
# erfolgreichen cycles.yml-Laufs (GitHub, `gh` + GH_TOKEN nötig). Ergebnis: build/cycles/ (cycles, lib/, licenses/ …).
# scripts/cycles/get.sh <linux|macos> <x86_64|arm64>
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT="$(cd "$HERE/../.." && pwd)"
OS="${1:?linux|macos}"; ARCH="${2:?x86_64|arm64}"
VERSION="$(tr -d ' \n' < "$HERE/VERSION")"
node "$HERE/fetch.mjs" --os "$OS" --arch "$ARCH" --out "$ROOT/build/cycles"
rc=$?
[ $rc -eq 0 ] && exit 0
[ $rc -eq 3 ] || exit $rc
echo "get: kein Paket am Gitea-Release — versuche das Artefakt von cycles.yml"
command -v gh >/dev/null || { echo "get: gh fehlt, kein Cycles-Paket"; exit 1; }
RUN="$(gh run list --workflow cycles.yml --status success --limit 1 --json databaseId -q '.[0].databaseId' 2>/dev/null)"
[ -n "$RUN" ] || { echo "get: kein erfolgreicher cycles.yml-Lauf — cycles.yml starten (Actions → cycles → Run workflow)"; exit 1; }
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
gh run download "$RUN" -n "cycles-$OS-$ARCH-$VERSION" -D "$TMP/dl" || exit 1
mkdir -p "$TMP/x"; tar -xJf "$TMP/dl/cycles-$OS-$ARCH-$VERSION.tar.xz" -C "$TMP/x" || exit 1
rm -rf "$ROOT/build/cycles"; mkdir -p "$ROOT/build"; mv "$TMP/x/cycles" "$ROOT/build/cycles"
echo "get: Artefakt von Lauf $RUN nach build/cycles"
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# [215] Cycles-Auslieferordner zu cycles-<os>-<arch>-<version>.tar.xz packen (Wurzelordner im Archiv: `cycles/`).
# scripts/cycles/pack.sh <dist-Ordner> <linux|macos> <x86_64|arm64> [Ausgabeordner]
# Schreibt auch <archiv>.sha256 (sha256sum-Format). Name wie scripts/cycles/cycles-lib.cjs (assetName).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DIST="${1:?dist-Ordner}"; OS="${2:?linux|macos}"; ARCH="${3:?x86_64|arm64}"
OUTDIR="$(mkdir -p "${4:-.}" && cd "${4:-.}" && pwd)"
VERSION="$(tr -d ' \n' < "$HERE/VERSION")"
[ -x "$DIST/cycles" ] || { echo "pack: $DIST/cycles fehlt"; exit 1; }
[ -s "$DIST/licenses/Cycles-LICENSE.txt" ] || { echo "pack: Lizenztexte fehlen (licenses/)"; exit 1; }
NAME="cycles-$OS-$ARCH-$VERSION.tar.xz"
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
cp -R "$DIST" "$TMP/cycles"
XZ_OPT="-T0 -6" tar -C "$TMP" -cJf "$OUTDIR/$NAME" cycles
( cd "$OUTDIR" && { sha256sum "$NAME" 2>/dev/null || shasum -a 256 "$NAME"; } > "$NAME.sha256" )
ls -la "$OUTDIR/$NAME"; cat "$OUTDIR/$NAME.sha256"
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# [215] Rauchtest für ein gebautes Cycles-Paket (CI, nach dem Bau): kleine Szene (spike-scene.py) mit 4 Samples rendern,
# PNG-Kopf und die Fortschrittszeilen prüfen. Läuft auf der CPU (gehostete CI-Runner haben keine GPU).
# scripts/cycles/smoke.sh <dist-Ordner>
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DIST="${1:?dist-Ordner}"
T="$(mktemp -d)"; trap 'rm -rf "$T"' EXIT
python3 "$HERE/spike-scene.py" "$T/haus.xml" >/dev/null
( cd "$T" && "$DIST/cycles" --background --device CPU --samples 4 --width 160 --height 90 --output out.png haus.xml ) 2>&1 | tr '\r' '\n' | tee "$T/log.txt" | tail -8
grep -q "Sample 4/4" "$T/log.txt" || { echo "smoke: keine Fortschrittszeile 'Sample 4/4'"; exit 1; }
[ "$(head -c 8 "$T/out.png" | od -An -tx1 | tr -d ' \n')" = "89504e470d0a1a0a" ] || { echo "smoke: out.png ist kein PNG"; exit 1; }
echo "smoke: ok ($(wc -c < "$T/out.png") Bytes PNG)"
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env node
// [215] Tauri (macOS): ausgepacktes Cycles-Paket (build/cycles, scripts/cycles/get.sh) als Sidecar bereitstellen.
// node scripts/cycles/tauri-prepare.mjs [Paketordner] (Standard: build/cycles)
// `bundle.externalBin: ["binaries/cycles"]` (src-tauri/tauri.cycles.conf.json) verlangt je Ziel `binaries/cycles-<triple>`.
// Das Paket ist arm64: für die universale App (arm64 + x64) entstehen auch die Namen x86_64 und universal — Kopien des
// arm64-Programms, nur damit der Bau durchläuft; auf Intel-Macs meldet `cycles_where` (src-tauri/src/cycles.rs) „nicht verfügbar“.
// `scripts/tauri-native.mjs` hängt die Konfiguration automatisch an `tauri build`, sobald die Sidecars da sind.
import { copyFileSync, existsSync, mkdirSync, chmodSync } from "node:fs";
import { join, resolve } from "node:path";
const root = resolve(import.meta.dirname, "..", "..");
const dir = resolve(process.argv[2] ?? join(root, "build", "cycles"));
const bin = join(dir, "cycles");
if (!existsSync(bin)) {
console.error(`tauri-prepare: ${bin} fehlt — zuerst scripts/cycles/get.sh macos arm64`);
process.exit(1);
}
const out = join(root, "src-tauri", "binaries");
mkdirSync(out, { recursive: true });
for (const triple of ["aarch64-apple-darwin", "x86_64-apple-darwin", "universal-apple-darwin"]) {
const to = join(out, `cycles-${triple}`);
copyFileSync(bin, to);
chmodSync(to, 0o755);
console.log(`tauri-prepare: ${to}`);
}
+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env node
// [215] Cycles-Paket als Asset an das Gitea-Release `cycles-<version>` hängen (git.openbureau.ch/karim/dossier).
//
// node scripts/cycles/upload-gitea.mjs --file cycles-linux-x86_64-5.3.0.tar.xz [--file …] [--dry-run]
//
// Das Release `cycles-<version>` ist ein Bau-Zwischenspeicher, kein Dossier-Release: veröffentlicht (sonst nicht ohne Token
// ladbar), als Vorabversion markiert. Gleichnamige Anhänge werden ersetzt (erst unter temporärem Namen hoch, dann alt löschen
// und umbenennen, wie release-gitea.mjs [268]); zu jedem Paket gehört `<name>.sha256` daneben. Zugang: GITEA_TOKEN (Schreibrecht).
import { readFileSync, existsSync } from "node:fs";
import { createRequire } from "node:module";
import { basename } from "node:path";
const require = createRequire(import.meta.url);
const lib = require("./cycles-lib.cjs");
const rel = require("../release-gitea-lib.cjs");
const args = process.argv.slice(2);
const files = args.flatMap((a, i) => (a === "--file" && args[i + 1] ? [args[i + 1]] : []));
const dryRun = args.includes("--dry-run");
const version = (() => {
const i = args.indexOf("--version");
return i >= 0 ? args[i + 1] : lib.cyclesVersion();
})();
if (!files.length) {
console.error("upload-gitea: --file <paket.tar.xz> fehlt");
process.exit(2);
}
const token = process.env.GITEA_TOKEN;
if (!token && !dryRun) {
console.error("GITEA_TOKEN fehlt (Token mit Schreibrecht auf karim/dossier).");
process.exit(2);
}
const tag = lib.releaseTag(version);
const api = `${rel.HOST}/api/v1/repos/${rel.REPO}`;
const headers = { Accept: "application/json", ...(token && token !== "proxy-injected" ? { Authorization: `token ${token}` } : {}) };
async function call(method, path, body, extra = {}) {
if (dryRun && method !== "GET") {
console.log(`[dry-run] ${method} ${path}`);
return { id: 0, assets: [] };
}
const res = await fetch(path.startsWith("http") ? path : `${api}${path}`, { method, headers: { ...headers, ...extra }, body });
if (res.status === 404 && method === "GET") return null;
if (!res.ok) throw new Error(`${method} ${path}: ${res.status} ${await res.text()}`);
return res.status === 204 ? {} : res.json();
}
async function upload(release, name, data) {
const old = (release.assets ?? []).find((a) => a.name === name);
const upName = old ? rel.tempAssetName(name, Date.now()) : name;
const form = new FormData();
form.append("attachment", new Blob([data]), upName);
const created = await call("POST", `/releases/${release.id}/assets?name=${encodeURIComponent(upName)}`, form);
if (old) {
await call("DELETE", `/releases/${release.id}/assets/${old.id}`);
await call("PATCH", `/releases/${release.id}/assets/${created.id}`, JSON.stringify({ name }), { "Content-Type": "application/json" });
}
console.log(` hochgeladen: ${name} (${(data.length / 1e6).toFixed(1)} MB)`);
}
let release = await call("GET", `/releases/tags/${encodeURIComponent(tag)}`);
if (!release) {
release = await call(
"POST",
"/releases",
JSON.stringify({
tag_name: tag,
name: `Cycles ${version} (Bau-Paket)`,
body: `Cycles ${version} als Hilfsprogramm für die Dossier-App ([215]); gebaut von .github/workflows/cycles.yml. Kein App-Release.`,
draft: false,
prerelease: true,
target_commitish: "master",
}),
{ "Content-Type": "application/json" },
);
}
for (const f of files) {
if (!existsSync(f)) throw new Error(`Datei fehlt: ${f}`);
const name = basename(f);
if (!/^cycles-(linux|macos)-(x86_64|arm64)-\d+\.\d+\.\d+\.tar\.xz$/.test(name)) throw new Error(`kein Cycles-Paketname: ${name}`);
await upload(release, name, readFileSync(f));
if (existsSync(`${f}.sha256`)) await upload(release, `${name}.sha256`, readFileSync(`${f}.sha256`));
}
console.log(`Release ${tag}: ${rel.HOST}/${rel.REPO}/releases/tag/${tag}`);