23 lines
540 B
Python
23 lines
540 B
Python
import os
|
|
import subprocess
|
|
|
|
from lib import common
|
|
|
|
strip = os.environ.get("STRIP", "strip")
|
|
|
|
|
|
def _is_elf(filepath):
|
|
with open(filepath, "rb") as f:
|
|
return f.read(4) == b"\x7fELF"
|
|
|
|
|
|
def autostrip(composer):
|
|
for ent in common.treedir(composer.workdir):
|
|
if not ent.is_file(follow_symlinks=False):
|
|
continue
|
|
if not (os.access(ent.path, os.X_OK) or ".so" in ent.name):
|
|
continue
|
|
if not _is_elf(ent.path):
|
|
continue
|
|
subprocess.run([strip, ent.path], check=True)
|