@@ -22,6 +22,27 @@ function engineDistributionTarget(version) {
2222 return 'enso/dist/' + version
2323}
2424
25+ /**
26+ * electron-builder preserves symlinks in extraResources, but Bazel uses them for sandboxing.
27+ * This function replaces symlinks with real files by copying their targets.
28+ */
29+ async function replaceSymlinksWithFiles ( root ) {
30+ const entries = await fs . readdir ( root , { withFileTypes : true } )
31+ for ( const entry of entries ) {
32+ const full = path . join ( root , entry . name )
33+ const st = await fs . lstat ( full )
34+ if ( st . isSymbolicLink ( ) ) {
35+ const linkTarget = await fs . readlink ( full )
36+ const absTarget = path . resolve ( path . dirname ( full ) , linkTarget )
37+ const data = await fs . readFile ( absTarget )
38+ await fs . unlink ( full )
39+ await fs . writeFile ( full , data , { mode : st . mode } )
40+ } else if ( st . isDirectory ( ) ) {
41+ await replaceSymlinksWithFiles ( full )
42+ }
43+ }
44+ }
45+
2546/**
2647 * AppImage is known to have sandboxing issues, for example:
2748 * https://github.com/enso-org/enso/issues/3801 or
@@ -151,5 +172,13 @@ module.exports = {
151172 if ( context . electronPlatformName === 'linux' ) {
152173 await patchAppImage ( context )
153174 }
175+
176+ const productName = context . packager . appInfo . productFilename
177+ const resourcesDir =
178+ process . platform === 'darwin' ?
179+ path . join ( context . appOutDir , `${ productName } .app` , 'Contents' , 'Resources' )
180+ : path . join ( context . appOutDir , 'resources' )
181+ const ensoDir = path . join ( resourcesDir , 'enso' )
182+ await replaceSymlinksWithFiles ( ensoDir )
154183 } ,
155184}
0 commit comments