summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2015-05-14 19:01:41 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-15 18:13:40 +0100
commit9c4ff467f66428488b1cd9798066a8cb5d6b4c3b (patch)
treed194c63d32f246b30ba31ed98d74f950cff6afd1 /meta/classes
parent6adbd2deb92a4159106b78fe880d97ac7e686e95 (diff)
downloadpoky-9c4ff467f66428488b1cd9798066a8cb5d6b4c3b.tar.gz
split_and_strip_files: regroup hardlinks to make build deterministic
Reverted 7c0fd561bad0250a00cef63e3d787573112a59cf Created separate group of hardlinks for the files inside the same package. This should prevent stripped files to be populated outside of package directories. This turns out not to be straightforward and has overlap with the other hardlink handling code in this area. The code is condensed into a more concise and documented form. [Original patch from Ed with tweaks from RP] [YOCTO #7586] (From OE-Core master rev: 82d00f7254b7d3bb6a167d675d798134884d1b19) (From OE-Core rev: 96270e79a70960289856cf424c9e4c1894acb18c) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/package.bbclass48
1 files changed, 26 insertions, 22 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 4cddbefe08..b81f4f9281 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -815,8 +815,8 @@ python split_and_strip_files () {
815 # 815 #
816 elffiles = {} 816 elffiles = {}
817 symlinks = {} 817 symlinks = {}
818 hardlinks = {}
819 kernmods = [] 818 kernmods = []
819 inodes = {}
820 libdir = os.path.abspath(dvar + os.sep + d.getVar("libdir", True)) 820 libdir = os.path.abspath(dvar + os.sep + d.getVar("libdir", True))
821 baselibdir = os.path.abspath(dvar + os.sep + d.getVar("base_libdir", True)) 821 baselibdir = os.path.abspath(dvar + os.sep + d.getVar("base_libdir", True))
822 if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'): 822 if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'):
@@ -854,6 +854,7 @@ python split_and_strip_files () {
854 #bb.note("Sym: %s (%d)" % (ltarget, isELF(ltarget))) 854 #bb.note("Sym: %s (%d)" % (ltarget, isELF(ltarget)))
855 symlinks[file] = target 855 symlinks[file] = target
856 continue 856 continue
857
857 # It's a file (or hardlink), not a link 858 # It's a file (or hardlink), not a link
858 # ...but is it ELF, and is it already stripped? 859 # ...but is it ELF, and is it already stripped?
859 elf_file = isELF(file) 860 elf_file = isELF(file)
@@ -865,28 +866,30 @@ python split_and_strip_files () {
865 msg = "File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn) 866 msg = "File '%s' from %s was already stripped, this will prevent future debugging!" % (file[len(dvar):], pn)
866 package_qa_handle_error("already-stripped", msg, d) 867 package_qa_handle_error("already-stripped", msg, d)
867 continue 868 continue
868 # Check if it's a hard link to something else 869
869 if s.st_nlink > 1: 870 # At this point we have an unstripped elf file. We need to:
870 file_reference = "%d_%d" % (s.st_dev, s.st_ino) 871 # a) Make sure any file we strip is not hardlinked to anything else outside this tree
871 # Hard link to something else 872 # b) Only strip any hardlinked file once (no races)
872 hardlinks[file] = file_reference 873 # c) Track any hardlinks between files so that we can reconstruct matching debug file hardlinks
873 continue 874
874 elffiles[file] = elf_file 875 # Use a reference of device ID and inode number to indentify files
876 file_reference = "%d_%d" % (s.st_dev, s.st_ino)
877 if file_reference in inodes:
878 os.unlink(file)
879 os.link(inodes[file_reference][0], file)
880 inodes[file_reference].append(file)
881 else:
882 inodes[file_reference] = [file]
883 # break hardlink
884 bb.utils.copyfile(file, file)
885 elffiles[file] = elf_file
886 # Modified the file so clear the cache
887 cpath.updatecache(file)
875 888
876 # 889 #
877 # First lets process debug splitting 890 # First lets process debug splitting
878 # 891 #
879 if (d.getVar('INHIBIT_PACKAGE_DEBUG_SPLIT', True) != '1'): 892 if (d.getVar('INHIBIT_PACKAGE_DEBUG_SPLIT', True) != '1'):
880 hardlinkmap = {}
881 # For hardlinks, process only one of the files
882 for file in hardlinks:
883 file_reference = hardlinks[file]
884 if file_reference not in hardlinkmap:
885 # If this is a new file, add it as a reference, and
886 # update it's type, so we can fall through and split
887 elffiles[file] = isELF(file)
888 hardlinkmap[file_reference] = file
889
890 for file in elffiles: 893 for file in elffiles:
891 src = file[len(dvar):] 894 src = file[len(dvar):]
892 dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend 895 dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend
@@ -899,13 +902,14 @@ python split_and_strip_files () {
899 splitdebuginfo(file, fpath, debugsrcdir, sourcefile, d) 902 splitdebuginfo(file, fpath, debugsrcdir, sourcefile, d)
900 903
901 # Hardlink our debug symbols to the other hardlink copies 904 # Hardlink our debug symbols to the other hardlink copies
902 for file in hardlinks: 905 for ref in inodes:
903 if file not in elffiles: 906 if len(inodes[ref]) == 1:
907 continue
908 for file in inodes[ref][1:]:
904 src = file[len(dvar):] 909 src = file[len(dvar):]
905 dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend 910 dest = debuglibdir + os.path.dirname(src) + debugdir + "/" + os.path.basename(src) + debugappend
906 fpath = dvar + dest 911 fpath = dvar + dest
907 file_reference = hardlinks[file] 912 target = inodes[ref][0][len(dvar):]
908 target = hardlinkmap[file_reference][len(dvar):]
909 ftarget = dvar + debuglibdir + os.path.dirname(target) + debugdir + "/" + os.path.basename(target) + debugappend 913 ftarget = dvar + debuglibdir + os.path.dirname(target) + debugdir + "/" + os.path.basename(target) + debugappend
910 bb.utils.mkdirhier(os.path.dirname(fpath)) 914 bb.utils.mkdirhier(os.path.dirname(fpath))
911 #bb.note("Link %s -> %s" % (fpath, ftarget)) 915 #bb.note("Link %s -> %s" % (fpath, ftarget))