Issue
Following the documentation I was able to setup the grunt task and make a successful build. Now I need to have preInstall and postInstall scripts but I could not find any documentation on how to do that.
This is my setup:
rpm: {
options: {
// Task-specific options go here.
name: 'cdrapi',
version: '1.0.0',
release: false,
homepage: 'www.website.com',
summary: 'api package',
license: '??',
distribution: 'CentOS 6.x',
requires: ['nodejs'],
preInstall: 'echo "You are in the pre install section"'
},
files: {
dest: '/opt/cdr/api/',
src: ['**/*', '!**/*.map', '!**/**/*.ts', '!**/bdd_tests/**'],
cwd: 'build',
expand: true
}
}
The above preInstall tag does not do anything, it won't even reflect on the rpm spec file.
Solution
It looks like the argument to preInstall
and postInstall
is supposed to be a file not an inline script.
See the code here:
src += readScriptlet('\n%pre', options.preInstall);
src += readScriptlet('\n%post', options.postInstall);
src += readScriptlet('\n%preun', options.preUninstall);
src += readScriptlet('\n%postun', options.postUninstall);
and the readScriptlet function:
function readScriptlet(label, scriptFile) {
var src = '';
if (scriptFile) {
var options = {
encoding: scriptFile.encoding || 'utf8'
};
var data = fs.readFileSync(scriptFile.src, options);
src += label + '\n';
src += data.trim() + '\n\n';
}
return src;
}
Answered By - Etan Reisner Answer Checked By - Timothy Miller (WPSolving Admin)