1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _bluebirdLst() {
|
9 | const data = require("bluebird-lst");
|
10 |
|
11 | _bluebirdLst = function () {
|
12 | return data;
|
13 | };
|
14 |
|
15 | return data;
|
16 | }
|
17 |
|
18 | function _zipBin() {
|
19 | const data = require("7zip-bin");
|
20 |
|
21 | _zipBin = function () {
|
22 | return data;
|
23 | };
|
24 |
|
25 | return data;
|
26 | }
|
27 |
|
28 | function _appBuilderBin() {
|
29 | const data = require("app-builder-bin");
|
30 |
|
31 | _appBuilderBin = function () {
|
32 | return data;
|
33 | };
|
34 |
|
35 | return data;
|
36 | }
|
37 |
|
38 | function _builderUtil() {
|
39 | const data = require("builder-util");
|
40 |
|
41 | _builderUtil = function () {
|
42 | return data;
|
43 | };
|
44 |
|
45 | return data;
|
46 | }
|
47 |
|
48 | function _bundledTool() {
|
49 | const data = require("builder-util/out/bundledTool");
|
50 |
|
51 | _bundledTool = function () {
|
52 | return data;
|
53 | };
|
54 |
|
55 | return data;
|
56 | }
|
57 |
|
58 | function _fs() {
|
59 | const data = require("builder-util/out/fs");
|
60 |
|
61 | _fs = function () {
|
62 | return data;
|
63 | };
|
64 |
|
65 | return data;
|
66 | }
|
67 |
|
68 | function _fsExtraP() {
|
69 | const data = require("fs-extra-p");
|
70 |
|
71 | _fsExtraP = function () {
|
72 | return data;
|
73 | };
|
74 |
|
75 | return data;
|
76 | }
|
77 |
|
78 | var path = _interopRequireWildcard(require("path"));
|
79 |
|
80 | function _core() {
|
81 | const data = require("../core");
|
82 |
|
83 | _core = function () {
|
84 | return data;
|
85 | };
|
86 |
|
87 | return data;
|
88 | }
|
89 |
|
90 | function errorMessages() {
|
91 | const data = _interopRequireWildcard(require("../errorMessages"));
|
92 |
|
93 | errorMessages = function () {
|
94 | return data;
|
95 | };
|
96 |
|
97 | return data;
|
98 | }
|
99 |
|
100 | function _pathManager() {
|
101 | const data = require("../util/pathManager");
|
102 |
|
103 | _pathManager = function () {
|
104 | return data;
|
105 | };
|
106 |
|
107 | return data;
|
108 | }
|
109 |
|
110 | function _LinuxTargetHelper() {
|
111 | const data = require("./LinuxTargetHelper");
|
112 |
|
113 | _LinuxTargetHelper = function () {
|
114 | return data;
|
115 | };
|
116 |
|
117 | return data;
|
118 | }
|
119 |
|
120 | function _tools() {
|
121 | const data = require("./tools");
|
122 |
|
123 | _tools = function () {
|
124 | return data;
|
125 | };
|
126 |
|
127 | return data;
|
128 | }
|
129 |
|
130 | let writeConfigFile = (() => {
|
131 | var _ref = (0, _bluebirdLst().coroutine)(function* (tmpDir, templatePath, options) {
|
132 |
|
133 | function replacer(match, p1) {
|
134 | if (p1 in options) {
|
135 | return options[p1];
|
136 | } else {
|
137 | throw new Error(`Macro ${p1} is not defined`);
|
138 | }
|
139 | }
|
140 |
|
141 | const config = (yield (0, _fsExtraP().readFile)(templatePath, "utf8")).replace(/\${([a-zA-Z]+)}/g, replacer).replace(/<%=([a-zA-Z]+)%>/g, (match, p1) => {
|
142 | _builderUtil().log.warn("<%= varName %> is deprecated, please use ${varName} instead");
|
143 |
|
144 | return replacer(match, p1.trim());
|
145 | });
|
146 | const outputPath = yield tmpDir.getTempFile({
|
147 | suffix: path.basename(templatePath, ".tpl")
|
148 | });
|
149 | yield (0, _fsExtraP().outputFile)(outputPath, config);
|
150 | return outputPath;
|
151 | });
|
152 |
|
153 | return function writeConfigFile(_x, _x2, _x3) {
|
154 | return _ref.apply(this, arguments);
|
155 | };
|
156 | })(); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
157 |
|
158 | class FpmTarget extends _core().Target {
|
159 | constructor(name, packager, helper, outDir) {
|
160 | super(name, false);
|
161 | this.packager = packager;
|
162 | this.helper = helper;
|
163 | this.outDir = outDir;
|
164 | this.options = Object.assign({}, this.packager.platformSpecificBuildOptions, this.packager.config[this.name]);
|
165 | this.scriptFiles = this.createScripts();
|
166 | }
|
167 |
|
168 | createScripts() {
|
169 | var _this = this;
|
170 |
|
171 | return (0, _bluebirdLst().coroutine)(function* () {
|
172 | const defaultTemplatesDir = (0, _pathManager().getTemplatePath)("linux");
|
173 | const packager = _this.packager;
|
174 | const templateOptions = Object.assign({
|
175 |
|
176 | executable: packager.executableName,
|
177 | productFilename: packager.appInfo.productFilename
|
178 | }, packager.platformSpecificBuildOptions);
|
179 |
|
180 | function getResource(value, defaultFile) {
|
181 | if (value == null) {
|
182 | return path.join(defaultTemplatesDir, defaultFile);
|
183 | }
|
184 |
|
185 | return path.resolve(packager.projectDir, value);
|
186 | }
|
187 |
|
188 | return yield Promise.all([writeConfigFile(packager.info.tempDirManager, getResource(_this.options.afterInstall, "after-install.tpl"), templateOptions), writeConfigFile(packager.info.tempDirManager, getResource(_this.options.afterRemove, "after-remove.tpl"), templateOptions)]);
|
189 | })();
|
190 | }
|
191 |
|
192 | checkOptions() {
|
193 | return this.computeFpmMetaInfoOptions();
|
194 | }
|
195 |
|
196 | computeFpmMetaInfoOptions() {
|
197 | var _this2 = this;
|
198 |
|
199 | return (0, _bluebirdLst().coroutine)(function* () {
|
200 | const packager = _this2.packager;
|
201 | const projectUrl = yield packager.appInfo.computePackageUrl();
|
202 | const errors = [];
|
203 |
|
204 | if (projectUrl == null) {
|
205 | errors.push("Please specify project homepage, see https://electron.build/configuration/configuration#Metadata-homepage");
|
206 | }
|
207 |
|
208 | const options = _this2.options;
|
209 | let author = options.maintainer;
|
210 |
|
211 | if (author == null) {
|
212 | const a = packager.info.metadata.author;
|
213 |
|
214 | if (a == null || a.email == null) {
|
215 | errors.push(errorMessages().authorEmailIsMissed);
|
216 | } else {
|
217 | author = `${a.name} <${a.email}>`;
|
218 | }
|
219 | }
|
220 |
|
221 | if (errors.length > 0) {
|
222 | throw new Error(errors.join("\n\n"));
|
223 | }
|
224 |
|
225 | return {
|
226 | maintainer: author,
|
227 | url: projectUrl,
|
228 | vendor: options.vendor || author
|
229 | };
|
230 | })();
|
231 | }
|
232 |
|
233 | build(appOutDir, arch) {
|
234 | var _this3 = this;
|
235 |
|
236 | return (0, _bluebirdLst().coroutine)(function* () {
|
237 | const fpmMetaInfoOptions = yield _this3.computeFpmMetaInfoOptions();
|
238 | const target = _this3.name;
|
239 |
|
240 | let nameFormat = "${name}-${version}-${arch}.${ext}";
|
241 | let isUseArchIfX64 = false;
|
242 |
|
243 | if (target === "deb") {
|
244 | nameFormat = "${name}_${version}_${arch}.${ext}";
|
245 | isUseArchIfX64 = true;
|
246 | } else if (target === "rpm") {
|
247 | nameFormat = "${name}-${version}.${arch}.${ext}";
|
248 | isUseArchIfX64 = true;
|
249 | }
|
250 |
|
251 | const artifactPath = path.join(_this3.outDir, _this3.packager.expandArtifactNamePattern(_this3.options, target, arch, nameFormat, !isUseArchIfX64));
|
252 |
|
253 | _this3.logBuilding(target, artifactPath, arch);
|
254 |
|
255 | yield (0, _fs().unlinkIfExists)(artifactPath);
|
256 |
|
257 | if (_this3.packager.packagerOptions.prepackaged != null) {
|
258 | yield (0, _fsExtraP().ensureDir)(_this3.outDir);
|
259 | }
|
260 |
|
261 | const scripts = yield _this3.scriptFiles;
|
262 | const packager = _this3.packager;
|
263 | const appInfo = packager.appInfo;
|
264 | const options = _this3.options;
|
265 | const synopsis = options.synopsis;
|
266 | const args = ["-s", "dir", "-t", target, "--architecture", target === "pacman" && arch === _builderUtil().Arch.ia32 ? "i686" : (0, _builderUtil().toLinuxArchString)(arch), "--name", appInfo.name, "--force", "--after-install", scripts[0], "--after-remove", scripts[1], "--description", (0, _builderUtil().smarten)(target === "rpm" ? _this3.helper.getDescription(options) : `${synopsis || ""}\n ${_this3.helper.getDescription(options)}`), "--version", appInfo.version, "--package", artifactPath];
|
267 |
|
268 | for (const key of Object.keys(fpmMetaInfoOptions)) {
|
269 | const value = fpmMetaInfoOptions[key];
|
270 |
|
271 | if (value != null) {
|
272 | args.push(`--${key}`, value);
|
273 | }
|
274 | }
|
275 |
|
276 | if (_builderUtil().debug.enabled) {
|
277 | args.push("--log", "debug", "--debug");
|
278 | }
|
279 |
|
280 | const packageCategory = options.packageCategory;
|
281 |
|
282 | if (packageCategory != null && packageCategory !== null) {
|
283 | args.push("--category", packageCategory);
|
284 | }
|
285 |
|
286 | const compression = options.compression;
|
287 |
|
288 | if (target === "deb") {
|
289 | args.push("--deb-compression", compression || "xz");
|
290 | (0, _builderUtil().use)(options.priority, it => args.push("--deb-priority", it));
|
291 | } else if (target === "rpm") {
|
292 | args.push("--rpm-compression", (compression === "xz" ? "xzmt" : compression) || "xzmt");
|
293 | args.push("--rpm-os", "linux");
|
294 |
|
295 | if (synopsis != null) {
|
296 | args.push("--rpm-summary", (0, _builderUtil().smarten)(synopsis));
|
297 | }
|
298 | }
|
299 |
|
300 |
|
301 | let depends = options.depends || _this3.packager.platformSpecificBuildOptions.depends;
|
302 |
|
303 | if (depends == null) {
|
304 | if (target === "deb") {
|
305 | depends = ["gconf2", "gconf-service", "libnotify4", "libappindicator1", "libxtst6", "libnss3", "libxss1"];
|
306 | } else if (target === "pacman") {
|
307 |
|
308 | depends = ["c-ares", "ffmpeg", "gtk3", "http-parser", "libevent", "libvpx", "libxslt", "libxss", "minizip", "nss", "re2", "snappy", "libnotify", "libappindicator-gtk2", "libappindicator-gtk3", "libappindicator-sharp"];
|
309 | } else if (target === "rpm") {
|
310 |
|
311 | depends = ["libnotify", "libappindicator", "libXScrnSaver"];
|
312 | } else {
|
313 | depends = [];
|
314 | }
|
315 | } else if (!Array.isArray(depends)) {
|
316 |
|
317 | if (typeof depends === "string") {
|
318 | depends = [depends];
|
319 | } else {
|
320 | throw new Error(`depends must be Array or String, but specified as: ${depends}`);
|
321 | }
|
322 | }
|
323 |
|
324 | for (const dep of depends) {
|
325 | args.push("--depends", dep);
|
326 | }
|
327 |
|
328 | (0, _builderUtil().use)(packager.info.metadata.license, it => args.push("--license", it));
|
329 | (0, _builderUtil().use)(appInfo.buildNumber, it => args.push("--iteration", it));
|
330 | (0, _builderUtil().use)(options.fpm, it => args.push(...it));
|
331 | args.push(`${appOutDir}/=${_LinuxTargetHelper().installPrefix}/${appInfo.productFilename}`);
|
332 |
|
333 | for (const icon of yield _this3.helper.icons) {
|
334 | args.push(`${icon.file}=/usr/share/icons/hicolor/${icon.size}x${icon.size}/apps/${packager.executableName}.png`);
|
335 | }
|
336 |
|
337 | const desktopFilePath = yield _this3.helper.writeDesktopEntry(_this3.options);
|
338 | args.push(`${desktopFilePath}=/usr/share/applications/${_this3.packager.executableName}.desktop`);
|
339 |
|
340 | if (_this3.packager.packagerOptions.effectiveOptionComputed != null && (yield _this3.packager.packagerOptions.effectiveOptionComputed([args, desktopFilePath]))) {
|
341 | return;
|
342 | }
|
343 |
|
344 | const env = Object.assign({}, process.env, {
|
345 | FPM_COMPRESS_PROGRAM: _appBuilderBin().appBuilderPath,
|
346 | SZA_PATH: _zipBin().path7za,
|
347 | SZA_COMPRESSION_LEVEL: packager.compression === "store" ? "0" : "9",
|
348 | SZA_ARCHIVE_TYPE: "xz"
|
349 | });
|
350 |
|
351 |
|
352 | if (target !== "rpm" && (yield (0, _builderUtil().isMacOsSierra)())) {
|
353 | const linuxToolsPath = yield (0, _tools().getLinuxToolsPath)();
|
354 | Object.assign(env, {
|
355 | PATH: (0, _bundledTool().computeEnv)(process.env.PATH, [path.join(linuxToolsPath, "bin")]),
|
356 | DYLD_LIBRARY_PATH: (0, _bundledTool().computeEnv)(process.env.DYLD_LIBRARY_PATH, [path.join(linuxToolsPath, "lib")])
|
357 | });
|
358 | }
|
359 |
|
360 | yield (0, _builderUtil().exec)((yield _tools().fpmPath.value), args, {
|
361 | env
|
362 | });
|
363 |
|
364 | _this3.packager.dispatchArtifactCreated(artifactPath, _this3, arch);
|
365 | })();
|
366 | }
|
367 |
|
368 | }
|
369 |
|
370 | exports.default = FpmTarget;
|
371 |
|
\ | No newline at end of file |