Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to set %_target_os #175

Merged
merged 3 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ Default: `undefined`

Machine architecture the package is targeted to, used to set the `--target` option.

#### options.os
Type: `String`
Default: Operating system platform of the host machine

Operating system platform the package is targeted to, used to set the `--target` option.
fcastilloec marked this conversation as resolved.
Show resolved Hide resolved

#### options.requires
Type: `Array[String]`
Default: The minimum list of packages needed for Electron to run
Expand Down
5 changes: 4 additions & 1 deletion src/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class RedhatInstaller extends common.ElectronInstaller {
async createPackage () {
this.options.logger(`Creating package at ${this.stagingDir}`)

const output = await spawn('rpmbuild', ['-bb', this.specPath, '--target', this.options.arch, '--define', `_topdir ${this.stagingDir}`], this.options.logger)
const output = await spawn('rpmbuild', ['-bb', this.specPath, '--target', `${this.options.arch}-${this.options.vendor}-${this.options.os}`, '--define', `_topdir ${this.stagingDir}`], this.options.logger)
this.options.logger(`rpmbuild output: ${output}`)
}

Expand Down Expand Up @@ -126,6 +126,9 @@ class RedhatInstaller extends common.ElectronInstaller {
this.options.requires = common.mergeUserSpecified(this.userSupplied, 'requires', this.defaults)

this.normalizeVersion()

this.options.vendor = 'none'
this.options.os = this.options.os || process.platform
}

/**
Expand Down
39 changes: 39 additions & 0 deletions test/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,43 @@ describe('module', function () {
}
}
)

describeInstaller(
'with an app with default %_target_os',
{
src: 'test/fixtures/app-with-asar/',
options: {
arch: 'x86'
}
},
'generates a `.rpm` package with default %_target_os',
async outputDir => {
await assertASARRpmExists(outputDir)
const stdout = await spawn('rpm', ['-qp', '--qf', '%{OS}', 'footest.x86.rpm'], { cwd: outputDir })
if (stdout !== process.platform) {
throw new Error(`RPM built with wrong platform: ${stdout}`)
}
}
)

if (process.platform === 'darwin') {
describeInstaller(
'with an app with %_target_os linux',
{
src: 'test/fixtures/app-with-asar/',
options: {
arch: 'x86',
os: 'linux'
}
},
'generates a `.rpm` package with linux %_target_os',
async outputDir => {
await assertASARRpmExists(outputDir)
const stdout = await spawn('rpm', ['-qp', '--qf', '%{OS}', 'footest.x86.rpm'], { cwd: outputDir })
if (stdout !== 'linux') {
throw new Error(`RPM was not built for linux: ${stdout}`)
}
}
)
}
})