diff options
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r-- | meta/classes/package.bbclass | 48 |
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)) |