#544 Add support for new EPEL10 major/minor schema
Merged 10 days ago by onosek. Opened 4 months ago by dherrera.
dherrera/fedpkg epel10-work  into  master

file modified
+9 -6
@@ -88,14 +88,17 @@ 

              self.mockconfig = 'fedora-%s-%s' % (self._distval, self.localarch)

              self.override = 'f%s-override' % self._distval

              self._distunset = 'rhel'

-         # Works until RHEL 10

          elif re.match(r'el\d$', branch) or \

-                 re.match(r'epel\d$', branch):

-             self._distval = branch.split('el')[1]

+                 re.match(r'epel\d+(?:\.\d+)?$', branch):

+             major, minor = re.findall(r'(\d+)(?:\.(\d+))?', branch)[0]

+             self._distval = major

              self._distvar = 'rhel'

-             self._disttag = 'el%s' % self._distval

-             self.mockconfig = 'epel-%s-%s' % (self._distval, self.localarch)

-             self.override = 'epel%s-override' % self._distval

+             self._disttag = 'el%s' % major if minor == '' \

+                 else 'el%s_%s' % (major, minor)

+             self.mockconfig = 'epel-%s-%s' % (major, self.localarch) if minor == '' \

+                 else 'epel-%s.%s-%s' % (major, minor, self.localarch)

+             self.override = 'epel%s-override' % self._distval if minor == '' \

+                 else 'epel%s.%s-override' % (major, minor)

              self._distunset = 'fedora'

          elif re.match(r'epel\d+-next$', branch):

              self._distval = re.search(r'\d+', branch).group(0)

file modified
+13 -7
@@ -311,7 +311,7 @@ 

      :param branch: a string of the branch name

      :return: a boolean

      """

-     return bool(re.match(r'^(?:el|epel)\d+(?:-next)?$', branch))

+     return bool(re.match(r'^(?:el|epel)\d+(?:\.\d+)?(?:-next)?$', branch))

  

  

  def assert_valid_epel_package(name, branch):
@@ -322,16 +322,22 @@ 

      :param branch: a string of the EPEL branch name (e.g. epel7)

      :return: None or rpkgError

      """

-     # Extract any digits in the branch name to determine the EL version

-     version = ''.join([i for i in branch if re.match(r'\d', i)])

+     # Extract the major part of the EL version

+     version, _ = re.findall(r'(\d+)(?:\.(\d+))?', branch)[0]

  

      # Starting with epel9 and epel9-next, check against CentOS compose metadata.

      if int(version) >= 9:

-         # Currently we only have a latest symlink.  In the future we'll need

-         # separate latest symlinks that include the major version.

+         # Currently the stream-9 branch resides in the production address path..

+         # To remove this block, we need for the stream-9 link to point to production

          # https://bugzilla.redhat.com/show_bug.cgi?id=2005139

-         url = 'https://composes.stream.centos.org/production/' \

-               'latest-CentOS-Stream/compose/metadata/rpms.json'

+         if int(version) == 9:

+             url = 'https://composes.stream.centos.org/production/' \

+                   'latest-CentOS-Stream/compose/metadata/rpms.json'

+         else:

+             url = ('https://composes.stream.centos.org/stream-{0}/'

+                    'production/latest-CentOS-Stream/compose/metadata/rpms.json'

+                    .format(version))

+ 

          error_msg = ('The connection to composes.stream.centos.org failed while '

                       'trying to determine if this is a valid EPEL package.')

          try:

file modified
+30
@@ -267,6 +267,36 @@ 

          self.assert_rpmdefines()

  

      @patch('pyrpkg.Commands.branch_merge', new_callable=PropertyMock)

+     def test_load_epel10_dist_tag(self, branch_merge):

+         branch_merge.return_value = 'epel10'

+ 

+         self.cmd.load_rpmdefines()

+ 

+         self.assertEqual('10', self.cmd._distval)

+         self.assertEqual('rhel', self.cmd._distvar)

+         self.assertEqual('el10', self.cmd._disttag)

+         self.assertEqual('epel-10-i686', self.cmd.mockconfig)

+         self.assertEqual('epel10-override', self.cmd.override)

+         self.assertTrue(hasattr(self.cmd, '_distunset'))

+ 

+         self.assert_rpmdefines()

+ 

+     @patch('pyrpkg.Commands.branch_merge', new_callable=PropertyMock)

+     def test_load_epel10_10_dist_tag(self, branch_merge):

+         branch_merge.return_value = 'epel10.10'

+ 

+         self.cmd.load_rpmdefines()

+ 

+         self.assertEqual('10', self.cmd._distval)

+         self.assertEqual('rhel', self.cmd._distvar)

+         self.assertEqual('el10_10', self.cmd._disttag)

+         self.assertEqual('epel-10.10-i686', self.cmd.mockconfig)

+         self.assertEqual('epel10.10-override', self.cmd.override)

+         self.assertTrue(hasattr(self.cmd, '_distunset'))

+ 

+         self.assert_rpmdefines()

+ 

+     @patch('pyrpkg.Commands.branch_merge', new_callable=PropertyMock)

      @patch('fedpkg.Commands._findrawhidebranch')

      def test_load_rawhide_dist_tag(self, _findrawhidebranch, branch_merge):

          _findrawhidebranch.return_value = '28'

file modified
+82
@@ -207,6 +207,25 @@ 

          )

  

  

+ class TestIsEpel(unittest.TestCase):

+     """Test is_epel"""

+ 

+     def test_valid_epel_branch_names(self):

+         self.assertEqual(utils.is_epel("el6"), True)

+         self.assertEqual(utils.is_epel("epel7"), True)

+         self.assertEqual(utils.is_epel("epel8"), True)

+         self.assertEqual(utils.is_epel("epel8-next"), True)

+         self.assertEqual(utils.is_epel("epel9"), True)

+         self.assertEqual(utils.is_epel("epel9-next"), True)

+         self.assertEqual(utils.is_epel("epel10"), True)

+         self.assertEqual(utils.is_epel("epel10.1"), True)

+         self.assertEqual(utils.is_epel("epel10.10"), True)

+         self.assertEqual(utils.is_epel("epel10.11"), True)

+ 

+         self.assertEqual(utils.is_epel("f36"), False)

+         self.assertEqual(utils.is_epel("rawhide"), False)

+ 

+ 

  @patch('requests.get')

  class TestAssertValidEPELPackage(unittest.TestCase):

      """Test assert_valid_epel_package"""
@@ -225,6 +244,69 @@ 

              self, rpkgError, 'The status code was: 404',

              utils.assert_valid_epel_package, 'pkg', 'epel7')

  

+     def test_correct_url_epel7(self, get):

+         get.return_value = Mock(ok=False, status_code=404)

+ 

+         six.assertRaisesRegex(

+             self, rpkgError, 'The status code was: 404',

+             utils.assert_valid_epel_package, 'pkg', 'epel7')

+         get.assert_called_once_with(

+             'https://infrastructure.fedoraproject.org/repo/json/pkg_el7.json',

+             timeout=60)

+ 

+     def test_correct_url_epel8(self, get):

+         get.return_value = Mock(ok=False, status_code=404)

+ 

+         six.assertRaisesRegex(

+             self, rpkgError, 'The status code was: 404',

+             utils.assert_valid_epel_package, 'pkg', 'epel8')

+         get.assert_called_once_with(

+             'https://infrastructure.fedoraproject.org/repo/json/pkg_el8.json',

+             timeout=60)

+ 

+     def test_correct_url_epel8_next(self, get):

+         get.return_value = Mock(ok=False, status_code=404)

+ 

+         six.assertRaisesRegex(

+             self, rpkgError, 'The status code was: 404',

+             utils.assert_valid_epel_package, 'pkg', 'epel8-next')

+         get.assert_called_once_with(

+             'https://infrastructure.fedoraproject.org/repo/json/pkg_el8.json',

+             timeout=60)

+ 

+     def test_correct_url_epel9(self, get):

+         get.return_value = Mock(ok=False, status_code=404)

+ 

+         six.assertRaisesRegex(

+             self, rpkgError, 'The status code was: 404',

+             utils.assert_valid_epel_package, 'pkg', 'epel9')

+         get.assert_called_once_with(

+             'https://composes.stream.centos.org/production/'

+             'latest-CentOS-Stream/compose/metadata/rpms.json',

+             timeout=60)

+ 

+     def test_correct_url_epel10(self, get):

+         get.return_value = Mock(ok=False, status_code=404)

+ 

+         six.assertRaisesRegex(

+             self, rpkgError, 'The status code was: 404',

+             utils.assert_valid_epel_package, 'pkg', 'epel10')

+         get.assert_called_once_with(

+             'https://composes.stream.centos.org/stream-10/production'

+             '/latest-CentOS-Stream/compose/metadata/rpms.json',

+             timeout=60)

+ 

+     def test_correct_url_epel10_10(self, get):

+         get.return_value = Mock(ok=False, status_code=404)

+ 

+         six.assertRaisesRegex(

+             self, rpkgError, 'The status code was: 404',

+             utils.assert_valid_epel_package, 'pkg', 'epel10.10')

+         get.assert_called_once_with(

+             'https://composes.stream.centos.org/stream-10/production'

+             '/latest-CentOS-Stream/compose/metadata/rpms.json',

+             timeout=60)

+ 

      def test_should_not_have_epel_branch_for_el6_pkg(self, get):

          get.return_value.json.return_value = {

              'arches': [

These changes are required to support EPEL10 new schemas [0]

Things that changed
- Support for reading mayor/minor version on the epel name through the code
- Fixed assert_valid_epel_package to work correctly with EPEL10 [1]
- Changed load_rpmdefines method to get correct information regarding EPEL10.X branches

[0] https://discussion.fedoraproject.org/t/epel-10-proposal/44304
[1] https://bugzilla.redhat.com/show_bug.cgi?id=2005139

1 new commit added

  • Fix mayor -> major
4 months ago

Double checking: Is this still a work in progress?

rebased onto af020e9

21 days ago

I think we can use a similar regex here as we use in other files, that doesn't limit the major or minor version to two digits.

epel\d+(?:\.\d+)?$

Instead of defining url twice, I think it would make sense to use an if/else statement here and always assign url once. We can also drop the comments about currently only having the latest symlink as it's no longer accurate.

We may want to test with an actual Fedora branch name like f36 instead of fedora36.

I think this is a typo and should be rawhide.

3 new commits added

  • Fix new test typo
  • Fix assert_valid_epel_package url for EPEL10+
  • Remove up to 2 digit limitation for EPEL branch name
16 days ago

Addressed @carlwgeorge 's comments and fixed an issue in my assert_valid_epel_package implementation where epel10+ didn't point to the correct path.

rebased onto af020e9

16 days ago

Remade the branch so that it's easier to navigate.
Old branch is at dherrera/fedpkg/old-epel10-work

This looks good to me.

@onosek, what do you think? We're eager to get this bit of code out to unblock requesting epel10 branches. I know you just recently released version 1.45, so if you're not wanting to tag another release so soon we'd be happy to add a patch to the fedpkg spec file to include this.

1 new commit added

  • Intentation fix reported by flake8
14 days ago

6 new commits added

  • Intentation fix reported by flake8
  • Extend load_rpmdefines to work with EPEL10+
  • Add EPEL10+ url pattern on assert_valid_epel_package
  • Test url usage in assert_valid_epel_package
  • Add EPEL10 branch name cases as valid
  • Test for valid EPEL branch names
14 days ago

The latest commit is just an indentation fix found after fixing flake8 in the CI env ( PR #553 ).

rebased onto 0db445b

10 days ago

Commit a270fc7 fixes this pull-request

Pull-Request has been merged by onosek

10 days ago

Thanks for the change. I just put the flake8 fix from the last commit directly into the relevant commit.