#292 Sync scriplets check with latest guidelines
Closed 6 years ago by leamas. Opened 6 years ago by eclipseo.
Unknown source update_scriplets  into  master

file modified
+206 -28
@@ -1567,8 +1567,8 @@

  

      def __init__(self, base):

          GenericCheckBase.__init__(self, base)

-         self.url = 'http://fedoraproject.org/wiki/Packaging' \

-                    ':ScriptletSnippets#Icon_Cache'

+         self.url = 'https://fedoraproject.org/wiki/EPEL' \

+                    ':Packaging#Icon_Cache'

          self.text = 'gtk-update-icon-cache is invoked in %postun' \

                      ' and %posttrans if package contains icons.'

          self.automatic = True
@@ -1581,14 +1581,26 @@

              if self.rpms.find('/usr/share/icons/*', pkg):

                  using.append(pkg)

                  rpm_pkg = self.rpms.get(pkg)

-                 if not in_list('gtk-update-icon-cache',

-                                [rpm_pkg.postun, rpm_pkg.posttrans]):

-                     failed = True

+                 if self.flags['EPEL5'] or self.flags['EPEL6'] \

+                     or self.flags['EPEL7']:

+                     if not in_list('gtk-update-icon-cache',

+                                 [rpm_pkg.postun, rpm_pkg.posttrans]):

+                         failed = True

+                 else:

+                     if in_list('gtk-update-icon-cache',

+                                 [rpm_pkg.postun, rpm_pkg.posttrans]):

+                         failed = True

          if not using:

              self.set_passed(self.NA)

              return

          text = "icons in " + ', '.join(using)

-         self.set_passed(self.FAIL if failed else self.PENDING, text)

+         if self.flags['EPEL5'] or self.flags['EPEL6'] or self.flags['EPEL7']:

+             self.set_passed(self.FAIL if failed else self.PENDING, text)

+         else:

+             self.url = ''

+             self.text = 'gtk-update-icon-cache must not be invoked' \

+                         ' in %post and %posttrans for Fedora 26 and later.'

+             self.set_passed(self.FAIL if failed else self.NA, text)

  

  

  class CheckUpdateDesktopDatabase(GenericCheckBase):
@@ -1596,11 +1608,12 @@

  

      def __init__(self, base):

          GenericCheckBase.__init__(self, base)

-         self.url = 'http://fedoraproject.org/wiki/Packaging' \

-                    ':ScriptletSnippets#desktop-database'

+         self.url = 'https://fedoraproject.org/wiki/EPEL' \

+                    ':Packaging#desktop-database'

          self.text = 'update-desktop-database is invoked in %post and' \

                      ' %postun if package contains desktop file(s)' \

                      ' with a MimeType: entry.'

+ 

          self.automatic = True

          self.needs.append('generic-large-docs')   # Needed to unpack rpms

          self.type = 'MUST'
@@ -1633,14 +1646,27 @@

              if dt_files:

                  using.append(pkg)

                  rpm_pkg = self.rpms.get(pkg)

-                 if not in_list('update-desktop-database',

-                                [rpm_pkg.post, rpm_pkg.postun]):

-                     failed = True

+                 if self.flags['EPEL5'] or self.flags['EPEL6'] \

+                     or self.flags['EPEL7']:

+                     if not in_list('update-desktop-database',

+                                 [rpm_pkg.post, rpm_pkg.postun]):

+                         failed = True

+                 else:

+                     if in_list('update-desktop-database',

+                             [rpm_pkg.post, rpm_pkg.postun]):

+                         failed = True

          if not using:

              self.set_passed(self.NA)

              return

          text = "desktop file(s) with MimeType entry in " + ', '.join(using)

-         self.set_passed(self.FAIL if failed else self.PENDING, text)

+         if self.flags['EPEL5'] or self.flags['EPEL6'] or self.flags['EPEL7']:

+             self.set_passed(self.FAIL if failed else self.PENDING, text)

+         else:

+             self.url = 'https://fedoraproject.org/w/index.php?title=' \

+                        'Packaging:Scriptlets&oldid=494555#desktop-database'

+             self.text = 'update-desktop-database must not be invoked' \

+                         ' in %post and %postun for Fedora 24 and later.'

+             self.set_passed(self.FAIL if failed else self.NA, text)

  

  

  class CheckGioQueryModules(GenericCheckBase):
@@ -1665,14 +1691,27 @@

              if self.rpms.find(gio_pattern, pkg):

                  using.append(pkg)

                  rpmpkg = self.rpms.get(pkg)

-                 if not in_list('gio-querymodules',

-                                [rpmpkg.post, rpmpkg.postun]):

-                     failed = True

+                 if self.flags['EPEL5'] or self.flags['EPEL6'] \

+                     or self.flags['EPEL7']:

+                     if not in_list('gio-querymodules',

+                                 [rpmpkg.post, rpmpkg.postun]):

+                         failed = True

+                 else:

+                     if in_list('gio-querymodules',

+                                 [rpmpkg.post, rpmpkg.postun]):

+                         failed = True

          if not using:

              self.set_passed(self.NA)

              return

          text = "gio module file(s) in " + ', '.join(using)

-         self.set_passed(self.FAIL if failed else self.PENDING, text)

+         if self.flags['EPEL5'] or self.flags['EPEL6'] or self.flags['EPEL7']:

+             self.set_passed(self.FAIL if failed else self.PENDING, text)

+         else:

+             self.url = 'https://fedoraproject.org/w/index.php?title=' \

+                        'Packaging:Scriptlets&oldid=494555#GIO_modules'

+             self.text = 'gio-querymodules must not be invoked in %postun' \

+                         ' and %post ifor Fedora 24 and later.'

+             self.set_passed(self.FAIL if failed else self.NA, text)

  

  

  class CheckGtkQueryModules(GenericCheckBase):
@@ -1680,9 +1719,10 @@

  

      def __init__(self, base):

          GenericCheckBase.__init__(self, base)

-         self.url = 'http://fedoraproject.org/wiki/Packaging' \

-                    ':ScriptletSnippets#GTK.2B_modules'

+         self.url = 'https://fedoraproject.org/wiki/EPEL' \

+                    ':Packaging#GTK.2B_modules'

          self.text = 'gtk-query-immodules is invoked when required'

+ 

          self.automatic = True

          self.type = 'MUST'

  
@@ -1695,14 +1735,28 @@

              if self.rpms.find(pattern, pkg):

                  using.append(pkg)

                  rpmpkg = self.rpms.get(pkg)

-                 if not in_list('gtk-query-immodules',

-                                [rpmpkg.postun, rpmpkg.posttrans]):

-                     failed = True

+                 if self.flags['EPEL5'] or self.flags['EPEL6'] \

+                     or self.flags['EPEL7']:

+                     if not in_list('gtk-query-immodules',

+                                 [rpmpkg.postun, rpmpkg.posttrans]):

+                         failed = True

+                 else:

+                     if in_list('gtk-query-immodules',

+                                 [rpmpkg.postun, rpmpkg.posttrans]):

+                         failed = True

+                     

          if not using:

              self.set_passed(self.NA)

              return

          text = "Gtk module file(s) in " + ', '.join(using)

-         self.set_passed(self.FAIL if failed else self.PENDING, text)

+         if self.flags['EPEL5'] or self.flags['EPEL6'] or self.flags['EPEL7']:

+             self.set_passed(self.FAIL if failed else self.PENDING, text)

+         else:

+             self.url = 'https://fedoraproject.org/w/index.php?title=' \

+                        'Packaging:Scriptlets&oldid=494555#GTK.2B_modules'

+             self.text = 'gtk-query-immodules must not be invoked for' \

+                         ' Fedora 24 and later.'

+             self.set_passed(self.FAIL if failed else self.NA, text)

  

  

  class CheckGlibCompileSchemas(GenericCheckBase):
@@ -1710,10 +1764,11 @@

  

      def __init__(self, base):

          GenericCheckBase.__init__(self, base)

-         self.url = 'http://fedoraproject.org/wiki/Packaging' \

-                    ':ScriptletSnippets#GSettings_Schema'

+         self.url = 'https://fedoraproject.org/wiki/EPEL' \

+                    ':Packaging#GSettings_Schema'

          self.text = 'glib-compile-schemas is run in %postun and' \

                      ' %posttrans if package has *.gschema.xml files. '

+ 

          self.automatic = True

          self.type = 'MUST'

  
@@ -1724,14 +1779,28 @@

              if self.rpms.find('*.gschema.xml', pkg):

                  using.append(pkg)

                  rpm_pkg = self.rpms.get(pkg)

-                 if not in_list('glib-compile-schemas',

-                                [rpm_pkg.postun, rpm_pkg.posttrans]):

-                     failed = True

+                 if self.flags['EPEL5'] or self.flags['EPEL6'] \

+                     or self.flags['EPEL7']:

+                     if not in_list('glib-compile-schemas',

+                                 [rpm_pkg.postun, rpm_pkg.posttrans]):

+                         failed = True

+                 else:

+                     if in_list('glib-compile-schemas',

+                                 [rpm_pkg.postun, rpm_pkg.posttrans]):

+                         failed = True

+                     

          if not using:

              self.set_passed(self.NA)

              return

          text = 'gschema file(s) in ' + ', '.join(using)

-         self.set_passed(self.FAIL if failed else self.PENDING, text)

+         if self.flags['EPEL5'] or self.flags['EPEL6'] or self.flags['EPEL7']:

+             self.set_passed(self.FAIL if failed else self.PENDING, text)

+         else:

+             self.url = 'https://fedoraproject.org/w/index.php?title=' \

+                        'Packaging:Scriptlets&oldid=494555#GSettings_Schema'

+             self.text = 'glib-compile-schemas must not be run in %postun and' \

+                         ' %posttrans for Fedora 24 and later.'

+             self.set_passed(self.FAIL if failed else self.NA, text)

  

  

  class CheckGconfSchemaInstall(GenericCheckBase):
@@ -1791,5 +1860,114 @@

          self.set_passed(self.FAIL if failed else self.PENDING, text)

  

  

+ class CheckGdkPixbufLoaders(GenericCheckBase):

+     ''' Check that gdk-pixbuf-query-loaders is run if required. '''

+ 

+     def __init__(self, base):

+         GenericCheckBase.__init__(self, base)

+         self.url = 'https://fedoraproject.org/wiki/EPEL' \

+                    ':Packaging#gdk-pixbuf_loaders'

+         self.text = 'gdk-pixbuf-query-loaders is invoked in %post and' \

+                     ' %postun to update gdk-pixbuf'

+ 

+         self.automatic = True

+         self.type = 'MUST'

+ 

+     def run(self):

+         using = []

+         failed = False

+         libdir = Mock.get_macro('%_libdir', self.spec, self.flags)

+         pattern = os.path.join(libdir, 'gdk-pixbuf-2.0/2.10.0/loaders/', '*')

+         for pkg in self.spec.packages:

+             if self.rpms.find(pattern, pkg):

+                 using.append(pkg)

+                 rpmpkg = self.rpms.get(pkg)

+                 if self.flags['EPEL5'] or self.flags['EPEL6'] \

+                     or self.flags['EPEL7']:

+                     if not in_list('gdk-pixbuf-query-loaders',

+                                 [rpmpkg.postun, rpmpkg.post]):

+                         failed = True

+                 else:

+                     if in_list('gdk-pixbuf-query-loaders',

+                                 [rpmpkg.postun, rpmpkg.post]):

+                         failed = True

+                     

+         if not using:

+             self.set_passed(self.NA)

+             return

+         text = "gdk-pixbux module file(s) in " + ', '.join(using)

+         if self.flags['EPEL5'] or self.flags['EPEL6'] or self.flags['EPEL7']:

+             self.set_passed(self.FAIL if failed else self.PENDING, text)

+         else:

+             self.url = 'https://fedoraproject.org/w/index.php?title=' \

+                        'Packaging:Scriptlets&oldid=494555#gdk-pixbuf_loaders'

+             self.text = 'gdk-pixbuf-query-loaders must not be invoked for' \

+                         ' Fedora 24 and later.'

+             self.set_passed(self.FAIL if failed else self.NA, text)

+ 

+ 

+ class CheckSystemdUnitdirScriplets(GenericCheckBase):

+     ''' Check that Systemd unitdir scriplets are run if required. '''

+ 

+     def __init__(self, base):

+         GenericCheckBase.__init__(self, base)

+         self.url = 'https://fedoraproject.org/wiki/Packaging' \

+                    ':Scriptlets#Scriptlets'

+         self.text = 'systemd_post is invoked in %post, systemd_preun in' \

+                     ' %preun, and systemd_postun in %postun for Systemd' \

+                     ' service files.'

+         self.automatic = True

+         self.type = 'MUST'

+ 

+     def run(self):

+         using = []

+         failed = False

+         for pkg in self.spec.packages:

+             if self.rpms.find('/usr/lib/systemd/system/*', pkg):

+                 using.append(pkg)

+                 rpmpkg = self.rpms.get(pkg)

+                 if not in_list('systemd_post', [rpmpkg.post]) \

+                     or not in_list('systemd_preun', [rpmpkg.preun]) \

+                     or not in_list('systemd_postun', [rpmpkg.postun]):

+                     failed = True

+                     

+         if not using:

+             self.set_passed(self.NA)

+             return

+         text = "Systemd service file(s) in " + ', '.join(using)

+         self.set_passed(self.FAIL if failed else self.PENDING, text)

+ 

+ 

+ class CheckSystemdUserunitdirScriplets(GenericCheckBase):

+     ''' Check that Systemd userunitdir scriplets are run if required. '''

+ 

+     def __init__(self, base):

+         GenericCheckBase.__init__(self, base)

+         self.url = 'https://fedoraproject.org/wiki/Packaging' \

+                    ':Scriptlets#User_units'

+         self.text = 'systemd_user_post is invoked in %post and' \

+                     ' systemd_user_preun in %preun for Systemd' \

+                     ' user units service files.'

+         self.automatic = True

+         self.type = 'MUST'

+ 

+     def run(self):

+         using = []

+         failed = False

+         for pkg in self.spec.packages:

+             if self.rpms.find('/usr/lib/systemd/user/*', pkg):

+                 using.append(pkg)

+                 rpmpkg = self.rpms.get(pkg)

+                 if not in_list('systemd_user_post', [rpmpkg.post]) \

+                     or not in_list('systemd_user_preun', [rpmpkg.preun]):

+                     failed = True

+                     

+         if not using:

+             self.set_passed(self.NA)

+             return

+         text = "Systemd user unit service file(s) in " + ', '.join(using)

+         self.set_passed(self.FAIL if failed else self.PENDING, text)

+ 

+ 

  #

  # vim: set expandtab ts=4 sw=4:

file modified
+24 -9
@@ -117,7 +117,7 @@

  

  

  class CheckClean(GenericShouldCheckBase):

-     ''' Packags has or has not %clean depending on EPEL5. '''

+     ''' Package has or has not %clean depending on EPEL5. '''

  

      def __init__(self, base):

          GenericShouldCheckBase.__init__(self, base)
@@ -750,9 +750,9 @@

  

      def __init__(self, base):

          GenericShouldCheckBase.__init__(self, base)

-         self.url = 'http://fedoraproject.org/wiki/Packaging' \

-                    ':ScriptletSnippets#mimeinfo'

-         self.text = 'update-mime-database is invoked in %post and' \

+         self.url = 'https://fedoraproject.org/wiki/EPEL' \

+                    ':Packaging#mimeinfo'

+         self.text = 'update-mime-database is invoked in %posttrans and' \

                      ' %postun if package stores mime configuration' \

                      ' in /usr/share/mime/packages.'

  
@@ -766,14 +766,29 @@

              if self.rpms.find('/usr/share/mime/packages/*', pkg):

                  using.append(pkg)

                  rpm_pkg = self.rpms.get(pkg)

-                 if not in_list('update-mime-database',

-                                [rpm_pkg.postun, rpm_pkg.post]):

-                     failed = True

+                 if self.flags['EPEL5'] or self.flags['EPEL6'] \

+                     or self.flags['EPEL7']:

+                     if not in_list('update-mime-database',

+                                 [rpm_pkg.postun, rpm_pkg.posttrans]):

+                         failed = True

+                 else:

+                     if in_list('update-mime-database',

+                                 [rpm_pkg.postun, rpm_pkg.posttrans]):

+                         failed = True

+                     

          if not using:

              self.set_passed(self.NA)

              return

-         text = "mimeinfo files in: " + ', '.join(using)

-         self.set_passed(self.FAIL if failed else self.PENDING, text)

+         text = 'mimeinfo file(s) in ' + ', '.join(using)

+         if self.flags['EPEL5'] or self.flags['EPEL6'] or self.flags['EPEL7']:

+             self.set_passed(self.FAIL if failed else self.PENDING, text)

+         else:

+             self.url = 'https://fedoraproject.org/w/index.php?title=' \

+                        'Packaging:Scriptlets&oldid=494555#mimeinfo'

+             self.text = 'update-mime-database must not be run in %postun and' \

+                         ' %posttrans for Fedora 24 and later.'

+ 

+             self.set_passed(self.FAIL if failed else self.NA, text)

  

  

  # vim: set expandtab ts=4 sw=4:

This PR does multiple things:

  • Remove the checking of scriplets which are deprecated since Fedora 24
  • A warning is issued if one use a deprecated scriplet
  • This deprecated scriplet are still in use in EPEL and the checks are activated accordingly if an EPEL flag is set
  • Add a check for gdk-pixbuf-query-loaders for EPEL
  • Add checks for systemd scriplets and user unit scriplets if a service file is detected

1 new commit added

  • Remove gtk-update-icon-cache check for Fedora
6 years ago

Thanks for patch! Committed into devel branch (I'm closing it for the master branch).

Pull-Request has been closed by leamas

6 years ago