mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-08-02 10:11:53 +02:00
fix: polish v0.9.7 micro update
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { spawnSync } = require('node:child_process');
|
||||
|
||||
const scriptDir = __dirname;
|
||||
const tauriDir = path.resolve(scriptDir, '..');
|
||||
const repoRoot = path.resolve(tauriDir, '..', '..');
|
||||
const backendDir = path.join(repoRoot, 'backend');
|
||||
const privacyCoreDir = path.join(repoRoot, 'privacy-core');
|
||||
const outputDir = path.join(tauriDir, 'src-tauri', 'backend-runtime');
|
||||
const venvMarkerPath = path.join(backendDir, '.venv-dir');
|
||||
const releaseAttestationPath = path.join(backendDir, 'data', 'release_attestation.json');
|
||||
@@ -77,15 +79,58 @@ function ensureRuntimePrereqs() {
|
||||
}
|
||||
}
|
||||
|
||||
function privacyCoreArtifactName() {
|
||||
if (process.platform === 'win32') return 'privacy_core.dll';
|
||||
if (process.platform === 'darwin') return 'libprivacy_core.dylib';
|
||||
return 'libprivacy_core.so';
|
||||
}
|
||||
|
||||
function privacyCoreArtifactPath() {
|
||||
return path.join(privacyCoreDir, 'target', 'release', privacyCoreArtifactName());
|
||||
}
|
||||
|
||||
function ensurePrivacyCoreArtifact() {
|
||||
const artifact = privacyCoreArtifactPath();
|
||||
if (fs.existsSync(artifact)) {
|
||||
return artifact;
|
||||
}
|
||||
console.log('privacy-core release library missing; building it for desktop packaging...');
|
||||
const result = spawnSync(
|
||||
'cargo',
|
||||
['build', '--release', '--manifest-path', path.join(privacyCoreDir, 'Cargo.toml')],
|
||||
{
|
||||
cwd: repoRoot,
|
||||
env: process.env,
|
||||
stdio: 'inherit',
|
||||
},
|
||||
);
|
||||
if (result.error || result.status !== 0) {
|
||||
throw new Error(
|
||||
'Failed to build privacy-core release library. Install Rust/Cargo and rerun the desktop build.',
|
||||
);
|
||||
}
|
||||
if (!fs.existsSync(artifact)) {
|
||||
throw new Error(`privacy-core build completed but artifact is missing: ${artifact}`);
|
||||
}
|
||||
return artifact;
|
||||
}
|
||||
|
||||
function stageBackendRuntime() {
|
||||
fs.rmSync(outputDir, { recursive: true, force: true });
|
||||
fs.cpSync(backendDir, outputDir, {
|
||||
recursive: true,
|
||||
filter: shouldCopy,
|
||||
});
|
||||
stagePrivacyCoreArtifact();
|
||||
stageReleaseAttestation();
|
||||
}
|
||||
|
||||
function stagePrivacyCoreArtifact() {
|
||||
const artifact = ensurePrivacyCoreArtifact();
|
||||
const stagedPath = path.join(outputDir, path.basename(artifact));
|
||||
fs.copyFileSync(artifact, stagedPath);
|
||||
}
|
||||
|
||||
function stageReleaseAttestation() {
|
||||
if (!fs.existsSync(releaseAttestationPath)) {
|
||||
console.warn(`backend-runtime staged without release attestation: ${releaseAttestationPath}`);
|
||||
|
||||
@@ -91,7 +91,8 @@ pub async fn ensure_and_start_managed_backend(
|
||||
.open(&stderr_log)
|
||||
.map_err(|e| format!("managed_backend_stderr_log_failed:{e}"))?;
|
||||
|
||||
let mut child = Command::new(&python_bin)
|
||||
let mut command = Command::new(&python_bin);
|
||||
command
|
||||
.current_dir(&runtime_root)
|
||||
.arg("-m")
|
||||
.arg("uvicorn")
|
||||
@@ -103,7 +104,13 @@ pub async fn ensure_and_start_managed_backend(
|
||||
.arg("--timeout-keep-alive")
|
||||
.arg("120")
|
||||
.env("PYTHONUNBUFFERED", "1")
|
||||
.env("SB_DATA_DIR", data_dir.as_os_str())
|
||||
.env("SB_DATA_DIR", data_dir.as_os_str());
|
||||
|
||||
if let Some(privacy_core_lib) = bundled_privacy_core_lib(&runtime_root) {
|
||||
command.env("PRIVACY_CORE_LIB", privacy_core_lib.as_os_str());
|
||||
}
|
||||
|
||||
let mut child = command
|
||||
.stdout(Stdio::from(stdout))
|
||||
.stderr(Stdio::from(stderr))
|
||||
.spawn()
|
||||
@@ -191,6 +198,18 @@ fn sync_release_attestation(bundled_root: &Path, install_root: &Path) -> Result<
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn bundled_privacy_core_lib(runtime_root: &Path) -> Option<PathBuf> {
|
||||
let file_name = if cfg!(target_os = "windows") {
|
||||
"privacy_core.dll"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"libprivacy_core.dylib"
|
||||
} else {
|
||||
"libprivacy_core.so"
|
||||
};
|
||||
let candidate = runtime_root.join(file_name);
|
||||
candidate.exists().then_some(candidate)
|
||||
}
|
||||
|
||||
fn release_attestation_path(root: &Path) -> PathBuf {
|
||||
RELEASE_ATTESTATION_RELATIVE_PATH
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user