summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexz <azvyagintsev@mirantis.com>2016-08-29 13:57:35 +0300
committeralexz <azvyagintsev@mirantis.com>2016-08-29 15:45:36 +0300
commitdd03155047f88035ee88bdc21acdb8c04b08fd33 (patch)
treed2bebe4a2163f7b700e03e4c075aedd11f0f2d4c
parent5ec8f1ee88a2a968f22011646db6a39498e97413 (diff)
Allow posibility to provide rpm 'Release' version
* This option allow to iterate pkg version, w\o updating plugin version Closes-Bug: #1616929 Change-Id: I41cfb19da93d2d6e0c95fcb17ead1d08fbfcab99
Notes
Notes (review): Verified+1: Fuel CI <fuel-ci-bot@mirantis.com> Code-Review+1: Sergey Slipushenko <sslypushenko@mirantis.com> Code-Review+1: Krzysztof Szukiełojć <kszukielojc@mirantis.com> Code-Review+1: Andriy Popovych <apopovych@mirantis.com> Code-Review+1: Ilya Kutukov <ikutukov@mirantis.com> Code-Review+1: Andrew Woodward <xarses@gmail.com> Code-Review+2: Igor Kalnitsky <ikalnitsky@mirantis.com> Workflow+1: Igor Kalnitsky <ikalnitsky@mirantis.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 31 Aug 2016 08:54:34 +0000 Reviewed-on: https://review.openstack.org/362016 Project: openstack/fuel-plugins Branch: refs/heads/master
-rw-r--r--fuel_plugin_builder/actions/build.py5
-rw-r--r--fuel_plugin_builder/cli.py2
-rw-r--r--fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako2
-rw-r--r--fuel_plugin_builder/tests/test_build.py77
4 files changed, 66 insertions, 20 deletions
diff --git a/fuel_plugin_builder/actions/build.py b/fuel_plugin_builder/actions/build.py
index 439703a..293d582 100644
--- a/fuel_plugin_builder/actions/build.py
+++ b/fuel_plugin_builder/actions/build.py
@@ -253,10 +253,13 @@ class BuildPluginV3(BuildPluginV2):
253 postinst = utils.read_if_exist( 253 postinst = utils.read_if_exist(
254 join_path(self.plugin_path, "post_install.sh")) 254 join_path(self.plugin_path, "post_install.sh"))
255 255
256 plugin_build_version = str(self.meta.get('build_version', '1'))
257
256 data.update( 258 data.update(
257 {'postinstall_hook': postinst, 259 {'postinstall_hook': postinst,
258 'preinstall_hook': preinst, 260 'preinstall_hook': preinst,
259 'uninstall_hook': uninst} 261 'uninstall_hook': uninst,
262 'build_version': plugin_build_version}
260 ) 263 )
261 264
262 return data 265 return data
diff --git a/fuel_plugin_builder/cli.py b/fuel_plugin_builder/cli.py
index a51d893..18b4dae 100644
--- a/fuel_plugin_builder/cli.py
+++ b/fuel_plugin_builder/cli.py
@@ -65,7 +65,7 @@ def parse_args():
65 description='fpb is a fuel plugin builder which ' 65 description='fpb is a fuel plugin builder which '
66 'helps you create plugin for Fuel') 66 'helps you create plugin for Fuel')
67 67
68 #TODO(vsharshov): we should move to subcommands instead of 68 # TODO(vsharshov): we should move to subcommands instead of
69 # exclusive group, because in this case we could not 69 # exclusive group, because in this case we could not
70 # support such behavior [-a xxx | [-b yyy -c zzz]] 70 # support such behavior [-a xxx | [-b yyy -c zzz]]
71 group = parser.add_mutually_exclusive_group(required=True) 71 group = parser.add_mutually_exclusive_group(required=True)
diff --git a/fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako b/fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako
index a0e5bbd..2514d37 100644
--- a/fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako
+++ b/fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako
@@ -16,7 +16,7 @@ Source0: ${ name }.fp
16Vendor: ${ vendor } 16Vendor: ${ vendor }
17BuildRoot: %{_tmppath}/%{name}-%{version}-build 17BuildRoot: %{_tmppath}/%{name}-%{version}-build
18Group: Development/Libraries 18Group: Development/Libraries
19Release: 1 19Release: ${ build_version }
20BuildArch: noarch 20BuildArch: noarch
21AutoReq: no 21AutoReq: no
22 22
diff --git a/fuel_plugin_builder/tests/test_build.py b/fuel_plugin_builder/tests/test_build.py
index b0a0961..fbced38 100644
--- a/fuel_plugin_builder/tests/test_build.py
+++ b/fuel_plugin_builder/tests/test_build.py
@@ -46,10 +46,11 @@ class BaseBuild(BaseTestCase):
46 self.plugin_path = '/tmp/{0}'.format(self.plugins_name) 46 self.plugin_path = '/tmp/{0}'.format(self.plugins_name)
47 self.builder = self.create_builder(self.plugin_path) 47 self.builder = self.create_builder(self.plugin_path)
48 48
49 def create_builder(self, plugin_path): 49 def create_builder(self, plugin_path, meta=None):
50 meta = meta or self.meta
50 with mock.patch( 51 with mock.patch(
51 'fuel_plugin_builder.actions.build.utils.parse_yaml', 52 'fuel_plugin_builder.actions.build.utils.parse_yaml',
52 return_value=self.meta): 53 return_value=meta):
53 return self.builder_class(plugin_path) 54 return self.builder_class(plugin_path)
54 55
55 def test_run(self): 56 def test_run(self):
@@ -310,7 +311,7 @@ class TestBaseBuildV3(BaseBuild):
310 return join_path(self.plugin_path, path) 311 return join_path(self.plugin_path, path)
311 312
312 @mock.patch('fuel_plugin_builder.actions.build.utils') 313 @mock.patch('fuel_plugin_builder.actions.build.utils')
313 def test_make_package(self, utils_mock): 314 def _test_make_package(self, utils_mock):
314 utils_mock.get_current_year.return_value = '2014' 315 utils_mock.get_current_year.return_value = '2014'
315 utils_mock.read_if_exist.side_effect = ['echo uninst', 'echo preinst', 316 utils_mock.read_if_exist.side_effect = ['echo uninst', 'echo preinst',
316 'echo postinst'] 317 'echo postinst']
@@ -324,9 +325,28 @@ class TestBaseBuildV3(BaseBuild):
324 fp_dst, 325 fp_dst,
325 'plugin_name-1.2') 326 'plugin_name-1.2')
326 327
328 utils_mock.exec_cmd.assert_called_once_with(
329 'rpmbuild -vv --nodeps --define "_topdir {0}" -bb '
330 '{1}'.format(
331 self.path_from_plugin('.build/rpm'),
332 self.path_from_plugin('.build/rpm/plugin_rpm.spec')))
333
334 utils_mock.copy_files_in_dir.assert_called_once_with(
335 self.path_from_plugin('.build/rpm/RPMS/noarch/*.rpm'),
336 self.plugin_path)
337
338 utils_mock.read_if_exist.assert_has_calls([
339 mock.call(self.path_from_plugin('uninstall.sh')),
340 mock.call(self.path_from_plugin('pre_install.sh')),
341 mock.call(self.path_from_plugin('post_install.sh'))])
342 return utils_mock
343
344 def test_make_package(self):
345 utils_mock = self._test_make_package()
327 spec_src = os.path.abspath(join_path( 346 spec_src = os.path.abspath(join_path(
328 os.path.dirname(__file__), '..', 347 os.path.dirname(__file__), '..',
329 self.builder.rpm_spec_src_path)) 348 self.builder.rpm_spec_src_path))
349
330 utils_mock.render_to_file.assert_called_once_with( 350 utils_mock.render_to_file.assert_called_once_with(
331 spec_src, 351 spec_src,
332 join_path(self.plugin_path, '.build/rpm/plugin_rpm.spec'), 352 join_path(self.plugin_path, '.build/rpm/plugin_rpm.spec'),
@@ -340,19 +360,42 @@ class TestBaseBuildV3(BaseBuild):
340 'year': '2014', 360 'year': '2014',
341 'preinstall_hook': 'echo preinst', 361 'preinstall_hook': 'echo preinst',
342 'postinstall_hook': 'echo postinst', 362 'postinstall_hook': 'echo postinst',
343 'uninstall_hook': 'echo uninst'}) 363 'uninstall_hook': 'echo uninst',
344 364 'build_version': '1'})
345 utils_mock.exec_cmd.assert_called_once_with( 365
346 'rpmbuild -vv --nodeps --define "_topdir {0}" -bb ' 366 def test_make_package_with_build_version(self):
347 '{1}'.format( 367
348 self.path_from_plugin('.build/rpm'), 368 meta = {
349 self.path_from_plugin('.build/rpm/plugin_rpm.spec'))) 369 'releases': BaseBuild.releases,
370 'version': '1.2.3',
371 'name': 'plugin_name',
372 'title': 'Plugin title',
373 'description': 'Description',
374 'licenses': ['Apache', 'BSD'],
375 'authors': ['author1', 'author2'],
376 'homepage': 'url',
377 'build_version': '34'
378 }
379
380 self.builder = self.create_builder(self.plugin_path, meta=meta)
381 utils_mock = self._test_make_package()
350 382
351 utils_mock.copy_files_in_dir.assert_called_once_with( 383 spec_src = os.path.abspath(join_path(
352 self.path_from_plugin('.build/rpm/RPMS/noarch/*.rpm'), 384 os.path.dirname(__file__), '..',
353 self.plugin_path) 385 self.builder.rpm_spec_src_path))
354 386
355 utils_mock.read_if_exist.assert_has_calls([ 387 utils_mock.render_to_file.assert_called_once_with(
356 mock.call(self.path_from_plugin('uninstall.sh')), 388 spec_src,
357 mock.call(self.path_from_plugin('pre_install.sh')), 389 join_path(self.plugin_path, '.build/rpm/plugin_rpm.spec'),
358 mock.call(self.path_from_plugin('post_install.sh'))]) 390 {'vendor': 'author1, author2',
391 'description': 'Description',
392 'license': 'Apache and BSD',
393 'summary': 'Plugin title',
394 'version': '1.2.3',
395 'homepage': 'url',
396 'name': 'plugin_name-1.2',
397 'year': '2014',
398 'preinstall_hook': 'echo preinst',
399 'postinstall_hook': 'echo postinst',
400 'uninstall_hook': 'echo uninst',
401 'build_version': '34'})