INNER CODE UNIT · Python
copy_file
CyrilPeng/Venera-Next · .github/scripts/appimage_runtime.py:58
def copy_file(source, destination):
destination.parent.mkdir(parents=True, exist_ok=True)
# Dereference system links: an absolute link would escape the AppDir.
shutil.copy2(source, destination)
def owning_package(source):
# ldconfig may report /lib aliases on merged-/usr hosts while dpkg records
# the package's /usr/lib path (or the other way around).
candidates = [source, source.resolve()]
for path in list(candidates):
name = str(path)
if name.startswith("/usr/lib/"):
candidates.append(Path(name.removeprefix("/usr")))
elif name.startswith("/lib/"):
candidates.append(Path("/usr" + name))
for path in dict.fromkeys(candidates):
result = subprocess.run(["dpkg-query", "-S", str(path)], text=True, capture_output=True)