Files
semios-packages/hooks/autostrip.py
T
2026-06-13 12:13:59 +08:00

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)