forked from openSUSE/rpmlint-checks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckGNOMEMacros.py
185 lines (138 loc) · 7.8 KB
/
CheckGNOMEMacros.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# vim:sw=4:et
#############################################################################
# File : CheckGNOMEMacros.py
# Package : rpmlint
# Author : Vincent Untz
# Purpose : Check for GNOME related packaging errors
#############################################################################
import re
import string
import rpm
from Filter import *
import AbstractCheck
import Config
## FIXME
# Maybe detect packages installing icons in other themes than hicolor and not
# updating the icon cache for those themes?
_gnome_post_postun_checks = [
('glib2-gsettings-schema',
re.compile('^/usr/share/glib-2.0/schemas/.+\.gschema.xml$'),
'glib2-tools',
re.compile('^[^#]*glib-compile-schemas', re.MULTILINE),
True),
('glib2-gio-module',
re.compile('^/usr/lib(?:64)?/gio/modules/'),
'glib2-tools',
re.compile('^[^#]*gio-querymodules', re.MULTILINE),
True),
('gdk-pixbuf-loader',
re.compile('^/usr/lib(?:64)?/gdk-pixbuf-2.0/[^/]+/loaders/'),
'gdk-pixbuf-query-loaders',
re.compile('^[^#]*gdk-pixbuf-query-loaders', re.MULTILINE),
True),
('gtk2-immodule',
re.compile('^/usr/lib(?:64)?/gtk-2.0/[^/]+/immodules/'),
'gtk2',
re.compile('^[^#]*gtk-query-immodules-2.0', re.MULTILINE),
True),
('gtk3-immodule',
re.compile('^/usr/lib(?:64)?/gtk-3.0/[^/]+/immodules/'),
'gtk3-tools',
re.compile('^[^#]*gtk-query-immodules-3.0', re.MULTILINE),
True),
# Not fatal since it would make too many things fail
('hicolor-icon-cache',
re.compile('^/usr/share/icons/hicolor/'),
None,
re.compile('^[^#]*gtk-update-icon-cache', re.MULTILINE),
False),
('mime-database',
re.compile('^/usr/share/mime/packages/.+\.xml$'),
None,
re.compile('^[^#]*update-mime-database', re.MULTILINE),
True),
# Not fatal since it would make too many things fail
('desktop-database',
re.compile('^/usr/share/applications/.+\.desktop$'),
None,
re.compile('^[^#]*update-desktop-database', re.MULTILINE),
False)
]
_gnome_gconf_filename_re = re.compile('^/usr/share/GConf/schemas/.+\.schemas$')
_gnome_gconf_sciptlet_re = re.compile('^[^#]*gconftool-2', re.MULTILINE)
class GNOMECheck(AbstractCheck.AbstractCheck):
def __init__(self):
AbstractCheck.AbstractCheck.__init__(self, "CheckGNOMEMacros")
def check(self, pkg):
if pkg.isSource():
return
ghosts = pkg.ghostFiles()
pkg_requires = set(map(lambda x: string.split(x[0],'(')[0], pkg.requires()))
postin = pkg[rpm.RPMTAG_POSTIN] or pkg[rpm.RPMTAG_POSTINPROG]
postun = pkg[rpm.RPMTAG_POSTUN] or pkg[rpm.RPMTAG_POSTUNPROG]
posttrans = pkg[rpm.RPMTAG_POSTTRANS] or pkg[rpm.RPMTAG_POSTTRANSPROG]
for filename in (x for x in pkg.files() if x not in ghosts):
for (name, file_re, required, post_re, fatal) in _gnome_post_postun_checks:
if fatal:
gnomePrint = printError
else:
gnomePrint = printWarning
if file_re.search(filename):
if required and required not in pkg_requires:
gnomePrint(pkg, 'suse-' + name + '-missing-requires', filename)
if not postin or not post_re.search(postin):
gnomePrint(pkg, 'suse-' + name + '-missing-postin', filename)
if not postun or not post_re.search(postun):
gnomePrint(pkg, 'suse-' + name + '-missing-postun', filename)
if _gnome_gconf_filename_re.search(filename):
if not ((postin and _gnome_gconf_sciptlet_re.search(postin)) or
(posttrans and _gnome_gconf_sciptlet_re.search(posttrans))):
printError(pkg, 'suse-gconf-schema-missing-scriptlets', filename)
check=GNOMECheck()
if Config.info:
addDetails(
'suse-glib2-gsettings-schema-missing-requires',
'''A GSettings schema is in your package, but there is no dependency for the tool to recompile the schema database. Use %glib2_gsettings_schema_requires.''',
'suse-glib2-gsettings-schema-missing-postin',
'''A GSettings schema is in your package, but the schema database is not recompiled in the %post scriptlet. Use %glib2_gsettings_schema_post.''',
'suse-glib2-gsettings-schema-missing-postun',
'''A GSettings schema is in your package, but the schema database is not recompiled in the %postun scriptlet. Use %glib2_gsettings_schema_postun.''',
'suse-glib2-gio-module-missing-requires',
'''A GIO module is in your package, but there is no dependency for the tool to rebuild the GIO module cache. Use %glib2_gio_module_requires.''',
'suse-glib2-gio-module-missing-postin',
'''A GIO module is in your package, but the GIO module cache is not rebuilt in the %post scriptlet. Use %glib2_gio_module_post.''',
'suse-glib2-gio-module-missing-postun',
'''A GIO module is in your package, but the GIO module cache is not rebuilt in the %postun scriptlet. Use %glib2_gio_module_postun.''',
'suse-gdk-pixbuf-loader-missing-requires',
'''A gdk-pixbuf loader is in your package, but there is no dependency for the tool to rebuild the gdk-pixbuf loader cache. Use %gdk_pixbuf_loader_requires.''',
'suse-gdk-pixbuf-loader-missing-postin',
'''A gdk-pixbuf loader is in your package, but the gdk-pixbuf loader cache is not rebuilt in the %post scriptlet. Use %gdk_pixbuf_loader_post.''',
'suse-gdk-pixbuf-loader-missing-postun',
'''A gdk-pixbuf loader is in your package, but the gdk-pixbuf loader cache is not rebuilt in the %postun scriptlet. Use %gdk_pixbuf_loader_postun.''',
'suse-gtk2-immodule-missing-requires',
'''A GTK+ 2 IM module is in your package, but there is no dependency for the tool to rebuild the GTK+ 2 IM module cache. Use %gtk2_immodule_requires.''',
'suse-gtk2-immodule-missing-postin',
'''A GTK+ 2 IM module is in your package, but the GTK+ 2 IM module cache is not rebuilt in the %post scriptlet. Use %gtk2_immodule_post.''',
'suse-gtk2-immodule-missing-postun',
'''A GTK+ 2 IM module is in your package, but the GTK+ 2 IM module cache is not rebuilt in the %postun scriptlet. Use %gtk2_immodule_postun.''',
'suse-gtk3-immodule-missing-requires',
'''A GTK+ 3 IM module is in your package, but there is no dependency for the tool to rebuild the GTK+ 3 IM module cache. Use %gtk3_immodule_requires.''',
'suse-gtk3-immodule-missing-postin',
'''A GTK+ 3 IM module is in your package, but the GTK+ 3 IM module cache is not rebuilt in the %post scriptlet. Use %gtk3_immodule_post.''',
'suse-gtk3-immodule-missing-postun',
'''A GTK+ 3 IM module is in your package, but the GTK+ 3 IM module cache is not rebuilt in the %postun scriptlet. Use %gtk3_immodule_postun.''',
'suse-hicolor-icon-cache-missing-postin',
'''An icon for the hicolor theme is in your package, but the hicolor icon cache is not rebuilt in the %post scriptlet. Use %icon_theme_cache_post.''',
'suse-hicolor-icon-cache-missing-postun',
'''An icon for the hicolor theme is in your package, but the hicolor icon cache is not rebuilt in the %postun scriptlet. Use %icon_theme_cache_postun.''',
'suse-mime-database-missing-postin',
'''A MIME definition is in your package, but the MIME database is not rebuilt in the %post scriptlet. Use %mime_database_post.''',
'suse-mime-database-missing-postun',
'''A MIME definition is in your package, but the MIME database is not rebuilt in the %postun scriptlet. Use %mime_database_postun.''',
'suse-desktop-database-missing-postin',
'''A desktop file is in your package, but the desktop database is not rebuilt in the %post scriptlet. Use %desktop_database_post.''',
'suse-desktop-database-missing-postun',
'''A desktop file is in your package, but the desktop database is not rebuilt in the %postun scriptlet. Use %desktop_database_postun.''',
'suse-gconf-schema-missing-scriptlets',
'''A GConf schema is in your package, but the GConf configuration is not updated by scriptlets. Please use the gconf RPM macros.'''
)