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

fix: builds on rpm>=4.20.0 #344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion resources/spec.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ print('\n\n\n') }

%>%install
mkdir -p %{buildroot}/usr/
cp <%= process.platform === 'darwin' ? '-R' : '-r' %> usr/* %{buildroot}/usr/
cp <%= process.platform === 'darwin' ? '-R' : '-r' %> <%= usrPath %> %{buildroot}/usr/


%files
Expand Down
16 changes: 16 additions & 0 deletions src/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ async function rpmSupportsBooleanDependencies (logger) {
return rpmVersionSupportsBooleanDependencies(await getRpmVersion(logger))
}

/**
* Retrieves the RPM version number and determines the path to the `usr` directory based on the version.
*/
async function getRpmUsrPath (logger) {
return rpmUsrPath(await getRpmVersion(logger))
}

async function getRpmVersion (logger) {
const versionOutput = await spawn('rpmbuild', ['--version'], logger)
return _.last(versionOutput.trim().split(' '))
Expand All @@ -48,6 +55,14 @@ function rpmVersionSupportsBooleanDependencies (rpmVersionString) {
return rpmVersion >= [4, 13, 0]
}

/**
* Determines the path to the `usr` directory based on the RPM version.
*/
function rpmUsrPath (rpmVersionString) {
const rpmVersion = rpmVersionString.split('.').slice(0, 3).map(n => parseInt(n))
return rpmVersion >= [4, 20, 0] ? '../usr/.' : 'usr/*'
}

/**
* Transforms the list of trash requires into an RPM boolean dependency list.
*/
Expand Down Expand Up @@ -75,6 +90,7 @@ module.exports = {
}
},
getRpmVersion,
getRpmUsrPath,
rpmSupportsBooleanDependencies,
rpmVersionSupportsBooleanDependencies,
trashRequiresAsBoolean
Expand Down
1 change: 1 addition & 0 deletions src/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class RedhatInstaller extends common.ElectronInstaller {
])
this.defaults = {
...common.getDefaultsFromPackageJSON(pkg, { revision: 1 }),
usrPath: await redhatDependencies.getRpmUsrPath(this.userSupplied.logger),
version: pkg.version || '0.0.0',
license: pkg.license,
compressionLevel: 2,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/custom.spec.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ print('\n\n\n') }

%>%install
mkdir -p %{buildroot}/usr/
cp <%= process.platform === 'darwin' ? '-R' : '-r' %> usr/* %{buildroot}/usr/
cp <%= process.platform === 'darwin' ? '-R' : '-r' %> <%= usrPath %> %{buildroot}/usr/


%files
Expand Down
Loading