Add in the ability to choose which type of boot type the rpm should have
and adjust the specfile that is generated to remove the unwanted config files for the types which were not selected.
This commit is contained in:
parent
aa530fa2bd
commit
ead28165e4
@ -9,6 +9,8 @@ import sys
|
|||||||
import tempfile
|
import tempfile
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
import tempita
|
import tempita
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -104,7 +106,7 @@ def warn(msg):
|
|||||||
print("WARNING: %s" % (msg))
|
print("WARNING: %s" % (msg))
|
||||||
|
|
||||||
|
|
||||||
def generate_spec_contents(tmpl_fn, revno, version):
|
def generate_spec_contents(args, tmpl_fn, revno, version):
|
||||||
|
|
||||||
# Tmpl params
|
# Tmpl params
|
||||||
subs = {}
|
subs = {}
|
||||||
@ -172,6 +174,22 @@ def generate_spec_contents(tmpl_fn, revno, version):
|
|||||||
'%{_bindir}/*',
|
'%{_bindir}/*',
|
||||||
'/usr/lib/cloud-init/*',
|
'/usr/lib/cloud-init/*',
|
||||||
]
|
]
|
||||||
|
# Since setup.py installs them
|
||||||
|
# all, we need to selectively
|
||||||
|
# knock off the wrong ones and
|
||||||
|
# ensure the right one is kept
|
||||||
|
post_remove_keep = {
|
||||||
|
'initd': '/etc/init.d/',
|
||||||
|
'systemd': '/etc/systemd/',
|
||||||
|
'upstart': '/etc/init/',
|
||||||
|
}
|
||||||
|
post_remove = []
|
||||||
|
for (k, v) in post_remove_keep.iteritems():
|
||||||
|
if k != args.boot:
|
||||||
|
post_remove.append(v)
|
||||||
|
else:
|
||||||
|
other_files.append(v)
|
||||||
|
subs['post_remove'] = post_remove
|
||||||
subs['files'] = other_files
|
subs['files'] = other_files
|
||||||
|
|
||||||
with open(tmpl_fn, 'r') as fh:
|
with open(tmpl_fn, 'r') as fh:
|
||||||
@ -188,6 +206,13 @@ def archive_code():
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("-b", "--boot", dest="boot",
|
||||||
|
help="select boot type (default: %(default)s)",
|
||||||
|
metavar="TYPE", default='initd',
|
||||||
|
choices=['upstart', 'initd', 'systemd'])
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Clean out the root dir and make sure the dirs we want are in place
|
# Clean out the root dir and make sure the dirs we want are in place
|
||||||
root_dir = os.path.expanduser("~/rpmbuild")
|
root_dir = os.path.expanduser("~/rpmbuild")
|
||||||
@ -207,7 +232,8 @@ def main():
|
|||||||
# Form the spec file to be used
|
# Form the spec file to be used
|
||||||
tmpl_fn = os.path.join(os.getcwd(), 'redhat', 'cloud-init.spec')
|
tmpl_fn = os.path.join(os.getcwd(), 'redhat', 'cloud-init.spec')
|
||||||
info("Generated spec file from template %r" % (tmpl_fn))
|
info("Generated spec file from template %r" % (tmpl_fn))
|
||||||
(base_name, arc_name, contents) = generate_spec_contents(tmpl_fn,
|
(base_name, arc_name, contents) = generate_spec_contents(args,
|
||||||
|
tmpl_fn,
|
||||||
revno, version)
|
revno, version)
|
||||||
spec_fn = os.path.join(root_dir, 'cloud-init.spec')
|
spec_fn = os.path.join(root_dir, 'cloud-init.spec')
|
||||||
with open(spec_fn, 'w') as fh:
|
with open(spec_fn, 'w') as fh:
|
||||||
|
@ -37,11 +37,15 @@ ssh keys and to let the user run various scripts.
|
|||||||
%build
|
%build
|
||||||
%{__python} setup.py build
|
%{__python} setup.py build
|
||||||
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
|
%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
|
||||||
|
|
||||||
|
# Remove anything after it was installed??
|
||||||
|
{{for r in post_remove}}
|
||||||
|
rm -rfv $RPM_BUILD_ROOT/{{r}}
|
||||||
|
{{endfor}}
|
||||||
|
|
||||||
%clean
|
%clean
|
||||||
rm -rf $RPM_BUILD_ROOT
|
rm -rf $RPM_BUILD_ROOT
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user