2013-07-03 11:02:38 +00:00
|
|
|
#! /bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import tarfile
|
2013-11-13 14:49:20 +00:00
|
|
|
import argparse
|
2013-07-03 11:02:38 +00:00
|
|
|
from os.path import dirname, join, abspath
|
|
|
|
from shutil import copy
|
|
|
|
from subprocess import check_call
|
|
|
|
|
2013-11-13 14:49:20 +00:00
|
|
|
parser = argparse.ArgumentParser(
|
2013-12-03 22:54:38 +00:00
|
|
|
description='Build salt rpms',
|
2013-11-13 14:49:20 +00:00
|
|
|
)
|
|
|
|
parser.add_argument('buildid',
|
2013-12-02 18:10:03 +00:00
|
|
|
help='The build id to use i.e. the bit after the salt version in the package name',
|
2013-11-13 14:49:20 +00:00
|
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2013-07-03 11:02:38 +00:00
|
|
|
src = abspath(join(dirname(__file__), '../..'))
|
|
|
|
|
|
|
|
sys.path.append(src)
|
2013-12-02 18:10:03 +00:00
|
|
|
|
2013-07-03 11:02:38 +00:00
|
|
|
import salt.version
|
|
|
|
|
|
|
|
salt_version = '.'.join(map(str, salt.version.__version_info__[0:3]))
|
|
|
|
|
|
|
|
rpmbuild = join(os.environ['HOME'], 'rpmbuild')
|
|
|
|
copy(join(src, 'pkg/rpm/salt.spec'), join(rpmbuild, 'SPECS'))
|
|
|
|
for f in os.listdir(join(src, 'pkg/rpm')):
|
|
|
|
if f in ['salt.spec', 'build']:
|
|
|
|
continue
|
|
|
|
copy(join(src, 'pkg/rpm', f), join(rpmbuild, 'SOURCES'))
|
|
|
|
|
2013-12-02 18:10:03 +00:00
|
|
|
|
2013-07-03 11:02:38 +00:00
|
|
|
def srcfilter(ti):
|
2013-11-13 14:49:20 +00:00
|
|
|
if '/.git' in ti.name:
|
2013-07-03 11:02:38 +00:00
|
|
|
return None
|
|
|
|
return ti
|
|
|
|
|
|
|
|
with tarfile.open(join(rpmbuild, 'SOURCES/salt-%s.tar.gz' % salt_version), 'w|gz') as tf:
|
2013-12-03 22:54:38 +00:00
|
|
|
tf.add(src, arcname='salt-%s' % salt_version,
|
|
|
|
filter=srcfilter)
|
2013-07-03 11:02:38 +00:00
|
|
|
|
2013-12-02 18:10:03 +00:00
|
|
|
|
2013-07-03 11:02:38 +00:00
|
|
|
cmd = ['rpmbuild', '-bb',
|
|
|
|
'--define=salt_version %s' % salt_version,
|
2013-11-13 14:49:20 +00:00
|
|
|
'--define=buildid %s' % args.buildid,
|
2013-07-03 11:02:38 +00:00
|
|
|
'salt.spec']
|
2013-12-02 18:10:03 +00:00
|
|
|
print('Executing: %s' % ' '.join('"%s"' % c for c in cmd))
|
2013-12-03 22:54:38 +00:00
|
|
|
check_call(cmd, cwd=join(rpmbuild, 'SPECS'))
|