app-builder-lib 27.0.0-alpha.12 → 27.0.0-alpha.13

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.
Files changed (220) hide show
  1. package/dist/asar/asarUtil.js +1 -1
  2. package/dist/asar/asarUtil.js.map +1 -1
  3. package/dist/codeSign/certInfo.d.ts +4 -1
  4. package/dist/codeSign/certInfo.d.ts.map +1 -1
  5. package/dist/codeSign/certInfo.js +5 -3
  6. package/dist/codeSign/certInfo.js.map +1 -1
  7. package/dist/codeSign/forceCodeSigning.d.ts +22 -0
  8. package/dist/codeSign/forceCodeSigning.d.ts.map +1 -0
  9. package/dist/codeSign/forceCodeSigning.js +18 -0
  10. package/dist/codeSign/forceCodeSigning.js.map +1 -0
  11. package/dist/codeSign/mac/macCodeSign.d.ts +13 -1
  12. package/dist/codeSign/mac/macCodeSign.d.ts.map +1 -1
  13. package/dist/codeSign/mac/macCodeSign.js +29 -2
  14. package/dist/codeSign/mac/macCodeSign.js.map +1 -1
  15. package/dist/codeSign/mac/macSignatureVerifier.d.ts +23 -0
  16. package/dist/codeSign/mac/macSignatureVerifier.d.ts.map +1 -0
  17. package/dist/codeSign/mac/macSignatureVerifier.js +96 -0
  18. package/dist/codeSign/mac/macSignatureVerifier.js.map +1 -0
  19. package/dist/codeSign/win/authenticodeSignature.d.ts +14 -2
  20. package/dist/codeSign/win/authenticodeSignature.d.ts.map +1 -1
  21. package/dist/codeSign/win/authenticodeSignature.js +78 -30
  22. package/dist/codeSign/win/authenticodeSignature.js.map +1 -1
  23. package/dist/codeSign/win/pkcs11SignManager.d.ts.map +1 -1
  24. package/dist/codeSign/win/pkcs11SignManager.js +4 -3
  25. package/dist/codeSign/win/pkcs11SignManager.js.map +1 -1
  26. package/dist/codeSign/win/publisherName.d.ts +31 -0
  27. package/dist/codeSign/win/publisherName.d.ts.map +1 -0
  28. package/dist/codeSign/win/publisherName.js +78 -0
  29. package/dist/codeSign/win/publisherName.js.map +1 -0
  30. package/dist/codeSign/win/signtoolBaseSignManager.d.ts +16 -9
  31. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
  32. package/dist/codeSign/win/signtoolBaseSignManager.js +46 -35
  33. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
  34. package/dist/codeSign/win/verifyUpdatePublisher.d.ts.map +1 -1
  35. package/dist/codeSign/win/verifyUpdatePublisher.js +7 -4
  36. package/dist/codeSign/win/verifyUpdatePublisher.js.map +1 -1
  37. package/dist/codeSign/win/windowsSignAzureManager.d.ts +1 -1
  38. package/dist/codeSign/win/windowsSignAzureManager.d.ts.map +1 -1
  39. package/dist/codeSign/win/windowsSignAzureManager.js +24 -6
  40. package/dist/codeSign/win/windowsSignAzureManager.js.map +1 -1
  41. package/dist/configuration.d.ts +46 -3
  42. package/dist/configuration.d.ts.map +1 -1
  43. package/dist/configuration.js.map +1 -1
  44. package/dist/electron/mac/asarIntegrityDigest.js +2 -2
  45. package/dist/electron/mac/asarIntegrityDigest.js.map +1 -1
  46. package/dist/electron/mac/electronMacUtils.d.ts +3 -2
  47. package/dist/electron/mac/electronMacUtils.d.ts.map +1 -1
  48. package/dist/electron/mac/electronMacUtils.js +3 -2
  49. package/dist/electron/mac/electronMacUtils.js.map +1 -1
  50. package/dist/fileMatcher.d.ts.map +1 -1
  51. package/dist/fileMatcher.js +4 -2
  52. package/dist/fileMatcher.js.map +1 -1
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +4 -3
  56. package/dist/index.js.map +1 -1
  57. package/dist/indexInternal.d.ts +7 -2
  58. package/dist/indexInternal.d.ts.map +1 -1
  59. package/dist/indexInternal.js +6 -2
  60. package/dist/indexInternal.js.map +1 -1
  61. package/dist/linuxPackager.js +1 -1
  62. package/dist/linuxPackager.js.map +1 -1
  63. package/dist/macPackager.d.ts +26 -0
  64. package/dist/macPackager.d.ts.map +1 -1
  65. package/dist/macPackager.js +168 -12
  66. package/dist/macPackager.js.map +1 -1
  67. package/dist/options/PlatformSpecificBuildOptions.d.ts +15 -12
  68. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  69. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  70. package/dist/options/SquirrelWindowsOptions.d.ts +3 -0
  71. package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
  72. package/dist/options/SquirrelWindowsOptions.js.map +1 -1
  73. package/dist/options/macOptions.d.ts +7 -2
  74. package/dist/options/macOptions.d.ts.map +1 -1
  75. package/dist/options/macOptions.js.map +1 -1
  76. package/dist/options/winOptions.d.ts +61 -15
  77. package/dist/options/winOptions.d.ts.map +1 -1
  78. package/dist/options/winOptions.js +20 -0
  79. package/dist/options/winOptions.js.map +1 -1
  80. package/dist/packager.d.ts +1 -0
  81. package/dist/packager.d.ts.map +1 -1
  82. package/dist/packager.js +7 -2
  83. package/dist/packager.js.map +1 -1
  84. package/dist/platformPackager.d.ts +14 -5
  85. package/dist/platformPackager.d.ts.map +1 -1
  86. package/dist/platformPackager.js +44 -13
  87. package/dist/platformPackager.js.map +1 -1
  88. package/dist/publish/PublishManager.d.ts +3 -0
  89. package/dist/publish/PublishManager.d.ts.map +1 -1
  90. package/dist/publish/PublishManager.js +50 -16
  91. package/dist/publish/PublishManager.js.map +1 -1
  92. package/dist/publish/manifestUploadCheck.d.ts +10 -0
  93. package/dist/publish/manifestUploadCheck.d.ts.map +1 -0
  94. package/dist/publish/manifestUploadCheck.js +75 -0
  95. package/dist/publish/manifestUploadCheck.js.map +1 -0
  96. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  97. package/dist/publish/updateInfoBuilder.js +51 -17
  98. package/dist/publish/updateInfoBuilder.js.map +1 -1
  99. package/dist/publish/updateManifestVerifier.d.ts +22 -0
  100. package/dist/publish/updateManifestVerifier.d.ts.map +1 -0
  101. package/dist/publish/updateManifestVerifier.js +65 -0
  102. package/dist/publish/updateManifestVerifier.js.map +1 -0
  103. package/dist/targets/ArchiveTarget.d.ts.map +1 -1
  104. package/dist/targets/ArchiveTarget.js +6 -2
  105. package/dist/targets/ArchiveTarget.js.map +1 -1
  106. package/dist/targets/archive.d.ts.map +1 -1
  107. package/dist/targets/archive.js +3 -3
  108. package/dist/targets/archive.js.map +1 -1
  109. package/dist/targets/linux/FlatpakTarget.js +5 -5
  110. package/dist/targets/linux/FlatpakTarget.js.map +1 -1
  111. package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
  112. package/dist/targets/linux/FpmTarget.js +10 -7
  113. package/dist/targets/linux/FpmTarget.js.map +1 -1
  114. package/dist/targets/linux/LinuxTargetHelper.js +1 -1
  115. package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
  116. package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
  117. package/dist/targets/linux/appimage/AppImageTarget.js +6 -1
  118. package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
  119. package/dist/targets/linux/appimage/appImageUtil.js +9 -9
  120. package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
  121. package/dist/targets/linux/flatpakBundle.d.ts.map +1 -1
  122. package/dist/targets/linux/flatpakBundle.js +25 -20
  123. package/dist/targets/linux/flatpakBundle.js.map +1 -1
  124. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  125. package/dist/targets/linux/snap/coreLegacy.js +22 -6
  126. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  127. package/dist/targets/linux/snap/snapPlugs.d.ts +2 -2
  128. package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -1
  129. package/dist/targets/linux/snap/snapPlugs.js +1 -1
  130. package/dist/targets/linux/snap/snapPlugs.js.map +1 -1
  131. package/dist/targets/linux/snap/snapcraftBuilder.d.ts.map +1 -1
  132. package/dist/targets/linux/snap/snapcraftBuilder.js +19 -17
  133. package/dist/targets/linux/snap/snapcraftBuilder.js.map +1 -1
  134. package/dist/targets/mac/MacTargetHelper.d.ts +15 -3
  135. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  136. package/dist/targets/mac/MacTargetHelper.js +96 -13
  137. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  138. package/dist/targets/mac/pkg.d.ts.map +1 -1
  139. package/dist/targets/mac/pkg.js +7 -5
  140. package/dist/targets/mac/pkg.js.map +1 -1
  141. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  142. package/dist/targets/win/nsis/NsisTarget.js +8 -2
  143. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  144. package/dist/targets/win/nsis/nsisOptions.d.ts +1 -1
  145. package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
  146. package/dist/toolsets/nsis.js +1 -1
  147. package/dist/toolsets/nsis.js.map +1 -1
  148. package/dist/toolsets/wine.d.ts +3 -0
  149. package/dist/toolsets/wine.d.ts.map +1 -1
  150. package/dist/toolsets/wine.js +14 -5
  151. package/dist/toolsets/wine.js.map +1 -1
  152. package/dist/util/appFileCopier.d.ts.map +1 -1
  153. package/dist/util/appFileCopier.js +9 -3
  154. package/dist/util/appFileCopier.js.map +1 -1
  155. package/dist/util/buildOutputVerifier.d.ts +40 -0
  156. package/dist/util/buildOutputVerifier.d.ts.map +1 -0
  157. package/dist/util/buildOutputVerifier.js +420 -0
  158. package/dist/util/buildOutputVerifier.js.map +1 -0
  159. package/dist/util/config/fileOptions.js +2 -2
  160. package/dist/util/config/fileOptions.js.map +1 -1
  161. package/dist/util/config/legacyConfigGuard.d.ts.map +1 -1
  162. package/dist/util/config/legacyConfigGuard.js +2 -2
  163. package/dist/util/config/legacyConfigGuard.js.map +1 -1
  164. package/dist/util/config/legacyOptions.d.ts +9 -2
  165. package/dist/util/config/legacyOptions.d.ts.map +1 -1
  166. package/dist/util/config/legacyOptions.js +8 -2
  167. package/dist/util/config/legacyOptions.js.map +1 -1
  168. package/dist/util/electronGet.d.ts.map +1 -1
  169. package/dist/util/electronGet.js +3 -1
  170. package/dist/util/electronGet.js.map +1 -1
  171. package/dist/util/flags.d.ts.map +1 -1
  172. package/dist/util/flags.js +3 -9
  173. package/dist/util/flags.js.map +1 -1
  174. package/dist/util/mac/macosIconComposer.d.ts.map +1 -1
  175. package/dist/util/mac/macosIconComposer.js +6 -5
  176. package/dist/util/mac/macosIconComposer.js.map +1 -1
  177. package/dist/util/macroExpander.js +1 -1
  178. package/dist/util/macroExpander.js.map +1 -1
  179. package/dist/util/nativeBinaryVerifier.d.ts.map +1 -1
  180. package/dist/util/nativeBinaryVerifier.js +3 -1
  181. package/dist/util/nativeBinaryVerifier.js.map +1 -1
  182. package/dist/util/packageMetadata.js +1 -1
  183. package/dist/util/packageMetadata.js.map +1 -1
  184. package/dist/util/removedEnvVars.d.ts +2 -0
  185. package/dist/util/removedEnvVars.d.ts.map +1 -1
  186. package/dist/util/removedEnvVars.js +15 -1
  187. package/dist/util/removedEnvVars.js.map +1 -1
  188. package/dist/util/streamSpawnToFile.d.ts +3 -1
  189. package/dist/util/streamSpawnToFile.d.ts.map +1 -1
  190. package/dist/util/streamSpawnToFile.js +6 -2
  191. package/dist/util/streamSpawnToFile.js.map +1 -1
  192. package/dist/version.d.ts +1 -1
  193. package/dist/version.js +1 -1
  194. package/dist/version.js.map +1 -1
  195. package/dist/vm/ParallelsVm.d.ts +10 -0
  196. package/dist/vm/ParallelsVm.d.ts.map +1 -1
  197. package/dist/vm/ParallelsVm.js +22 -8
  198. package/dist/vm/ParallelsVm.js.map +1 -1
  199. package/dist/vm/PwshVm.d.ts +0 -1
  200. package/dist/vm/PwshVm.d.ts.map +1 -1
  201. package/dist/vm/PwshVm.js +10 -15
  202. package/dist/vm/PwshVm.js.map +1 -1
  203. package/dist/vm/WineVm.d.ts.map +1 -1
  204. package/dist/vm/WineVm.js +4 -4
  205. package/dist/vm/WineVm.js.map +1 -1
  206. package/dist/vm/vm.d.ts +9 -3
  207. package/dist/vm/vm.d.ts.map +1 -1
  208. package/dist/vm/vm.js +40 -32
  209. package/dist/vm/vm.js.map +1 -1
  210. package/dist/winPackager.d.ts +16 -1
  211. package/dist/winPackager.d.ts.map +1 -1
  212. package/dist/winPackager.js +77 -19
  213. package/dist/winPackager.js.map +1 -1
  214. package/package.json +9 -9
  215. package/scheme.json +497 -23
  216. package/templates/nsis/include/allowOnlyOneInstallerInstance.nsh +14 -9
  217. package/dist/vm/MonoVm.d.ts +0 -9
  218. package/dist/vm/MonoVm.d.ts.map +0 -1
  219. package/dist/vm/MonoVm.js +0 -16
  220. package/dist/vm/MonoVm.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"appImageUtil.js","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appImageUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAkB,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACpH,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAsCxD,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,mBAA8C,EAAE,IAA4B,EAAE,YAAoB;IACjJ,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IAExD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAEvB,0CAA0C;QAC1C,MAAM,+BAA+B,CAAC,IAAI,CAAC,CAAA;QAE3C,MAAM,EAAE,gBAAgB,EAAE,SA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;AAC7F,CAAC;AAoBD,SAAS,OAAO,CAAC,MAAoB;IACnC,OAAO,UAAU,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAA;AACpE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACvD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACnC,gGAAgG;IAChG,sFAAsF;IACtF,MAAM,qBAAqB,GAAG,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAErF,OAAO;;;;;;;;;;;;;0CAaiC,kBAAkB;;;;;;;;;;;;;;;;eAgB7C,MAAM,CAAC,cAAc;;mBAEjB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAiFlB,kBAAkB;;;;EAKtC,WAAW;QACT,CAAC,CAAC;sDACgD,MAAM,CAAC,eAAe;;;;;;;sDAOtB,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,wBAAwB,MAAM,CAAC,QAAQ,8CAA8C,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;;;2CAGtK,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,uBAAuB,MAAM,CAAC,QAAQ;;;;;sDAKhE,MAAM,CAAC,QAAQ;;;;;;;;;;;;;;;;;;;;GAoBlE;QACC,CAAC,CAAC,EACN;CACC,CAAA;AACD,CAAC","sourcesContent":["import { Arch, copyDir, CopyDirOptions, copyFile, exec, exists, InvalidConfigurationError, log } from \"builder-util\"\nimport fs from \"fs-extra\"\nimport * as path from \"path\"\nimport { FileAssociation } from \"../../../options/FileAssociation.js\"\nimport { getAppImageTools } from \"../../../toolsets/appimage.js\"\nimport { copyIcons, copyMimeTypes } from \"./appLauncher.js\"\nimport { shellQuote } from \"../launcherScript.js\"\nimport { appendBlockmap } from \"../../differentialUpdateInfoBuilder.js\"\nimport { BlockMapDataHolder } from \"builder-util-runtime\"\nimport { APP_RUN_ENTRYPOINT } from \"./AppImageTarget.js\"\nimport { ToolsetConfig } from \"../../../configuration.js\"\nimport { IconInfo } from \"../../../util/iconConverter.js\"\n\ninterface Options {\n productName: string\n productFilename: string\n executableName: string\n /** Arguments injected into the AppRun launcher (the .desktop Exec key stays `AppRun %U`). */\n executableArgs?: ReadonlyArray<string>\n desktopEntry: string\n icons: IconInfo[]\n license?: string | null\n fileAssociations: FileAssociation[]\n /**\n * The compression type available for static runtime is limited as it's only compiled with support for gzip and zstd.\n * \"xz\" is only valid for the legacy FUSE2 (0.0.0) toolset.\n *\n * [stderr] Squashfs image uses lzo compression, this version supports only zlib, zstd.\n * Failed to open squashfs image\n * Failed to extract AppImage\n *\n */\n compression?: \"gzip\" | \"zstd\" | \"xz\"\n /** Pre-computed desktop basename (already validated). When absent, falls back to `executableName`. */\n desktopBaseName?: string\n}\n\nexport interface AppImageBuilderOptions {\n appDir: string\n stageDir: string\n arch: Arch\n output: string\n options: Options\n /** How the copy of `appDir` into the stage treats the symlinks in it (see `getStagingCopyLinkOptions`). */\n appDirCopyOptions?: Pick<CopyDirOptions, \"allowedSymlinkRoots\" | \"externalLinks\"> | null\n}\n\nexport async function buildStaticRuntimeAppImage(appimageToolVersion: ToolsetConfig[\"appimage\"], opts: AppImageBuilderOptions, resourcesDir: string): Promise<BlockMapDataHolder> {\n const { stageDir, output, appDir, options, arch } = opts\n\n try {\n await fs.remove(output)\n\n // Write AppRun launcher and related files\n await writeAppLauncherAndRelatedFiles(opts)\n\n const { runtimeLibraries: libraries, runtime, mksquashfs } = await getAppImageTools(appimageToolVersion, arch, resourcesDir)\n await copyDir(libraries, path.join(stageDir, \"usr\", \"lib\"))\n\n // Copy app directory to stage\n // mksquashfs doesn't support merging, so we copy the entire app dir\n await copyDir(appDir, stageDir, opts.appDirCopyOptions ?? undefined)\n\n const runtimeData = await fs.readFile(runtime)\n\n // Create squashfs with offset for runtime\n const args: string[] = [stageDir, output, \"-offset\", runtimeData.length.toString(), \"-all-root\", \"-noappend\", \"-no-progress\", \"-quiet\", \"-no-xattrs\", \"-no-fragments\"]\n if (options.compression) {\n args.push(\"-comp\", options.compression)\n }\n await exec(mksquashfs, args, {\n cwd: stageDir,\n })\n\n // Write runtime data at the beginning of the file\n await writeRuntimeData(output, runtimeData)\n\n // Make executable\n await fs.chmod(output, 0o755)\n\n // Append blockmap inside try block to ensure cleanup on failure\n const updateInfo = await appendBlockmap(output)\n return updateInfo\n } catch (error) {\n // Clean up partial build on failure\n await fs.remove(output).catch(() => {})\n throw error\n }\n}\n\nexport async function buildLegacyFuse2AppImage(opts: AppImageBuilderOptions, resourcesDir: string): Promise<BlockMapDataHolder> {\n const { stageDir, output, appDir, options, arch } = opts\n\n try {\n await fs.remove(output)\n\n await writeAppLauncherAndRelatedFiles(opts)\n\n const { runtime, mksquashfs, runtimeLibraries } = await getAppImageTools(\"0.0.0\", arch, resourcesDir)\n // Mirror the app-builder-lib Go implementation: bundle lib/<arch> into usr/lib for x64 and ia32.\n // arm targets don't have a dedicated lib dir in the FUSE2 toolset.\n if (arch === Arch.x64 || arch === Arch.ia32) {\n await copyDir(runtimeLibraries, path.join(stageDir, \"usr\", \"lib\"))\n }\n await copyDir(appDir, stageDir, opts.appDirCopyOptions ?? undefined)\n\n const runtimeData = await fs.readFile(runtime)\n\n const args: string[] = [stageDir, output, \"-offset\", runtimeData.length.toString(), \"-all-root\", \"-noappend\", \"-no-progress\", \"-quiet\", \"-no-xattrs\", \"-no-fragments\"]\n if (options.compression) {\n args.push(\"-comp\", options.compression)\n if (options.compression === \"xz\") {\n // Match the dictionary/block-size settings used by the original app-builder Go implementation\n args.push(\"-Xdict-size\", \"100%\", \"-b\", \"1048576\")\n }\n }\n await exec(mksquashfs, args, { cwd: stageDir })\n\n await writeRuntimeData(output, runtimeData)\n await fs.chmod(output, 0o755)\n\n const updateInfo = await appendBlockmap(output)\n return updateInfo\n } catch (error) {\n await fs.remove(output).catch(() => {})\n throw error\n }\n}\n\nasync function writeRuntimeData(filePath: string, runtimeData: Buffer): Promise<void> {\n const fd = await fs.open(filePath, \"r+\")\n try {\n await fs.write(fd, runtimeData, 0, runtimeData.length, 0)\n } finally {\n try {\n await fs.close(fd)\n } catch (closeError: any) {\n // Log but don't throw - preserve original error if any\n log.warn({ message: closeError.message, file: filePath }, `failed to close file descriptor`)\n }\n }\n}\n\n/**\n * Escapes a string for safe use in shell scripts by wrapping in single quotes\n * and escaping any single quotes within the string.\n *\n * This allows strings with spaces, special characters, etc. to be safely used.\n */\nfunction escapeShellString(str: string): string {\n // Escape single quotes by replacing ' with '\\''\n // Then wrap the whole string in single quotes\n return `'${str.replace(/'/g, \"'\\\\''\")}'`\n}\n\n/**\n * Validates that critical path fields (executable name, product filename, license filename)\n * contain only characters that are safe for use in filesystem paths and embedded bash strings.\n * Allowed: Unicode letters, digits, dots, underscores, hyphens, spaces, and parentheses.\n */\nexport function validateCriticalPathString(str: string, fieldName: string): void {\n if (!/^[\\p{L}\\p{N}._\\- ()]+$/u.test(str)) {\n throw new InvalidConfigurationError(\n `${fieldName} contains characters that cannot be safely used in file paths: ${str}. Please use only letters, digits, hyphens, underscores, dots, spaces, and parentheses.`\n )\n }\n}\n\nasync function writeAppLauncherAndRelatedFiles(opts: AppImageBuilderOptions): Promise<void> {\n const {\n stageDir,\n options: { license, executableName, executableArgs, productFilename, productName, desktopEntry, desktopBaseName },\n } = opts\n\n // executableName and productFilename are embedded directly into double-quoted bash strings\n // and used as filesystem paths, so they must pass the whitelist.\n // productName is not validated here because it is only ever passed through escapeShellString().\n validateCriticalPathString(executableName, \"executableName\")\n validateCriticalPathString(productFilename, \"productFilename\")\n\n // Write desktop file\n const desktopFileName = `${desktopBaseName ?? executableName}.desktop`\n await fs.writeFile(path.join(stageDir, desktopFileName), desktopEntry, { mode: 0o644 })\n await copyIcons(opts)\n\n const templateConfig: AppRunScriptBase = {\n DesktopFileName: desktopFileName,\n ExecutableName: executableName,\n ExecutableArgs: executableArgs,\n ProductName: productName,\n ProductFilename: productFilename,\n ResourceName: `appimagekit-${executableName}`,\n }\n\n const mimeTypeFile = await copyMimeTypes(stageDir, opts.options)\n if (mimeTypeFile) {\n templateConfig.MimeTypeFile = mimeTypeFile\n }\n\n let finalConfig: AppRunScript = templateConfig\n\n // Copy license file if provided\n if (license) {\n // Validate license file exists\n if (!(await exists(license))) {\n throw new InvalidConfigurationError(`License file not found: ${license}`)\n }\n\n const licenseBaseName = path.basename(license)\n const ext = path.extname(license).toLowerCase()\n\n // Validate license filename for path safety\n validateCriticalPathString(licenseBaseName, \"licenseBaseName\")\n\n // Validate extension\n if (![\".txt\", \".html\"].includes(ext)) {\n log.warn({ license, expected: \".txt or .html\" }, `license file has unexpected extension`)\n }\n\n await copyFile(license, path.join(stageDir, licenseBaseName))\n\n finalConfig = {\n ...templateConfig,\n EulaFile: licenseBaseName,\n IsHtmlEula: ext === \".html\",\n }\n }\n\n const appRunContent = generateAppRunScript(finalConfig)\n await fs.writeFile(path.join(stageDir, APP_RUN_ENTRYPOINT), appRunContent, { mode: 0o755 })\n}\n\nexport type AppRunScriptBase = {\n ExecutableName: string\n DesktopFileName: string\n ProductFilename: string\n ProductName: string\n ResourceName: string\n MimeTypeFile?: string\n /** Arguments injected into the launcher, so the .desktop Exec key stays `AppRun %U`. */\n ExecutableArgs?: ReadonlyArray<string>\n}\n\nexport type AppRunScriptWithEula = AppRunScriptBase & {\n EulaFile: string\n IsHtmlEula: boolean\n}\n\nexport type AppRunScript = AppRunScriptBase | AppRunScriptWithEula\n\nfunction hasEula(config: AppRunScript): config is AppRunScriptWithEula {\n return \"EulaFile\" in config && typeof config.EulaFile === \"string\"\n}\n\nexport function generateAppRunScript(config: AppRunScript): string {\n const eulaEnabled = hasEula(config)\n // executableArgs are baked into the launcher (single-quoted) rather than the .desktop Exec key,\n // consistent with the other Linux targets. \"$@\" still forwards launch-time arguments.\n const executableArgsLiteral = (config.ExecutableArgs ?? []).map(shellQuote).join(\" \")\n\n return `#!/usr/bin/env bash\nset -e\n\nTHIS=\"$0\"\n# http://stackoverflow.com/questions/3190818/\nargs=(\"$@\")\nNUMBER_OF_ARGS=\"$#\"\n\nif [ -z \"$APPDIR\" ] ; then\n # Find the AppDir. It is the directory that contains AppRun.\n # This assumes that this script resides inside the AppDir or a subdirectory.\n # If this script is run inside an AppImage, then the AppImage runtime likely has already set $APPDIR\n path=\"$(dirname \"$(readlink -f \"\\${THIS}\")\")\"\n while [[ \"$path\" != \"\" && ! -e \"$path/${APP_RUN_ENTRYPOINT}\" ]]; do\n path=\\${path%/*}\n done\n APPDIR=\"$path\"\nfi\n\nif [ -z \"$APPDIR\" ] ; then\n echo \"ERROR: could not locate the AppDir. Ensure this script is run from within a properly structured AppImage.\" >&2\n exit 1\nfi\n\nexport PATH=\"\\${APPDIR}:\\${APPDIR}/usr/sbin\\${PATH:+:\\${PATH}}\"\nexport XDG_DATA_DIRS=\"\\${APPDIR}/usr/share/\\${XDG_DATA_DIRS:+:\\${XDG_DATA_DIRS}}:/usr/share/gnome:/usr/local/share/:/usr/share/\"\nexport LD_LIBRARY_PATH=\"\\${APPDIR}/usr/lib\\${LD_LIBRARY_PATH:+:\\${LD_LIBRARY_PATH}}\"\nexport GSETTINGS_SCHEMA_DIR=\"\\${APPDIR}/usr/share/glib-2.0/schemas\\${GSETTINGS_SCHEMA_DIR:+:\\${GSETTINGS_SCHEMA_DIR}}\"\n\nBIN=\"$APPDIR/${config.ExecutableName}\"\n# Configured executableArgs, applied ahead of any launch-time arguments.\nEXECUTABLE_ARGS=(${executableArgsLiteral})\n\nif [ -z \"$APPIMAGE_EXIT_AFTER_INSTALL\" ] ; then\n trap atexit EXIT\nfi\n\nisEulaAccepted=1\n\nHAVE_NO_SANDBOX=0\nfor arg in \"\\${EXECUTABLE_ARGS[@]}\" \"\\${args[@]}\" ; do\n if [ \"$arg\" = --no-sandbox ] ; then\n HAVE_NO_SANDBOX=1\n break\n fi\ndone\nNO_SANDBOX=()\n# Use 'unshare -Ur true' as a heuristic to detect whether user namespaces are available.\n# Notes:\n# - When running as root, this check will always succeed even if the sandbox configuration\n# actually relies on unprivileged user namespaces. In practice, Chrome/Electron usually\n# disables or adjusts the sandbox separately when running as root, so this probe is mostly\n# a no-op in that scenario.\n# - On minimal systems (e.g. Alpine or stripped-down containers) 'unshare' may not exist.\n# In that case the shell will return exit code 127 (\"command not found\"), which will cause\n# us to add '--no-sandbox'. This is an intentional fail-safe: we prefer the app to start\n# without sandboxing rather than crash on startup.\nif [ $HAVE_NO_SANDBOX -eq 0 ] && ! unshare -Ur true 2>/dev/null ; then\n NO_SANDBOX=(--no-sandbox)\nfi\n\natexit()\n{\n if [ $isEulaAccepted == 1 ] ; then\n if [ $NUMBER_OF_ARGS -eq 0 ] ; then\n exec \"$BIN\" \"\\${NO_SANDBOX[@]}\" \"\\${EXECUTABLE_ARGS[@]}\"\n else\n exec \"$BIN\" \"\\${NO_SANDBOX[@]}\" \"\\${EXECUTABLE_ARGS[@]}\" \"\\${args[@]}\"\n fi\n fi\n}\n\nerror()\n{\n if [ -x /usr/bin/zenity ] ; then\n LD_LIBRARY_PATH=\"\" zenity --error --text \"\\${1}\" 2>/dev/null\n elif [ -x /usr/bin/kdialog ] ; then\n LD_LIBRARY_PATH=\"\" kdialog --msgbox \"\\${1}\" 2>/dev/null\n elif [ -x /usr/bin/Xdialog ] ; then\n LD_LIBRARY_PATH=\"\" Xdialog --msgbox \"\\${1}\" 2>/dev/null\n else\n echo \"\\${1}\"\n fi\n exit 1\n}\n\nyesno()\n{\n TITLE=$1\n TEXT=$2\n if [ -x /usr/bin/zenity ] ; then\n LD_LIBRARY_PATH=\"\" zenity --question --title=\"$TITLE\" --text=\"$TEXT\" 2>/dev/null || exit 0\n elif [ -x /usr/bin/kdialog ] ; then\n LD_LIBRARY_PATH=\"\" kdialog --title \"$TITLE\" --yesno \"$TEXT\" || exit 0\n elif [ -x /usr/bin/Xdialog ] ; then\n LD_LIBRARY_PATH=\"\" Xdialog --title \"$TITLE\" --clear --yesno \"$TEXT\" 10 80 || exit 0\n else\n echo \"zenity, kdialog, Xdialog missing. Skipping \\${THIS}.\"\n exit 0\n fi\n}\n\ncheck_dep()\n{\n DEP=$1\n if ! command -v \"$DEP\" &>/dev/null ; then\n echo \"$DEP is missing. Skipping \\${THIS}.\"\n exit 0\n fi\n}\n\nif [ -z \"$APPIMAGE\" ] ; then\n APPIMAGE=\"$APPDIR/${APP_RUN_ENTRYPOINT}\"\n # not running from within an AppImage; hence using the AppRun for Exec=\nfi\n\n${\n eulaEnabled\n ? `if [ -z \"$APPIMAGE_SILENT_INSTALL\" ] ; then\n EULA_MARK_DIR=\"\\${XDG_CONFIG_HOME:-$HOME/.config}/${config.ProductFilename}\"\n EULA_MARK_FILE=\"$EULA_MARK_DIR/eulaAccepted\"\n # show EULA only if desktop file doesn't exist\n if [ ! -e \"$EULA_MARK_FILE\" ] ; then\n if [ -x /usr/bin/zenity ] ; then\n # on cancel simply exits and our trap handler launches app, so, $isEulaAccepted is set here to 0 and then to 1 if EULA accepted\n isEulaAccepted=0\n LD_LIBRARY_PATH=\"\" zenity --text-info --title=${escapeShellString(config.ProductName)} --filename=\"$APPDIR/${config.EulaFile}\" --ok-label=Agree --cancel-label=Disagree ${config.IsHtmlEula ? \"--html\" : \"\"}\n elif [ -x /usr/bin/Xdialog ] ; then\n isEulaAccepted=0\n LD_LIBRARY_PATH=\"\" Xdialog --title ${escapeShellString(config.ProductName)} --textbox \"$APPDIR/${config.EulaFile}\" 30 80 --ok-label Agree --cancel-label Disagree\n elif [ -x /usr/bin/kdialog ] ; then\n # cannot find any option to force Agree/Disagree buttons for kdialog. And official example exactly with OK button https://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs#Example_21._--textbox_dialog_box\n # in any case we pass labels text\n isEulaAccepted=0\n LD_LIBRARY_PATH=\"\" kdialog --textbox \"$APPDIR/${config.EulaFile}\" --yes-label Agree --cancel-label \"Disagree\"\n fi\n\n case $? in\n 0)\n isEulaAccepted=1\n echo \"License accepted\"\n mkdir -p \"$EULA_MARK_DIR\"\n touch \"$EULA_MARK_FILE\"\n ;;\n 1)\n echo \"License not accepted\"\n exit 0\n ;;\n -1)\n echo \"An unexpected error has occurred.\"\n isEulaAccepted=1\n ;;\n esac\n fi\nfi`\n : \"\"\n}\n`\n}\n"]}
1
+ {"version":3,"file":"appImageUtil.js","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appImageUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAkB,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACpH,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAA;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAsCxD,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAC,mBAA8C,EAAE,IAA4B,EAAE,YAAoB;IACjJ,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IAExD,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAEvB,0CAA0C;QAC1C,MAAM,+BAA+B,CAAC,IAAI,CAAC,CAAA;QAE3C,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAA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,CAAC;AAoBD,SAAS,OAAO,CAAC,MAAoB;IACnC,OAAO,UAAU,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAA;AACpE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACvD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACnC,gGAAgG;IAChG,sFAAsF;IACtF,MAAM,qBAAqB,GAAG,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAErF,OAAO;;;;;;;;;;;;;0CAaiC,kBAAkB;;;;;;;;;;;;;;;;eAgB7C,MAAM,CAAC,cAAc;;mBAEjB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAiFlB,kBAAkB;;;;EAKtC,WAAW;QACT,CAAC,CAAC;sDACgD,MAAM,CAAC,eAAe;;;;;;;+DAOb,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,wBAAwB,MAAM,CAAC,QAAQ,8CAA8C,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;;;oDAGtK,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,uBAAuB,MAAM,CAAC,QAAQ;;;;;+DAKhE,MAAM,CAAC,QAAQ;;;;;;;;;;;;;;;;;;;;GAoB3E;QACC,CAAC,CAAC,EACN;CACC,CAAA;AACD,CAAC","sourcesContent":["import { Arch, copyDir, CopyDirOptions, copyFile, exec, exists, InvalidConfigurationError, log } from \"builder-util\"\nimport fs from \"fs-extra\"\nimport * as path from \"path\"\nimport { FileAssociation } from \"../../../options/FileAssociation.js\"\nimport { getAppImageTools } from \"../../../toolsets/appimage.js\"\nimport { copyIcons, copyMimeTypes } from \"./appLauncher.js\"\nimport { shellQuote } from \"../launcherScript.js\"\nimport { appendBlockmap } from \"../../differentialUpdateInfoBuilder.js\"\nimport { BlockMapDataHolder } from \"builder-util-runtime\"\nimport { APP_RUN_ENTRYPOINT } from \"./AppImageTarget.js\"\nimport { ToolsetConfig } from \"../../../configuration.js\"\nimport { IconInfo } from \"../../../util/iconConverter.js\"\n\ninterface Options {\n productName: string\n productFilename: string\n executableName: string\n /** Arguments injected into the AppRun launcher (the .desktop Exec key stays `AppRun %U`). */\n executableArgs?: ReadonlyArray<string>\n desktopEntry: string\n icons: IconInfo[]\n license?: string | null\n fileAssociations: FileAssociation[]\n /**\n * The compression type available for static runtime is limited as it's only compiled with support for gzip and zstd.\n * \"xz\" is only valid for the legacy FUSE2 (0.0.0) toolset.\n *\n * [stderr] Squashfs image uses lzo compression, this version supports only zlib, zstd.\n * Failed to open squashfs image\n * Failed to extract AppImage\n *\n */\n compression?: \"gzip\" | \"zstd\" | \"xz\"\n /** Pre-computed desktop basename (already validated). When absent, falls back to `executableName`. */\n desktopBaseName?: string\n}\n\nexport interface AppImageBuilderOptions {\n appDir: string\n stageDir: string\n arch: Arch\n output: string\n options: Options\n /** How the copy of `appDir` into the stage treats the symlinks in it (see `getStagingCopyLinkOptions`). */\n appDirCopyOptions?: Pick<CopyDirOptions, \"allowedSymlinkRoots\" | \"externalLinks\"> | null\n}\n\nexport async function buildStaticRuntimeAppImage(appimageToolVersion: ToolsetConfig[\"appimage\"], opts: AppImageBuilderOptions, resourcesDir: string): Promise<BlockMapDataHolder> {\n const { stageDir, output, appDir, options, arch } = opts\n\n try {\n await fs.remove(output)\n\n // Write AppRun launcher and related files\n await writeAppLauncherAndRelatedFiles(opts)\n\n const { runtimeLibraries: libraries, runtime, mksquashfs } = await getAppImageTools(appimageToolVersion, arch, resourcesDir)\n await copyDir(libraries, path.join(stageDir, \"usr\", \"lib\"))\n\n // Copy app directory to stage\n // mksquashfs doesn't support merging, so we copy the entire app dir\n await copyDir(appDir, stageDir, opts.appDirCopyOptions ?? undefined)\n\n const runtimeData = await fs.readFile(runtime)\n\n // Create squashfs with offset for runtime\n const args: string[] = [stageDir, output, \"-offset\", runtimeData.length.toString(), \"-all-root\", \"-noappend\", \"-no-progress\", \"-quiet\", \"-no-xattrs\", \"-no-fragments\"]\n if (options.compression) {\n args.push(\"-comp\", options.compression)\n }\n await exec(mksquashfs, args, {\n cwd: stageDir,\n })\n\n // Write runtime data at the beginning of the file\n await writeRuntimeData(output, runtimeData)\n\n // Make executable\n await fs.chmod(output, 0o755)\n\n // Append blockmap inside try block to ensure cleanup on failure\n const updateInfo = await appendBlockmap(output)\n return updateInfo\n } catch (error) {\n // Clean up partial build on failure\n await fs.remove(output).catch(() => {})\n throw error\n }\n}\n\nexport async function buildLegacyFuse2AppImage(opts: AppImageBuilderOptions, resourcesDir: string): Promise<BlockMapDataHolder> {\n const { stageDir, output, appDir, options, arch } = opts\n\n try {\n await fs.remove(output)\n\n await writeAppLauncherAndRelatedFiles(opts)\n\n const { runtime, mksquashfs, runtimeLibraries } = await getAppImageTools(\"0.0.0\", arch, resourcesDir)\n // Mirror the app-builder-lib Go implementation: bundle lib/<arch> into usr/lib for x64 and ia32.\n // arm targets don't have a dedicated lib dir in the FUSE2 toolset.\n if (arch === Arch.x64 || arch === Arch.ia32) {\n await copyDir(runtimeLibraries, path.join(stageDir, \"usr\", \"lib\"))\n }\n await copyDir(appDir, stageDir, opts.appDirCopyOptions ?? undefined)\n\n const runtimeData = await fs.readFile(runtime)\n\n const args: string[] = [stageDir, output, \"-offset\", runtimeData.length.toString(), \"-all-root\", \"-noappend\", \"-no-progress\", \"-quiet\", \"-no-xattrs\", \"-no-fragments\"]\n if (options.compression) {\n args.push(\"-comp\", options.compression)\n if (options.compression === \"xz\") {\n // Match the dictionary/block-size settings used by the original app-builder Go implementation\n args.push(\"-Xdict-size\", \"100%\", \"-b\", \"1048576\")\n }\n }\n await exec(mksquashfs, args, { cwd: stageDir })\n\n await writeRuntimeData(output, runtimeData)\n await fs.chmod(output, 0o755)\n\n const updateInfo = await appendBlockmap(output)\n return updateInfo\n } catch (error) {\n await fs.remove(output).catch(() => {})\n throw error\n }\n}\n\nasync function writeRuntimeData(filePath: string, runtimeData: Buffer): Promise<void> {\n const fd = await fs.open(filePath, \"r+\")\n try {\n await fs.write(fd, runtimeData, 0, runtimeData.length, 0)\n } finally {\n try {\n await fs.close(fd)\n } catch (closeError: any) {\n // Log but don't throw - preserve original error if any\n log.warn({ message: closeError.message, file: filePath }, `failed to close file descriptor`)\n }\n }\n}\n\n/**\n * Escapes a string for safe use in shell scripts by wrapping in single quotes\n * and escaping any single quotes within the string.\n *\n * This allows strings with spaces, special characters, etc. to be safely used.\n */\nfunction escapeShellString(str: string): string {\n // Escape single quotes by replacing ' with '\\''\n // Then wrap the whole string in single quotes\n return `'${str.replace(/'/g, \"'\\\\''\")}'`\n}\n\n/**\n * Validates that critical path fields (executable name, product filename, license filename)\n * contain only characters that are safe for use in filesystem paths and embedded bash strings.\n * Allowed: Unicode letters, digits, dots, underscores, hyphens, spaces, and parentheses.\n */\nexport function validateCriticalPathString(str: string, fieldName: string): void {\n if (!/^[\\p{L}\\p{N}._\\- ()]+$/u.test(str)) {\n throw new InvalidConfigurationError(\n `${fieldName} contains characters that cannot be safely used in file paths: ${str}. Please use only letters, digits, hyphens, underscores, dots, spaces, and parentheses.`\n )\n }\n}\n\nasync function writeAppLauncherAndRelatedFiles(opts: AppImageBuilderOptions): Promise<void> {\n const {\n stageDir,\n options: { license, executableName, executableArgs, productFilename, productName, desktopEntry, desktopBaseName },\n } = opts\n\n // executableName and productFilename are embedded directly into double-quoted bash strings\n // and used as filesystem paths, so they must pass the whitelist.\n // productName is not validated here because it is only ever passed through escapeShellString().\n validateCriticalPathString(executableName, \"executableName\")\n validateCriticalPathString(productFilename, \"productFilename\")\n\n // Write desktop file\n const desktopFileName = `${desktopBaseName ?? executableName}.desktop`\n await fs.writeFile(path.join(stageDir, desktopFileName), desktopEntry, { mode: 0o644 })\n await copyIcons(opts)\n\n const templateConfig: AppRunScriptBase = {\n DesktopFileName: desktopFileName,\n ExecutableName: executableName,\n ExecutableArgs: executableArgs,\n ProductName: productName,\n ProductFilename: productFilename,\n ResourceName: `appimagekit-${executableName}`,\n }\n\n const mimeTypeFile = await copyMimeTypes(stageDir, opts.options)\n if (mimeTypeFile) {\n templateConfig.MimeTypeFile = mimeTypeFile\n }\n\n let finalConfig: AppRunScript = templateConfig\n\n // Copy license file if provided\n if (license) {\n // Validate license file exists\n if (!(await exists(license))) {\n throw new InvalidConfigurationError(`License file not found: ${license}`)\n }\n\n const licenseBaseName = path.basename(license)\n const ext = path.extname(license).toLowerCase()\n\n // Validate license filename for path safety\n validateCriticalPathString(licenseBaseName, \"licenseBaseName\")\n\n // Validate extension\n if (![\".txt\", \".html\"].includes(ext)) {\n log.warn({ license, expected: \".txt or .html\" }, `license file has unexpected extension`)\n }\n\n await copyFile(license, path.join(stageDir, licenseBaseName))\n\n finalConfig = {\n ...templateConfig,\n EulaFile: licenseBaseName,\n IsHtmlEula: ext === \".html\",\n }\n }\n\n const appRunContent = generateAppRunScript(finalConfig)\n await fs.writeFile(path.join(stageDir, APP_RUN_ENTRYPOINT), appRunContent, { mode: 0o755 })\n}\n\nexport type AppRunScriptBase = {\n ExecutableName: string\n DesktopFileName: string\n ProductFilename: string\n ProductName: string\n ResourceName: string\n MimeTypeFile?: string\n /** Arguments injected into the launcher, so the .desktop Exec key stays `AppRun %U`. */\n ExecutableArgs?: ReadonlyArray<string>\n}\n\nexport type AppRunScriptWithEula = AppRunScriptBase & {\n EulaFile: string\n IsHtmlEula: boolean\n}\n\nexport type AppRunScript = AppRunScriptBase | AppRunScriptWithEula\n\nfunction hasEula(config: AppRunScript): config is AppRunScriptWithEula {\n return \"EulaFile\" in config && typeof config.EulaFile === \"string\"\n}\n\nexport function generateAppRunScript(config: AppRunScript): string {\n const eulaEnabled = hasEula(config)\n // executableArgs are baked into the launcher (single-quoted) rather than the .desktop Exec key,\n // consistent with the other Linux targets. \"$@\" still forwards launch-time arguments.\n const executableArgsLiteral = (config.ExecutableArgs ?? []).map(shellQuote).join(\" \")\n\n return `#!/usr/bin/env bash\nset -e\n\nTHIS=\"$0\"\n# http://stackoverflow.com/questions/3190818/\nargs=(\"$@\")\nNUMBER_OF_ARGS=\"$#\"\n\nif [ -z \"$APPDIR\" ] ; then\n # Find the AppDir. It is the directory that contains AppRun.\n # This assumes that this script resides inside the AppDir or a subdirectory.\n # If this script is run inside an AppImage, then the AppImage runtime likely has already set $APPDIR\n path=\"$(dirname \"$(readlink -f \"\\${THIS}\")\")\"\n while [[ \"$path\" != \"\" && ! -e \"$path/${APP_RUN_ENTRYPOINT}\" ]]; do\n path=\\${path%/*}\n done\n APPDIR=\"$path\"\nfi\n\nif [ -z \"$APPDIR\" ] ; then\n echo \"ERROR: could not locate the AppDir. Ensure this script is run from within a properly structured AppImage.\" >&2\n exit 1\nfi\n\nexport PATH=\"\\${APPDIR}:\\${APPDIR}/usr/sbin\\${PATH:+:\\${PATH}}\"\nexport XDG_DATA_DIRS=\"\\${APPDIR}/usr/share/\\${XDG_DATA_DIRS:+:\\${XDG_DATA_DIRS}}:/usr/share/gnome:/usr/local/share/:/usr/share/\"\nexport LD_LIBRARY_PATH=\"\\${APPDIR}/usr/lib\\${LD_LIBRARY_PATH:+:\\${LD_LIBRARY_PATH}}\"\nexport GSETTINGS_SCHEMA_DIR=\"\\${APPDIR}/usr/share/glib-2.0/schemas\\${GSETTINGS_SCHEMA_DIR:+:\\${GSETTINGS_SCHEMA_DIR}}\"\n\nBIN=\"$APPDIR/${config.ExecutableName}\"\n# Configured executableArgs, applied ahead of any launch-time arguments.\nEXECUTABLE_ARGS=(${executableArgsLiteral})\n\nif [ -z \"$APPIMAGE_EXIT_AFTER_INSTALL\" ] ; then\n trap atexit EXIT\nfi\n\nisEulaAccepted=1\n\nHAVE_NO_SANDBOX=0\nfor arg in \"\\${EXECUTABLE_ARGS[@]}\" \"\\${args[@]}\" ; do\n if [ \"$arg\" = --no-sandbox ] ; then\n HAVE_NO_SANDBOX=1\n break\n fi\ndone\nNO_SANDBOX=()\n# Use 'unshare -Ur true' as a heuristic to detect whether user namespaces are available.\n# Notes:\n# - When running as root, this check will always succeed even if the sandbox configuration\n# actually relies on unprivileged user namespaces. In practice, Chrome/Electron usually\n# disables or adjusts the sandbox separately when running as root, so this probe is mostly\n# a no-op in that scenario.\n# - On minimal systems (e.g. Alpine or stripped-down containers) 'unshare' may not exist.\n# In that case the shell will return exit code 127 (\"command not found\"), which will cause\n# us to add '--no-sandbox'. This is an intentional fail-safe: we prefer the app to start\n# without sandboxing rather than crash on startup.\nif [ $HAVE_NO_SANDBOX -eq 0 ] && ! unshare -Ur true 2>/dev/null ; then\n NO_SANDBOX=(--no-sandbox)\nfi\n\natexit()\n{\n if [ $isEulaAccepted == 1 ] ; then\n if [ $NUMBER_OF_ARGS -eq 0 ] ; then\n exec \"$BIN\" \"\\${NO_SANDBOX[@]}\" \"\\${EXECUTABLE_ARGS[@]}\"\n else\n exec \"$BIN\" \"\\${NO_SANDBOX[@]}\" \"\\${EXECUTABLE_ARGS[@]}\" \"\\${args[@]}\"\n fi\n fi\n}\n\nerror()\n{\n if [ -x /usr/bin/zenity ] ; then\n LD_LIBRARY_PATH=\"\" /usr/bin/zenity --error --text \"\\${1}\" 2>/dev/null\n elif [ -x /usr/bin/kdialog ] ; then\n LD_LIBRARY_PATH=\"\" /usr/bin/kdialog --msgbox \"\\${1}\" 2>/dev/null\n elif [ -x /usr/bin/Xdialog ] ; then\n LD_LIBRARY_PATH=\"\" /usr/bin/Xdialog --msgbox \"\\${1}\" 2>/dev/null\n else\n echo \"\\${1}\"\n fi\n exit 1\n}\n\nyesno()\n{\n TITLE=$1\n TEXT=$2\n if [ -x /usr/bin/zenity ] ; then\n LD_LIBRARY_PATH=\"\" /usr/bin/zenity --question --title=\"$TITLE\" --text=\"$TEXT\" 2>/dev/null || exit 0\n elif [ -x /usr/bin/kdialog ] ; then\n LD_LIBRARY_PATH=\"\" /usr/bin/kdialog --title \"$TITLE\" --yesno \"$TEXT\" || exit 0\n elif [ -x /usr/bin/Xdialog ] ; then\n LD_LIBRARY_PATH=\"\" /usr/bin/Xdialog --title \"$TITLE\" --clear --yesno \"$TEXT\" 10 80 || exit 0\n else\n echo \"zenity, kdialog, Xdialog missing. Skipping \\${THIS}.\"\n exit 0\n fi\n}\n\ncheck_dep()\n{\n DEP=$1\n if ! command -v \"$DEP\" &>/dev/null ; then\n echo \"$DEP is missing. Skipping \\${THIS}.\"\n exit 0\n fi\n}\n\nif [ -z \"$APPIMAGE\" ] ; then\n APPIMAGE=\"$APPDIR/${APP_RUN_ENTRYPOINT}\"\n # not running from within an AppImage; hence using the AppRun for Exec=\nfi\n\n${\n eulaEnabled\n ? `if [ -z \"$APPIMAGE_SILENT_INSTALL\" ] ; then\n EULA_MARK_DIR=\"\\${XDG_CONFIG_HOME:-$HOME/.config}/${config.ProductFilename}\"\n EULA_MARK_FILE=\"$EULA_MARK_DIR/eulaAccepted\"\n # show EULA only if desktop file doesn't exist\n if [ ! -e \"$EULA_MARK_FILE\" ] ; then\n if [ -x /usr/bin/zenity ] ; then\n # on cancel simply exits and our trap handler launches app, so, $isEulaAccepted is set here to 0 and then to 1 if EULA accepted\n isEulaAccepted=0\n LD_LIBRARY_PATH=\"\" /usr/bin/zenity --text-info --title=${escapeShellString(config.ProductName)} --filename=\"$APPDIR/${config.EulaFile}\" --ok-label=Agree --cancel-label=Disagree ${config.IsHtmlEula ? \"--html\" : \"\"}\n elif [ -x /usr/bin/Xdialog ] ; then\n isEulaAccepted=0\n LD_LIBRARY_PATH=\"\" /usr/bin/Xdialog --title ${escapeShellString(config.ProductName)} --textbox \"$APPDIR/${config.EulaFile}\" 30 80 --ok-label Agree --cancel-label Disagree\n elif [ -x /usr/bin/kdialog ] ; then\n # cannot find any option to force Agree/Disagree buttons for kdialog. And official example exactly with OK button https://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs#Example_21._--textbox_dialog_box\n # in any case we pass labels text\n isEulaAccepted=0\n LD_LIBRARY_PATH=\"\" /usr/bin/kdialog --textbox \"$APPDIR/${config.EulaFile}\" --yes-label Agree --cancel-label \"Disagree\"\n fi\n\n case $? in\n 0)\n isEulaAccepted=1\n echo \"License accepted\"\n mkdir -p \"$EULA_MARK_DIR\"\n touch \"$EULA_MARK_FILE\"\n ;;\n 1)\n echo \"License not accepted\"\n exit 0\n ;;\n -1)\n echo \"An unexpected error has occurred.\"\n isEulaAccepted=1\n ;;\n esac\n fi\nfi`\n : \"\"\n}\n`\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"flatpakBundle.d.ts","sourceRoot":"","sources":["../../../src/targets/linux/flatpakBundle.ts"],"names":[],"mappings":"AAmBA,2KAA2K;AAC3K,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,MAAM,CAAA;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAA;CAC3B;AAED,qFAAqF;AACrF,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,CAAA;AAEvD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,sBAAsB,CAAA;IAChC,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAA;IACZ,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAA;IACpB,8GAA8G;IAC9G,OAAO,EAAE,MAAM,CAAA;IACf,0HAA0H;IAC1H,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;IACzB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AC9D,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;IAC5B,qIAAqI;IACrI,mBAAmB,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAClD,4CAA4C;IAC5C,kBAAkB,EAAE,MAAM,EAAE,CAAA;IAC5B,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAuID;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyGrF"}
@@ -1,15 +1,15 @@
1
- import { exec, InvalidConfigurationError, log } from "builder-util";
1
+ import { exec, Executables, InvalidConfigurationError, log } from "builder-util";
2
2
  import { cp, mkdir, realpath, symlink, writeFile } from "fs/promises";
3
3
  import * as path from "path";
4
4
  import * as semver from "semver";
5
- import { BREAKING_CHANGES_URL } from "../../util/config/legacyOptions.js";
5
+ import { BUILD_CHANGES_URL } from "../../util/config/legacyOptions.js";
6
6
  // flatpak-builder 1.2.2 is the one of Ubuntu 22.04, the oldest current distribution release (Debian 12 and RHEL 8/9 have 1.2.3). It fixes
7
7
  // CVE-2022-21682 with an option that flatpak supports from 1.12.4 on; Ubuntu 22.04 has flatpak 1.12.7
8
8
  const MIN_VERSIONS = { flatpak: "1.12.4", "flatpak-builder": "1.2.2" };
9
9
  // the freedesktop SDK 24.08 and newer recommend it for meson and cmake modules
10
10
  const MODULES_FLATPAK_BUILDER_VERSION = "1.4.4";
11
11
  const MODULES_FREEDESKTOP_SDK_VERSION = "24.8.0";
12
- const NEW_IN_V27 = `This is new in electron-builder v27. See ${BREAKING_CHANGES_URL}#flatpak-tooling-requirements`;
12
+ const NEW_IN_V27 = `This is new in electron-builder v27. See ${BUILD_CHANGES_URL}#flatpak-tooling-requirements`;
13
13
  const FLATPAK_DOCS = "https://www.electron.build/docs/flatpak";
14
14
  const UNPRIVILEGED_CONTAINERS_DOCS = `${FLATPAK_DOCS}#building-in-unprivileged-containers`;
15
15
  /**
@@ -26,10 +26,10 @@ function hintOn(...hints) {
26
26
  };
27
27
  }
28
28
  /** Checks that the tool runs and is new enough, and returns its version, or null when the output has none. */
29
- async function requireTool(tool, cwd) {
29
+ async function requireTool(tools, tool, cwd) {
30
30
  let stdout;
31
31
  try {
32
- stdout = await exec(tool, ["--version"], { cwd });
32
+ stdout = await exec(tools[tool], ["--version"], { cwd });
33
33
  }
34
34
  catch (e) {
35
35
  log.error({ error: e.message }, `cannot run ${tool}`);
@@ -92,27 +92,27 @@ async function requireDirectoryInAppPrefix(prefix, realPrefix, file, what) {
92
92
  }
93
93
  }
94
94
  /** Whether a ref is installed for the user and system-wide. */
95
- async function findRef(ref, cwd) {
96
- const isInstalled = (installation) => exec("flatpak", ["info", "--show-commit", installation, ref], { cwd }).then(() => true, () => false);
95
+ async function findRef(flatpak, ref, cwd) {
96
+ const isInstalled = (installation) => exec(flatpak, ["info", "--show-commit", installation, ref], { cwd }).then(() => true, () => false);
97
97
  const [inUser, inSystem] = await Promise.all([isInstalled("--user"), isInstalled("--system")]);
98
98
  return { inUser, inSystem };
99
99
  }
100
100
  /** Brings a ref that the build needs up to date, wherever it is installed, and installs it for the user when it is installed nowhere. */
101
- async function installOrUpdateRef(ref, cwd) {
102
- const { inUser, inSystem } = await findRef(ref, cwd);
101
+ async function installOrUpdateRef(flatpak, ref, cwd) {
102
+ const { inUser, inSystem } = await findRef(flatpak, ref, cwd);
103
103
  if (inUser || inSystem) {
104
- await exec("flatpak", ["update", ...(inUser ? ["--user"] : []), "--no-deps", "--noninteractive", ref], { cwd });
104
+ await exec(flatpak, ["update", ...(inUser ? ["--user"] : []), "--no-deps", "--noninteractive", ref], { cwd });
105
105
  return;
106
106
  }
107
107
  log.info({ ref }, "installing flatpak ref, this can download several gigabytes");
108
- await exec("flatpak", ["install", "--user", "--no-deps", "--noninteractive", ref], { cwd }).catch(hintOn([
108
+ await exec(flatpak, ["install", "--user", "--no-deps", "--noninteractive", ref], { cwd }).catch(hintOn([
109
109
  "No remote refs found",
110
110
  `missing flatpak refs are installed with "flatpak install --user", which only searches the remotes of the user installation. If flathub is not one of them, add it with: flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo (otherwise check that the configured runtime, sdk and base versions exist)`,
111
111
  ]));
112
112
  }
113
113
  /** Checks that a ref that the build is not to install or update is installed, in either installation. */
114
- async function requireInstalledRef(kind, ref, cwd) {
115
- const { inUser, inSystem } = await findRef(ref, cwd);
114
+ async function requireInstalledRef(flatpak, kind, ref, cwd) {
115
+ const { inUser, inSystem } = await findRef(flatpak, ref, cwd);
116
116
  if (!inUser && !inSystem) {
117
117
  throw new InvalidConfigurationError(`the ${kind} ${ref} is not installed, and flatpak.installOrUpdateRefs does not include "${kind}", so the build does not install it. Install it, for example with: flatpak install --user flathub ${ref} (or add "${kind}" to flatpak.installOrUpdateRefs)`);
118
118
  }
@@ -135,8 +135,13 @@ export async function buildFlatpakBundle(options) {
135
135
  // checked before anything is installed or built
136
136
  const copies = options.files.map(([source, destination]) => [source, inAppPrefix(prefix, destination, "flatpak.files destination")]);
137
137
  const links = options.symlinks.map(([target, link]) => [target, inAppPrefix(prefix, link, "flatpak.symlinks link")]);
138
- await requireTool("flatpak", cwd);
139
- const builderVersion = await requireTool("flatpak-builder", cwd);
138
+ // by absolute path (toolsets.executables or their default install locations), never looked up on PATH
139
+ const tools = {
140
+ flatpak: Executables.resolve("flatpak"),
141
+ "flatpak-builder": Executables.resolve("flatpak-builder"),
142
+ };
143
+ await requireTool(tools, "flatpak", cwd);
144
+ const builderVersion = await requireTool(tools, "flatpak-builder", cwd);
140
145
  // a freedesktop SDK before 24.08 is left out; any other SDK is not modelled and warned about. Loose, because the strict coerce rejects
141
146
  // the zero-padded minor of "22.08"
142
147
  const sdkVersion = manifest.sdk === "org.freedesktop.Sdk" ? semver.coerce(manifest["runtime-version"], { loose: true }) : null;
@@ -156,16 +161,16 @@ export async function buildFlatpakBundle(options) {
156
161
  // the refs to use as installed are checked first, so that a missing one fails the build before anything is downloaded
157
162
  const toInstallOrUpdate = refs.filter(([kind]) => options.installOrUpdateRefs.includes(kind));
158
163
  for (const [kind, ref] of refs.filter(it => !toInstallOrUpdate.includes(it))) {
159
- await requireInstalledRef(kind, ref, cwd);
164
+ await requireInstalledRef(tools.flatpak, kind, ref, cwd);
160
165
  }
161
166
  for (const [, ref] of toInstallOrUpdate) {
162
- await installOrUpdateRef(ref, cwd);
167
+ await installOrUpdateRef(tools.flatpak, ref, cwd);
163
168
  }
164
169
  await writeFile(manifestFile, JSON.stringify(manifest, null, 2));
165
170
  // flatpak-builder downloads the sources of the modules, and git or curl may need credentials from the environment for that. Without
166
171
  // modules it fetches nothing, so it gets the environment that exec filters for every other command
167
172
  const builderEnv = (manifest.modules?.length ?? 0) > 0 ? process.env : undefined;
168
- const runFlatpakBuilder = (stage) => exec("flatpak-builder", ["--arch", arch, stage, ...options.flatpakBuilderArgs, appDir, manifestFile], { cwd, env: builderEnv }).catch(hintOn([
173
+ const runFlatpakBuilder = (stage) => exec(tools["flatpak-builder"], ["--arch", arch, stage, ...options.flatpakBuilderArgs, appDir, manifestFile], { cwd, env: builderEnv }).catch(hintOn([
169
174
  "Failure spawning rofiles-fuse",
170
175
  `flatpak-builder could not start rofiles-fuse because FUSE is not available, which is typical in unprivileged containers. Set flatpak.additionalArgs.flatpakBuilder to ["--disable-rofiles-fuse"]. Such containers usually also need flatpak.additionalArgs.buildExport set to ["--disable-sandbox"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,
171
176
  ],
@@ -200,11 +205,11 @@ export async function buildFlatpakBundle(options) {
200
205
  await symlink(path.posix.join("/app", target), linkPath);
201
206
  }
202
207
  await runFlatpakBuilder("--finish-only");
203
- await exec("flatpak", ["build-export", "--arch", arch, ...options.buildExportArgs, repo, appDir, ...branch], { cwd }).catch(hintOn([
208
+ await exec(tools.flatpak, ["build-export", "--arch", arch, ...options.buildExportArgs, repo, appDir, ...branch], { cwd }).catch(hintOn([
204
209
  "bwrap: ",
205
210
  `flatpak build-export could not start the sandbox of its icon validator because bubblewrap (bwrap) cannot create namespaces, which is typical in unprivileged containers. Set flatpak.additionalArgs.buildExport to ["--disable-sandbox"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,
206
211
  ]));
207
212
  await mkdir(path.dirname(options.artifactPath), { recursive: true });
208
- await exec("flatpak", ["build-bundle", "--arch", arch, ...options.buildBundleArgs, repo, options.artifactPath, manifest.id, ...branch], { cwd });
213
+ await exec(tools.flatpak, ["build-bundle", "--arch", arch, ...options.buildBundleArgs, repo, options.artifactPath, manifest.id, ...branch], { cwd });
209
214
  }
210
215
  //# sourceMappingURL=flatpakBundle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flatpakBundle.js","sourceRoot":"","sources":["../../../src/targets/linux/flatpakBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAEzE,0IAA0I;AAC1I,sGAAsG;AACtG,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAA;AAEtE,+EAA+E;AAC/E,MAAM,+BAA+B,GAAG,OAAO,CAAA;AAC/C,MAAM,+BAA+B,GAAG,QAAQ,CAAA;AAEhD,MAAM,UAAU,GAAG,4CAA4C,oBAAoB,+BAA+B,CAAA;AAElH,MAAM,YAAY,GAAG,yCAAyC,CAAA;AAC9D,MAAM,4BAA4B,GAAG,GAAG,YAAY,sCAAsC,CAAA;AAuC1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;KAChR,CAAC,CACH,CAAA;IAED,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACpE,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;AAClJ,CAAC","sourcesContent":["import { exec, InvalidConfigurationError, log } from \"builder-util\"\nimport { cp, mkdir, realpath, symlink, writeFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { BREAKING_CHANGES_URL } from \"../../util/config/legacyOptions.js\"\n\n// flatpak-builder 1.2.2 is the one of Ubuntu 22.04, the oldest current distribution release (Debian 12 and RHEL 8/9 have 1.2.3). It fixes\n// CVE-2022-21682 with an option that flatpak supports from 1.12.4 on; Ubuntu 22.04 has flatpak 1.12.7\nconst MIN_VERSIONS = { flatpak: \"1.12.4\", \"flatpak-builder\": \"1.2.2\" }\n\n// the freedesktop SDK 24.08 and newer recommend it for meson and cmake modules\nconst MODULES_FLATPAK_BUILDER_VERSION = \"1.4.4\"\nconst MODULES_FREEDESKTOP_SDK_VERSION = \"24.8.0\"\n\nconst NEW_IN_V27 = `This is new in electron-builder v27. See ${BREAKING_CHANGES_URL}#flatpak-tooling-requirements`\n\nconst FLATPAK_DOCS = \"https://www.electron.build/docs/flatpak\"\nconst UNPRIVILEGED_CONTAINERS_DOCS = `${FLATPAK_DOCS}#building-in-unprivileged-containers`\n\n/** The part of a [flatpak-builder manifest](https://docs.flatpak.org/en/latest/flatpak-builder-command-reference.html#flatpak-manifest) that the flatpak target writes. */\nexport interface FlatpakBuilderManifest {\n id: string\n command: string\n runtime: string\n \"runtime-version\": string\n sdk: string\n base: string\n \"base-version\": string\n \"finish-args\": string[]\n branch?: string\n modules?: (string | any)[]\n}\n\n/** The refs a build needs: the runtime, the SDK and the base app of the manifest. */\nexport type FlatpakRefKind = \"runtime\" | \"sdk\" | \"base\"\n\nexport interface FlatpakBundleOptions {\n manifest: FlatpakBuilderManifest\n /** flatpak's name for the target architecture, e.g. `x86_64` */\n arch: string\n /** where to write the single-file bundle */\n artifactPath: string\n /** an empty directory for the manifest, the app directory, the repository and the state of flatpak-builder */\n tempDir: string\n /** `[source, destination]` pairs, copied in order; a destination is relative to the app prefix (`/app` in the sandbox) */\n files: [string, string][]\n /** `[target, link]` pairs, both relative to the app prefix */\n symlinks: [string, string][]\n /** the refs to install when they are missing and update when they are installed; the others are used as installed, and have to be */\n installOrUpdateRefs: ReadonlyArray<FlatpakRefKind>\n /** added to both runs of flatpak-builder */\n flatpakBuilderArgs: string[]\n buildExportArgs: string[]\n buildBundleArgs: string[]\n}\n\n/**\n * Logs how to fix a failure that has a known cause, given as `[marker, hint]` pairs: the hint of the first marker that the error\n * contains. The error is rethrown as is: `exec` has already put the output of the tool in it.\n */\nfunction hintOn(...hints: Array<[marker: string, hint: string]>) {\n return (e: Error): never => {\n const hint = hints.find(([marker]) => e.message.includes(marker))\n if (hint != null) {\n log.error(null, hint[1])\n }\n throw e\n }\n}\n\n/** Checks that the tool runs and is new enough, and returns its version, or null when the output has none. */\nasync function requireTool(tool: keyof typeof MIN_VERSIONS, cwd: string): Promise<semver.SemVer | null> {\n let stdout: string\n try {\n stdout = await exec(tool, [\"--version\"], { cwd })\n } catch (e: any) {\n log.error({ error: e.message }, `cannot run ${tool}`)\n throw new InvalidConfigurationError(`cannot run ${tool} - flatpak and flatpak-builder must be installed to build the flatpak target`)\n }\n log.info({ version: stdout.trim() }, `${tool} found`)\n\n // the output is \"Flatpak 1.16.6\", \"flatpak-builder 1.2.3\" or \"flatpak-builder-1.4.4\" depending on the tool and the distribution\n const version = semver.coerce(stdout)\n if (version != null && semver.lt(version, MIN_VERSIONS[tool])) {\n throw new InvalidConfigurationError(\n `${tool} ${version.version} is not supported - version ${MIN_VERSIONS[tool]} or newer is required to build the flatpak target. ${NEW_IN_V27}`\n )\n }\n return version\n}\n\nfunction isInside(dir: string, file: string): boolean {\n const relative = path.relative(dir, file)\n return relative !== \"..\" && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)\n}\n\n/**\n * Where a path given relative to the app prefix lands in the build directory. One that leaves the prefix is refused: the copy or\n * the link would be written elsewhere on the build machine, such as over the metadata of the build directory.\n */\nfunction inAppPrefix(prefix: string, relativePath: string, what: string): string {\n const resolved = path.join(prefix, relativePath)\n if (!isInside(prefix, resolved)) {\n throw new InvalidConfigurationError(`${what} \"${relativePath}\" is outside the app prefix (/app in the sandbox): use a path inside it, such as \"/lib/<name>\". ${NEW_IN_V27}`)\n }\n return resolved\n}\n\n/**\n * Refuses to write `file` when a symlink takes its directory out of the app prefix, which inAppPrefix cannot see: the base app, the\n * modules and an earlier flatpak.files pair put files into the prefix that are not checked, and a link among them, such as\n * `lib -> ../..` or `lib -> /home`, would make the copy or the link land elsewhere on the build machine. Only the directory is\n * resolved: what is at `file` itself is replaced, not followed, by both cp and symlink.\n */\nasync function requireDirectoryInAppPrefix(prefix: string, realPrefix: string, file: string, what: string): Promise<void> {\n const relative = path.relative(prefix, file)\n if (relative === \"\") {\n // the prefix itself, which a directory is merged into\n return\n }\n // the deepest directory that exists, since what is still to be created cannot be a link. A link that leads nowhere is passed over\n // as well: mkdir and cp fail on it rather than create anything through it\n let existing = path.dirname(file)\n let resolved: string | null = null\n while (resolved == null) {\n try {\n resolved = await realpath(existing)\n } catch (e: any) {\n // ENOTDIR: a file of an earlier pair is in the way, which the copy or mkdir reports itself\n if ((e.code !== \"ENOENT\" && e.code !== \"ENOTDIR\") || existing === path.dirname(existing)) {\n throw e\n }\n existing = path.dirname(existing)\n }\n }\n if (!isInside(realPrefix, resolved)) {\n const shown = `/${relative.split(path.sep).join(\"/\")}`\n throw new InvalidConfigurationError(\n `${what} \"${shown}\" resolves outside the app prefix (/app in the sandbox) through a symlink, to \"${resolved}\": a link in the prefix, from the base app, a module or an earlier flatpak.files pair, points outside it. ${NEW_IN_V27}`\n )\n }\n}\n\n/** Whether a ref is installed for the user and system-wide. */\nasync function findRef(ref: string, cwd: string): Promise<{ inUser: boolean; inSystem: boolean }> {\n const isInstalled = (installation: \"--user\" | \"--system\") =>\n exec(\"flatpak\", [\"info\", \"--show-commit\", installation, ref], { cwd }).then(\n () => true,\n () => false\n )\n const [inUser, inSystem] = await Promise.all([isInstalled(\"--user\"), isInstalled(\"--system\")])\n return { inUser, inSystem }\n}\n\n/** Brings a ref that the build needs up to date, wherever it is installed, and installs it for the user when it is installed nowhere. */\nasync function installOrUpdateRef(ref: string, cwd: string): Promise<void> {\n const { inUser, inSystem } = await findRef(ref, cwd)\n\n if (inUser || inSystem) {\n await exec(\"flatpak\", [\"update\", ...(inUser ? [\"--user\"] : []), \"--no-deps\", \"--noninteractive\", ref], { cwd })\n return\n }\n\n log.info({ ref }, \"installing flatpak ref, this can download several gigabytes\")\n await exec(\"flatpak\", [\"install\", \"--user\", \"--no-deps\", \"--noninteractive\", ref], { cwd }).catch(\n hintOn([\n \"No remote refs found\",\n `missing flatpak refs are installed with \"flatpak install --user\", which only searches the remotes of the user installation. If flathub is not one of them, add it with: flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo (otherwise check that the configured runtime, sdk and base versions exist)`,\n ])\n )\n}\n\n/** Checks that a ref that the build is not to install or update is installed, in either installation. */\nasync function requireInstalledRef(kind: FlatpakRefKind, ref: string, cwd: string): Promise<void> {\n const { inUser, inSystem } = await findRef(ref, cwd)\n if (!inUser && !inSystem) {\n throw new InvalidConfigurationError(\n `the ${kind} ${ref} is not installed, and flatpak.installOrUpdateRefs does not include \"${kind}\", so the build does not install it. Install it, for example with: flatpak install --user flathub ${ref} (or add \"${kind}\" to flatpak.installOrUpdateRefs)`\n )\n }\n log.info({ ref }, \"flatpak ref is used as installed, without an update\")\n}\n\n/**\n * Builds a single-file flatpak bundle out of files that are already built.\n *\n * flatpak-builder runs twice. `--build-only` creates the app directory from the base app (and builds the modules of the\n * manifest, if any) and stops, the files are then placed into the app prefix, and `--finish-only` turns the directory into an\n * app with the permissions of the manifest. Nothing has to run inside the build sandbox to get the files in.\n */\nexport async function buildFlatpakBundle(options: FlatpakBundleOptions): Promise<void> {\n const { manifest, arch, tempDir: cwd } = options\n const manifestFile = path.join(cwd, \"manifest.json\")\n const appDir = path.join(cwd, \"build\")\n const prefix = path.join(appDir, \"files\")\n const repo = path.join(cwd, \"repo\")\n const branch = manifest.branch ? [manifest.branch] : []\n // checked before anything is installed or built\n const copies = options.files.map(([source, destination]) => [source, inAppPrefix(prefix, destination, \"flatpak.files destination\")] as const)\n const links = options.symlinks.map(([target, link]) => [target, inAppPrefix(prefix, link, \"flatpak.symlinks link\")] as const)\n\n await requireTool(\"flatpak\", cwd)\n const builderVersion = await requireTool(\"flatpak-builder\", cwd)\n // a freedesktop SDK before 24.08 is left out; any other SDK is not modelled and warned about. Loose, because the strict coerce rejects\n // the zero-padded minor of \"22.08\"\n const sdkVersion = manifest.sdk === \"org.freedesktop.Sdk\" ? semver.coerce(manifest[\"runtime-version\"], { loose: true }) : null\n const isOldFreedesktopSdk = sdkVersion != null && semver.lt(sdkVersion, MODULES_FREEDESKTOP_SDK_VERSION)\n if ((manifest.modules?.length ?? 0) > 0 && builderVersion != null && semver.lt(builderVersion, MODULES_FLATPAK_BUILDER_VERSION) && !isOldFreedesktopSdk) {\n // once per process: every arch is built with the same flatpak-builder\n log\n .once(\"flatpak-builder-modules-version\")\n .warn(\n { flatpakBuilder: builderVersion.version, recommended: MODULES_FLATPAK_BUILDER_VERSION },\n `flatpak.modules are built with flatpak-builder ${builderVersion.version}. The freedesktop SDK 24.08 and newer recommend flatpak-builder ${MODULES_FLATPAK_BUILDER_VERSION} or newer for meson and cmake modules: update it if a module fails to build or does not install where it should`\n )\n }\n\n // the sdk has the version of the runtime\n const refs: [FlatpakRefKind, string][] = [\n [\"runtime\", `runtime/${manifest.runtime}/${arch}/${manifest[\"runtime-version\"]}`],\n [\"sdk\", `runtime/${manifest.sdk}/${arch}/${manifest[\"runtime-version\"]}`],\n [\"base\", `app/${manifest.base}/${arch}/${manifest[\"base-version\"]}`],\n ]\n // the refs to use as installed are checked first, so that a missing one fails the build before anything is downloaded\n const toInstallOrUpdate = refs.filter(([kind]) => options.installOrUpdateRefs.includes(kind))\n for (const [kind, ref] of refs.filter(it => !toInstallOrUpdate.includes(it))) {\n await requireInstalledRef(kind, ref, cwd)\n }\n for (const [, ref] of toInstallOrUpdate) {\n await installOrUpdateRef(ref, cwd)\n }\n\n await writeFile(manifestFile, JSON.stringify(manifest, null, 2))\n\n // flatpak-builder downloads the sources of the modules, and git or curl may need credentials from the environment for that. Without\n // modules it fetches nothing, so it gets the environment that exec filters for every other command\n const builderEnv = (manifest.modules?.length ?? 0) > 0 ? process.env : undefined\n const runFlatpakBuilder = (stage: \"--build-only\" | \"--finish-only\") =>\n exec(\"flatpak-builder\", [\"--arch\", arch, stage, ...options.flatpakBuilderArgs, appDir, manifestFile], { cwd, env: builderEnv }).catch(\n hintOn(\n [\n \"Failure spawning rofiles-fuse\",\n `flatpak-builder could not start rofiles-fuse because FUSE is not available, which is typical in unprivileged containers. Set flatpak.additionalArgs.flatpakBuilder to [\"--disable-rofiles-fuse\"]. Such containers usually also need flatpak.additionalArgs.buildExport set to [\"--disable-sandbox\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ],\n // rofiles-fuse started, but could not mount the app directory, so flatpak-builder finds it empty\n [\n `Command '${manifest.command}' not found`,\n `flatpak-builder did not find ${manifest.command}, which electron-builder placed in the app directory, because rofiles-fuse could not mount that directory. It needs the FUSE mount helper on the build machine: fusermount3 from the fuse3 package, or fusermount from the fuse package where rofiles-fuse is built against FUSE 2. Install it, or set flatpak.additionalArgs.flatpakBuilder to [\"--disable-rofiles-fuse\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ],\n // flatpak-builder before 1.4 composes AppStream metadata with appstream-compose, which the freedesktop SDK 24.08 and newer do\n // not ship; it runs only when the app has a metainfo or appdata file named after its id\n [\n \"execvp appstream-compose\",\n `flatpak-builder could not compose the AppStream metadata of the app (share/metainfo/${manifest.id}.metainfo.xml or share/appdata/${manifest.id}.appdata.xml, from flatpak.files or a module): it runs appstream-compose, which the freedesktop SDK no longer ships from 24.08 on. flatpak-builder 1.4 and newer use appstreamcli instead: update flatpak-builder, or leave the file out. See ${FLATPAK_DOCS}#build-requirements`,\n ]\n )\n )\n\n await runFlatpakBuilder(\"--build-only\")\n\n // flatpak-builder has created it, and the paths that the links in it lead to are compared with the one it resolves to\n const realPrefix = await realpath(prefix)\n // one after another, so that a pair can add to what an earlier one has placed. The filter sees every item of a directory, and the\n // destination itself, before it is written or its parent directory created; a symlink in the copied directory is still kept as it is\n const filter = async (_source: string, file: string) => {\n await requireDirectoryInAppPrefix(prefix, realPrefix, file, \"flatpak.files destination\")\n return true\n }\n for (const [source, destination] of copies) {\n await cp(source, destination, { recursive: true, verbatimSymlinks: true, filter })\n }\n for (const [target, linkPath] of links) {\n // before mkdir, which would create the missing directories wherever a link leads\n await requireDirectoryInAppPrefix(prefix, realPrefix, linkPath, \"flatpak.symlinks link\")\n await mkdir(path.dirname(linkPath), { recursive: true })\n // resolved in the sandbox, where the prefix is mounted at /app\n await symlink(path.posix.join(\"/app\", target), linkPath)\n }\n\n await runFlatpakBuilder(\"--finish-only\")\n\n await exec(\"flatpak\", [\"build-export\", \"--arch\", arch, ...options.buildExportArgs, repo, appDir, ...branch], { cwd }).catch(\n hintOn([\n \"bwrap: \",\n `flatpak build-export could not start the sandbox of its icon validator because bubblewrap (bwrap) cannot create namespaces, which is typical in unprivileged containers. Set flatpak.additionalArgs.buildExport to [\"--disable-sandbox\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ])\n )\n\n await mkdir(path.dirname(options.artifactPath), { recursive: true })\n await exec(\"flatpak\", [\"build-bundle\", \"--arch\", arch, ...options.buildBundleArgs, repo, options.artifactPath, manifest.id, ...branch], { cwd })\n}\n"]}
1
+ {"version":3,"file":"flatpakBundle.js","sourceRoot":"","sources":["../../../src/targets/linux/flatpakBundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,yBAAyB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAEtE,0IAA0I;AAC1I,sGAAsG;AACtG,MAAM,YAAY,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAA;AAEtE,+EAA+E;AAC/E,MAAM,+BAA+B,GAAG,OAAO,CAAA;AAC/C,MAAM,+BAA+B,GAAG,QAAQ,CAAA;AAEhD,MAAM,UAAU,GAAG,4CAA4C,iBAAiB,+BAA+B,CAAA;AAE/G,MAAM,YAAY,GAAG,yCAAyC,CAAA;AAC9D,MAAM,4BAA4B,GAAG,GAAG,YAAY,sCAAsC,CAAA;AA6C1F;;;GAGG;AACH,SAAS,MAAM,CAAC,GAAG,KAA4C;IAC7D,OAAO,CAAC,CAAQ,EAAS,EAAE;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;QACjE,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,GAAG,CAAC,KAAK,CAAC,IAAI,EA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AM,CAAC;QACL,SAAS;QACT,iPAAiP,4BAA4B,EAAE;KAChR,CAAC,CACH,CAAA;IAED,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACpE,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;AACtJ,CAAC","sourcesContent":["import { exec, Executables, InvalidConfigurationError, log } from \"builder-util\"\nimport { cp, mkdir, realpath, symlink, writeFile } from \"fs/promises\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\nimport { BUILD_CHANGES_URL } from \"../../util/config/legacyOptions.js\"\n\n// flatpak-builder 1.2.2 is the one of Ubuntu 22.04, the oldest current distribution release (Debian 12 and RHEL 8/9 have 1.2.3). It fixes\n// CVE-2022-21682 with an option that flatpak supports from 1.12.4 on; Ubuntu 22.04 has flatpak 1.12.7\nconst MIN_VERSIONS = { flatpak: \"1.12.4\", \"flatpak-builder\": \"1.2.2\" }\n\n// the freedesktop SDK 24.08 and newer recommend it for meson and cmake modules\nconst MODULES_FLATPAK_BUILDER_VERSION = \"1.4.4\"\nconst MODULES_FREEDESKTOP_SDK_VERSION = \"24.8.0\"\n\nconst NEW_IN_V27 = `This is new in electron-builder v27. See ${BUILD_CHANGES_URL}#flatpak-tooling-requirements`\n\nconst FLATPAK_DOCS = \"https://www.electron.build/docs/flatpak\"\nconst UNPRIVILEGED_CONTAINERS_DOCS = `${FLATPAK_DOCS}#building-in-unprivileged-containers`\n\n/** The part of a [flatpak-builder manifest](https://docs.flatpak.org/en/latest/flatpak-builder-command-reference.html#flatpak-manifest) that the flatpak target writes. */\nexport interface FlatpakBuilderManifest {\n id: string\n command: string\n runtime: string\n \"runtime-version\": string\n sdk: string\n base: string\n \"base-version\": string\n \"finish-args\": string[]\n branch?: string\n modules?: (string | any)[]\n}\n\n/** The refs a build needs: the runtime, the SDK and the base app of the manifest. */\nexport type FlatpakRefKind = \"runtime\" | \"sdk\" | \"base\"\n\nexport interface FlatpakBundleOptions {\n manifest: FlatpakBuilderManifest\n /** flatpak's name for the target architecture, e.g. `x86_64` */\n arch: string\n /** where to write the single-file bundle */\n artifactPath: string\n /** an empty directory for the manifest, the app directory, the repository and the state of flatpak-builder */\n tempDir: string\n /** `[source, destination]` pairs, copied in order; a destination is relative to the app prefix (`/app` in the sandbox) */\n files: [string, string][]\n /** `[target, link]` pairs, both relative to the app prefix */\n symlinks: [string, string][]\n /** the refs to install when they are missing and update when they are installed; the others are used as installed, and have to be */\n installOrUpdateRefs: ReadonlyArray<FlatpakRefKind>\n /** added to both runs of flatpak-builder */\n flatpakBuilderArgs: string[]\n buildExportArgs: string[]\n buildBundleArgs: string[]\n}\n\n/** The absolute paths of the tools, which are never looked up on PATH. */\ninterface FlatpakTools {\n flatpak: string\n \"flatpak-builder\": string\n}\n\n/**\n * Logs how to fix a failure that has a known cause, given as `[marker, hint]` pairs: the hint of the first marker that the error\n * contains. The error is rethrown as is: `exec` has already put the output of the tool in it.\n */\nfunction hintOn(...hints: Array<[marker: string, hint: string]>) {\n return (e: Error): never => {\n const hint = hints.find(([marker]) => e.message.includes(marker))\n if (hint != null) {\n log.error(null, hint[1])\n }\n throw e\n }\n}\n\n/** Checks that the tool runs and is new enough, and returns its version, or null when the output has none. */\nasync function requireTool(tools: FlatpakTools, tool: keyof typeof MIN_VERSIONS, cwd: string): Promise<semver.SemVer | null> {\n let stdout: string\n try {\n stdout = await exec(tools[tool], [\"--version\"], { cwd })\n } catch (e: any) {\n log.error({ error: e.message }, `cannot run ${tool}`)\n throw new InvalidConfigurationError(`cannot run ${tool} - flatpak and flatpak-builder must be installed to build the flatpak target`)\n }\n log.info({ version: stdout.trim() }, `${tool} found`)\n\n // the output is \"Flatpak 1.16.6\", \"flatpak-builder 1.2.3\" or \"flatpak-builder-1.4.4\" depending on the tool and the distribution\n const version = semver.coerce(stdout)\n if (version != null && semver.lt(version, MIN_VERSIONS[tool])) {\n throw new InvalidConfigurationError(\n `${tool} ${version.version} is not supported - version ${MIN_VERSIONS[tool]} or newer is required to build the flatpak target. ${NEW_IN_V27}`\n )\n }\n return version\n}\n\nfunction isInside(dir: string, file: string): boolean {\n const relative = path.relative(dir, file)\n return relative !== \"..\" && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)\n}\n\n/**\n * Where a path given relative to the app prefix lands in the build directory. One that leaves the prefix is refused: the copy or\n * the link would be written elsewhere on the build machine, such as over the metadata of the build directory.\n */\nfunction inAppPrefix(prefix: string, relativePath: string, what: string): string {\n const resolved = path.join(prefix, relativePath)\n if (!isInside(prefix, resolved)) {\n throw new InvalidConfigurationError(`${what} \"${relativePath}\" is outside the app prefix (/app in the sandbox): use a path inside it, such as \"/lib/<name>\". ${NEW_IN_V27}`)\n }\n return resolved\n}\n\n/**\n * Refuses to write `file` when a symlink takes its directory out of the app prefix, which inAppPrefix cannot see: the base app, the\n * modules and an earlier flatpak.files pair put files into the prefix that are not checked, and a link among them, such as\n * `lib -> ../..` or `lib -> /home`, would make the copy or the link land elsewhere on the build machine. Only the directory is\n * resolved: what is at `file` itself is replaced, not followed, by both cp and symlink.\n */\nasync function requireDirectoryInAppPrefix(prefix: string, realPrefix: string, file: string, what: string): Promise<void> {\n const relative = path.relative(prefix, file)\n if (relative === \"\") {\n // the prefix itself, which a directory is merged into\n return\n }\n // the deepest directory that exists, since what is still to be created cannot be a link. A link that leads nowhere is passed over\n // as well: mkdir and cp fail on it rather than create anything through it\n let existing = path.dirname(file)\n let resolved: string | null = null\n while (resolved == null) {\n try {\n resolved = await realpath(existing)\n } catch (e: any) {\n // ENOTDIR: a file of an earlier pair is in the way, which the copy or mkdir reports itself\n if ((e.code !== \"ENOENT\" && e.code !== \"ENOTDIR\") || existing === path.dirname(existing)) {\n throw e\n }\n existing = path.dirname(existing)\n }\n }\n if (!isInside(realPrefix, resolved)) {\n const shown = `/${relative.split(path.sep).join(\"/\")}`\n throw new InvalidConfigurationError(\n `${what} \"${shown}\" resolves outside the app prefix (/app in the sandbox) through a symlink, to \"${resolved}\": a link in the prefix, from the base app, a module or an earlier flatpak.files pair, points outside it. ${NEW_IN_V27}`\n )\n }\n}\n\n/** Whether a ref is installed for the user and system-wide. */\nasync function findRef(flatpak: string, ref: string, cwd: string): Promise<{ inUser: boolean; inSystem: boolean }> {\n const isInstalled = (installation: \"--user\" | \"--system\") =>\n exec(flatpak, [\"info\", \"--show-commit\", installation, ref], { cwd }).then(\n () => true,\n () => false\n )\n const [inUser, inSystem] = await Promise.all([isInstalled(\"--user\"), isInstalled(\"--system\")])\n return { inUser, inSystem }\n}\n\n/** Brings a ref that the build needs up to date, wherever it is installed, and installs it for the user when it is installed nowhere. */\nasync function installOrUpdateRef(flatpak: string, ref: string, cwd: string): Promise<void> {\n const { inUser, inSystem } = await findRef(flatpak, ref, cwd)\n\n if (inUser || inSystem) {\n await exec(flatpak, [\"update\", ...(inUser ? [\"--user\"] : []), \"--no-deps\", \"--noninteractive\", ref], { cwd })\n return\n }\n\n log.info({ ref }, \"installing flatpak ref, this can download several gigabytes\")\n await exec(flatpak, [\"install\", \"--user\", \"--no-deps\", \"--noninteractive\", ref], { cwd }).catch(\n hintOn([\n \"No remote refs found\",\n `missing flatpak refs are installed with \"flatpak install --user\", which only searches the remotes of the user installation. If flathub is not one of them, add it with: flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo (otherwise check that the configured runtime, sdk and base versions exist)`,\n ])\n )\n}\n\n/** Checks that a ref that the build is not to install or update is installed, in either installation. */\nasync function requireInstalledRef(flatpak: string, kind: FlatpakRefKind, ref: string, cwd: string): Promise<void> {\n const { inUser, inSystem } = await findRef(flatpak, ref, cwd)\n if (!inUser && !inSystem) {\n throw new InvalidConfigurationError(\n `the ${kind} ${ref} is not installed, and flatpak.installOrUpdateRefs does not include \"${kind}\", so the build does not install it. Install it, for example with: flatpak install --user flathub ${ref} (or add \"${kind}\" to flatpak.installOrUpdateRefs)`\n )\n }\n log.info({ ref }, \"flatpak ref is used as installed, without an update\")\n}\n\n/**\n * Builds a single-file flatpak bundle out of files that are already built.\n *\n * flatpak-builder runs twice. `--build-only` creates the app directory from the base app (and builds the modules of the\n * manifest, if any) and stops, the files are then placed into the app prefix, and `--finish-only` turns the directory into an\n * app with the permissions of the manifest. Nothing has to run inside the build sandbox to get the files in.\n */\nexport async function buildFlatpakBundle(options: FlatpakBundleOptions): Promise<void> {\n const { manifest, arch, tempDir: cwd } = options\n const manifestFile = path.join(cwd, \"manifest.json\")\n const appDir = path.join(cwd, \"build\")\n const prefix = path.join(appDir, \"files\")\n const repo = path.join(cwd, \"repo\")\n const branch = manifest.branch ? [manifest.branch] : []\n // checked before anything is installed or built\n const copies = options.files.map(([source, destination]) => [source, inAppPrefix(prefix, destination, \"flatpak.files destination\")] as const)\n const links = options.symlinks.map(([target, link]) => [target, inAppPrefix(prefix, link, \"flatpak.symlinks link\")] as const)\n\n // by absolute path (toolsets.executables or their default install locations), never looked up on PATH\n const tools: FlatpakTools = {\n flatpak: Executables.resolve(\"flatpak\"),\n \"flatpak-builder\": Executables.resolve(\"flatpak-builder\"),\n }\n await requireTool(tools, \"flatpak\", cwd)\n const builderVersion = await requireTool(tools, \"flatpak-builder\", cwd)\n // a freedesktop SDK before 24.08 is left out; any other SDK is not modelled and warned about. Loose, because the strict coerce rejects\n // the zero-padded minor of \"22.08\"\n const sdkVersion = manifest.sdk === \"org.freedesktop.Sdk\" ? semver.coerce(manifest[\"runtime-version\"], { loose: true }) : null\n const isOldFreedesktopSdk = sdkVersion != null && semver.lt(sdkVersion, MODULES_FREEDESKTOP_SDK_VERSION)\n if ((manifest.modules?.length ?? 0) > 0 && builderVersion != null && semver.lt(builderVersion, MODULES_FLATPAK_BUILDER_VERSION) && !isOldFreedesktopSdk) {\n // once per process: every arch is built with the same flatpak-builder\n log\n .once(\"flatpak-builder-modules-version\")\n .warn(\n { flatpakBuilder: builderVersion.version, recommended: MODULES_FLATPAK_BUILDER_VERSION },\n `flatpak.modules are built with flatpak-builder ${builderVersion.version}. The freedesktop SDK 24.08 and newer recommend flatpak-builder ${MODULES_FLATPAK_BUILDER_VERSION} or newer for meson and cmake modules: update it if a module fails to build or does not install where it should`\n )\n }\n\n // the sdk has the version of the runtime\n const refs: [FlatpakRefKind, string][] = [\n [\"runtime\", `runtime/${manifest.runtime}/${arch}/${manifest[\"runtime-version\"]}`],\n [\"sdk\", `runtime/${manifest.sdk}/${arch}/${manifest[\"runtime-version\"]}`],\n [\"base\", `app/${manifest.base}/${arch}/${manifest[\"base-version\"]}`],\n ]\n // the refs to use as installed are checked first, so that a missing one fails the build before anything is downloaded\n const toInstallOrUpdate = refs.filter(([kind]) => options.installOrUpdateRefs.includes(kind))\n for (const [kind, ref] of refs.filter(it => !toInstallOrUpdate.includes(it))) {\n await requireInstalledRef(tools.flatpak, kind, ref, cwd)\n }\n for (const [, ref] of toInstallOrUpdate) {\n await installOrUpdateRef(tools.flatpak, ref, cwd)\n }\n\n await writeFile(manifestFile, JSON.stringify(manifest, null, 2))\n\n // flatpak-builder downloads the sources of the modules, and git or curl may need credentials from the environment for that. Without\n // modules it fetches nothing, so it gets the environment that exec filters for every other command\n const builderEnv = (manifest.modules?.length ?? 0) > 0 ? process.env : undefined\n const runFlatpakBuilder = (stage: \"--build-only\" | \"--finish-only\") =>\n exec(tools[\"flatpak-builder\"], [\"--arch\", arch, stage, ...options.flatpakBuilderArgs, appDir, manifestFile], { cwd, env: builderEnv }).catch(\n hintOn(\n [\n \"Failure spawning rofiles-fuse\",\n `flatpak-builder could not start rofiles-fuse because FUSE is not available, which is typical in unprivileged containers. Set flatpak.additionalArgs.flatpakBuilder to [\"--disable-rofiles-fuse\"]. Such containers usually also need flatpak.additionalArgs.buildExport set to [\"--disable-sandbox\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ],\n // rofiles-fuse started, but could not mount the app directory, so flatpak-builder finds it empty\n [\n `Command '${manifest.command}' not found`,\n `flatpak-builder did not find ${manifest.command}, which electron-builder placed in the app directory, because rofiles-fuse could not mount that directory. It needs the FUSE mount helper on the build machine: fusermount3 from the fuse3 package, or fusermount from the fuse package where rofiles-fuse is built against FUSE 2. Install it, or set flatpak.additionalArgs.flatpakBuilder to [\"--disable-rofiles-fuse\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ],\n // flatpak-builder before 1.4 composes AppStream metadata with appstream-compose, which the freedesktop SDK 24.08 and newer do\n // not ship; it runs only when the app has a metainfo or appdata file named after its id\n [\n \"execvp appstream-compose\",\n `flatpak-builder could not compose the AppStream metadata of the app (share/metainfo/${manifest.id}.metainfo.xml or share/appdata/${manifest.id}.appdata.xml, from flatpak.files or a module): it runs appstream-compose, which the freedesktop SDK no longer ships from 24.08 on. flatpak-builder 1.4 and newer use appstreamcli instead: update flatpak-builder, or leave the file out. See ${FLATPAK_DOCS}#build-requirements`,\n ]\n )\n )\n\n await runFlatpakBuilder(\"--build-only\")\n\n // flatpak-builder has created it, and the paths that the links in it lead to are compared with the one it resolves to\n const realPrefix = await realpath(prefix)\n // one after another, so that a pair can add to what an earlier one has placed. The filter sees every item of a directory, and the\n // destination itself, before it is written or its parent directory created; a symlink in the copied directory is still kept as it is\n const filter = async (_source: string, file: string) => {\n await requireDirectoryInAppPrefix(prefix, realPrefix, file, \"flatpak.files destination\")\n return true\n }\n for (const [source, destination] of copies) {\n await cp(source, destination, { recursive: true, verbatimSymlinks: true, filter })\n }\n for (const [target, linkPath] of links) {\n // before mkdir, which would create the missing directories wherever a link leads\n await requireDirectoryInAppPrefix(prefix, realPrefix, linkPath, \"flatpak.symlinks link\")\n await mkdir(path.dirname(linkPath), { recursive: true })\n // resolved in the sandbox, where the prefix is mounted at /app\n await symlink(path.posix.join(\"/app\", target), linkPath)\n }\n\n await runFlatpakBuilder(\"--finish-only\")\n\n await exec(tools.flatpak, [\"build-export\", \"--arch\", arch, ...options.buildExportArgs, repo, appDir, ...branch], { cwd }).catch(\n hintOn([\n \"bwrap: \",\n `flatpak build-export could not start the sandbox of its icon validator because bubblewrap (bwrap) cannot create namespaces, which is typical in unprivileged containers. Set flatpak.additionalArgs.buildExport to [\"--disable-sandbox\"]. See ${UNPRIVILEGED_CONTAINERS_DOCS}`,\n ])\n )\n\n await mkdir(path.dirname(options.artifactPath), { recursive: true })\n await exec(tools.flatpak, [\"build-bundle\", \"--arch\", arch, ...options.buildBundleArgs, repo, options.artifactPath, manifest.id, ...branch], { cwd })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"coreLegacy.d.ts","sourceRoot":"","sources":["../../../../src/targets/linux/snap/coreLegacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,IAAI,EAA8G,MAAM,cAAc,CAAA;AAMlL,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAkB,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAMnF,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAM9C,OAAO,EAAE,UAAU,EAAE,CAAA;AAkBrB,qBAAa,cAAe,SAAQ,QAAQ,CAAC,iBAAiB,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;CAAE,CAAC;IACxG,OAAO,CAAC,gBAAgB,CAAQ;IAEhC,YAAY,WAAyJ;IAErK,OAAO,CAAC,cAAc;IAQhB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC;IAiJpD,SAAS,CAAC,KAA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,CAAC,gBAAgB,CAAQ;IAEhC,YAAY,WAAyJ;IAErK,OAAO,CAAC,cAAc;IAQhB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC;IAiJpD,SAAS,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,GAAG,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAgFrH,iBAAiB;YAgDjB,oBAAoB;YAqCpB,cAAc;IA4B5B,OAAO,CAAC,0BAA0B;IAmBlC,OAAO,CAAC,uBAAuB;IAY/B,OAAO,CAAC,iBAAiB;CAe1B;AA6BD;;;;;;;;;;;;GAYG;AACH;;;;GAIG;AACH,wBAAgB,sCAAsC,CAAC,eAAe,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAQ5H;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,MAAM,CAS3H"}
@@ -1,7 +1,7 @@
1
- import { replaceDefault as _replaceDefault, Arch, copyDir, exec, InvalidConfigurationError, log, serializeToYaml, toLinuxArchString, validateShellEmbeddable } from "builder-util";
1
+ import { replaceDefault as _replaceDefault, Arch, copyDir, exec, Executables, InvalidConfigurationError, log, serializeToYaml, stripSensitiveEnvVars, toLinuxArchString, validateShellEmbeddable, } from "builder-util";
2
2
  import { asArray, deepAssign, isValidKey } from "builder-util-runtime";
3
3
  import _fsExtra from "fs-extra";
4
- import { chmod, copyFile, mkdir, readdir, rename, writeFile } from "fs/promises";
4
+ import { chmod, copyFile, lstat, mkdir, readdir, rename, writeFile } from "fs/promises";
5
5
  import { load } from "js-yaml";
6
6
  import * as path from "path";
7
7
  import { getAppImageTools } from "../../../toolsets/appimage.js";
@@ -254,9 +254,9 @@ export class SnapCoreLegacy extends SnapCore {
254
254
  log.info({ releaseName }, "downloading snap template");
255
255
  const templateDir = await downloadBuilderToolset({ releaseName, filenameWithExt, checksums, githubOrgRepo: "electron-userland/electron-builder-binaries" });
256
256
  await this.stageSnapFiles({ stageDir, appOutDir, hooksDir, extraAppArgs, isTemplate: true });
257
- // chmod -R g-s to avoid setgid bits in final image
257
+ // no setgid bits in the final image (chmod -R g-s)
258
258
  for (const dir of [stageDir, appOutDir, templateDir]) {
259
- await exec("chmod", ["-R", "g-s", dir]).catch(err => log.warn({ error: err.message }, "chmod g-s failed"));
259
+ await clearSetgidBits(dir).catch(err => log.warn({ error: err.message }, "chmod g-s failed"));
260
260
  }
261
261
  const { mksquashfs } = await getAppImageTools(appimageToolset, snapArch, this.packager.buildResourcesDir);
262
262
  // Collect top-level entries from each dir as individual path args (mirrors Go ReadDirContentTo)
@@ -298,9 +298,10 @@ export class SnapCoreLegacy extends SnapCore {
298
298
  if (isDestructiveMode) {
299
299
  snapArgs.push("--destructive-mode");
300
300
  }
301
- await exec("snapcraft", snapArgs, {
301
+ // a local build: snapcraft needs no credentials
302
+ await exec(Executables.resolve("snapcraft"), snapArgs, {
302
303
  cwd: stageDir,
303
- env: { ...process.env, SNAPCRAFT_HAS_TTY: "false" },
304
+ env: { ...stripSensitiveEnvVars(process.env), SNAPCRAFT_HAS_TTY: "false" },
304
305
  });
305
306
  if (!isDestructiveMode) {
306
307
  await rename(path.join(stageDir, snapOutputName), artifactPath);
@@ -373,6 +374,21 @@ export class SnapCoreLegacy extends SnapCore {
373
374
  }
374
375
  }
375
376
  }
377
+ /** Clears the setgid bit of a directory and of everything in it, like `chmod -R g-s`: symlinks are not followed. */
378
+ async function clearSetgidBits(file) {
379
+ const stat = await lstat(file);
380
+ if (stat.isSymbolicLink()) {
381
+ return;
382
+ }
383
+ if ((stat.mode & 0o2000) !== 0) {
384
+ await chmod(file, stat.mode & 0o7777 & ~0o2000);
385
+ }
386
+ if (stat.isDirectory()) {
387
+ for (const name of await readdir(file)) {
388
+ await clearSetgidBits(path.join(file, name));
389
+ }
390
+ }
391
+ }
376
392
  async function readDirPaths(dir, filter) {
377
393
  const entries = await readdir(dir);
378
394
  const result = [];