def make_src_pkg(dest_dir, spec, sources, env=None, template=None, saltenv='base'):
 _create_rpmmacros()
 tree_base = _mk_tree()
 spec_path = _get_spec(tree_base, spec, template, saltenv)
 if isinstance(sources, str):
  sources = sources.split(',')
 for src in sources:
  _get_src(tree_base, src, saltenv)
 cmd = 'rpmbuild --define "_topdir {0}" -bs --define "_source_filedigest_algorithm md5" --define "_binary_filedigest_algorithm md5" --define "dist .el5" {1}'.format(tree_base, spec_path)
 __salt__['cmd.run'](cmd)
 srpms = os.path.join(tree_base, 'SRPMS')
 ret = []
 if (not os.path.isdir(dest_dir)):
  os.makedirs(dest_dir)
 for fn_ in os.listdir(srpms):
  full = os.path.join(srpms, fn_)
  tgt = os.path.join(dest_dir, fn_)
  shutil.copy(full, tgt)
  ret.append(tgt)
 return ret

def make_src_pkg ( dest_dir , spec , sources , env = None , template = None , saltenv = 'base' ) : _create_rpmmacros ( ) tree_base = _mk_tree ( ) spec_path = _get_spec ( tree_base , spec , template , saltenv ) if isinstance ( sources , str ) : sources = sources . split ( ',' ) for src in sources : _get_src ( tree_base , src , saltenv ) cmd = 'rpmbuild --define "_topdir {0}" -bs --define "_source_filedigest_algorithm md5" --define "_binary_filedigest_algorithm md5" --define "dist .el5" {1}' . format ( tree_base , spec_path ) __salt__ [ 'cmd.run' ] ( cmd ) srpms = os . path . join ( tree_base , 'SRPMS' ) ret = [ ] if ( not os . path . isdir ( dest_dir ) ) : os . makedirs ( dest_dir ) for fn_ in os . listdir ( srpms ) : full = os . path . join ( srpms , fn_ ) tgt = os . path . join ( dest_dir , fn_ ) shutil . copy ( full , tgt ) ret . append ( tgt ) return ret
create a source rpm from the given spec file and sources cli example: .