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kBAAM,KAAK;AAAnC,WAAP;AACD,SAZuB;;AAAA;AAAA;AAAA;AAAA,WAAxB;AAcA,UAAI,eAAe,EAAnB;;AACA,WAAK,MAAM,IAAX,IAAmB,SAAnB,EAA8B;AAC5B,wBAAgB,8DAA8D,KAAK,IAAI,aAAa,mBAAmB,IAAI,KAAK,WAAW,IAAI,KAAK,QAAQ,MAAM,YAAY,KAA9K;AACD;;AACD,aAAO,YAAP;AAzB4D;AA0B7D;;AAEa,eAAN,CAAoB,QAApB,EAAoC;AAAA;;AAAA;AAC1C,UAAI,YAAY,EAAhB;;AACA,WAAK,MAAM,eAAX,IAA8B,OAAK,QAAL,CAAc,gBAA5C,EAA8D;AAC5D,YAAI,gBAAgB,QAAhB,IAA4B,IAAhC,EAAsC;AACpC,uBACA,oBAAoB,gBAAgB,QAAQ;qBAC/B,OAAK,QAAL,CAAc,OAAd,CAAsB,eAAe;6BAC7B,gBAAgB,GAAG;;uBAHxC;AAMD;AACF,OAXyC,CAa1C;;;AACA,UAAI,cAAc,EAAlB,EAAsB;AACpB,eAAO,EAAP;AACD;;AAED,YAAM,eAAe,gBAArB;AACA,YAAM,cAAc,KAAK,IAAL,CAAU,QAAV,EAAoB,YAApB,CAApB;AACA,YAAM,WAAW,GAAG,OAAK,QAAL,CAAc,cAAc,MAAhD;AACA,YAAM,eAAe,KAAK,IAAL,CAAU,WAAV,EAAuB,QAAvB,CAArB;AACA,YAAM,2BAAU,WAAV,CAAN;AAEA,YAAM,2BAAU,YAAV,EAAwB;;IAE9B,SAAS;aAFH,CAAN,CAxB0C,CA6B1C;;AACA,aAAO,qDAAqD,YAAY,IAAI,QAAQ,KAApF;AA9B0C;AA+B3C;;AA5I+C,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { Arch, executeAppBuilder, serializeToYaml } from \"builder-util\"\nimport { UUID } from \"builder-util-runtime\"\nimport { copyOrLinkFile, unlinkIfExists } from \"builder-util/out/fs\"\nimport * as ejs from \"ejs\"\nimport { ensureDir, outputFile, readFile, symlink, writeFile } from \"fs-extra-p\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { AppImageOptions } from \"..\"\nimport { Target } from \"../core\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport { getAppUpdatePublishConfiguration } from \"../publish/PublishManager\"\nimport { getNotLocalizedLicenseFile } from \"../util/license\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { LinuxTargetHelper } from \"./LinuxTargetHelper\"\nimport { createStageDir } from \"./targetUtil\"\n\nconst appRunTemplate = new Lazy<(data: any) => string>(async () => {\n return ejs.compile(await readFile(path.join(getTemplatePath(\"linux\"), \"AppRun.sh\"), \"utf-8\"))\n})\n\n// https://unix.stackexchange.com/questions/375191/append-to-sub-directory-inside-squashfs-file\nexport default class AppImageTarget extends Target {\n readonly options: AppImageOptions = {...this.packager.platformSpecificBuildOptions, ...(this.packager.config as any)[this.name]}\n private readonly desktopEntry: Lazy<string>\n\n constructor(ignored: string, private readonly packager: LinuxPackager, private readonly helper: LinuxTargetHelper, readonly outDir: string) {\n super(\"appImage\")\n\n // we add X-AppImage-BuildId to ensure that new desktop file will be installed\n this.desktopEntry = new Lazy<string>(() => helper.computeDesktopEntry(this.options, \"AppRun\", {\n \"X-AppImage-Version\": `${packager.appInfo.buildVersion}`,\n \"X-AppImage-BuildId\": UUID.v1(),\n }))\n }\n\n async build(appOutDir: string, arch: Arch): Promise<any> {\n const packager = this.packager\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 // tslint:disable-next-line:no-invalid-template-strings\n const artifactName = packager.expandArtifactNamePattern(options, \"AppImage\", arch, \"${name}-${version}-${arch}.${ext}\", false)\n const artifactPath = path.join(this.outDir, artifactName)\n this.logBuilding(\"AppImage\", artifactPath, arch)\n\n const stageDir = await createStageDir(this, packager, arch)\n const resourceName = `appimagekit-${this.packager.executableName}`\n let additionalInstall = await this.copyIcons(stageDir.dir, resourceName)\n additionalInstall += await this.copyMimeTypes(stageDir.dir)\n\n const license = await getNotLocalizedLicenseFile(options.license, this.packager, [\"txt\"])\n if (license != null) {\n await copyOrLinkFile(license, stageDir.getTempFile(\"eula.txt\"))\n }\n\n const finalDesktopFilename = `${this.packager.executableName}.desktop`\n await Promise.all([\n unlinkIfExists(artifactPath),\n writeFile(stageDir.getTempFile(\"/AppRun\"), (await appRunTemplate.value)({\n systemIntegration: options.systemIntegration || \"ask\",\n isShowEula: license != null,\n desktopFileName: finalDesktopFilename,\n executableName: this.packager.executableName,\n productName: this.packager.appInfo.productName,\n resourceName,\n additionalInstall,\n }), {\n mode: \"0755\",\n }),\n writeFile(stageDir.getTempFile(finalDesktopFilename), await this.desktopEntry.value),\n ])\n\n // must be after this.helper.icons call\n if (this.helper.maxIconPath == null) {\n throw new Error(\"Icon is not provided\")\n }\n\n if (this.packager.packagerOptions.effectiveOptionComputed != null && await this.packager.packagerOptions.effectiveOptionComputed({desktop: await this.desktopEntry.value})) {\n return\n }\n\n const publishConfig = await getAppUpdatePublishConfiguration(packager, arch, false /* in any case validation will be done on publish */)\n if (publishConfig != null) {\n await outputFile(path.join(packager.getResourcesDir(stageDir.dir), \"app-update.yml\"), serializeToYaml(publishConfig))\n }\n\n const args = [\"appimage\", \"--stage\", stageDir.dir, \"--arch\", Arch[arch], \"--output\", artifactPath, \"--app\", appOutDir]\n if (packager.compression === \"maximum\") {\n args.push(\"--compression\", \"xz\")\n }\n\n packager.info.dispatchArtifactCreated({\n file: artifactPath,\n safeArtifactName: packager.computeSafeArtifactName(artifactName, \"AppImage\", arch, false),\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: true,\n updateInfo: JSON.parse(await executeAppBuilder(args)),\n })\n }\n\n private async copyIcons(stageDir: string, resourceName: string): Promise<string> {\n const iconDirRelativePath = \"usr/share/icons/hicolor\"\n const iconDir = path.join(stageDir, iconDirRelativePath)\n await ensureDir(iconDir)\n\n // https://github.com/AppImage/AppImageKit/issues/438#issuecomment-319094239\n // expects icons in the /usr/share/icons/hicolor\n const iconNames = await BluebirdPromise.map(this.helper.icons, async icon => {\n const filename = `${this.packager.executableName}.png`\n const iconSizeDir = `${icon.size}x${icon.size}/apps`\n const dir = path.join(iconDir, iconSizeDir)\n await ensureDir(dir)\n const finalIconFile = path.join(dir, filename)\n await copyOrLinkFile(icon.file, finalIconFile, null, true)\n\n if (icon.file === this.helper.maxIconPath) {\n await symlink(path.relative(stageDir, finalIconFile), path.join(stageDir, filename))\n }\n return {filename, iconSizeDir, size: icon.size}\n })\n\n let installIcons = \"\"\n for (const icon of iconNames) {\n installIcons += `xdg-icon-resource install --noupdate --context apps --size ${icon.size} \"$APPDIR/${iconDirRelativePath}/${icon.iconSizeDir}/${icon.filename}\" \"${resourceName}\"\\n`\n }\n return installIcons\n }\n\n private async copyMimeTypes(stageDir: string): Promise<string> {\n let mimeTypes = \"\"\n for (const fileAssociation of this.packager.fileAssociations) {\n if (fileAssociation.mimeType != null) {\n mimeTypes +=\n `<mime-type type=\"${fileAssociation.mimeType}\">\\n\n <comment>${this.packager.appInfo.productFilename} document</comment>\\n\n <glob pattern=\"*.${fileAssociation.ext}\"/>\\n\n <generic-icon name=\"x-office-document\"/>\\n\n </mime-type>\\n`\n }\n }\n\n // if no mime-types specified, return\n if (mimeTypes === \"\") {\n return \"\"\n }\n\n const relativePath = \"usr/share/mime\"\n const mimeTypeDir = path.join(stageDir, relativePath)\n const fileName = `${this.packager.executableName}.xml`\n const mimeTypeFile = path.join(mimeTypeDir, fileName)\n await ensureDir(mimeTypeDir)\n\n await writeFile(mimeTypeFile, `<?xml version=\"1.0\"?>\n<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n ${mimeTypes}\n</mime-info>`)\n\n // noinspection SpellCheckingInspection\n return `xdg-mime install $SYSTEM_WIDE --novendor \"$APPDIR/${relativePath}/${fileName}\"\\n`\n }\n}\n"],"sourceRoot":""}
|