index.js
function buildRpm(buildRoot, specFile, rpmDest, execOpts, cb) {
  // Build the RPM package.
  var cmd = [
    'rpmbuild',
    '-bb',
    '-vv',
    '--buildroot',
    buildRoot,
    specFile
  ].join(' ');

  logger(chalk.cyan('Executing:'), cmd);

  execOpts = execOpts || {};

  exec(cmd, execOpts, function rpmbuild(err, stdout) {

    if (err) {
      return cb(err);
    }

    if (stdout) {
      var rpm = stdout.match(/(\/.+\..+\.rpm)/);

      if (rpm && rpm.length > 0) {
        var rpmDestination = rpm[0];

        if (rpmDest) {
          rpmDestination = path.join(rpmDest, path.basename(rpmDestination));
          logger(chalk.cyan('Copying RPM package to:'), rpmDestination);
          fsx.copySync(rpm[0], rpmDestination);
        }

        return cb(null, rpmDestination);
      }
    }
  });
}
function buildRpm(buildRoot, specFile, rpmDest, execOpts, cb) {
  // Build the RPM package.
  var cmd = [
    'rpmbuild',
    '-bb',
    '-vv',
    '--buildroot',
    buildRoot,
    specFile
  ].join(' ');

  logger(chalk.cyan('Executing:'), cmd);

  execOpts = execOpts || {};

  exec(cmd, execOpts, function rpmbuild(err, stdout) {

    if (err) {
      return cb(err);
    }

    if (stdout) {
      var rpm = stdout.match(/(\/.+\..+\.rpm)/);

      if (rpm && rpm.length > 0) {
        var rpmDestination = rpm[0];

        if (rpmDest) {
          rpmDestination = path.join(rpmDest, path.basename(rpmDestination));
          logger(chalk.cyan('Copying RPM package to:'), rpmDestination);
          fsx.copySync(rpm[0], rpmDestination);
        }

        return cb(null, rpmDestination);
      }
    }
  });
}
function buildRpm ( buildRoot , specFile , rpmDest , execOpts , cb ) { // Build the RPM package. var cmd = [ 'rpmbuild' , '-bb' , '-vv' , '--buildroot' , buildRoot , specFile ] . join ( ' ' ) ; logger ( chalk . cyan ( 'Executing:' ) , cmd ) ; execOpts = execOpts || { } ; exec ( cmd , execOpts , function rpmbuild ( err , stdout ) { if ( err ) { return cb ( err ) ; } if ( stdout ) { var rpm = stdout . match ( / (\/.+\..+\.rpm) / ) ; if ( rpm && rpm . length > 0 ) { var rpmDestination = rpm [ 0 ] ; if ( rpmDest ) { rpmDestination = path . join ( rpmDest , path . basename ( rpmDestination ) ) ; logger ( chalk . cyan ( 'Copying RPM package to:' ) , rpmDestination ) ; fsx . copySync ( rpm [ 0 ] , rpmDestination ) ; } return cb ( null , rpmDestination ) ; } } } ) ; }
Runs the rpmbuild tool in a child process.

@param  {String}   buildRoot  where all included files reside
@param  {String}   specFile   path to the file from which the RPM package will be created
@param  {String}   rpmDest    where the .rpm file should be copied to
@param  {Function} cb         callback function to be executed when the task is done
Runs the rpmbuild tool in a child process .