View | Details | Raw Unified | Return to bug 28229
Collapse All | Expand All

(-)a/branches/ucs-3.1/ucs/base/univention-config-registry/debian/changelog (+6 lines)
 Lines 1-3    Link Here 
1
univention-config-registry (8.0.2-1) unstable; urgency=low
2
3
  * Support modules for multifiles (Bug #26058)
4
5
 -- Philipp Hahn <hahn@univention.de>  Wed, 15 Aug 2012 16:48:51 +0200
6
1
univention-config-registry (8.0.1-2) unstable; urgency=low
7
univention-config-registry (8.0.1-2) unstable; urgency=low
2
8
3
  * Fix error handling in univention-install-config-registry (Bug #3952)
9
  * Fix error handling in univention-install-config-registry (Bug #3952)
(-)a/branches/ucs-3.1/ucs/base/univention-config-registry/python/univention/config_registry.py (-75 / +54 lines)
 Lines 466-471   class configHandlerDiverting(configHandler): Link Here 
466
		self.user = None
466
		self.user = None
467
		self.group = None
467
		self.group = None
468
		self.mode = None
468
		self.mode = None
469
		self.preinst = None
470
		self.postinst = None
469
471
470
	def __hash__(self):
472
	def __hash__(self):
471
		return hash(self.to_file)
473
		return hash(self.to_file)
 Lines 549-554   class configHandlerMultifile(configHandlerDiverting): Link Here 
549
		ucr, changed = args
551
		ucr, changed = args
550
		print 'Multifile: %s' % self.to_file
552
		print 'Multifile: %s' % self.to_file
551
553
554
		if hasattr(self, 'preinst') and self.preinst:
555
			runModule(self.preinst, 'preinst', ucr, changed)
556
552
		if self.def_count == 0 or not self.from_files:
557
		if self.def_count == 0 or not self.from_files:
553
			return
558
			return
554
559
 Lines 574-579   class configHandlerMultifile(configHandlerDiverting): Link Here 
574
		self._set_perm(st)
579
		self._set_perm(st)
575
		to_fp.close()
580
		to_fp.close()
576
581
582
		if hasattr( self, 'postinst' ) and self.postinst:
583
			runModule(self.postinst, 'postinst', ucr, changed)
584
577
		script_file = os.path.join(script_dir, self.to_file.strip("/"))
585
		script_file = os.path.join(script_dir, self.to_file.strip("/"))
578
		if os.path.isfile(script_file):
586
		if os.path.isfile(script_file):
579
			runScript(script_file, 'postinst', changed)
587
			runScript(script_file, 'postinst', changed)
 Lines 597-609   class configHandlerFile(configHandlerDiverting): Link Here 
597
	def __init__(self, from_file, to_file):
605
	def __init__(self, from_file, to_file):
598
		super(configHandlerFile, self).__init__(to_file)
606
		super(configHandlerFile, self).__init__(to_file)
599
		self.from_file = from_file
607
		self.from_file = from_file
600
		self.preinst = None
601
		self.postinst = None
602
608
603
	def __call__(self, args):
609
	def __call__(self, args):
604
		ucr, changed = args
610
		ucr, changed = args
605
611
606
		if hasattr( self, 'preinst') and self.preinst:
612
		if hasattr(self, 'preinst') and self.preinst:
607
			runModule(self.preinst, 'preinst', ucr, changed)
613
			runModule(self.preinst, 'preinst', ucr, changed)
608
614
609
		print 'File: %s' % self.to_file
615
		print 'File: %s' % self.to_file
 Lines 734-791   class configHandlers: Link Here 
734
		else:
740
		else:
735
			return m(entry)
741
			return m(entry)
736
742
737
	def _get_handler_file(self, entry):
743
	def _parse_common_file_handler(self, handler, entry);
738
			"""Parse file entry and return Handler instance."""
744
		"""Parse common file and multifile entries."""
739
			try:
745
		try:
740
				name = entry['File'][0]
746
			handler.preinst = entry['Preinst'][0]
741
			except LookupError:
747
		except LookupError:
742
				return None
748
			pass
743
			from_path = os.path.join(file_dir, name)
744
			handler = configHandlerFile(from_path, name)
745
			if os.path.exists(from_path):
746
				handler.variables = grepVariables(open(from_path, 'r').read())
747
749
748
			try:
750
		try:
749
				handler.preinst = entry['Preinst'][0]
751
			handler.postinst = entry['Postinst'][0]
750
			except LookupError:
752
		except LookupError:
751
				pass
753
			pass
752
754
755
		handler.variables |= set(entry.get('Variables', set()))
756
757
		try:
758
			user = entry['User'][0]
759
		except LookupError:
760
			pass
761
		else:
753
			try:
762
			try:
754
				handler.postinst = entry['Postinst'][0]
763
				handler.user = pwd.getpwnam(user).pw_uid
755
			except LookupError:
764
			except LookupError:
756
				pass
765
				print >> sys.stderr, 'W: failed to convert the username %s to the uid' % (user,)
757
758
			handler.variables |= set(entry.get('Variables', set()))
759
766
767
		try:
768
			group = entry['Group'][0]
769
		except LookupError:
770
			pass
771
		else:
760
			try:
772
			try:
761
				user = entry['User'][0]
773
				handler.group = grp.getgrnam(group).gr_gid
762
			except LookupError:
774
			except LookupError:
763
				pass
775
				print >> sys.stderr, 'W: failed to convert the groupname %s to the gid' % (group,)
764
			else:
765
				try:
766
					handler.user = pwd.getpwnam(user).pw_uid
767
				except LookupError:
768
					print >> sys.stderr, 'W: failed to convert the username %s to the uid' % (user,)
769
776
777
		try:
778
			mode = entry['Mode'][0]
779
		except LookupError:
780
			pass
781
		else:
770
			try:
782
			try:
771
				group = entry['Group'][0]
783
				handler.mode = int(mode, 8)
772
			except LookupError:
784
			except ValueError:
773
				pass
785
				print >> sys.stderr, 'W: failed to convert mode %s' % (mode,)
774
			else:
775
				try:
776
					handler.group = grp.getgrnam(group).gr_gid
777
				except LookupError:
778
					print >> sys.stderr, 'W: failed to convert the groupname %s to the gid' % (group,)
779
786
787
	def _get_handler_file(self, entry):
788
			"""Parse file entry and return Handler instance."""
780
			try:
789
			try:
781
				mode = entry['Mode'][0]
790
				name = entry['File'][0]
782
			except LookupError:
791
			except LookupError:
783
				pass
792
				return None
784
			else:
793
			from_path = os.path.join(file_dir, name)
785
				try:
794
			handler = configHandlerFile(from_path, name)
786
					handler.mode = int(mode, 8)
795
			if os.path.exists(from_path):
787
				except ValueError:
796
				handler.variables = grepVariables(open(from_path, 'r').read())
788
					print >> sys.stderr, 'W: failed to convert mode %s' % (mode,)
797
798
			self._parse_common_file_handler(handler, entry)
789
799
790
			return handler
800
			return handler
791
801
 Lines 824-861   class configHandlers: Link Here 
824
				from_path = os.path.join(file_dir, mfile)
834
				from_path = os.path.join(file_dir, mfile)
825
				handler = configHandlerMultifile(from_path, mfile)
835
				handler = configHandlerMultifile(from_path, mfile)
826
836
827
			handler.variables |= set(entry.get('Variables', set()))
837
			self._parse_common_file_handler(handler, entry)
828
829
			try:
830
				user = entry['User'][0]
831
			except LookupError:
832
				pass
833
			else:
834
				try:
835
					handler.user = pwd.getpwnam(user).pw_uid
836
				except LookupError:
837
					print >> sys.stderr, 'W: failed to convert the username %s to the uid' % (user,)
838
839
			try:
840
				group = entry['Group'][0]
841
			except LookupError:
842
				pass
843
			else:
844
				try:
845
					handler.group = grp.getgrnam(group).gr_gid
846
				except LookupError:
847
					print >> sys.stderr, 'W: failed to convert the groupname %s to the gid' % (group,)
848
849
			try:
850
				mode = entry['Mode'][0]
851
			except LookupError:
852
				pass
853
			else:
854
				try:
855
					handler.mode = int(mode, 8)
856
				except ValueError:
857
					print >> sys.stderr, 'W: failed to convert mode %s' % (mode,)
858
859
838
860
			# Add pending subfiles from earlier entries
839
			# Add pending subfiles from earlier entries
861
			self._multifiles[mfile] = handler
840
			self._multifiles[mfile] = handler

Return to bug 28229