| | |
| | | re.MULTILINE|re.DOTALL) |
| | | return cddl_re.sub('', text) |
| | | |
| | | def mangle_path(manifest, action, src, dest): |
| | | def do_ctfconvert(converter, file): |
| | | args = [converter, '-i', '-m', '-k', file] |
| | | print(*args, file=sys.stderr) |
| | | subprocess.call(args) |
| | | |
| | | def mangle_path(manifest, action, src, dest, ctfconvert): |
| | | if elf.is_elf_object(src): |
| | | if ctfconvert is not None: |
| | | do_ctfconvert(ctfconvert, src) |
| | | mangle_elf(manifest, action, src, dest) |
| | | else: |
| | | # a 'text' document (script, man page, config file, ... |
| | |
| | | # |
| | | # mangler.bypass = (true|false) |
| | | # |
| | | def mangle_paths(manifest, search_paths, destination): |
| | | def mangle_paths(manifest, search_paths, destination, ctfconvert): |
| | | for action in manifest.gen_actions_by_type("file"): |
| | | bypass = action.attrs.pop('mangler.bypass', 'false').lower() |
| | | if bypass == 'true': |
| | |
| | | if directory != destination: |
| | | src = os.path.join(directory, path) |
| | | if os.path.isfile(src): |
| | | mangle_path(manifest, action, src, dest) |
| | | mangle_path(manifest, action, |
| | | src, dest, ctfconvert) |
| | | break |
| | | |
| | | def load_manifest(manifest_file): |
| | |
| | | search_paths = [] |
| | | destination = None |
| | | manifests = [] |
| | | ctfconvert = None |
| | | |
| | | try: |
| | | opts, args = getopt.getopt(sys.argv[1:], "D:d:m:", |
| | | ["destination=", "search-directory=", "manifest="]) |
| | | opts, args = getopt.getopt(sys.argv[1:], "c:D:d:m:", |
| | | ["ctf=", "destination=", "search-directory=", "manifest="]) |
| | | except getopt.GetoptError as err: |
| | | print(str(err)) |
| | | usage() |
| | |
| | | usage() |
| | | else: |
| | | manifests.append(manifest) |
| | | elif opt in [ "-c", "--ctf" ]: |
| | | ctfconvert = arg |
| | | else: |
| | | usage() |
| | | |
| | |
| | | usage() |
| | | |
| | | for manifest in manifests: |
| | | mangle_paths(manifest, search_paths, destination) |
| | | mangle_paths(manifest, search_paths, destination, ctfconvert) |
| | | print(manifest) |
| | | |
| | | sys.exit(0) |