Merge lp:~harlowja/cloud-init/rpm-patch-inputs into lp:~cloud-init-dev/cloud-init/trunk

Proposed by Joshua Harlow
Status: Merged
Merged at revision: 672
Proposed branch: lp:~harlowja/cloud-init/rpm-patch-inputs
Merge into: lp:~cloud-init-dev/cloud-init/trunk
Diff against target: 126 lines (+32/-6)
3 files modified
cloudinit/distros/__init__.py (+3/-2)
packages/brpm (+11/-4)
packages/redhat/cloud-init.spec.in (+18/-0)
To merge this branch: bzr merge lp:~harlowja/cloud-init/rpm-patch-inputs
Reviewer Review Type Date Requested Status
cloud-init Commiters Pending
Review via email: mp+126342@code.launchpad.net

Description of the change

Allow the brpm package to be ran with a set of patch files to include when building.

To post a comment you must log in.
673. By Joshua Harlow

Add a top_dir define.

674. By Joshua Harlow

Clean doesn't seem needed.

675. By Joshua Harlow

Ensure the patches get activated.

676. By Joshua Harlow

Add a nice '-p1'

677. By Joshua Harlow

Stop the bad habit of using 'or'.

678. By Joshua Harlow

Also ensure that if mirror info is not invalid
before we start iterating over it (it could
be sent is as none).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/distros/__init__.py'
2--- cloudinit/distros/__init__.py 2012-09-25 03:45:56 +0000
3+++ cloudinit/distros/__init__.py 2012-09-28 18:11:24 +0000
4@@ -82,7 +82,7 @@
5 return arch
6
7 def _get_arch_package_mirror_info(self, arch=None):
8- mirror_info = self.get_option("package_mirrors", None)
9+ mirror_info = self.get_option("package_mirrors", [])
10 if arch == None:
11 arch = self.get_primary_arch()
12 return _get_arch_package_mirror_info(mirror_info, arch)
13@@ -92,7 +92,6 @@
14 # this resolves the package_mirrors config option
15 # down to a single dict of {mirror_name: mirror_url}
16 arch_info = self._get_arch_package_mirror_info(arch)
17-
18 return _get_package_mirror_info(availability_zone=availability_zone,
19 mirror_info=arch_info)
20
21@@ -353,6 +352,8 @@
22 # given a arch specific 'mirror_info' entry (from package_mirrors)
23 # search through the 'search' entries, and fallback appropriately
24 # return a dict with only {name: mirror} entries.
25+ if not mirror_info:
26+ mirror_info = {}
27
28 ec2_az_re = ("^[a-z][a-z]-(%s)-[1-9][0-9]*[a-z]$" %
29 "north|northeast|east|southeast|south|southwest|west|northwest")
30
31=== modified file 'packages/brpm'
32--- packages/brpm 2012-07-09 20:41:45 +0000
33+++ packages/brpm 2012-09-28 18:11:24 +0000
34@@ -91,7 +91,7 @@
35 return "* %s" % (d)
36
37
38-def generate_spec_contents(args, tmpl_fn, arc_fn):
39+def generate_spec_contents(args, tmpl_fn, top_dir, arc_fn):
40
41 # Figure out the version and revno
42 cmd = [util.abs_join(find_root(), 'tools', 'read-version')]
43@@ -148,7 +148,9 @@
44 else:
45 subs['systemd'] = False
46
47+ subs['defines'] = ["_topdir %s" % (top_dir)]
48 subs['init_sys'] = args.boot
49+ subs['patches'] = [os.path.basename(p) for p in args.patches]
50 return templater.render_from_file(tmpl_fn, params=subs)
51
52
53@@ -164,6 +166,10 @@
54 " (default: %(default)s)"),
55 default=False,
56 action='store_true')
57+ parser.add_argument("-p", "--patch", dest="patches",
58+ help=("include the following patch when building"),
59+ default=[],
60+ action='append')
61 args = parser.parse_args()
62 capture = True
63 if args.verbose:
64@@ -192,16 +198,17 @@
65 # Form the spec file to be used
66 tmpl_fn = util.abs_join(find_root(), 'packages',
67 'redhat', 'cloud-init.spec.in')
68- contents = generate_spec_contents(args, tmpl_fn,
69+ contents = generate_spec_contents(args, tmpl_fn, root_dir,
70 os.path.basename(archive_fn))
71 spec_fn = util.abs_join(root_dir, 'cloud-init.spec')
72 util.write_file(spec_fn, contents)
73 print("Created spec file at %r" % (spec_fn))
74+ for p in args.patches:
75+ util.copy(p, util.abs_join(arc_dir, os.path.basename(p)))
76
77 # Now build it!
78 print("Running 'rpmbuild' in %r" % (root_dir))
79- cmd = ['rpmbuild', '--clean',
80- '-ba', spec_fn]
81+ cmd = ['rpmbuild', '-ba', spec_fn]
82 util.subp(cmd, capture=capture)
83
84 # Copy the items built to our local dir
85
86=== modified file 'packages/redhat/cloud-init.spec.in'
87--- packages/redhat/cloud-init.spec.in 2012-07-09 21:09:04 +0000
88+++ packages/redhat/cloud-init.spec.in 2012-09-28 18:11:24 +0000
89@@ -5,6 +5,10 @@
90 # Or: http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
91 # Or: http://www.rpm.org/max-rpm/ch-rpm-inside.html
92
93+#for $d in $defines
94+%define ${d}
95+#end for
96+
97 Name: cloud-init
98 Version: ${version}
99 Release: ${release}%{?dist}
100@@ -36,6 +40,13 @@
101 Requires: ${r}
102 #end for
103
104+# Custom patches
105+#set $size = 0
106+#for $p in $patches
107+Patch${size}: $p
108+#set $size += 1
109+#end for
110+
111 #if $sysvinit
112 Requires(post): chkconfig
113 Requires(postun): initscripts
114@@ -58,6 +69,13 @@
115 %prep
116 %setup -q -n %{name}-%{version}~${release}
117
118+# Custom patches activation
119+#set $size = 0
120+#for $p in $patches
121+%patch${size} -p1
122+#set $size += 1
123+#end for
124+
125 %build
126 %{__python} setup.py build
127