mirror of
https://github.com/naveenrajm7/rpmbuild.git
synced 2025-07-12 04:13:50 +00:00
Merge pull request #8 from belden/issue-7-specfile-below-root
Correctly operate on specfiles located below root
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,8 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# editor
|
||||
*.swp
|
||||
|
||||
# dependencies
|
||||
package-lock.json
|
||||
node_modules
|
||||
|
16
src/main.ts
16
src/main.ts
@ -4,6 +4,7 @@ const exec = require('@actions/exec');
|
||||
const io = require('@actions/io');
|
||||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
@ -18,10 +19,15 @@ async function run() {
|
||||
|
||||
// get inputs from workflow
|
||||
// specFile name
|
||||
const specFile = core.getInput('spec_file');
|
||||
const configPath = core.getInput('spec_file'); // user input, eg: `foo.spec' or `rpm/foo.spec'
|
||||
const basename = path.basename(configPath); // always just `foo.spec`
|
||||
const specFile = {
|
||||
srcFullPath: `/github/workspace/${configPath}`,
|
||||
destFullPath: `/github/home/rpmbuild/SPECS/${basename}`,
|
||||
};
|
||||
|
||||
// Read spec file and get values
|
||||
var data = fs.readFileSync(specFile, 'utf8');
|
||||
var data = fs.readFileSync(specFile.srcFullPath, 'utf8');
|
||||
let name = '';
|
||||
let version = '';
|
||||
|
||||
@ -40,8 +46,8 @@ async function run() {
|
||||
// setup rpm tree
|
||||
await exec.exec('rpmdev-setuptree');
|
||||
|
||||
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
|
||||
await exec.exec(`cp /github/workspace/${specFile} /github/home/rpmbuild/SPECS/`);
|
||||
// Copy spec file from path specFile to /github/home/rpmbuild/SPECS/
|
||||
await exec.exec(`cp ${specFile.srcFullPath} ${specFile.destFullPath}`);
|
||||
|
||||
// Make the code in /github/workspace/ into a tar.gz, located in /github/home/rpmbuild/SOURCES/
|
||||
const oldGitDir = process.env.GIT_DIR;
|
||||
@ -52,7 +58,7 @@ async function run() {
|
||||
// Execute rpmbuild , -ba generates both RPMS and SPRMS
|
||||
try {
|
||||
await exec.exec(
|
||||
`rpmbuild -ba /github/home/rpmbuild/SPECS/${specFile}`
|
||||
`rpmbuild -ba ${specFile.destFullPath}`
|
||||
);
|
||||
} catch (err) {
|
||||
core.setFailed(`action failed with error: ${err}`);
|
||||
|
Reference in New Issue
Block a user