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 / +116 lines)
Line  Link Here
0
-- vartree.py
0
++ vartree.py
Lines 89-94 Link Here
89
import pwd
89
import pwd
90
import re
90
import re
91
import stat
91
import stat
92
import struct
92
import sys
93
import sys
93
import tempfile
94
import tempfile
94
import textwrap
95
import textwrap
Lines 4546-4551 Link Here
4546
4547
4547
		cfgfiledict_orig = cfgfiledict.copy()
4548
		cfgfiledict_orig = cfgfiledict.copy()
4548
4549
4550
		hashtype = self.settings.get("INTEGRITY_HASH").upper()
4551
		if hashtype is None:
4552
			hashtype = "SHA512"
4553
		elif hashtype != "SHA1" and hashtype != "SHA256":
4554
			hashtype = "SHA512"
4555
4549
		# open CONTENTS file (possibly overwriting old one) for recording
4556
		# open CONTENTS file (possibly overwriting old one) for recording
4550
		# Use atomic_ofstream for automatic coercion of raw bytes to
4557
		# Use atomic_ofstream for automatic coercion of raw bytes to
4551
		# unicode, in order to prevent TypeError when writing raw bytes
4558
		# unicode, in order to prevent TypeError when writing raw bytes
Lines 4556-4561 Link Here
4556
			mode='w', encoding=_encodings['repo.content'],
4563
			mode='w', encoding=_encodings['repo.content'],
4557
			errors='backslashreplace')
4564
			errors='backslashreplace')
4558
4565
4566
		# open CONTENTS_DIGESTS file (possibly overwriting old one) for recording
4567
		# Use atomic_ofstream for automatic coercion of raw bytes to
4568
		# unicode, in order to prevent TypeError when writing raw bytes
4569
		# to TextIOWrapper with python2.
4570
		digfile = atomic_ofstream(_unicode_encode(
4571
			os.path.join(self.dbtmpdir, 'CONTENTS_DIGESTS_'+hashtype),
4572
			encoding=_encodings['fs'], errors='strict'),
4573
			mode='w', encoding=_encodings['repo.content'],
4574
			errors='backslashreplace')
4575
4576
		# open CONTENTS_MODES file (possibly overwriting old one) for recording
4577
		# Use atomic_ofstream for automatic coercion of raw bytes to
4578
		# unicode, in order to prevent TypeError when writing raw bytes
4579
		# to TextIOWrapper with python2.
4580
		modfile = atomic_ofstream(_unicode_encode(
4581
			os.path.join(self.dbtmpdir, 'CONTENTS_MODES'),
4582
			encoding=_encodings['fs'], errors='strict'),
4583
			mode='w', encoding=_encodings['repo.content'],
4584
			errors='backslashreplace')
4585
4586
		# open CONTENTS_ATTRS_PAX file (possibly overwriting old one) for recording
4587
		# Use atomic_ofstream for automatic coercion of raw bytes to
4588
		# unicode, in order to prevent TypeError when writing raw bytes
4589
		# to TextIOWrapper with python2.
4590
		paxfile = atomic_ofstream(_unicode_encode(
4591
			os.path.join(self.dbtmpdir, 'CONTENTS_ATTRS_PAX'),
4592
			encoding=_encodings['fs'], errors='strict'),
4593
			mode='w', encoding=_encodings['repo.content'],
4594
			errors='backslashreplace')
4595
4596
		# open CONTENTS_ATTRS_CAPS file (possibly overwriting old one) for recording
4597
		# Use atomic_ofstream for automatic coercion of raw bytes to
4598
		# unicode, in order to prevent TypeError when writing raw bytes
4599
		# to TextIOWrapper with python2.
4600
		capfile = atomic_ofstream(_unicode_encode(
4601
			os.path.join(self.dbtmpdir, 'CONTENTS_ATTRS_CAPS'),
4602
			encoding=_encodings['fs'], errors='strict'),
4603
			mode='w', encoding=_encodings['repo.content'],
4604
			errors='backslashreplace')
4605
4559
		# Don't bump mtimes on merge since some application require
4606
		# Don't bump mtimes on merge since some application require
4560
		# preservation of timestamps.  This means that the unmerge phase must
4607
		# preservation of timestamps.  This means that the unmerge phase must
4561
		# check to see if file belongs to an installed instance in the same
4608
		# check to see if file belongs to an installed instance in the same
Lines 4568-4574 Link Here
4568
4615
4569
		# we do a first merge; this will recurse through all files in our srcroot but also build up a
4616
		# we do a first merge; this will recurse through all files in our srcroot but also build up a
4570
		# "second hand" of symlinks to merge later
4617
		# "second hand" of symlinks to merge later
4571
		if self.mergeme(srcroot, destroot, outfile, secondhand,
4618
		if self.mergeme(srcroot, destroot, outfile, digfile, modfile, paxfile, capfile, hashtype, secondhand,
4572
			self.settings["EPREFIX"].lstrip(os.sep), cfgfiledict, mymtime):
4619
			self.settings["EPREFIX"].lstrip(os.sep), cfgfiledict, mymtime):
4573
			return 1
4620
			return 1
4574
4621
Lines 4580-4586 Link Here
4580
			# couldn't get merged will be added to thirdhand.
4627
			# couldn't get merged will be added to thirdhand.
4581
4628
4582
			thirdhand = []
4629
			thirdhand = []
4583
			if self.mergeme(srcroot, destroot, outfile, thirdhand,
4630
			if self.mergeme(srcroot, destroot, outfile, digfile, modfile, paxfile, capfile, hashtype, thirdhand,
4584
				secondhand, cfgfiledict, mymtime):
4631
				secondhand, cfgfiledict, mymtime):
4585
				return 1
4632
				return 1
4586
4633
Lines 4594-4600 Link Here
4594
4641
4595
		if len(secondhand):
4642
		if len(secondhand):
4596
			# force merge of remaining symlinks (broken or circular; oh well)
4643
			# force merge of remaining symlinks (broken or circular; oh well)
4597
			if self.mergeme(srcroot, destroot, outfile, None,
4644
			if self.mergeme(srcroot, destroot, outfile, digfile, modfile, paxfile, capfile, hashtype, None,
4598
				secondhand, cfgfiledict, mymtime):
4645
				secondhand, cfgfiledict, mymtime):
4599
				return 1
4646
				return 1
4600
4647
Lines 4605-4610 Link Here
4605
		outfile.flush()
4652
		outfile.flush()
4606
		outfile.close()
4653
		outfile.close()
4607
4654
4655
		#if we opened it, close it
4656
		digfile.flush()
4657
		digfile.close()
4658
4659
		#if we opened it, close it
4660
		modfile.flush()
4661
		modfile.close()
4662
4663
		#if we opened it, close it
4664
		paxfile.flush()
4665
		paxfile.close()
4666
4667
		#if we opened it, close it
4668
		capfile.flush()
4669
		capfile.close()
4670
4608
		# write out our collection of md5sums
4671
		# write out our collection of md5sums
4609
		if cfgfiledict != cfgfiledict_orig:
4672
		if cfgfiledict != cfgfiledict_orig:
4610
			cfgfiledict.pop("IGNORE", None)
4673
			cfgfiledict.pop("IGNORE", None)
Lines 4616-4622 Link Here
4616
4679
4617
		return os.EX_OK
4680
		return os.EX_OK
4618
4681
4619
	def mergeme(self, srcroot, destroot, outfile, secondhand, stufftomerge, cfgfiledict, thismtime):
4682
	def mergeme(self, srcroot, destroot, outfile, digfile, modfile, paxfile, capfile, hashtype, secondhand, stufftomerge, cfgfiledict, thismtime):
4620
		"""
4683
		"""
4621
4684
4622
		This function handles actual merging of the package contents to the livefs.
4685
		This function handles actual merging of the package contents to the livefs.
Lines 4628-4633 Link Here
4628
		@type destroot: String (Path)
4691
		@type destroot: String (Path)
4629
		@param outfile: File to log operations to
4692
		@param outfile: File to log operations to
4630
		@type outfile: File Object
4693
		@type outfile: File Object
4694
		@param digfile: File to log digests to
4695
		@type digfile: File Object
4696
		@param modfile: File to log mode to
4697
		@type modfile: File Object
4698
		@param paxfile: File to log pax markings to
4699
		@type paxfile: File Object
4700
		@param capfile: File to log capabilities to
4701
		@type capfile: File Object
4702
		@param hashtype: Type of hash function to use, can be SHA1, SHA256 or SHA512
4703
		@type hashtype: String
4631
		@param secondhand: A set of items to merge in pass two (usually
4704
		@param secondhand: A set of items to merge in pass two (usually
4632
		or symlinks that point to non-existing files that may get merged later)
4705
		or symlinks that point to non-existing files that may get merged later)
4633
		@type secondhand: List
4706
		@type secondhand: List
Lines 4766-4771 Link Here
4766
				# confmem rejected this update
4839
				# confmem rejected this update
4767
				zing = "---"
4840
				zing = "---"
4768
4841
4842
			srcobj = srcroot+relative_path
4843
			destobj = destroot+relative_path
4844
4845
			digest_length = 0
4846
			if hashtype == "SHA1":
4847
				digest_length = 40
4848
			elif hashtype == "SHA256":
4849
				digest_length = 64
4850
			elif hashtype == "SHA512":
4851
				digest_length = 128
4852
4853
			if stat.S_ISREG(mymode):
4854
				line_digest = portage.checksum.perform_checksum(srcobj, hashtype, 0)[0]+"\n"
4855
				line_mode = "mode:"+oct(mymode)[-4:]+"\n"
4856
4857
				attrlist = xattr.list(mydest)
4858
				if len(attrlist)>0:
4859
					for i in attrlist:
4860
						if i == "user.pax.flags":
4861
							line_attr_pax = _unicode_decode(xattr.get(mydest, "user.pax.flags")).zfill(5)+"\n"
4862
						if i == "security.capability":
4863
							caps = xattr.get(mydest, "security.capability") # Take the actual value from xattr
4864
							caps_int = int(struct.unpack("<IIIII",caps)[1]) # Grab the bitfield, as integer
4865
							line_attr_caps = '{0:x}'.format(caps_int).zfill(16)+"\n" # Convert to a 16-pos hex string
4866
				else:
4867
					line_attr_pax = '{num:0{width}}\n'.format(num=0, width=5)
4868
					line_attr_caps = '{num:0{width}}\n'.format(num=0, width=16)
4869
			else: #DIR, LINK, FIFO, DEV
4870
				line_digest = '{num:0{width}}\n'.format(num=0, width=digest_length)
4871
				line_mode = "mode:"+oct(mymode)[-4:]+"\n"
4872
				line_attr_pax = '{num:0{width}}\n'.format(num=0, width=5)
4873
				line_attr_caps = '{num:0{width}}\n'.format(num=0, width=16)
4874
4875
			digfile.write(line_digest)
4876
			modfile.write(line_mode)
4877
			paxfile.write(line_attr_pax)
4878
			capfile.write(line_attr_caps)
4879
4769
			if stat.S_ISLNK(mymode):
4880
			if stat.S_ISLNK(mymode):
4770
				# we are merging a symbolic link
4881
				# we are merging a symbolic link
4771
				# Pass in the symlink target in order to bypass the
4882
				# Pass in the symlink target in order to bypass the

Return to bug 605082