Skip to content

Instantly share code, notes, and snippets.

@marguerite
Created March 13, 2024 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marguerite/940e9ee09c31bdef858ecae6d180d4d9 to your computer and use it in GitHub Desktop.
Save marguerite/940e9ee09c31bdef858ecae6d180d4d9 to your computer and use it in GitHub Desktop.
generate dependencies for wechat-uos-beta under openSUSE TW
import os
import stat
import subprocess
def find(d, a, b):
for f in os.listdir(d):
f = os.path.join(d, f)
if os.path.isdir(f):
find(f, a, b)
elif os.path.isfile(f):
if stat.S_IXUSR & os.stat(f).st_mode:
b.append(os.path.basename(f))
res = subprocess.run(["ldd", f], stdout=subprocess.PIPE, text=True).stdout.splitlines()
for line in res:
a.append(line.strip().split(" ")[0])
a = []
b = []
find("/opt/wechat-beta", a, b)
c = []
for i in list(set(a)):
if i not in b:
c.append(i)
print(c)
d = []
for lib in c:
res = subprocess.run(["zypper", "--no-refresh", "se", "-f", lib], stdout=subprocess.PIPE, text=True).stdout.splitlines()
p = False
changed = False
for line in res:
if "+-" in line:
p = True
changed = True
continue
elif p:
d.append(line.split("|")[1].strip())
p = False
if not changed:
print("{} not found".format(lib))
print(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment