Lines 4528-4533
Link Here
|
4528 |
mode='w', encoding=_encodings['repo.content'], |
4528 |
mode='w', encoding=_encodings['repo.content'], |
4529 |
errors='backslashreplace') |
4529 |
errors='backslashreplace') |
4530 |
|
4530 |
|
|
|
4531 |
|
4532 |
# open INTEGRITY file (possibly overwriting old one) for recording |
4533 |
# Use atomic_ofstream for automatic coercion of raw bytes to |
4534 |
# unicode, in order to prevent TypeError when writing raw bytes |
4535 |
# to TextIOWrapper with python2. |
4536 |
intfile = atomic_ofstream(_unicode_encode( |
4537 |
os.path.join(self.dbtmpdir, 'INTEGRITY'), |
4538 |
encoding=_encodings['fs'], errors='strict'), |
4539 |
mode='w', encoding=_encodings['repo.content'], |
4540 |
errors='backslashreplace') |
4541 |
|
4531 |
# Don't bump mtimes on merge since some application require |
4542 |
# Don't bump mtimes on merge since some application require |
4532 |
# preservation of timestamps. This means that the unmerge phase must |
4543 |
# preservation of timestamps. This means that the unmerge phase must |
4533 |
# check to see if file belongs to an installed instance in the same |
4544 |
# check to see if file belongs to an installed instance in the same |
Lines 4540-4546
Link Here
|
4540 |
|
4551 |
|
4541 |
# we do a first merge; this will recurse through all files in our srcroot but also build up a |
4552 |
# we do a first merge; this will recurse through all files in our srcroot but also build up a |
4542 |
# "second hand" of symlinks to merge later |
4553 |
# "second hand" of symlinks to merge later |
4543 |
if self.mergeme(srcroot, destroot, outfile, secondhand, |
4554 |
if self.mergeme(srcroot, destroot, outfile, intfile, secondhand, |
4544 |
self.settings["EPREFIX"].lstrip(os.sep), cfgfiledict, mymtime): |
4555 |
self.settings["EPREFIX"].lstrip(os.sep), cfgfiledict, mymtime): |
4545 |
return 1 |
4556 |
return 1 |
4546 |
|
4557 |
|
Lines 4552-4558
Link Here
|
4552 |
# couldn't get merged will be added to thirdhand. |
4563 |
# couldn't get merged will be added to thirdhand. |
4553 |
|
4564 |
|
4554 |
thirdhand = [] |
4565 |
thirdhand = [] |
4555 |
if self.mergeme(srcroot, destroot, outfile, thirdhand, |
4566 |
if self.mergeme(srcroot, destroot, outfile, intfile, thirdhand, |
4556 |
secondhand, cfgfiledict, mymtime): |
4567 |
secondhand, cfgfiledict, mymtime): |
4557 |
return 1 |
4568 |
return 1 |
4558 |
|
4569 |
|
Lines 4566-4572
Link Here
|
4566 |
|
4577 |
|
4567 |
if len(secondhand): |
4578 |
if len(secondhand): |
4568 |
# force merge of remaining symlinks (broken or circular; oh well) |
4579 |
# force merge of remaining symlinks (broken or circular; oh well) |
4569 |
if self.mergeme(srcroot, destroot, outfile, None, |
4580 |
if self.mergeme(srcroot, destroot, outfile, intfile, None, |
4570 |
secondhand, cfgfiledict, mymtime): |
4581 |
secondhand, cfgfiledict, mymtime): |
4571 |
return 1 |
4582 |
return 1 |
4572 |
|
4583 |
|
Lines 4577-4582
Link Here
|
4577 |
outfile.flush() |
4588 |
outfile.flush() |
4578 |
outfile.close() |
4589 |
outfile.close() |
4579 |
|
4590 |
|
|
|
4591 |
#if we opened it, close it |
4592 |
intfile.flush() |
4593 |
intfile.close() |
4594 |
|
4580 |
# write out our collection of md5sums |
4595 |
# write out our collection of md5sums |
4581 |
if cfgfiledict != cfgfiledict_orig: |
4596 |
if cfgfiledict != cfgfiledict_orig: |
4582 |
cfgfiledict.pop("IGNORE", None) |
4597 |
cfgfiledict.pop("IGNORE", None) |
Lines 4588-4594
Link Here
|
4588 |
|
4603 |
|
4589 |
return os.EX_OK |
4604 |
return os.EX_OK |
4590 |
|
4605 |
|
4591 |
def mergeme(self, srcroot, destroot, outfile, secondhand, stufftomerge, cfgfiledict, thismtime): |
4606 |
def mergeme(self, srcroot, destroot, outfile, intfile, secondhand, stufftomerge, cfgfiledict, thismtime): |
4592 |
""" |
4607 |
""" |
4593 |
|
4608 |
|
4594 |
This function handles actual merging of the package contents to the livefs. |
4609 |
This function handles actual merging of the package contents to the livefs. |
Lines 4600-4605
Link Here
|
4600 |
@type destroot: String (Path) |
4615 |
@type destroot: String (Path) |
4601 |
@param outfile: File to log operations to |
4616 |
@param outfile: File to log operations to |
4602 |
@type outfile: File Object |
4617 |
@type outfile: File Object |
|
|
4618 |
@param intfile: File to log integrity info to |
4619 |
@type intfile: File Object |
4603 |
@param secondhand: A set of items to merge in pass two (usually |
4620 |
@param secondhand: A set of items to merge in pass two (usually |
4604 |
or symlinks that point to non-existing files that may get merged later) |
4621 |
or symlinks that point to non-existing files that may get merged later) |
4605 |
@type secondhand: List |
4622 |
@type secondhand: List |
Lines 4740-4745
Link Here
|
4740 |
# confmem rejected this update |
4757 |
# confmem rejected this update |
4741 |
zing = "---" |
4758 |
zing = "---" |
4742 |
|
4759 |
|
|
|
4760 |
srcobj = srcroot+relative_path |
4761 |
destobj = destroot+relative_path |
4762 |
hashtype = self.settings["INTEGRITY_HASH"] |
4763 |
|
4764 |
line = "" |
4765 |
if stat.S_ISREG(mymode): |
4766 |
line = "mode:"+'{:o}'.format(mymode & stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)+" " |
4767 |
if hashtype.lower() == "sha1" or hashtype.lower() == "sha256" or hashtype.lower() == "sha512": |
4768 |
line += hashtype.lower()+":"+portage.checksum.perform_checksum(srcobj, hashtype.upper(), 0)[0]+" " |
4769 |
line += "file:"+destobj+"\n" |
4770 |
elif stat.S_ISDIR(mymode): |
4771 |
if not os.path.exists(destobj): |
4772 |
line = "mode:"+'{:o}'.format(mymode & stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)+" " |
4773 |
line += "file:"+destobj+"\n" |
4774 |
else: #LINK, FIFO, DEV |
4775 |
line = "mode:"+'{:o}'.format(mymode & stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)+" " |
4776 |
line += "file:"+destobj+"\n" |
4777 |
|
4778 |
intfile.write(line) |
4779 |
|
4743 |
if stat.S_ISLNK(mymode): |
4780 |
if stat.S_ISLNK(mymode): |
4744 |
# we are merging a symbolic link |
4781 |
# we are merging a symbolic link |
4745 |
# Pass in the symlink target in order to bypass the |
4782 |
# Pass in the symlink target in order to bypass the |