sandboxbox 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/build.js +78 -61
- package/bin/bwrap +0 -50
package/package.json
CHANGED
package/scripts/build.js
CHANGED
@@ -46,26 +46,21 @@ async function downloadAndBuild() {
|
|
46
46
|
}
|
47
47
|
}
|
48
48
|
|
49
|
-
//
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
49
|
+
// Build from source like SQLite does - the ONLY method
|
50
|
+
if (await buildFromSource(binaryPath)) {
|
51
|
+
return; // Build succeeded
|
52
|
+
} else {
|
53
|
+
// Build failed - exit with error to make the problem visible
|
54
|
+
console.error('❌ Bubblewrap build failed!');
|
55
|
+
console.error('');
|
56
|
+
console.error('💡 Install build tools:');
|
57
|
+
console.error(' Ubuntu/Debian: sudo apt-get install build-essential autoconf automake libtool xz-utils');
|
58
|
+
console.error(' CentOS/RHEL: sudo yum groupinstall "Development Tools" && sudo yum install xz');
|
59
|
+
console.error('');
|
60
|
+
console.error('🚫 SandboxBox cannot function without bubblewrap.');
|
61
|
+
console.error(' Please install build tools and try again.');
|
62
|
+
process.exit(1);
|
60
63
|
}
|
61
|
-
|
62
|
-
// Try to download pre-built binary first
|
63
|
-
if (await downloadPreBuiltBinary(binaryPath)) {
|
64
|
-
return;
|
65
|
-
}
|
66
|
-
|
67
|
-
// Build from source like SQLite does as last resort
|
68
|
-
await buildFromSource(binaryPath);
|
69
64
|
}
|
70
65
|
|
71
66
|
async function downloadPreBuiltBinary(binaryPath) {
|
@@ -260,50 +255,68 @@ async function buildFromSource(binaryPath) {
|
|
260
255
|
missingTools.push('xz');
|
261
256
|
}
|
262
257
|
|
258
|
+
try {
|
259
|
+
execSync('which autoconf', { stdio: 'ignore' });
|
260
|
+
} catch (e) {
|
261
|
+
missingTools.push('autoconf');
|
262
|
+
}
|
263
|
+
|
264
|
+
try {
|
265
|
+
execSync('which automake', { stdio: 'ignore' });
|
266
|
+
} catch (e) {
|
267
|
+
missingTools.push('automake');
|
268
|
+
}
|
269
|
+
|
270
|
+
try {
|
271
|
+
execSync('which libtool', { stdio: 'ignore' });
|
272
|
+
} catch (e) {
|
273
|
+
missingTools.push('libtool');
|
274
|
+
}
|
275
|
+
|
263
276
|
if (missingTools.length > 0) {
|
264
|
-
console.
|
265
|
-
console.
|
266
|
-
console.
|
267
|
-
console.
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
echo ""
|
273
|
-
echo "💡 Install bubblewrap system-wide:"
|
274
|
-
echo " sudo apt-get install bubblewrap # Ubuntu/Debian"
|
275
|
-
echo " sudo apk add bubblewrap # Alpine"
|
276
|
-
echo " sudo yum install bubblewrap # CentOS/RHEL"
|
277
|
-
echo ""
|
278
|
-
echo "Or install build tools and reinstall SandboxBox:"
|
279
|
-
echo " sudo apt-get install build-essential xz-utils"
|
280
|
-
echo " npm uninstall sandboxbox && npm install sandboxbox"
|
281
|
-
exit 1
|
282
|
-
`;
|
283
|
-
fs.writeFileSync(binaryPath, placeholderScript);
|
284
|
-
fs.chmodSync(binaryPath, 0o755);
|
285
|
-
console.log('📝 Created placeholder binary with installation instructions');
|
286
|
-
return;
|
277
|
+
console.error(`❌ Missing build tools: ${missingTools.join(', ')}`);
|
278
|
+
console.error('');
|
279
|
+
console.error('💡 Install build tools:');
|
280
|
+
console.error(' Ubuntu/Debian: sudo apt-get install build-essential autoconf automake libtool xz-utils');
|
281
|
+
console.error(' CentOS/RHEL: sudo yum groupinstall "Development Tools" && sudo yum install xz');
|
282
|
+
console.error('');
|
283
|
+
console.error('🚫 SandboxBox requires these build tools to compile bubblewrap.');
|
284
|
+
return false; // Indicate build failed
|
287
285
|
}
|
288
286
|
|
289
287
|
// Configure and build
|
290
288
|
console.log('⚙️ Configuring build...');
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
289
|
+
try {
|
290
|
+
execSync(`
|
291
|
+
cd "${sourceDir}" &&
|
292
|
+
timeout 60 ./configure --prefix="${tmpDir}/install" --disable-man
|
293
|
+
`, { stdio: 'inherit' });
|
294
|
+
} catch (e) {
|
295
|
+
console.error('❌ Configure step failed or timed out');
|
296
|
+
return false;
|
297
|
+
}
|
295
298
|
|
296
299
|
console.log('🏗️ Compiling bubblewrap...');
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
300
|
+
try {
|
301
|
+
execSync(`
|
302
|
+
cd "${sourceDir}" &&
|
303
|
+
timeout 300 make -j$(nproc 2>/dev/null || echo 4)
|
304
|
+
`, { stdio: 'inherit' });
|
305
|
+
} catch (e) {
|
306
|
+
console.error('❌ Compile step failed or timed out');
|
307
|
+
return false;
|
308
|
+
}
|
301
309
|
|
302
310
|
console.log('📦 Installing...');
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
311
|
+
try {
|
312
|
+
execSync(`
|
313
|
+
cd "${sourceDir}" &&
|
314
|
+
timeout 60 make install
|
315
|
+
`, { stdio: 'inherit' });
|
316
|
+
} catch (e) {
|
317
|
+
console.error('❌ Install step failed or timed out');
|
318
|
+
return false;
|
319
|
+
}
|
307
320
|
|
308
321
|
// Copy binary to final location
|
309
322
|
const builtBinary = path.join(tmpDir, 'install', 'bin', 'bwrap');
|
@@ -315,10 +328,15 @@ exit 1
|
|
315
328
|
// Test the binary
|
316
329
|
const version = execSync(`"${binaryPath}" --version`, { encoding: 'utf8' });
|
317
330
|
console.log(`🎯 Built: ${version.trim()}`);
|
331
|
+
return true; // Build succeeded
|
318
332
|
} else {
|
319
|
-
|
333
|
+
console.log('❌ Built binary not found');
|
334
|
+
return false; // Build failed
|
320
335
|
}
|
321
336
|
|
337
|
+
} catch (error) {
|
338
|
+
console.log(`❌ Build from source failed: ${error.message}`);
|
339
|
+
return false; // Build failed
|
322
340
|
} finally {
|
323
341
|
// Cleanup
|
324
342
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
@@ -327,12 +345,11 @@ exit 1
|
|
327
345
|
|
328
346
|
// Run the build
|
329
347
|
downloadAndBuild().catch(error => {
|
330
|
-
console.error('❌
|
331
|
-
console.
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
process.exit(0); // Don't fail npm install
|
348
|
+
console.error('❌ Bubblewrap build failed:', error.message);
|
349
|
+
console.error('');
|
350
|
+
console.error('🚫 SandboxBox cannot function without bubblewrap.');
|
351
|
+
console.error(' Please install build tools and try again.');
|
352
|
+
process.exit(1);
|
336
353
|
});
|
337
354
|
|
338
355
|
function createMinimalBubblewrap(binaryPath) {
|
package/bin/bwrap
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
# Minimal bubblewrap fallback for SandboxBox
|
3
|
-
# This provides basic namespace isolation functionality
|
4
|
-
|
5
|
-
# Handle --version flag for compatibility
|
6
|
-
if [[ "$1" == "--version" ]]; then
|
7
|
-
echo "bubblewrap 0.11.0 (minimal fallback for SandboxBox)"
|
8
|
-
exit 0
|
9
|
-
fi
|
10
|
-
|
11
|
-
# Handle --help flag
|
12
|
-
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then
|
13
|
-
echo "bubblewrap - minimal fallback version"
|
14
|
-
echo ""
|
15
|
-
echo "⚠️ This is a minimal fallback for SandboxBox"
|
16
|
-
echo "💡 For full functionality, install bubblewrap:"
|
17
|
-
echo " sudo apt-get install bubblewrap"
|
18
|
-
echo ""
|
19
|
-
echo "Usage: bwrap [options] -- command [args]"
|
20
|
-
exit 0
|
21
|
-
fi
|
22
|
-
|
23
|
-
echo "⚠️ Using minimal bubblewrap fallback"
|
24
|
-
echo "💡 For full functionality, install bubblewrap:"
|
25
|
-
echo " sudo apt-get install bubblewrap"
|
26
|
-
echo ""
|
27
|
-
|
28
|
-
# Filter out bubblewrap-specific options that unshare doesn't support
|
29
|
-
ARGS=()
|
30
|
-
for arg in "$@"; do
|
31
|
-
case "$arg" in
|
32
|
-
--ro-bind|--bind|--dev-bind|--proc|--tmpfs|--symlink|--dir|--file|--setenv|--die-with-parent|--new-session|--share-net|--unshare-net|--unshare-pid|--unshare-ipc|--unshare-uts|--unshare-cgroup|--unshare-user)
|
33
|
-
# Skip bubblewrap-specific options
|
34
|
-
;;
|
35
|
-
*)
|
36
|
-
ARGS+=("$arg")
|
37
|
-
;;
|
38
|
-
esac
|
39
|
-
done
|
40
|
-
|
41
|
-
# Basic namespace isolation using unshare
|
42
|
-
exec unshare \
|
43
|
-
--pid \
|
44
|
-
--mount \
|
45
|
-
--uts \
|
46
|
-
--ipc \
|
47
|
-
--net \
|
48
|
-
--fork \
|
49
|
-
--mount-proc \
|
50
|
-
"${ARGS[@]}"
|