mirror of
https://github.com/jorenchik/mdemory.git
synced 2026-03-21 16:16:19 +00:00
Linux piegādes sagatavošanas skripts
This commit is contained in:
46
linuxdeploy.py
Normal file
46
linuxdeploy.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
import subprocess
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print("Izmantošana: python linuxdeploy.py <ceļš_uz_izpildāmo_failu>")
|
||||
exit(1)
|
||||
|
||||
binary_path = sys.argv[1]
|
||||
release_dir = "./linuxrelease"
|
||||
lib_dir = os.path.join(release_dir, "lib")
|
||||
|
||||
if not os.path.isfile(binary_path):
|
||||
print(f"Kļūda: fails {binary_path} nevar būt atvērts.")
|
||||
exit(1)
|
||||
|
||||
os.makedirs(release_dir, exist_ok=True)
|
||||
|
||||
executable_dest = os.path.join(release_dir, os.path.basename(binary_path))
|
||||
shutil.copy2(binary_path, executable_dest)
|
||||
print(f"Izpildes fails {binary_path} ir nokopēts uz {executable_dest}")
|
||||
print(f"Tiek iegūtas koplietotās bibliotēkas (.so) no {binary_path}...")
|
||||
|
||||
libraries = []
|
||||
try:
|
||||
output = subprocess.check_output(["ldd", binary_path], universal_newlines=True)
|
||||
libraries = []
|
||||
for line in output.splitlines():
|
||||
parts = line.split("=>")
|
||||
if len(parts) > 1:
|
||||
lib_path = parts[1].strip().split(" ")[0]
|
||||
if os.path.isabs(lib_path):
|
||||
libraries.append(lib_path)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Neizdevās darbināt ldd uz {binary_path}: {e}")
|
||||
exit(1)
|
||||
print(f"Tika atrastas {len(libraries)} bibliotēkas.")
|
||||
|
||||
os.makedirs(lib_dir, exist_ok=True)
|
||||
for lib in libraries:
|
||||
dest_path = os.path.join(lib_dir, os.path.basename(lib))
|
||||
shutil.copy2(lib, dest_path)
|
||||
print(f"Nokopēta {lib}")
|
||||
|
||||
print(f"Piegādes komplekts ir sagatavots {release_dir}")
|
||||
Reference in New Issue
Block a user