File: patch-binary.py

package info (click to toggle)
ccache 4.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,420 kB
  • sloc: cpp: 50,251; asm: 28,570; sh: 9,632; ansic: 5,357; python: 834; perl: 68; makefile: 24
file content (18 lines) | stat: -rwxr-xr-x 464 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3

import sys

libexecdir = sys.argv[1]
sysconfdir = sys.argv[2]

replacements = [
    (b"/usr/local/libexec", libexecdir.encode()),
    (b"/usr/local/etc", sysconfdir.encode()),
]
ccache_bin = sys.stdin.buffer.read()
for repl_from, repl_to in replacements:
    ccache_bin = ccache_bin.replace(
        repl_from + b"\x00" * (4096 - len(repl_from)),
        repl_to + b"\x00" * (4096 - len(repl_to)),
    )
sys.stdout.buffer.write(ccache_bin)