linuxPackager.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.toAppImageOrSnapArch = exports.LinuxPackager = void 0;
  4. const builder_util_1 = require("builder-util");
  5. const core_1 = require("./core");
  6. const platformPackager_1 = require("./platformPackager");
  7. const LinuxTargetHelper_1 = require("./targets/LinuxTargetHelper");
  8. const targetFactory_1 = require("./targets/targetFactory");
  9. const filename_1 = require("./util/filename");
  10. class LinuxPackager extends platformPackager_1.PlatformPackager {
  11. constructor(info) {
  12. super(info, core_1.Platform.LINUX);
  13. const executableName = this.platformSpecificBuildOptions.executableName;
  14. this.executableName = executableName == null ? this.appInfo.sanitizedName.toLowerCase() : (0, filename_1.sanitizeFileName)(executableName);
  15. }
  16. get defaultTarget() {
  17. return ["snap", "appimage"];
  18. }
  19. createTargets(targets, mapper) {
  20. let helper;
  21. const getHelper = () => {
  22. if (helper == null) {
  23. helper = new LinuxTargetHelper_1.LinuxTargetHelper(this);
  24. }
  25. return helper;
  26. };
  27. for (const name of targets) {
  28. if (name === core_1.DIR_TARGET) {
  29. continue;
  30. }
  31. const targetClass = (() => {
  32. switch (name) {
  33. case "appimage":
  34. return require("./targets/AppImageTarget").default;
  35. case "snap":
  36. return require("./targets/snap").default;
  37. case "flatpak":
  38. return require("./targets/FlatpakTarget").default;
  39. case "deb":
  40. case "rpm":
  41. case "sh":
  42. case "freebsd":
  43. case "pacman":
  44. case "apk":
  45. case "p5p":
  46. return require("./targets/FpmTarget").default;
  47. default:
  48. return null;
  49. }
  50. })();
  51. mapper(name, outDir => {
  52. if (targetClass === null) {
  53. return (0, targetFactory_1.createCommonTarget)(name, outDir, this);
  54. }
  55. return new targetClass(name, this, getHelper(), outDir);
  56. });
  57. }
  58. }
  59. }
  60. exports.LinuxPackager = LinuxPackager;
  61. function toAppImageOrSnapArch(arch) {
  62. switch (arch) {
  63. case builder_util_1.Arch.x64:
  64. return "x86_64";
  65. case builder_util_1.Arch.ia32:
  66. return "i386";
  67. case builder_util_1.Arch.armv7l:
  68. return "arm";
  69. case builder_util_1.Arch.arm64:
  70. return "arm_aarch64";
  71. default:
  72. throw new Error(`Unsupported arch ${arch}`);
  73. }
  74. }
  75. exports.toAppImageOrSnapArch = toAppImageOrSnapArch;
  76. //# sourceMappingURL=linuxPackager.js.map