Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 605082 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-5 / +68 lines)
Line  Link Here
0
-- vartree.py
0
++ vartree.py
Lines 4574-4579 Link Here
4574
			mode='w', encoding=_encodings['repo.content'],
4574
			mode='w', encoding=_encodings['repo.content'],
4575
			errors='backslashreplace')
4575
			errors='backslashreplace')
4576
4576
4577
4578
		hashtype = self.settings.get("INTEGRITY_HASH").upper()
4579
		if hashtype is None:
4580
			hashtype = "SHA512"
4581
		elif hashtype != "SHA1" and hashtype != "SHA256":
4582
			hashtype = "SHA512"
4583
4584
		# open CONTENTS_DIGESTS file (possibly overwriting old one) for recording
4585
		# Use atomic_ofstream for automatic coercion of raw bytes to
4586
		# unicode, in order to prevent TypeError when writing raw bytes
4587
		# to TextIOWrapper with python2.
4588
		digfile = atomic_ofstream(_unicode_encode(
4589
			os.path.join(self.dbtmpdir, 'CONTENTS_DIGESTS_'+hashtype),
4590
			encoding=_encodings['fs'], errors='strict'),
4591
			mode='w', encoding=_encodings['repo.content'],
4592
			errors='backslashreplace')
4593
4594
		# open CONTENTS_DIGESTS file (possibly overwriting old one) for recording
4595
		# Use atomic_ofstream for automatic coercion of raw bytes to
4596
		# unicode, in order to prevent TypeError when writing raw bytes
4597
		# to TextIOWrapper with python2.
4598
		modfile = atomic_ofstream(_unicode_encode(
4599
			os.path.join(self.dbtmpdir, 'CONTENTS_MODES'),
4600
			encoding=_encodings['fs'], errors='strict'),
4601
			mode='w', encoding=_encodings['repo.content'],
4602
			errors='backslashreplace')
4603
4577
		# Don't bump mtimes on merge since some application require
4604
		# Don't bump mtimes on merge since some application require
4578
		# preservation of timestamps.  This means that the unmerge phase must
4605
		# preservation of timestamps.  This means that the unmerge phase must
4579
		# check to see if file belongs to an installed instance in the same
4606
		# check to see if file belongs to an installed instance in the same
Lines 4586-4592 Link Here
4586
4613
4587
		# we do a first merge; this will recurse through all files in our srcroot but also build up a
4614
		# we do a first merge; this will recurse through all files in our srcroot but also build up a
4588
		# "second hand" of symlinks to merge later
4615
		# "second hand" of symlinks to merge later
4589
		if self.mergeme(srcroot, destroot, outfile, secondhand,
4616
		if self.mergeme(srcroot, destroot, outfile, digfile, modfile, hashtype, secondhand,
4590
			self.settings["EPREFIX"].lstrip(os.sep), cfgfiledict, mymtime):
4617
			self.settings["EPREFIX"].lstrip(os.sep), cfgfiledict, mymtime):
4591
			return 1
4618
			return 1
4592
4619
Lines 4598-4604 Link Here
4598
			# couldn't get merged will be added to thirdhand.
4625
			# couldn't get merged will be added to thirdhand.
4599
4626
4600
			thirdhand = []
4627
			thirdhand = []
4601
			if self.mergeme(srcroot, destroot, outfile, thirdhand,
4628
			if self.mergeme(srcroot, destroot, outfile, digfile, modfile, hashtype, thirdhand,
4602
				secondhand, cfgfiledict, mymtime):
4629
				secondhand, cfgfiledict, mymtime):
4603
				return 1
4630
				return 1
4604
4631
Lines 4612-4618 Link Here
4612
4639
4613
		if len(secondhand):
4640
		if len(secondhand):
4614
			# force merge of remaining symlinks (broken or circular; oh well)
4641
			# force merge of remaining symlinks (broken or circular; oh well)
4615
			if self.mergeme(srcroot, destroot, outfile, None,
4642
			if self.mergeme(srcroot, destroot, outfile, digfile, modfile, hashtype, None,
4616
				secondhand, cfgfiledict, mymtime):
4643
				secondhand, cfgfiledict, mymtime):
4617
				return 1
4644
				return 1
4618
4645
Lines 4623-4628 Link Here
4623
		outfile.flush()
4650
		outfile.flush()
4624
		outfile.close()
4651
		outfile.close()
4625
4652
4653
		#if we opened it, close it
4654
		digfile.flush()
4655
		digfile.close()
4656
4657
		#if we opened it, close it
4658
		modfile.flush()
4659
		modfile.close()
4660
4626
		# write out our collection of md5sums
4661
		# write out our collection of md5sums
4627
		if cfgfiledict != cfgfiledict_orig:
4662
		if cfgfiledict != cfgfiledict_orig:
4628
			cfgfiledict.pop("IGNORE", None)
4663
			cfgfiledict.pop("IGNORE", None)
Lines 4634-4640 Link Here
4634
4669
4635
		return os.EX_OK
4670
		return os.EX_OK
4636
4671
4637
	def mergeme(self, srcroot, destroot, outfile, secondhand, stufftomerge, cfgfiledict, thismtime):
4672
	def mergeme(self, srcroot, destroot, outfile, digfile, modfile, hashtype, secondhand, stufftomerge, cfgfiledict, thismtime):
4638
		"""
4673
		"""
4639
4674
4640
		This function handles actual merging of the package contents to the livefs.
4675
		This function handles actual merging of the package contents to the livefs.
Lines 4646-4651 Link Here
4646
		@type destroot: String (Path)
4681
		@type destroot: String (Path)
4647
		@param outfile: File to log operations to
4682
		@param outfile: File to log operations to
4648
		@type outfile: File Object
4683
		@type outfile: File Object
4684
		@param digfile: File to log digests info to
4685
		@type digfile: File Object
4686
		@param modfile: File to log mode info to
4687
		@type modfile: File Object
4649
		@param secondhand: A set of items to merge in pass two (usually
4688
		@param secondhand: A set of items to merge in pass two (usually
4650
		or symlinks that point to non-existing files that may get merged later)
4689
		or symlinks that point to non-existing files that may get merged later)
4651
		@type secondhand: List
4690
		@type secondhand: List
Lines 4784-4789 Link Here
4784
				# confmem rejected this update
4823
				# confmem rejected this update
4785
				zing = "---"
4824
				zing = "---"
4786
4825
4826
			srcobj = srcroot+relative_path
4827
			destobj = destroot+relative_path
4828
4829
			digest_length = 0
4830
			if hashtype == "SHA1":
4831
				digest_length = 40
4832
			elif hashtype == "SHA256":
4833
				digest_length = 64
4834
			elif hashtype == "SHA512":
4835
				digest_length = 128
4836
4837
			if stat.S_ISREG(mymode):
4838
				line_digest = portage.checksum.perform_checksum(srcobj, hashtype, 0)[0]+"\n"
4839
				line_mode = "mode:"+oct(mymode)[-4:]+"\n"
4840
			elif stat.S_ISDIR(mymode):
4841
				line_digest = '{num:0{width}}\n'.format(num=0, width=digest_length)
4842
				line_mode = "mode:"+oct(mymode)[-4:]+"\n"
4843
			else: #LINK, FIFO, DEV
4844
				line_digest = '{num:0{width}}\n'.format(num=0, width=digest_length)
4845
				line_mode = "mode:"+oct(mymode)[-4:]+"\n"
4846
4847
			digfile.write(line_digest)
4848
			modfile.write(line_mode)
4849
4787
			if stat.S_ISLNK(mymode):
4850
			if stat.S_ISLNK(mymode):
4788
				# we are merging a symbolic link
4851
				# we are merging a symbolic link
4789
				# Pass in the symlink target in order to bypass the
4852
				# Pass in the symlink target in order to bypass the

Return to bug 605082