#523 Add new layout for packages that missing specfile
Merged 2 years ago by onosek. Opened 2 years ago by onosek.
onosek/rpkg incomplete_layout  into  master

file modified
+2 -1
@@ -11,7 +11,8 @@ 

  

  from pyrpkg.errors import LayoutError

  from .base import MetaLayout

- from .layouts import DistGitLayout, RetiredLayout, SRPMLayout  # noqa

+ from .layouts import (DistGitLayout, IncompleteLayout, RetiredLayout,

+                      SRPMLayout)  # noqa

  

  

  def build(path):

file modified
+27
@@ -79,6 +79,33 @@ 

          return cls(root_dir=path)

  

  

+ class IncompleteLayout(BaseLayout):

+     """

+     This layout is possibly missing specfile(s) or some other essentials

+     of previous layouts. Doesn't have to be retired yet. Just enough layout

+     to allow run 'retire' command.

+     """

+     def __init__(self, root_dir=None, sources_file_template='sources'):

+         """

+         Default class constructor to create a new object instance.

+         """

+         self.root_dir = root_dir

+         self.sources_file_template = sources_file_template

+ 

+     @classmethod

+     def from_path(cls, path):

+         """

+         Creates a new object instance from a valid path in the file system.

+ 

+         Raises exception if package is already retired.

+         """

+         super(IncompleteLayout, cls).from_path(path)

+ 

+         if cls(root_dir=path).is_retired():

+             raise LayoutError('Retired marker found.')

+         return cls(root_dir=path)

+ 

+ 

  class RetiredLayout(BaseLayout):

      """

      This class represents situation that package or module is retired.

empty or binary file added
@@ -0,0 +1,37 @@ 

+ import os

+ import unittest

+ 

+ from pyrpkg.layout import layouts

+ from pyrpkg import errors

+ 

+ 

+ fixtures_dir = os.path.join(os.path.dirname(__file__), 'fixtures')

+ 

+ 

+ class IncompleteLayoutTestCase(unittest.TestCase):

+     def setUp(self):

+         self.workdir = os.path.join(fixtures_dir, 'layouts/incomplete-package')

+         self.layout = layouts.IncompleteLayout.from_path(self.workdir)

+ 

+     def test_layout_data(self):

+         self.assertEqual(self.layout.sourcedir, None)

+         self.assertEqual(self.layout.specdir, None)

+         self.assertEqual(self.layout.specdir, None)

+         self.assertEqual(self.layout.root_dir, self.workdir)

+         self.assertEqual(self.layout.builddir, None)

+         self.assertEqual(self.layout.rpmdir, None)

+         self.assertEqual(self.layout.srcrpmdir, None)

+         self.assertEqual(self.layout.sources_file_template, 'sources')

+ 

+     def test_layout_not_retired(self):

+         self.assertEqual(None, self.layout.is_retired())

+ 

+ 

+ class IncompleteLayoutErrorsTestCase(unittest.TestCase):

+     def setUp(self):

+         self.workdir = os.path.join(fixtures_dir, 'layouts')

+ 

+     def test_path_error(self):

+         with self.assertRaises(errors.LayoutError) as e:

+             layouts.IncompleteLayout.from_path(os.path.join(self.workdir, 'notfound'))

+         self.assertEqual('package path does not exist', e.exception.args[0])

Some packages are missing some files that are essential for other
layouts. For example specfile(s). Rpkg detects these packages
and assigns the layout to them. It allows 'retire' command for these
packages.

JIRA: RHELCMP-2682
Resolves: rhbz#1885771

Signed-off-by: Ondrej Nosek onosek@redhat.com

rebased onto e81edab6c0dedebba86d050f318caf333211d78a

2 years ago

rebased onto ec856a9fe5737464cc703d5a0e1f259a3d0b0650

2 years ago

rebased onto 470a393

2 years ago

Pull-Request has been merged by onosek

2 years ago