diff options
Diffstat (limited to 'meta/lib/oe/package.py')
| -rw-r--r-- | meta/lib/oe/package.py | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py new file mode 100644 index 0000000000..f8b532220a --- /dev/null +++ b/meta/lib/oe/package.py | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | def runstrip(arg): | ||
| 2 | # Function to strip a single file, called from split_and_strip_files below | ||
| 3 | # A working 'file' (one which works on the target architecture) | ||
| 4 | # | ||
| 5 | # The elftype is a bit pattern (explained in split_and_strip_files) to tell | ||
| 6 | # us what type of file we're processing... | ||
| 7 | # 4 - executable | ||
| 8 | # 8 - shared library | ||
| 9 | # 16 - kernel module | ||
| 10 | |||
| 11 | import commands, stat, subprocess | ||
| 12 | |||
| 13 | (file, elftype, strip) = arg | ||
| 14 | |||
| 15 | newmode = None | ||
| 16 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): | ||
| 17 | origmode = os.stat(file)[stat.ST_MODE] | ||
| 18 | newmode = origmode | stat.S_IWRITE | stat.S_IREAD | ||
| 19 | os.chmod(file, newmode) | ||
| 20 | |||
| 21 | extraflags = "" | ||
| 22 | |||
| 23 | # kernel module | ||
| 24 | if elftype & 16: | ||
| 25 | extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates" | ||
| 26 | # .so and shared library | ||
| 27 | elif ".so" in file and elftype & 8: | ||
| 28 | extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded" | ||
| 29 | # shared or executable: | ||
| 30 | elif elftype & 8 or elftype & 4: | ||
| 31 | extraflags = "--remove-section=.comment --remove-section=.note" | ||
| 32 | |||
| 33 | stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) | ||
| 34 | bb.debug(1, "runstrip: %s" % stripcmd) | ||
| 35 | |||
| 36 | ret = subprocess.call(stripcmd, shell=True) | ||
| 37 | |||
| 38 | if newmode: | ||
| 39 | os.chmod(file, origmode) | ||
| 40 | |||
| 41 | if ret: | ||
| 42 | bb.error("runstrip: '%s' strip command failed" % stripcmd) | ||
| 43 | |||
| 44 | return | ||
| 45 | |||
| 46 | |||
| 47 | def file_translate(file): | ||
| 48 | ft = file.replace("@", "@at@") | ||
| 49 | ft = ft.replace(" ", "@space@") | ||
| 50 | ft = ft.replace("\t", "@tab@") | ||
| 51 | ft = ft.replace("[", "@openbrace@") | ||
| 52 | ft = ft.replace("]", "@closebrace@") | ||
| 53 | ft = ft.replace("_", "@underscore@") | ||
| 54 | return ft | ||
| 55 | |||
| 56 | def filedeprunner(arg): | ||
| 57 | import re, subprocess, shlex | ||
| 58 | |||
| 59 | (pkg, pkgfiles, rpmdeps, pkgdest) = arg | ||
| 60 | provides = {} | ||
| 61 | requires = {} | ||
| 62 | |||
| 63 | r = re.compile(r'[<>=]+ +[^ ]*') | ||
| 64 | |||
| 65 | def process_deps(pipe, pkg, pkgdest, provides, requires): | ||
| 66 | for line in pipe: | ||
| 67 | f = line.split(" ", 1)[0].strip() | ||
| 68 | line = line.split(" ", 1)[1].strip() | ||
| 69 | |||
| 70 | if line.startswith("Requires:"): | ||
| 71 | i = requires | ||
| 72 | elif line.startswith("Provides:"): | ||
| 73 | i = provides | ||
| 74 | else: | ||
| 75 | continue | ||
| 76 | |||
| 77 | file = f.replace(pkgdest + "/" + pkg, "") | ||
| 78 | file = file_translate(file) | ||
| 79 | value = line.split(":", 1)[1].strip() | ||
| 80 | value = r.sub(r'(\g<0>)', value) | ||
| 81 | |||
| 82 | if value.startswith("rpmlib("): | ||
| 83 | continue | ||
| 84 | if value == "python": | ||
| 85 | continue | ||
| 86 | if file not in i: | ||
| 87 | i[file] = [] | ||
| 88 | i[file].append(value) | ||
| 89 | |||
| 90 | return provides, requires | ||
| 91 | |||
| 92 | try: | ||
| 93 | dep_popen = subprocess.Popen(shlex.split(rpmdeps) + pkgfiles, stdout=subprocess.PIPE) | ||
| 94 | provides, requires = process_deps(dep_popen.stdout, pkg, pkgdest, provides, requires) | ||
| 95 | except OSError as e: | ||
| 96 | bb.error("rpmdeps: '%s' command failed, '%s'" % (shlex.split(rpmdeps) + pkgfiles, e)) | ||
| 97 | raise e | ||
| 98 | |||
| 99 | return (pkg, provides, requires) | ||
