diff --git a/branches/ucs-3.1/ucs/base/univention-config-registry/debian/changelog b/branches/ucs-3.1/ucs/base/univention-config-registry/debian/changelog index a4819a3..2ddba68 100644 --- a/branches/ucs-3.1/ucs/base/univention-config-registry/debian/changelog +++ b/branches/ucs-3.1/ucs/base/univention-config-registry/debian/changelog @@ -1,3 +1,9 @@ +univention-config-registry (8.0.2-1) unstable; urgency=low + + * Support modules for multifiles (Bug #26058) + + -- Philipp Hahn Wed, 15 Aug 2012 16:48:51 +0200 + univention-config-registry (8.0.1-2) unstable; urgency=low * Fix error handling in univention-install-config-registry (Bug #3952) diff --git a/branches/ucs-3.1/ucs/base/univention-config-registry/python/univention/config_registry.py b/branches/ucs-3.1/ucs/base/univention-config-registry/python/univention/config_registry.py index c1d8882..4543f95 100644 --- a/branches/ucs-3.1/ucs/base/univention-config-registry/python/univention/config_registry.py +++ b/branches/ucs-3.1/ucs/base/univention-config-registry/python/univention/config_registry.py @@ -466,6 +466,8 @@ class configHandlerDiverting(configHandler): self.user = None self.group = None self.mode = None + self.preinst = None + self.postinst = None def __hash__(self): return hash(self.to_file) @@ -549,6 +551,9 @@ class configHandlerMultifile(configHandlerDiverting): ucr, changed = args print 'Multifile: %s' % self.to_file + if hasattr(self, 'preinst') and self.preinst: + runModule(self.preinst, 'preinst', ucr, changed) + if self.def_count == 0 or not self.from_files: return @@ -574,6 +579,9 @@ class configHandlerMultifile(configHandlerDiverting): self._set_perm(st) to_fp.close() + if hasattr( self, 'postinst' ) and self.postinst: + runModule(self.postinst, 'postinst', ucr, changed) + script_file = os.path.join(script_dir, self.to_file.strip("/")) if os.path.isfile(script_file): runScript(script_file, 'postinst', changed) @@ -597,13 +605,11 @@ class configHandlerFile(configHandlerDiverting): def __init__(self, from_file, to_file): super(configHandlerFile, self).__init__(to_file) self.from_file = from_file - self.preinst = None - self.postinst = None def __call__(self, args): ucr, changed = args - if hasattr( self, 'preinst') and self.preinst: + if hasattr(self, 'preinst') and self.preinst: runModule(self.preinst, 'preinst', ucr, changed) print 'File: %s' % self.to_file @@ -734,58 +740,62 @@ class configHandlers: else: return m(entry) - def _get_handler_file(self, entry): - """Parse file entry and return Handler instance.""" - try: - name = entry['File'][0] - except LookupError: - return None - from_path = os.path.join(file_dir, name) - handler = configHandlerFile(from_path, name) - if os.path.exists(from_path): - handler.variables = grepVariables(open(from_path, 'r').read()) + def _parse_common_file_handler(self, handler, entry); + """Parse common file and multifile entries.""" + try: + handler.preinst = entry['Preinst'][0] + except LookupError: + pass - try: - handler.preinst = entry['Preinst'][0] - except LookupError: - pass + try: + handler.postinst = entry['Postinst'][0] + except LookupError: + pass + handler.variables |= set(entry.get('Variables', set())) + + try: + user = entry['User'][0] + except LookupError: + pass + else: try: - handler.postinst = entry['Postinst'][0] + handler.user = pwd.getpwnam(user).pw_uid except LookupError: - pass - - handler.variables |= set(entry.get('Variables', set())) + print >> sys.stderr, 'W: failed to convert the username %s to the uid' % (user,) + try: + group = entry['Group'][0] + except LookupError: + pass + else: try: - user = entry['User'][0] + handler.group = grp.getgrnam(group).gr_gid except LookupError: - pass - else: - try: - handler.user = pwd.getpwnam(user).pw_uid - except LookupError: - print >> sys.stderr, 'W: failed to convert the username %s to the uid' % (user,) + print >> sys.stderr, 'W: failed to convert the groupname %s to the gid' % (group,) + try: + mode = entry['Mode'][0] + except LookupError: + pass + else: try: - group = entry['Group'][0] - except LookupError: - pass - else: - try: - handler.group = grp.getgrnam(group).gr_gid - except LookupError: - print >> sys.stderr, 'W: failed to convert the groupname %s to the gid' % (group,) + handler.mode = int(mode, 8) + except ValueError: + print >> sys.stderr, 'W: failed to convert mode %s' % (mode,) + def _get_handler_file(self, entry): + """Parse file entry and return Handler instance.""" try: - mode = entry['Mode'][0] + name = entry['File'][0] except LookupError: - pass - else: - try: - handler.mode = int(mode, 8) - except ValueError: - print >> sys.stderr, 'W: failed to convert mode %s' % (mode,) + return None + from_path = os.path.join(file_dir, name) + handler = configHandlerFile(from_path, name) + if os.path.exists(from_path): + handler.variables = grepVariables(open(from_path, 'r').read()) + + self._parse_common_file_handler(handler, entry) return handler @@ -824,38 +834,7 @@ class configHandlers: from_path = os.path.join(file_dir, mfile) handler = configHandlerMultifile(from_path, mfile) - handler.variables |= set(entry.get('Variables', set())) - - try: - user = entry['User'][0] - except LookupError: - pass - else: - try: - handler.user = pwd.getpwnam(user).pw_uid - except LookupError: - print >> sys.stderr, 'W: failed to convert the username %s to the uid' % (user,) - - try: - group = entry['Group'][0] - except LookupError: - pass - else: - try: - handler.group = grp.getgrnam(group).gr_gid - except LookupError: - print >> sys.stderr, 'W: failed to convert the groupname %s to the gid' % (group,) - - try: - mode = entry['Mode'][0] - except LookupError: - pass - else: - try: - handler.mode = int(mode, 8) - except ValueError: - print >> sys.stderr, 'W: failed to convert mode %s' % (mode,) - + self._parse_common_file_handler(handler, entry) # Add pending subfiles from earlier entries self._multifiles[mfile] = handler