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

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 (217) hide show
  1. package/dist/asar/asarAlign.d.ts +35 -0
  2. package/dist/asar/asarAlign.d.ts.map +1 -0
  3. package/dist/asar/asarAlign.js +149 -0
  4. package/dist/asar/asarAlign.js.map +1 -0
  5. package/dist/asar/asarUtil.d.ts +15 -1
  6. package/dist/asar/asarUtil.d.ts.map +1 -1
  7. package/dist/asar/asarUtil.js +111 -61
  8. package/dist/asar/asarUtil.js.map +1 -1
  9. package/dist/codeSign/win/authenticodeSignature.d.ts +71 -0
  10. package/dist/codeSign/win/authenticodeSignature.d.ts.map +1 -0
  11. package/dist/codeSign/win/authenticodeSignature.js +241 -0
  12. package/dist/codeSign/win/authenticodeSignature.js.map +1 -0
  13. package/dist/codeSign/win/signtoolBaseSignManager.d.ts +11 -0
  14. package/dist/codeSign/win/signtoolBaseSignManager.d.ts.map +1 -1
  15. package/dist/codeSign/win/signtoolBaseSignManager.js +36 -16
  16. package/dist/codeSign/win/signtoolBaseSignManager.js.map +1 -1
  17. package/dist/codeSign/win/verifyUpdatePublisher.d.ts +25 -0
  18. package/dist/codeSign/win/verifyUpdatePublisher.d.ts.map +1 -0
  19. package/dist/codeSign/win/verifyUpdatePublisher.js +98 -0
  20. package/dist/codeSign/win/verifyUpdatePublisher.js.map +1 -0
  21. package/dist/configuration.d.ts +16 -13
  22. package/dist/configuration.d.ts.map +1 -1
  23. package/dist/configuration.js.map +1 -1
  24. package/dist/electron/ElectronFramework.d.ts +15 -0
  25. package/dist/electron/ElectronFramework.d.ts.map +1 -1
  26. package/dist/electron/ElectronFramework.js +33 -2
  27. package/dist/electron/ElectronFramework.js.map +1 -1
  28. package/dist/electron/mac/asarIntegrityDigest.d.ts +10 -0
  29. package/dist/electron/mac/asarIntegrityDigest.d.ts.map +1 -0
  30. package/dist/electron/mac/asarIntegrityDigest.js +122 -0
  31. package/dist/electron/mac/asarIntegrityDigest.js.map +1 -0
  32. package/dist/electron/mac/electronMac.js +1 -28
  33. package/dist/electron/mac/electronMac.js.map +1 -1
  34. package/dist/electron/mac/electronMacUtils.d.ts +8 -0
  35. package/dist/electron/mac/electronMacUtils.d.ts.map +1 -1
  36. package/dist/electron/mac/electronMacUtils.js +36 -0
  37. package/dist/electron/mac/electronMacUtils.js.map +1 -1
  38. package/dist/fileMatcher.d.ts +47 -12
  39. package/dist/fileMatcher.d.ts.map +1 -1
  40. package/dist/fileMatcher.js +150 -45
  41. package/dist/fileMatcher.js.map +1 -1
  42. package/dist/forge-maker.d.ts +64 -0
  43. package/dist/forge-maker.d.ts.map +1 -1
  44. package/dist/forge-maker.js +104 -2
  45. package/dist/forge-maker.js.map +1 -1
  46. package/dist/index.d.ts +4 -4
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +1 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/indexInternal.d.ts +5 -3
  51. package/dist/indexInternal.d.ts.map +1 -1
  52. package/dist/indexInternal.js +5 -3
  53. package/dist/indexInternal.js.map +1 -1
  54. package/dist/macPackager.d.ts +6 -0
  55. package/dist/macPackager.d.ts.map +1 -1
  56. package/dist/macPackager.js +48 -2
  57. package/dist/macPackager.js.map +1 -1
  58. package/dist/options/FuseOptionsV1.d.ts +4 -0
  59. package/dist/options/FuseOptionsV1.d.ts.map +1 -1
  60. package/dist/options/FuseOptionsV1.js.map +1 -1
  61. package/dist/options/PlatformSpecificBuildOptions.d.ts +166 -8
  62. package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
  63. package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
  64. package/dist/options/SnapOptions.d.ts +36 -15
  65. package/dist/options/SnapOptions.d.ts.map +1 -1
  66. package/dist/options/SnapOptions.js.map +1 -1
  67. package/dist/options/linuxOptions.d.ts +53 -18
  68. package/dist/options/linuxOptions.d.ts.map +1 -1
  69. package/dist/options/linuxOptions.js.map +1 -1
  70. package/dist/options/macOptions.d.ts +15 -1
  71. package/dist/options/macOptions.d.ts.map +1 -1
  72. package/dist/options/macOptions.js.map +1 -1
  73. package/dist/options/winOptions.d.ts +7 -4
  74. package/dist/options/winOptions.d.ts.map +1 -1
  75. package/dist/options/winOptions.js.map +1 -1
  76. package/dist/packager.d.ts +2 -0
  77. package/dist/packager.d.ts.map +1 -1
  78. package/dist/packager.js +6 -0
  79. package/dist/packager.js.map +1 -1
  80. package/dist/platformPackager.d.ts +11 -4
  81. package/dist/platformPackager.d.ts.map +1 -1
  82. package/dist/platformPackager.js +53 -18
  83. package/dist/platformPackager.js.map +1 -1
  84. package/dist/presets/rectCra.js +3 -1
  85. package/dist/presets/rectCra.js.map +1 -1
  86. package/dist/publish/PublishManager.d.ts +6 -1
  87. package/dist/publish/PublishManager.d.ts.map +1 -1
  88. package/dist/publish/PublishManager.js +80 -58
  89. package/dist/publish/PublishManager.js.map +1 -1
  90. package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
  91. package/dist/publish/updateInfoBuilder.js +8 -10
  92. package/dist/publish/updateInfoBuilder.js.map +1 -1
  93. package/dist/targets/ArchiveTarget.d.ts.map +1 -1
  94. package/dist/targets/ArchiveTarget.js +7 -1
  95. package/dist/targets/ArchiveTarget.js.map +1 -1
  96. package/dist/targets/archive.d.ts +12 -0
  97. package/dist/targets/archive.d.ts.map +1 -1
  98. package/dist/targets/archive.js +17 -3
  99. package/dist/targets/archive.js.map +1 -1
  100. package/dist/targets/blockmap/blockmap.d.ts +3 -2
  101. package/dist/targets/blockmap/blockmap.d.ts.map +1 -1
  102. package/dist/targets/blockmap/blockmap.js +3 -2
  103. package/dist/targets/blockmap/blockmap.js.map +1 -1
  104. package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
  105. package/dist/targets/differentialUpdateInfoBuilder.js +4 -0
  106. package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
  107. package/dist/targets/linux/FlatpakTarget.d.ts +17 -0
  108. package/dist/targets/linux/FlatpakTarget.d.ts.map +1 -1
  109. package/dist/targets/linux/FlatpakTarget.js +238 -48
  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 -14
  113. package/dist/targets/linux/FpmTarget.js.map +1 -1
  114. package/dist/targets/linux/LinuxTargetHelper.d.ts +1 -3
  115. package/dist/targets/linux/LinuxTargetHelper.d.ts.map +1 -1
  116. package/dist/targets/linux/LinuxTargetHelper.js +45 -20
  117. package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
  118. package/dist/targets/linux/appimage/AppImageTarget.d.ts.map +1 -1
  119. package/dist/targets/linux/appimage/AppImageTarget.js +5 -1
  120. package/dist/targets/linux/appimage/AppImageTarget.js.map +1 -1
  121. package/dist/targets/linux/appimage/appImageUtil.d.ts +3 -1
  122. package/dist/targets/linux/appimage/appImageUtil.d.ts.map +1 -1
  123. package/dist/targets/linux/appimage/appImageUtil.js +2 -2
  124. package/dist/targets/linux/appimage/appImageUtil.js.map +1 -1
  125. package/dist/targets/linux/appimage/appLauncher.d.ts +6 -0
  126. package/dist/targets/linux/appimage/appLauncher.d.ts.map +1 -1
  127. package/dist/targets/linux/appimage/appLauncher.js +13 -9
  128. package/dist/targets/linux/appimage/appLauncher.js.map +1 -1
  129. package/dist/targets/linux/flatpakBundle.d.ts +43 -0
  130. package/dist/targets/linux/flatpakBundle.d.ts.map +1 -0
  131. package/dist/targets/linux/flatpakBundle.js +210 -0
  132. package/dist/targets/linux/flatpakBundle.js.map +1 -0
  133. package/dist/targets/linux/snap/core24.d.ts +0 -18
  134. package/dist/targets/linux/snap/core24.d.ts.map +1 -1
  135. package/dist/targets/linux/snap/core24.js +29 -100
  136. package/dist/targets/linux/snap/core24.js.map +1 -1
  137. package/dist/targets/linux/snap/coreLegacy.d.ts +7 -0
  138. package/dist/targets/linux/snap/coreLegacy.d.ts.map +1 -1
  139. package/dist/targets/linux/snap/coreLegacy.js +25 -6
  140. package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
  141. package/dist/targets/linux/snap/snapPlugs.d.ts +76 -0
  142. package/dist/targets/linux/snap/snapPlugs.d.ts.map +1 -0
  143. package/dist/targets/linux/snap/snapPlugs.js +242 -0
  144. package/dist/targets/linux/snap/snapPlugs.js.map +1 -0
  145. package/dist/targets/mac/MacTargetHelper.d.ts +6 -0
  146. package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
  147. package/dist/targets/mac/MacTargetHelper.js +47 -3
  148. package/dist/targets/mac/MacTargetHelper.js.map +1 -1
  149. package/dist/targets/mac/pkg.d.ts.map +1 -1
  150. package/dist/targets/mac/pkg.js +1 -0
  151. package/dist/targets/mac/pkg.js.map +1 -1
  152. package/dist/targets/win/nsis/Defines.d.ts +1 -0
  153. package/dist/targets/win/nsis/Defines.d.ts.map +1 -1
  154. package/dist/targets/win/nsis/Defines.js.map +1 -1
  155. package/dist/targets/win/nsis/NsisTarget.d.ts +8 -1
  156. package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
  157. package/dist/targets/win/nsis/NsisTarget.js +36 -5
  158. package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
  159. package/dist/targets/win/nsis/nsisOptions.d.ts +6 -4
  160. package/dist/targets/win/nsis/nsisOptions.d.ts.map +1 -1
  161. package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
  162. package/dist/targets/win/nsis/nsisUtil.d.ts.map +1 -1
  163. package/dist/targets/win/nsis/nsisUtil.js +7 -2
  164. package/dist/targets/win/nsis/nsisUtil.js.map +1 -1
  165. package/dist/targets/win/winAppUtil.d.ts +2 -2
  166. package/dist/targets/win/winAppUtil.d.ts.map +1 -1
  167. package/dist/targets/win/winAppUtil.js +5 -3
  168. package/dist/targets/win/winAppUtil.js.map +1 -1
  169. package/dist/toolsets/appimage.d.ts.map +1 -1
  170. package/dist/toolsets/appimage.js +19 -19
  171. package/dist/toolsets/appimage.js.map +1 -1
  172. package/dist/toolsets/nsis.js +1 -1
  173. package/dist/toolsets/nsis.js.map +1 -1
  174. package/dist/toolsets/winCodeSign.d.ts +14 -1
  175. package/dist/toolsets/winCodeSign.d.ts.map +1 -1
  176. package/dist/toolsets/winCodeSign.js +14 -1
  177. package/dist/toolsets/winCodeSign.js.map +1 -1
  178. package/dist/util/AppFileWalker.js +9 -1
  179. package/dist/util/AppFileWalker.js.map +1 -1
  180. package/dist/util/appFileCopier.d.ts +15 -2
  181. package/dist/util/appFileCopier.d.ts.map +1 -1
  182. package/dist/util/appFileCopier.js +30 -20
  183. package/dist/util/appFileCopier.js.map +1 -1
  184. package/dist/util/config/config.d.ts +1 -1
  185. package/dist/util/config/config.d.ts.map +1 -1
  186. package/dist/util/config/config.js +42 -19
  187. package/dist/util/config/config.js.map +1 -1
  188. package/dist/util/config/fileOptions.d.ts +52 -0
  189. package/dist/util/config/fileOptions.d.ts.map +1 -0
  190. package/dist/util/config/fileOptions.js +210 -0
  191. package/dist/util/config/fileOptions.js.map +1 -0
  192. package/dist/util/config/legacyConfigGuard.d.ts.map +1 -1
  193. package/dist/util/config/legacyConfigGuard.js +31 -4
  194. package/dist/util/config/legacyConfigGuard.js.map +1 -1
  195. package/dist/util/config/legacyOptions.d.ts +11 -0
  196. package/dist/util/config/legacyOptions.d.ts.map +1 -1
  197. package/dist/util/config/legacyOptions.js +36 -10
  198. package/dist/util/config/legacyOptions.js.map +1 -1
  199. package/dist/util/electronGet.d.ts +13 -0
  200. package/dist/util/electronGet.d.ts.map +1 -1
  201. package/dist/util/electronGet.js +40 -17
  202. package/dist/util/electronGet.js.map +1 -1
  203. package/dist/util/removedEnvVars.d.ts +25 -0
  204. package/dist/util/removedEnvVars.d.ts.map +1 -0
  205. package/dist/util/removedEnvVars.js +54 -0
  206. package/dist/util/removedEnvVars.js.map +1 -0
  207. package/dist/util/trustedSourceRoots.d.ts +59 -0
  208. package/dist/util/trustedSourceRoots.d.ts.map +1 -0
  209. package/dist/util/trustedSourceRoots.js +127 -0
  210. package/dist/util/trustedSourceRoots.js.map +1 -0
  211. package/dist/version.d.ts +1 -1
  212. package/dist/version.js +1 -1
  213. package/dist/version.js.map +1 -1
  214. package/package.json +18 -17
  215. package/scheme.json +421 -436
  216. package/templates/nsis/include/installer.nsh +11 -8
  217. package/templates/nsis/installSection.nsh +5 -0
@@ -1 +1 @@
1
- {"version":3,"file":"AppImageTarget.js","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/AppImageTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,GAAG,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAGzC,OAAO,EAAE,oCAAoC,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAC7G,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAGxF,+FAA+F;AAE/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAA;AAE1C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,MAAM;IAUhD,YACE,QAAgB,EACC,QAAuB,EACvB,MAAyB,EACjC,MAAc;QAEvB,KAAK,CAAC,UAAU,CAAC,CAAA;QAJA,aAAQ,GAAR,QAAQ,CAAe;QACvB,WAAM,GAAN,MAAM,CAAmB;QACjC,WAAM,GAAN,MAAM,CAAQ;QAbhB,YAAO,GAAoB,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAkB,IAAI,CAAC,IAAI,CAAC,CAAA;QAiB/F,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,E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BACV,CAAC;4BACD,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;gCACf,OAAO,MAAM,CAAA,CAAC,yDAAyD;4BACzE,CAAC;4BACD,IAAI,QAAQ,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;gCACrC,OAAO,MAAM,CAAA;4BACf,CAAC;4BACD,OAAO,MAAM,CAAA,CAAC,iDAAiD;wBACjE,CAAC,CAAC,EAAE;qBACL;iBACF,EACD,QAAQ,CAAC,iBAAiB,CAC3B,CAAA;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,0BAA0B,CAAC,CAAA;YAC/D,MAAM,KAAK,CAAA;QACb,CAAC;gBAAS,CAAC;YACT,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAC1C,CAAC;QAED,MAAM,QAAQ,CAAC,0BAA0B,CAAC;YACxC,IAAI,EAAE,YAAY;YAClB,gBAAgB,EAAE,QAAQ,CAAC,uBAAuB,CAAC,YAAY,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC;YACzF,MAAM,EAAE,IAAI;YACZ,IAAI;YACJ,QAAQ;YACR,iBAAiB,EAAE,IAAI;YACvB,UAAU;SACX,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { Arch, log } from \"builder-util\"\n\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Target } from \"../../../core.js\"\nimport { LinuxPackager } from \"../../../linuxPackager.js\"\nimport { AppImageOptions } from \"../../../options/linuxOptions.js\"\nimport { getPackAppUpdatePublishConfiguration, writeAppUpdateYaml } from \"../../../publish/PublishManager.js\"\nimport { getNotLocalizedLicenseFile } from \"../../../util/license.js\"\nimport { LinuxTargetHelper } from \"../LinuxTargetHelper.js\"\nimport { createStageDir } from \"../../targetUtil.js\"\nimport { buildLegacyFuse2AppImage, buildStaticRuntimeAppImage } from \"./appImageUtil.js\"\nimport { BlockMapDataHolder } from \"builder-util-runtime\"\n\n// https://unix.stackexchange.com/questions/375191/append-to-sub-directory-inside-squashfs-file\n\nexport const APP_RUN_ENTRYPOINT = \"AppRun\"\n\nexport default class AppImageTarget extends Target {\n readonly options: AppImageOptions = this.packager.getOptionsForTarget<AppImageOptions>(this.name)\n\n private readonly desktopEntry: Lazy<string>\n\n // executableArgs are injected into the AppRun launcher, so the .desktop Exec key is just `AppRun %U`\n // (consistent with the other Linux targets). AppRun also auto-adds --no-sandbox when user namespaces\n // are unavailable, so it is only defaulted here for the legacy FUSE2 (0.0.0) runtime.\n private readonly launcherArgs: string[]\n\n constructor(\n _ignored: string,\n private readonly packager: LinuxPackager,\n private readonly helper: LinuxTargetHelper,\n readonly outDir: string\n ) {\n super(\"appImage\")\n\n const appimageTool = packager.config.toolsets?.appimage\n // --no-sandbox is only needed by the FUSE2 legacy runtime; unset / \"latest\" → static runtime, no flag.\n const defaultArgs = appimageTool === \"0.0.0\" ? [\"--no-sandbox\"] : []\n this.launcherArgs = this.options.executableArgs ?? defaultArgs\n\n this.desktopEntry = new Lazy<string>(() =>\n helper.computeDesktopEntry(this.options, `${APP_RUN_ENTRYPOINT} %U`, {\n \"X-AppImage-Version\": `${packager.appInfo.buildVersion}`,\n })\n )\n }\n\n get writesUpdateInfo(): boolean {\n return true\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n\n const options = this.options\n // https://github.com/electron-userland/electron-builder/issues/775\n // https://github.com/electron-userland/electron-builder/issues/1726\n const artifactName = packager.expandArtifactNamePattern(options, \"AppImage\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.emitArtifactBuildStarted({\n targetPresentableName: \"AppImage\",\n file: artifactPath,\n arch,\n })\n\n // Parallelize independent async operations\n const [publishConfig, stageDir, desktopEntry, icons, license] = await Promise.all([\n getPackAppUpdatePublishConfiguration(packager, packager.getPackTargets(appOutDir, arch) ?? [this], arch, false),\n createStageDir(this, packager, arch),\n this.desktopEntry.value,\n this.helper.icons,\n getNotLocalizedLicenseFile(options.license, this.packager, [\"txt\", \"html\"]),\n ])\n\n if (publishConfig != null) {\n await writeAppUpdateYaml(packager.getResourcesDir(appOutDir), publishConfig)\n }\n\n // Validated once here; throws InvalidConfigurationError for path traversal / NUL.\n const desktopBaseName = this.helper.getDesktopFileName()\n\n if (\n this.packager.packagerOptions.effectiveOptionComputed != null &&\n (await this.packager.packagerOptions.effectiveOptionComputed({ desktop: desktopEntry, desktopFileName: `${desktopBaseName}.desktop` }))\n ) {\n await stageDir.cleanup()\n return\n }\n\n let updateInfo: BlockMapDataHolder\n try {\n const appimageTool = this.packager.config.toolsets?.appimage\n if (appimageTool === \"0.0.0\") {\n updateInfo = await buildLegacyFuse2AppImage(\n {\n appDir: appOutDir,\n stageDir: stageDir.dir,\n arch,\n output: artifactPath,\n options: {\n productName: packager.appInfo.productName,\n productFilename: packager.appInfo.productFilename,\n executableName: packager.executableName,\n executableArgs: this.launcherArgs,\n license,\n desktopEntry,\n icons,\n fileAssociations: packager.fileAssociations,\n desktopBaseName,\n compression: (() => {\n const c = options.compression\n if (c === \"xz\" || c === \"gzip\") {\n return c\n }\n if (packager.compression === \"maximum\") {\n return \"xz\"\n }\n return undefined // normal/store/unset/zstd → mksquashfs defaults to gzip\n })(),\n },\n },\n packager.buildResourcesDir\n )\n } else {\n updateInfo = await buildStaticRuntimeAppImage(\n appimageTool,\n {\n appDir: appOutDir,\n stageDir: stageDir.dir,\n arch,\n output: artifactPath,\n options: {\n productName: packager.appInfo.productName,\n productFilename: packager.appInfo.productFilename,\n executableName: packager.executableName,\n executableArgs: this.launcherArgs,\n license,\n desktopEntry,\n icons,\n fileAssociations: packager.fileAssociations,\n desktopBaseName,\n compression: (() => {\n const c = options.compression\n if (c === \"gzip\" || c === \"zstd\") {\n return c\n }\n if (c === \"xz\") {\n return \"zstd\" // nearest equivalent; static runtime does not support xz\n }\n if (packager.compression === \"store\") {\n return \"gzip\"\n }\n return \"zstd\" // maximum/normal/unset → zstd for static runtime\n })(),\n },\n },\n packager.buildResourcesDir\n )\n }\n } catch (error: any) {\n log.error({ error: error.message }, \"failed to build AppImage\")\n throw error\n } finally {\n await stageDir.cleanup().catch(() => {})\n }\n\n await packager.emitArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"AppImage\", arch, false),\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: true,\n updateInfo,\n })\n }\n}\n"]}
1
+ {"version":3,"file":"AppImageTarget.js","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/AppImageTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,GAAG,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAGzC,OAAO,EAAE,oCAAoC,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAC7G,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAC/E,OAAO,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAGxF,+FAA+F;AAE/F,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAA;AAE1C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,MAAM;IAUhD,YACE,QAAgB,EACC,QAAuB,EACvB,MAAyB,EACjC,MAAc;QAEvB,KAAK,CAAC,UAAU,CAAC,CAAA;QAJA,aAAQ,GAAR,QAAQ,CAAe;QACvB,WAAM,GAAN,MAAM,CAAmB;QACjC,WA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\"\nimport * as path from \"path\"\nimport { Target } from \"../../../core.js\"\nimport { LinuxPackager } from \"../../../linuxPackager.js\"\nimport { AppImageOptions } from \"../../../options/linuxOptions.js\"\nimport { getPackAppUpdatePublishConfiguration, writeAppUpdateYaml } from \"../../../publish/PublishManager.js\"\nimport { getNotLocalizedLicenseFile } from \"../../../util/license.js\"\nimport { LinuxTargetHelper } from \"../LinuxTargetHelper.js\"\nimport { createStageDir } from \"../../targetUtil.js\"\nimport { getStagingCopyLinkOptions } from \"../../../util/trustedSourceRoots.js\"\nimport { buildLegacyFuse2AppImage, buildStaticRuntimeAppImage } from \"./appImageUtil.js\"\nimport { BlockMapDataHolder } from \"builder-util-runtime\"\n\n// https://unix.stackexchange.com/questions/375191/append-to-sub-directory-inside-squashfs-file\n\nexport const APP_RUN_ENTRYPOINT = \"AppRun\"\n\nexport default class AppImageTarget extends Target {\n readonly options: AppImageOptions = this.packager.getOptionsForTarget<AppImageOptions>(this.name)\n\n private readonly desktopEntry: Lazy<string>\n\n // executableArgs are injected into the AppRun launcher, so the .desktop Exec key is just `AppRun %U`\n // (consistent with the other Linux targets). AppRun also auto-adds --no-sandbox when user namespaces\n // are unavailable, so it is only defaulted here for the legacy FUSE2 (0.0.0) runtime.\n private readonly launcherArgs: string[]\n\n constructor(\n _ignored: string,\n private readonly packager: LinuxPackager,\n private readonly helper: LinuxTargetHelper,\n readonly outDir: string\n ) {\n super(\"appImage\")\n\n const appimageTool = packager.config.toolsets?.appimage\n // --no-sandbox is only needed by the FUSE2 legacy runtime; unset / \"latest\" → static runtime, no flag.\n const defaultArgs = appimageTool === \"0.0.0\" ? [\"--no-sandbox\"] : []\n this.launcherArgs = this.options.executableArgs ?? defaultArgs\n\n this.desktopEntry = new Lazy<string>(() =>\n helper.computeDesktopEntry(this.options, `${APP_RUN_ENTRYPOINT} %U`, {\n \"X-AppImage-Version\": `${packager.appInfo.buildVersion}`,\n })\n )\n }\n\n get writesUpdateInfo(): boolean {\n return true\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\n\n const options = this.options\n // https://github.com/electron-userland/electron-builder/issues/775\n // https://github.com/electron-userland/electron-builder/issues/1726\n const artifactName = packager.expandArtifactNamePattern(options, \"AppImage\", arch)\n const artifactPath = path.join(this.outDir, artifactName)\n\n await packager.emitArtifactBuildStarted({\n targetPresentableName: \"AppImage\",\n file: artifactPath,\n arch,\n })\n\n // Parallelize independent async operations\n const [publishConfig, stageDir, desktopEntry, icons, license] = await Promise.all([\n getPackAppUpdatePublishConfiguration(packager, packager.getPackTargets(appOutDir, arch) ?? [this], arch, false),\n createStageDir(this, packager, arch),\n this.desktopEntry.value,\n this.helper.icons,\n getNotLocalizedLicenseFile(options.license, this.packager, [\"txt\", \"html\"]),\n ])\n\n if (publishConfig != null) {\n await writeAppUpdateYaml(packager.getResourcesDir(appOutDir), publishConfig, appOutDir)\n }\n\n // Validated once here; throws InvalidConfigurationError for path traversal / NUL.\n const desktopBaseName = this.helper.getDesktopFileName()\n\n if (\n this.packager.packagerOptions.effectiveOptionComputed != null &&\n (await this.packager.packagerOptions.effectiveOptionComputed({ desktop: desktopEntry, desktopFileName: `${desktopBaseName}.desktop` }))\n ) {\n await stageDir.cleanup()\n return\n }\n\n let updateInfo: BlockMapDataHolder\n try {\n const appimageTool = this.packager.config.toolsets?.appimage\n const appDirCopyOptions = await getStagingCopyLinkOptions(packager)\n if (appimageTool === \"0.0.0\") {\n updateInfo = await buildLegacyFuse2AppImage(\n {\n appDir: appOutDir,\n appDirCopyOptions,\n stageDir: stageDir.dir,\n arch,\n output: artifactPath,\n options: {\n productName: packager.appInfo.productName,\n productFilename: packager.appInfo.productFilename,\n executableName: packager.executableName,\n executableArgs: this.launcherArgs,\n license,\n desktopEntry,\n icons,\n fileAssociations: packager.fileAssociations,\n desktopBaseName,\n compression: (() => {\n const c = options.compression\n if (c === \"xz\" || c === \"gzip\") {\n return c\n }\n if (packager.compression === \"maximum\") {\n return \"xz\"\n }\n return undefined // normal/store/unset/zstd → mksquashfs defaults to gzip\n })(),\n },\n },\n packager.buildResourcesDir\n )\n } else {\n updateInfo = await buildStaticRuntimeAppImage(\n appimageTool,\n {\n appDir: appOutDir,\n appDirCopyOptions,\n stageDir: stageDir.dir,\n arch,\n output: artifactPath,\n options: {\n productName: packager.appInfo.productName,\n productFilename: packager.appInfo.productFilename,\n executableName: packager.executableName,\n executableArgs: this.launcherArgs,\n license,\n desktopEntry,\n icons,\n fileAssociations: packager.fileAssociations,\n desktopBaseName,\n compression: (() => {\n const c = options.compression\n if (c === \"gzip\" || c === \"zstd\") {\n return c\n }\n if (c === \"xz\") {\n return \"zstd\" // nearest equivalent; static runtime does not support xz\n }\n if (packager.compression === \"store\") {\n return \"gzip\"\n }\n return \"zstd\" // maximum/normal/unset → zstd for static runtime\n })(),\n },\n },\n packager.buildResourcesDir\n )\n }\n } catch (error: any) {\n log.error({ error: error.message }, \"failed to build AppImage\")\n throw error\n } finally {\n await stageDir.cleanup().catch(() => {})\n }\n\n await packager.emitArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"AppImage\", arch, false),\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: true,\n updateInfo,\n })\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Arch } from "builder-util";
1
+ import { Arch, CopyDirOptions } from "builder-util";
2
2
  import { FileAssociation } from "../../../options/FileAssociation.js";
3
3
  import { BlockMapDataHolder } from "builder-util-runtime";
4
4
  import { ToolsetConfig } from "../../../configuration.js";
@@ -32,6 +32,8 @@ export interface AppImageBuilderOptions {
32
32
  arch: Arch;
33
33
  output: string;
34
34
  options: Options;
35
+ /** How the copy of `appDir` into the stage treats the symlinks in it (see `getStagingCopyLinkOptions`). */
36
+ appDirCopyOptions?: Pick<CopyDirOptions, "allowedSymlinkRoots" | "externalLinks"> | null;
35
37
  }
36
38
  export declare function buildStaticRuntimeAppImage(appimageToolVersion: ToolsetConfig["appimage"], opts: AppImageBuilderOptions, resourcesDir: string): Promise<BlockMapDataHolder>;
37
39
  export declare function buildLegacyFuse2AppImage(opts: AppImageBuilderOptions, resourcesDir: string): Promise<BlockMapDataHolder>;
@@ -1 +1 @@
1
- {"version":3,"file":"appImageUtil.d.ts","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appImageUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmE,MAAM,cAAc,CAAA;AAGpG,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAKrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AAEzD,UAAU,OAAO;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,6FAA6F;IAC7F,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACtC,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,gBAAgB,EAAE,eAAe,EAAE,CAAA;IACnC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IACpC,sGAAsG;IACtG,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,wBAAsB,0BAA0B,CAAC,mBAAmB,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,YAAY,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CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,wFAAwF;IACxF,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,oBAAoB,CAAA;AAMlE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAoKjE"}
@@ -16,7 +16,7 @@ export async function buildStaticRuntimeAppImage(appimageToolVersion, opts, reso
16
16
  await copyDir(libraries, path.join(stageDir, "usr", "lib"));
17
17
  // Copy app directory to stage
18
18
  // mksquashfs doesn't support merging, so we copy the entire app dir
19
- await copyDir(appDir, stageDir);
19
+ await copyDir(appDir, stageDir, opts.appDirCopyOptions ?? undefined);
20
20
  const runtimeData = await fs.readFile(runtime);
21
21
  // Create squashfs with offset for runtime
22
22
  const args = [stageDir, output, "-offset", runtimeData.length.toString(), "-all-root", "-noappend", "-no-progress", "-quiet", "-no-xattrs", "-no-fragments"];
@@ -51,7 +51,7 @@ export async function buildLegacyFuse2AppImage(opts, resourcesDir) {
51
51
  if (arch === Arch.x64 || arch === Arch.ia32) {
52
52
  await copyDir(runtimeLibraries, path.join(stageDir, "usr", "lib"));
53
53
  }
54
- await copyDir(appDir, stageDir);
54
+ await copyDir(appDir, stageDir, opts.appDirCopyOptions ?? undefined);
55
55
  const runtimeData = await fs.readFile(runtime);
56
56
  const args = [stageDir, output, "-offset", runtimeData.length.toString(), "-all-root", "-noappend", "-no-progress", "-quiet", "-no-xattrs", "-no-fragments"];
57
57
  if (options.compression) {
@@ -1 +1 @@
1
- {"version":3,"file":"appImageUtil.js","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appImageUtil.ts"],"names":[],"mappings":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;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, 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}\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)\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)\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;AACh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,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,4 +1,10 @@
1
+ import { FileAssociation } from "../../../options/FileAssociation.js";
1
2
  import { AppImageBuilderOptions } from "./appImageUtil.js";
2
3
  export declare function copyIcons(options: AppImageBuilderOptions): Promise<void>;
4
+ /**
5
+ * The shared-mime-info XML that declares the MIME types of the file associations that have one, or null when none has. Every value
6
+ * is XML-escaped, and an extension with characters other than `A-Za-z0-9_-` is skipped with a warning.
7
+ */
8
+ export declare function generateMimeTypeXml(fileAssociations: ReadonlyArray<FileAssociation>, productName: string): string | null;
3
9
  export declare function copyMimeTypes(stageDir: string, options: Pick<AppImageBuilderOptions["options"], "fileAssociations" | "productName" | "executableName">): Promise<string | null>;
4
10
  //# sourceMappingURL=appLauncher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"appLauncher.d.ts","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appLauncher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAK1D,wBAAsB,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2C9E;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,kBAAkB,GAAG,aAAa,GAAG,gBAAgB,CAAC,GACtG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuDxB"}
1
+ {"version":3,"file":"appLauncher.d.ts","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appLauncher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAK1D,wBAAsB,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2C9E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkCxH;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,kBAAkB,GAAG,aAAa,GAAG,gBAAgB,CAAC,GACtG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBxB"}
@@ -40,14 +40,11 @@ export async function copyIcons(options) {
40
40
  await fs.symlink(iconRelativeToStageFile, path.join(stageDir, iconFileName));
41
41
  await fs.symlink(iconRelativeToStageFile, path.join(stageDir, ".DirIcon"));
42
42
  }
43
- export async function copyMimeTypes(stageDir, options) {
44
- const { fileAssociations, productName, executableName } = options;
45
- if (!fileAssociations || fileAssociations.length === 0) {
46
- return null;
47
- }
48
- if (!fileAssociations || fileAssociations.length === 0) {
49
- return null;
50
- }
43
+ /**
44
+ * The shared-mime-info XML that declares the MIME types of the file associations that have one, or null when none has. Every value
45
+ * is XML-escaped, and an extension with characters other than `A-Za-z0-9_-` is skipped with a warning.
46
+ */
47
+ export function generateMimeTypeXml(fileAssociations, productName) {
51
48
  const mimeTypeParts = [];
52
49
  for (const fileAssociation of fileAssociations) {
53
50
  if (!fileAssociation.mimeType) {
@@ -73,11 +70,18 @@ export async function copyMimeTypes(stageDir, options) {
73
70
  if (mimeTypeParts.length === 0) {
74
71
  return null;
75
72
  }
73
+ return ['<?xml version="1.0"?>', '<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">', ...mimeTypeParts, "</mime-info>"].join("\n");
74
+ }
75
+ export async function copyMimeTypes(stageDir, options) {
76
+ const { fileAssociations, productName, executableName } = options;
77
+ const xmlContent = generateMimeTypeXml(fileAssociations ?? [], productName);
78
+ if (xmlContent == null) {
79
+ return null;
80
+ }
76
81
  const mimeTypeDir = path.join(stageDir, MIME_TYPE_DIR_RELATIVE_PATH);
77
82
  const fileName = `${executableName}.xml`;
78
83
  const mimeTypeFile = path.join(mimeTypeDir, fileName);
79
84
  await fs.ensureDir(mimeTypeDir);
80
- const xmlContent = ['<?xml version="1.0"?>', '<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">', ...mimeTypeParts, "</mime-info>"].join("\n");
81
85
  // Use 0o644 (rw-r--r--) instead of 0o666 to avoid world-writable permissions
82
86
  await fs.writeFile(mimeTypeFile, xmlContent, { mode: 0o644 });
83
87
  return path.join(MIME_TYPE_DIR_RELATIVE_PATH, fileName);
@@ -1 +1 @@
1
- {"version":3,"file":"appLauncher.js","source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AC,cAAc,CAAC,CAAA;IACpC,CAAC;IAED,+CAA+C;IAC/C,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAA;IACpE,MAAM,QAAQ,GAAG,GAAG,cAAc,MAAM,CAAA;IACxC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IAErD,MAAM,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IAE/B,MAAM,UAAU,GAAG,CAAC,uBAAuB,EAAE,2EAA2E,EAAE,GAAG,aAAa,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEtK,6EAA6E;IAC7E,MAAM,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAE7D,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import path from \"path\"\nimport fs from \"fs-extra\"\nimport { copyOrLinkFile, log, escapeForXml } from \"builder-util\"\nimport { AppImageBuilderOptions } from \"./appImageUtil.js\"\n\nconst ICON_DIR_RELATIVE_PATH = \"usr/share/icons/hicolor\"\nconst MIME_TYPE_DIR_RELATIVE_PATH = \"usr/share/mime/packages\"\n\nexport async function copyIcons(options: AppImageBuilderOptions): Promise<void> {\n const { stageDir, options: configuration } = options\n const iconCommonDir = path.join(stageDir, ICON_DIR_RELATIVE_PATH)\n\n await fs.ensureDir(iconCommonDir)\n\n const icons = configuration.icons\n if (!icons || icons.length === 0) {\n throw new Error(\"At least one icon is required for AppImage\")\n }\n\n const iconExtWithDot = path.extname(icons[0].file)\n const iconFileName = `${configuration.executableName}${iconExtWithDot}`\n const maxIconIndex = icons.length - 1\n\n const iconInfoList = icons.map(icon => {\n if (path.extname(icon.file) !== iconExtWithDot) {\n throw new Error(`All icons must have the same extension: expected ${iconExtWithDot}, but got ${icon.file}`)\n }\n let iconSizeDir: string\n\n if (iconExtWithDot === \".svg\") {\n // SVG icons go in scalable/apps directory per freedesktop icon theme spec\n iconSizeDir = \"scalable/apps\"\n } else {\n iconSizeDir = `${icon.size}x${icon.size}/apps`\n }\n\n const iconRelativeToStageFile = path.join(ICON_DIR_RELATIVE_PATH, iconSizeDir, iconFileName)\n const iconDir = path.join(iconCommonDir, iconSizeDir)\n const iconFile = path.join(iconDir, iconFileName)\n return { icon, iconDir, iconFile, iconRelativeToStageFile }\n })\n await Promise.all(\n iconInfoList.map(async ({ icon, iconDir, iconFile }) => {\n await fs.ensureDir(iconDir)\n await copyOrLinkFile(icon.file, iconFile)\n })\n )\n // Create symlinks for the last (largest) icon\n const { iconRelativeToStageFile } = iconInfoList[maxIconIndex]\n await fs.symlink(iconRelativeToStageFile, path.join(stageDir, iconFileName))\n await fs.symlink(iconRelativeToStageFile, path.join(stageDir, \".DirIcon\"))\n}\n\nexport async function copyMimeTypes(\n stageDir: string,\n options: Pick<AppImageBuilderOptions[\"options\"], \"fileAssociations\" | \"productName\" | \"executableName\">\n): Promise<string | null> {\n const { fileAssociations, productName, executableName } = options\n\n if (!fileAssociations || fileAssociations.length === 0) {\n return null\n }\n\n if (!fileAssociations || fileAssociations.length === 0) {\n return null\n }\n\n const mimeTypeParts: string[] = []\n\n for (const fileAssociation of fileAssociations) {\n if (!fileAssociation.mimeType) {\n continue\n }\n\n // XML-escape to prevent injection\n mimeTypeParts.push(`<mime-type type=\"${escapeForXml(fileAssociation.mimeType)}\">`)\n mimeTypeParts.push(` <comment>${escapeForXml(productName)} document</comment>`)\n\n // Handle extension(s)\n const extensions = Array.isArray(fileAssociation.ext) ? fileAssociation.ext : [fileAssociation.ext]\n\n for (const ext of extensions) {\n // Validate extension doesn't contain dangerous characters\n if (!/^[a-zA-Z0-9_-]+$/.test(ext)) {\n log.warn({ extension: ext }, `file extension contains unexpected characters and will be skipped`)\n continue\n }\n mimeTypeParts.push(` <glob pattern=\"*.${escapeForXml(ext)}\"/>`)\n }\n\n mimeTypeParts.push(' <generic-icon name=\"x-office-document\"/>')\n mimeTypeParts.push(\"</mime-type>\")\n }\n\n // If no mime-types were generated, return null\n if (mimeTypeParts.length === 0) {\n return null\n }\n\n const mimeTypeDir = path.join(stageDir, MIME_TYPE_DIR_RELATIVE_PATH)\n const fileName = `${executableName}.xml`\n const mimeTypeFile = path.join(mimeTypeDir, fileName)\n\n await fs.ensureDir(mimeTypeDir)\n\n const xmlContent = ['<?xml version=\"1.0\"?>', '<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">', ...mimeTypeParts, \"</mime-info>\"].join(\"\\n\")\n\n // Use 0o644 (rw-r--r--) instead of 0o666 to avoid world-writable permissions\n await fs.writeFile(mimeTypeFile, xmlContent, { mode: 0o644 })\n\n return path.join(MIME_TYPE_DIR_RELATIVE_PATH, fileName)\n}\n"]}
1
+ {"version":3,"file":"appLauncher.js","sourceRoot":"","sources":["../../../../src/targets/linux/appimage/appLauncher.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAIhE,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AACxD,MAAM,2BAA2B,GAAG,yBAAyB,CAAA;AAE7D,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAA+B;IAC7D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,CAAA;IACpD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAA;IAEjE,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC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,6EAA6E;IAC7E,MAAM,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAE7D,OAAO,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,CAAA;AACzD,CAAC","sourcesContent":["import path from \"path\"\nimport fs from \"fs-extra\"\nimport { copyOrLinkFile, log, escapeForXml } from \"builder-util\"\nimport { FileAssociation } from \"../../../options/FileAssociation.js\"\nimport { AppImageBuilderOptions } from \"./appImageUtil.js\"\n\nconst ICON_DIR_RELATIVE_PATH = \"usr/share/icons/hicolor\"\nconst MIME_TYPE_DIR_RELATIVE_PATH = \"usr/share/mime/packages\"\n\nexport async function copyIcons(options: AppImageBuilderOptions): Promise<void> {\n const { stageDir, options: configuration } = options\n const iconCommonDir = path.join(stageDir, ICON_DIR_RELATIVE_PATH)\n\n await fs.ensureDir(iconCommonDir)\n\n const icons = configuration.icons\n if (!icons || icons.length === 0) {\n throw new Error(\"At least one icon is required for AppImage\")\n }\n\n const iconExtWithDot = path.extname(icons[0].file)\n const iconFileName = `${configuration.executableName}${iconExtWithDot}`\n const maxIconIndex = icons.length - 1\n\n const iconInfoList = icons.map(icon => {\n if (path.extname(icon.file) !== iconExtWithDot) {\n throw new Error(`All icons must have the same extension: expected ${iconExtWithDot}, but got ${icon.file}`)\n }\n let iconSizeDir: string\n\n if (iconExtWithDot === \".svg\") {\n // SVG icons go in scalable/apps directory per freedesktop icon theme spec\n iconSizeDir = \"scalable/apps\"\n } else {\n iconSizeDir = `${icon.size}x${icon.size}/apps`\n }\n\n const iconRelativeToStageFile = path.join(ICON_DIR_RELATIVE_PATH, iconSizeDir, iconFileName)\n const iconDir = path.join(iconCommonDir, iconSizeDir)\n const iconFile = path.join(iconDir, iconFileName)\n return { icon, iconDir, iconFile, iconRelativeToStageFile }\n })\n await Promise.all(\n iconInfoList.map(async ({ icon, iconDir, iconFile }) => {\n await fs.ensureDir(iconDir)\n await copyOrLinkFile(icon.file, iconFile)\n })\n )\n // Create symlinks for the last (largest) icon\n const { iconRelativeToStageFile } = iconInfoList[maxIconIndex]\n await fs.symlink(iconRelativeToStageFile, path.join(stageDir, iconFileName))\n await fs.symlink(iconRelativeToStageFile, path.join(stageDir, \".DirIcon\"))\n}\n\n/**\n * The shared-mime-info XML that declares the MIME types of the file associations that have one, or null when none has. Every value\n * is XML-escaped, and an extension with characters other than `A-Za-z0-9_-` is skipped with a warning.\n */\nexport function generateMimeTypeXml(fileAssociations: ReadonlyArray<FileAssociation>, productName: string): string | null {\n const mimeTypeParts: string[] = []\n\n for (const fileAssociation of fileAssociations) {\n if (!fileAssociation.mimeType) {\n continue\n }\n\n // XML-escape to prevent injection\n mimeTypeParts.push(`<mime-type type=\"${escapeForXml(fileAssociation.mimeType)}\">`)\n mimeTypeParts.push(` <comment>${escapeForXml(productName)} document</comment>`)\n\n // Handle extension(s)\n const extensions = Array.isArray(fileAssociation.ext) ? fileAssociation.ext : [fileAssociation.ext]\n\n for (const ext of extensions) {\n // Validate extension doesn't contain dangerous characters\n if (!/^[a-zA-Z0-9_-]+$/.test(ext)) {\n log.warn({ extension: ext }, `file extension contains unexpected characters and will be skipped`)\n continue\n }\n mimeTypeParts.push(` <glob pattern=\"*.${escapeForXml(ext)}\"/>`)\n }\n\n mimeTypeParts.push(' <generic-icon name=\"x-office-document\"/>')\n mimeTypeParts.push(\"</mime-type>\")\n }\n\n // If no mime-types were generated, return null\n if (mimeTypeParts.length === 0) {\n return null\n }\n\n return ['<?xml version=\"1.0\"?>', '<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">', ...mimeTypeParts, \"</mime-info>\"].join(\"\\n\")\n}\n\nexport async function copyMimeTypes(\n stageDir: string,\n options: Pick<AppImageBuilderOptions[\"options\"], \"fileAssociations\" | \"productName\" | \"executableName\">\n): Promise<string | null> {\n const { fileAssociations, productName, executableName } = options\n\n const xmlContent = generateMimeTypeXml(fileAssociations ?? [], productName)\n if (xmlContent == null) {\n return null\n }\n\n const mimeTypeDir = path.join(stageDir, MIME_TYPE_DIR_RELATIVE_PATH)\n const fileName = `${executableName}.xml`\n const mimeTypeFile = path.join(mimeTypeDir, fileName)\n\n await fs.ensureDir(mimeTypeDir)\n\n // Use 0o644 (rw-r--r--) instead of 0o666 to avoid world-writable permissions\n await fs.writeFile(mimeTypeFile, xmlContent, { mode: 0o644 })\n\n return path.join(MIME_TYPE_DIR_RELATIVE_PATH, fileName)\n}\n"]}
@@ -0,0 +1,43 @@
1
+ /** 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. */
2
+ export interface FlatpakBuilderManifest {
3
+ id: string;
4
+ command: string;
5
+ runtime: string;
6
+ "runtime-version": string;
7
+ sdk: string;
8
+ base: string;
9
+ "base-version": string;
10
+ "finish-args": string[];
11
+ branch?: string;
12
+ modules?: (string | any)[];
13
+ }
14
+ /** The refs a build needs: the runtime, the SDK and the base app of the manifest. */
15
+ export type FlatpakRefKind = "runtime" | "sdk" | "base";
16
+ export interface FlatpakBundleOptions {
17
+ manifest: FlatpakBuilderManifest;
18
+ /** flatpak's name for the target architecture, e.g. `x86_64` */
19
+ arch: string;
20
+ /** where to write the single-file bundle */
21
+ artifactPath: string;
22
+ /** an empty directory for the manifest, the app directory, the repository and the state of flatpak-builder */
23
+ tempDir: string;
24
+ /** `[source, destination]` pairs, copied in order; a destination is relative to the app prefix (`/app` in the sandbox) */
25
+ files: [string, string][];
26
+ /** `[target, link]` pairs, both relative to the app prefix */
27
+ symlinks: [string, string][];
28
+ /** the refs to install when they are missing and update when they are installed; the others are used as installed, and have to be */
29
+ installOrUpdateRefs: ReadonlyArray<FlatpakRefKind>;
30
+ /** added to both runs of flatpak-builder */
31
+ flatpakBuilderArgs: string[];
32
+ buildExportArgs: string[];
33
+ buildBundleArgs: string[];
34
+ }
35
+ /**
36
+ * Builds a single-file flatpak bundle out of files that are already built.
37
+ *
38
+ * flatpak-builder runs twice. `--build-only` creates the app directory from the base app (and builds the modules of the
39
+ * manifest, if any) and stops, the files are then placed into the app prefix, and `--finish-only` turns the directory into an
40
+ * app with the permissions of the manifest. Nothing has to run inside the build sandbox to get the files in.
41
+ */
42
+ export declare function buildFlatpakBundle(options: FlatpakBundleOptions): Promise<void>;
43
+ //# sourceMappingURL=flatpakBundle.d.ts.map
@@ -0,0 +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,8DAA8D;IAC9D,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;AAiID;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoGrF"}
@@ -0,0 +1,210 @@
1
+ import { exec, InvalidConfigurationError, log } from "builder-util";
2
+ import { cp, mkdir, realpath, symlink, writeFile } from "fs/promises";
3
+ import * as path from "path";
4
+ import * as semver from "semver";
5
+ import { BREAKING_CHANGES_URL } from "../../util/config/legacyOptions.js";
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
+ // CVE-2022-21682 with an option that flatpak supports from 1.12.4 on; Ubuntu 22.04 has flatpak 1.12.7
8
+ const MIN_VERSIONS = { flatpak: "1.12.4", "flatpak-builder": "1.2.2" };
9
+ // the freedesktop SDK 24.08 and newer recommend it for meson and cmake modules
10
+ const MODULES_FLATPAK_BUILDER_VERSION = "1.4.4";
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`;
13
+ const FLATPAK_DOCS = "https://www.electron.build/docs/flatpak";
14
+ const UNPRIVILEGED_CONTAINERS_DOCS = `${FLATPAK_DOCS}#building-in-unprivileged-containers`;
15
+ /**
16
+ * 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
17
+ * contains. The error is rethrown as is: `exec` has already put the output of the tool in it.
18
+ */
19
+ function hintOn(...hints) {
20
+ return (e) => {
21
+ const hint = hints.find(([marker]) => e.message.includes(marker));
22
+ if (hint != null) {
23
+ log.error(null, hint[1]);
24
+ }
25
+ throw e;
26
+ };
27
+ }
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) {
30
+ let stdout;
31
+ try {
32
+ stdout = await exec(tool, ["--version"], { cwd });
33
+ }
34
+ catch (e) {
35
+ log.error({ error: e.message }, `cannot run ${tool}`);
36
+ throw new InvalidConfigurationError(`cannot run ${tool} - flatpak and flatpak-builder must be installed to build the flatpak target`);
37
+ }
38
+ log.info({ version: stdout.trim() }, `${tool} found`);
39
+ // 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
40
+ const version = semver.coerce(stdout);
41
+ if (version != null && semver.lt(version, MIN_VERSIONS[tool])) {
42
+ throw new InvalidConfigurationError(`${tool} ${version.version} is not supported - version ${MIN_VERSIONS[tool]} or newer is required to build the flatpak target. ${NEW_IN_V27}`);
43
+ }
44
+ return version;
45
+ }
46
+ function isInside(dir, file) {
47
+ const relative = path.relative(dir, file);
48
+ return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
49
+ }
50
+ /**
51
+ * Where a path given relative to the app prefix lands in the build directory. One that leaves the prefix is refused: the copy or
52
+ * the link would be written elsewhere on the build machine, such as over the metadata of the build directory.
53
+ */
54
+ function inAppPrefix(prefix, relativePath, what) {
55
+ const resolved = path.join(prefix, relativePath);
56
+ if (!isInside(prefix, resolved)) {
57
+ 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}`);
58
+ }
59
+ return resolved;
60
+ }
61
+ /**
62
+ * Refuses to write `file` when a symlink takes its directory out of the app prefix, which inAppPrefix cannot see: the base app, the
63
+ * modules and an earlier flatpak.files pair put files into the prefix that are not checked, and a link among them, such as
64
+ * `lib -> ../..` or `lib -> /home`, would make the copy or the link land elsewhere on the build machine. Only the directory is
65
+ * resolved: what is at `file` itself is replaced, not followed, by both cp and symlink.
66
+ */
67
+ async function requireDirectoryInAppPrefix(prefix, realPrefix, file, what) {
68
+ const relative = path.relative(prefix, file);
69
+ if (relative === "") {
70
+ // the prefix itself, which a directory is merged into
71
+ return;
72
+ }
73
+ // the deepest directory that exists, since what is still to be created cannot be a link. A link that leads nowhere is passed over
74
+ // as well: mkdir and cp fail on it rather than create anything through it
75
+ let existing = path.dirname(file);
76
+ let resolved = null;
77
+ while (resolved == null) {
78
+ try {
79
+ resolved = await realpath(existing);
80
+ }
81
+ catch (e) {
82
+ // ENOTDIR: a file of an earlier pair is in the way, which the copy or mkdir reports itself
83
+ if ((e.code !== "ENOENT" && e.code !== "ENOTDIR") || existing === path.dirname(existing)) {
84
+ throw e;
85
+ }
86
+ existing = path.dirname(existing);
87
+ }
88
+ }
89
+ if (!isInside(realPrefix, resolved)) {
90
+ const shown = `/${relative.split(path.sep).join("/")}`;
91
+ throw new InvalidConfigurationError(`${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}`);
92
+ }
93
+ }
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);
97
+ const [inUser, inSystem] = await Promise.all([isInstalled("--user"), isInstalled("--system")]);
98
+ return { inUser, inSystem };
99
+ }
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);
103
+ if (inUser || inSystem) {
104
+ await exec("flatpak", ["update", ...(inUser ? ["--user"] : []), "--no-deps", "--noninteractive", ref], { cwd });
105
+ return;
106
+ }
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([
109
+ "No remote refs found",
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
+ ]));
112
+ }
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);
116
+ if (!inUser && !inSystem) {
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
+ }
119
+ log.info({ ref }, "flatpak ref is used as installed, without an update");
120
+ }
121
+ /**
122
+ * Builds a single-file flatpak bundle out of files that are already built.
123
+ *
124
+ * flatpak-builder runs twice. `--build-only` creates the app directory from the base app (and builds the modules of the
125
+ * manifest, if any) and stops, the files are then placed into the app prefix, and `--finish-only` turns the directory into an
126
+ * app with the permissions of the manifest. Nothing has to run inside the build sandbox to get the files in.
127
+ */
128
+ export async function buildFlatpakBundle(options) {
129
+ const { manifest, arch, tempDir: cwd } = options;
130
+ const manifestFile = path.join(cwd, "manifest.json");
131
+ const appDir = path.join(cwd, "build");
132
+ const prefix = path.join(appDir, "files");
133
+ const repo = path.join(cwd, "repo");
134
+ const branch = manifest.branch ? [manifest.branch] : [];
135
+ // checked before anything is installed or built
136
+ const copies = options.files.map(([source, destination]) => [source, inAppPrefix(prefix, destination, "flatpak.files destination")]);
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);
140
+ // 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
+ // the zero-padded minor of "22.08"
142
+ const sdkVersion = manifest.sdk === "org.freedesktop.Sdk" ? semver.coerce(manifest["runtime-version"], { loose: true }) : null;
143
+ const isOldFreedesktopSdk = sdkVersion != null && semver.lt(sdkVersion, MODULES_FREEDESKTOP_SDK_VERSION);
144
+ if ((manifest.modules?.length ?? 0) > 0 && builderVersion != null && semver.lt(builderVersion, MODULES_FLATPAK_BUILDER_VERSION) && !isOldFreedesktopSdk) {
145
+ // once per process: every arch is built with the same flatpak-builder
146
+ log
147
+ .once("flatpak-builder-modules-version")
148
+ .warn({ flatpakBuilder: builderVersion.version, recommended: MODULES_FLATPAK_BUILDER_VERSION }, `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`);
149
+ }
150
+ // the sdk has the version of the runtime
151
+ const refs = [
152
+ ["runtime", `runtime/${manifest.runtime}/${arch}/${manifest["runtime-version"]}`],
153
+ ["sdk", `runtime/${manifest.sdk}/${arch}/${manifest["runtime-version"]}`],
154
+ ["base", `app/${manifest.base}/${arch}/${manifest["base-version"]}`],
155
+ ];
156
+ // the refs to use as installed are checked first, so that a missing one fails the build before anything is downloaded
157
+ const toInstallOrUpdate = refs.filter(([kind]) => options.installOrUpdateRefs.includes(kind));
158
+ for (const [kind, ref] of refs.filter(it => !toInstallOrUpdate.includes(it))) {
159
+ await requireInstalledRef(kind, ref, cwd);
160
+ }
161
+ for (const [, ref] of toInstallOrUpdate) {
162
+ await installOrUpdateRef(ref, cwd);
163
+ }
164
+ await writeFile(manifestFile, JSON.stringify(manifest, null, 2));
165
+ // flatpak-builder downloads the sources of the modules, and git or curl may need credentials from the environment for that. Without
166
+ // modules it fetches nothing, so it gets the environment that exec filters for every other command
167
+ 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([
169
+ "Failure spawning rofiles-fuse",
170
+ `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
+ ],
172
+ // rofiles-fuse started, but could not mount the app directory, so flatpak-builder finds it empty
173
+ [
174
+ `Command '${manifest.command}' not found`,
175
+ `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}`,
176
+ ],
177
+ // flatpak-builder before 1.4 composes AppStream metadata with appstream-compose, which the freedesktop SDK 24.08 and newer do
178
+ // not ship; it runs only when the app has a metainfo or appdata file named after its id
179
+ [
180
+ "execvp appstream-compose",
181
+ `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`,
182
+ ]));
183
+ await runFlatpakBuilder("--build-only");
184
+ // flatpak-builder has created it, and the paths that the links in it lead to are compared with the one it resolves to
185
+ const realPrefix = await realpath(prefix);
186
+ // 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
187
+ // destination itself, before it is written or its parent directory created; a symlink in the copied directory is still kept as it is
188
+ const filter = async (_source, file) => {
189
+ await requireDirectoryInAppPrefix(prefix, realPrefix, file, "flatpak.files destination");
190
+ return true;
191
+ };
192
+ for (const [source, destination] of copies) {
193
+ await cp(source, destination, { recursive: true, verbatimSymlinks: true, filter });
194
+ }
195
+ for (const [target, linkPath] of links) {
196
+ // before mkdir, which would create the missing directories wherever a link leads
197
+ await requireDirectoryInAppPrefix(prefix, realPrefix, linkPath, "flatpak.symlinks link");
198
+ await mkdir(path.dirname(linkPath), { recursive: true });
199
+ // resolved in the sandbox, where the prefix is mounted at /app
200
+ await symlink(path.posix.join("/app", target), linkPath);
201
+ }
202
+ await runFlatpakBuilder("--finish-only");
203
+ await exec("flatpak", ["build-export", "--arch", arch, ...options.buildExportArgs, repo, appDir, ...branch], { cwd }).catch(hintOn([
204
+ "bwrap: ",
205
+ `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
+ ]));
207
+ 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 });
209
+ }
210
+ //# sourceMappingURL=flatpakBundle.js.map