Skip to content

Commit e21b5ab

Browse files
hicom150fcastilloec
authored andcommitted
Add option to set %_target_os
1 parent 1e829d4 commit e21b5ab

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ Default: `undefined`
275275

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

278+
#### options.os
279+
Type: `String`
280+
Default: Operating system platform of the host machine
281+
282+
Operating system platform the package is targeted to, used to set the `--target` option.
283+
278284
#### options.requires
279285
Type: `Array[String]`
280286
Default: The minimum list of packages needed for Electron to run

src/installer.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const debug = require('debug')
66
const fs = require('fs-extra')
77
const path = require('path')
88
const wrap = require('word-wrap')
9+
const os = require('os')
910

1011
const redhatDependencies = require('./dependencies')
1112
const spawn = require('./spawn')
@@ -59,7 +60,7 @@ class RedhatInstaller extends common.ElectronInstaller {
5960
async createPackage () {
6061
this.options.logger(`Creating package at ${this.stagingDir}`)
6162

62-
const output = await spawn('rpmbuild', ['-bb', this.specPath, '--target', this.options.arch, '--define', `_topdir ${this.stagingDir}`], this.options.logger)
63+
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)
6364
this.options.logger(`rpmbuild output: ${output}`)
6465
}
6566

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

128129
this.normalizeVersion()
130+
131+
this.options.vendor = 'none'
132+
this.options.os = this.options.os || os.platform()
129133
}
130134

131135
/**

test/installer.js

+34
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const fs = require('fs-extra')
66
const installer = require('..')
77
const path = require('path')
88
const { spawn } = require('@malept/cross-spawn-promise')
9+
const os = require('os')
910

1011
const assertASARRpmExists = outputDir =>
1112
access(path.join(outputDir, 'footest.x86.rpm'))
@@ -144,4 +145,37 @@ describe('module', function () {
144145
}
145146
}
146147
)
148+
149+
describeInstaller(
150+
'with an app with default %_target_os',
151+
{
152+
src: 'test/fixtures/app-with-asar/',
153+
options: {
154+
arch: 'x86'
155+
}
156+
},
157+
'generates a `.rpm` package with default %_target_os',
158+
async outputDir => {
159+
await assertASARRpmExists(outputDir)
160+
const stdout = await spawn('rpm', ['-qp', '--qf', '\'%{OS}\'', 'footest.x86.rpm'], { cwd: outputDir })
161+
return stdout === os.platform()
162+
}
163+
)
164+
165+
describeInstaller(
166+
'with an app with %_target_os linux',
167+
{
168+
src: 'test/fixtures/app-with-asar/',
169+
options: {
170+
arch: 'x86',
171+
os: 'linux'
172+
}
173+
},
174+
'generates a `.rpm` package with linux %_target_os',
175+
async outputDir => {
176+
await assertASARRpmExists(outputDir)
177+
const stdout = await spawn('rpm', ['-qp', '--qf', '\'%{OS}\'', 'footest.x86.rpm'], { cwd: outputDir })
178+
return stdout === 'linux'
179+
}
180+
)
147181
})

0 commit comments

Comments
 (0)