Browse Source

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
tags/4.2.0
alexz 2 years ago
parent
commit
dd03155047

+ 4
- 1
fuel_plugin_builder/actions/build.py View File

@@ -253,10 +253,13 @@ class BuildPluginV3(BuildPluginV2):
253 253
         postinst = utils.read_if_exist(
254 254
             join_path(self.plugin_path, "post_install.sh"))
255 255
 
256
+        plugin_build_version = str(self.meta.get('build_version', '1'))
257
+
256 258
         data.update(
257 259
             {'postinstall_hook': postinst,
258 260
              'preinstall_hook': preinst,
259
-             'uninstall_hook': uninst}
261
+             'uninstall_hook': uninst,
262
+             'build_version': plugin_build_version}
260 263
         )
261 264
 
262 265
         return data

+ 1
- 1
fuel_plugin_builder/cli.py View File

@@ -65,7 +65,7 @@ def parse_args():
65 65
         description='fpb is a fuel plugin builder which '
66 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 69
     # exclusive group, because in this case we could not
70 70
     # support such behavior [-a xxx | [-b yyy -c zzz]]
71 71
     group = parser.add_mutually_exclusive_group(required=True)

+ 1
- 1
fuel_plugin_builder/templates/v3/build/plugin_rpm.spec.mako View File

@@ -16,7 +16,7 @@ Source0:        ${ name }.fp
16 16
 Vendor:         ${ vendor }
17 17
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
18 18
 Group:          Development/Libraries
19
-Release:        1
19
+Release:        ${ build_version }
20 20
 BuildArch:      noarch
21 21
 AutoReq:        no
22 22
 

+ 60
- 17
fuel_plugin_builder/tests/test_build.py View File

@@ -46,10 +46,11 @@ class BaseBuild(BaseTestCase):
46 46
         self.plugin_path = '/tmp/{0}'.format(self.plugins_name)
47 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 51
         with mock.patch(
51 52
                 'fuel_plugin_builder.actions.build.utils.parse_yaml',
52
-                return_value=self.meta):
53
+                return_value=meta):
53 54
             return self.builder_class(plugin_path)
54 55
 
55 56
     def test_run(self):
@@ -310,7 +311,7 @@ class TestBaseBuildV3(BaseBuild):
310 311
         return join_path(self.plugin_path, path)
311 312
 
312 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 315
         utils_mock.get_current_year.return_value = '2014'
315 316
         utils_mock.read_if_exist.side_effect = ['echo uninst', 'echo preinst',
316 317
                                                 'echo postinst']
@@ -324,9 +325,28 @@ class TestBaseBuildV3(BaseBuild):
324 325
             fp_dst,
325 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 346
         spec_src = os.path.abspath(join_path(
328 347
             os.path.dirname(__file__), '..',
329 348
             self.builder.rpm_spec_src_path))
349
+
330 350
         utils_mock.render_to_file.assert_called_once_with(
331 351
             spec_src,
332 352
             join_path(self.plugin_path, '.build/rpm/plugin_rpm.spec'),
@@ -340,19 +360,42 @@ class TestBaseBuildV3(BaseBuild):
340 360
              'year': '2014',
341 361
              'preinstall_hook': 'echo preinst',
342 362
              'postinstall_hook': 'echo postinst',
343
-             'uninstall_hook': 'echo uninst'})
344
-
345
-        utils_mock.exec_cmd.assert_called_once_with(
346
-            'rpmbuild -vv --nodeps --define "_topdir {0}" -bb '
347
-            '{1}'.format(
348
-                self.path_from_plugin('.build/rpm'),
349
-                self.path_from_plugin('.build/rpm/plugin_rpm.spec')))
363
+             'uninstall_hook': 'echo uninst',
364
+             'build_version': '1'})
365
+
366
+    def test_make_package_with_build_version(self):
367
+
368
+        meta = {
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(
352
-            self.path_from_plugin('.build/rpm/RPMS/noarch/*.rpm'),
353
-            self.plugin_path)
383
+        spec_src = os.path.abspath(join_path(
384
+            os.path.dirname(__file__), '..',
385
+            self.builder.rpm_spec_src_path))
354 386
 
355
-        utils_mock.read_if_exist.assert_has_calls([
356
-            mock.call(self.path_from_plugin('uninstall.sh')),
357
-            mock.call(self.path_from_plugin('pre_install.sh')),
358
-            mock.call(self.path_from_plugin('post_install.sh'))])
387
+        utils_mock.render_to_file.assert_called_once_with(
388
+            spec_src,
389
+            join_path(self.plugin_path, '.build/rpm/plugin_rpm.spec'),
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'})

Loading…
Cancel
Save