Skip to content

Commit

Permalink
feat(electron-updater): Linux electron-updater — multiple archs support
Browse files Browse the repository at this point in the history
Close #2216
  • Loading branch information
develar committed Oct 23, 2017
1 parent 3143269 commit fc8fb9e
Show file tree
Hide file tree
Showing 12 changed files with 159 additions and 80 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"7zip-bin": "^2.2.7",
"archiver": "^2.1.0",
"async-exit-hook": "^2.0.1",
"aws-sdk": "^2.135.0",
"aws-sdk": "^2.138.0",
"bluebird-lst": "^1.0.5",
"chalk": "2.1.0",
"chromium-pickle-js": "^0.2.0",
Expand Down Expand Up @@ -92,7 +92,7 @@
"decompress-zip": "^0.3.0",
"depcheck": "^0.6.8",
"develar-typescript-json-schema": "0.17.0",
"electron-builder-tslint-config": "^1.0.4",
"electron-builder-tslint-config": "^1.1.0",
"env-paths": "^1.0.0",
"finalhandler": "^1.1.0",
"gitbook-plugin-analytics": "^0.2.1",
Expand All @@ -108,7 +108,7 @@
"serve-static": "^1.13.1",
"ts-babel": "^4.1.7",
"ts-jsdoc": "^2.0.6",
"tslint": "^5.7.0",
"tslint": "^5.8.0",
"typescript": "^2.6.0-rc",
"v8-compile-cache": "^1.1.0",
"whitespace": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/builder-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"is-ci": "^1.0.10",
"stat-mode": "^0.2.2",
"bluebird-lst": "^1.0.5",
"chalk": "2.1.0",
"chalk": "2.1.0",
"debug": "^3.1.0",
"node-emoji": "^1.8.1",
"builder-util-runtime": "^0.0.0-semantic-release",
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"7zip-bin": "^2.2.7",
"async-exit-hook": "^2.0.1",
"bluebird-lst": "^1.0.5",
"chalk": "2.1.0",
"chalk": "2.1.0",
"chromium-pickle-js": "^0.2.0",
"cuint": "^0.2.2",
"app-package-builder": "0.0.0-semantic-release",
Expand Down
12 changes: 9 additions & 3 deletions packages/electron-builder/src/publish/updateUnfoBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hashFile } from "builder-util"
import { hashFile, Arch } from "builder-util"
import { GenericServerOptions, PublishConfiguration, UpdateInfo, GithubOptions, WindowsUpdateInfo } from "builder-util-runtime"
import { outputFile, outputJson, readFile } from "fs-extra-p"
import { safeDump } from "js-yaml"
Expand Down Expand Up @@ -34,7 +34,7 @@ function isGenerateUpdatesFilesForAllChannels(packager: PlatformPackager<any>) {
if this is a "beta" version, we need to generate both the "alpha" and "beta" .yml file
if this is a "stable" version, we need to generate all the "alpha", "beta" and "stable" .yml file
*/
function computeChannelNames(packager: PlatformPackager<any>, publishConfig: PublishConfiguration) {
function computeChannelNames(packager: PlatformPackager<any>, publishConfig: PublishConfiguration): Array<string> {
const currentChannel: string = (publishConfig as GenericServerOptions).channel || "latest"
// for GitHub should be pre-release way be used
if (currentChannel === "alpha" || publishConfig.provider === "github" || !isGenerateUpdatesFilesForAllChannels(packager)) {
Expand All @@ -53,6 +53,12 @@ function computeChannelNames(packager: PlatformPackager<any>, publishConfig: Pub
}
}

function getUpdateInfoFileName(channel: string, packager: PlatformPackager<any>, arch: Arch | null): string {
const osSuffix = packager.platform === Platform.WINDOWS ? "" : `-${packager.platform.buildConfigurationKey}`
const archSuffix = (arch != null && arch !== Arch.x64 && packager.platform === Platform.LINUX) ? `-${Arch[arch]}` : ""

This comment has been minimized.

Copy link
@milosodalovic

milosodalovic Feb 5, 2022

@develar I'm trying to implement auto-updating for both x64 and ia32 versions of the windows app. I'm using GitHub to publish releases and my idea was to have .exe files for both architectures on the same place. I've been hoping I could use two different channel .yml files that would be pointing to the right installation file depending on the arch. For this purpose it seems logical to have archSuffix attached to the windows 32 bit update info file name too.

I might be missing something here but I don't see a better way to handle auto-update for 32 and 64 windows app.
@develar Thanks for checking this.

return `${channel}${osSuffix}${archSuffix}.yml`
}

/** @internal */
export async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<PublishConfiguration>): Promise<Array<ArtifactCreated>> {
const packager = event.packager
Expand Down Expand Up @@ -109,7 +115,7 @@ export async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: A
await writeOldMacInfo(publishConfig, outDir, dir, channel, createdFiles, version, packager)
}

const updateInfoFile = path.join(dir, `${channel}${packager.platform === Platform.WINDOWS ? "" : `-${packager.platform.buildConfigurationKey}`}.yml`)
const updateInfoFile = path.join(dir, getUpdateInfoFileName(channel, packager, event.arch))
if (createdFiles.has(updateInfoFile)) {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"bluebird-lst": "^1.0.5",
"builder-util-runtime": "^0.0.0-semantic-release",
"builder-util": "^0.0.0-semantic-release",
"chalk": "2.1.0"
"chalk": "2.2.0"
},
"typings": "./out/publisher.d.ts"
}
4 changes: 2 additions & 2 deletions packages/electron-publisher-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
],
"dependencies": {
"fs-extra-p": "^4.4.4",
"aws-sdk": "^2.135.0",
"aws-sdk": "^2.138.0",
"mime": "^2.0.3",
"electron-publish": "~0.0.0-semantic-release",
"builder-util": "^0.0.0-semantic-release",
"bluebird-lst": "^1.0.4"
"bluebird-lst": "^1.0.5"
},
"typings": "./out/s3Publisher.d.ts"
}
4 changes: 3 additions & 1 deletion packages/electron-updater/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export function getDefaultChannelName() {
function getChannelFilePrefix() {
const currentPlatform = getCurrentPlatform()
if (currentPlatform === "linux") {
return "-linux"
const arch = process.env.TEST_UPDATER_ARCH || process.arch
const archSuffix = arch === "x64" ? "" : `-${arch}`
return "-linux" + archSuffix
}
else {
return currentPlatform === "darwin" ? "-mac" : ""
Expand Down
7 changes: 7 additions & 0 deletions test/out/linux/__snapshots__/linuxPackagerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ Object {
"file": "TestApp-1.1.0-i386.AppImage",
"updateInfo": Object {},
},
Object {
"file": "latest-linux-ia32.yml",
"fileContent": Object {
"path": "TestApp-1.1.0-i386.AppImage",
"version": "1.1.0",
},
},
],
}
`;
Expand Down
50 changes: 50 additions & 0 deletions test/out/updater/__snapshots__/differentialUpdateTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,56 @@ Array [
]
`;

exports[`AppImage ia32 1`] = `
Object {
"linux": Array [
Object {
"arch": "ia32",
"file": "TestApp-1.0.0-i386.AppImage",
"updateInfo": Object {},
},
Object {
"file": "latest-linux-ia32.yml",
"fileContent": Object {
"path": "TestApp-1.0.0-i386.AppImage",
"version": "1.0.0",
},
},
],
}
`;

exports[`AppImage ia32 2`] = `
Object {
"linux": Array [
Object {
"arch": "ia32",
"file": "TestApp-1.0.1-i386.AppImage",
"updateInfo": Object {},
},
Object {
"file": "latest-linux-ia32.yml",
"fileContent": Object {
"path": "TestApp-1.0.1-i386.AppImage",
"version": "1.0.1",
},
},
],
}
`;

exports[`AppImage ia32 3`] = `
Object {
"name": "TestApp-1.0.1-i386.AppImage",
}
`;

exports[`AppImage ia32 4`] = `
Array [
"TestApp-1.0.1-i386.AppImage",
]
`;

exports[`web installer 1`] = `
Object {
"win": Array [
Expand Down
12 changes: 10 additions & 2 deletions test/src/linux/linuxPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ test.ifNotWindows.ifNotCiMac("AppImage", app({
provider: "generic",
url: "https://example.com/downloads"
},
}
},
}))

test.ifAll.ifNotWindows.ifNotCiMac("AppImage ia32", app({targets: Platform.LINUX.createTarget("Appimage", Arch.ia32)}))
test.ifAll.ifNotWindows.ifNotCiMac("AppImage ia32", app({
targets: Platform.LINUX.createTarget("Appimage", Arch.ia32),
config: {
publish: {
provider: "generic",
url: "https://example.com/downloads"
},
},
}))

test.ifNotWindows.ifNotCiMac.ifAll("AppImage - doNotAsk system integration", app({
targets: Platform.LINUX.createTarget(),
Expand Down
11 changes: 8 additions & 3 deletions test/src/updater/differentialUpdateTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,15 @@ test.ifAll.ifDevOrWinCi("web installer", async () => {
await testBlockMap(outDirs[0], path.join(outDirs[1], "nsis-web"), NsisUpdater)
})

test.ifAll.ifDevOrLinuxCi("AppImage", async () => {
async function testLinux(arch: Arch) {
process.env.TEST_UPDATER_PLATFORM = "linux"
process.env.TEST_UPDATER_ARCH = Arch[arch]

let outDirs: Array<string> = []

async function buildApp(version: string) {
await assertPack("test-app-one", {
targets: Platform.LINUX.createTarget(["appimage"], Arch.x64),
targets: Platform.LINUX.createTarget(["appimage"], arch),
config: {
extraMetadata: {
version,
Expand Down Expand Up @@ -273,7 +274,11 @@ test.ifAll.ifDevOrLinuxCi("AppImage", async () => {

process.env.APPIMAGE = path.join(outDirs[0], "TestApp-1.0.0-x86_64.AppImage")
await testBlockMap(outDirs[0], path.join(outDirs[1]), AppImageUpdater)
})
}

test.ifAll.ifDevOrLinuxCi("AppImage", () => testLinux(Arch.x64))

test.ifAll.ifDevOrLinuxCi("AppImage ia32", () => testLinux(Arch.ia32))

// test.ifAll("s3", async () => {
// if (process.env.OLD_DIST == null) {
Expand Down
Loading

0 comments on commit fc8fb9e

Please sign in to comment.