forked from CosmicFusion/debian-bleedingedge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen-i386-whitelist.py
executable file
·78 lines (62 loc) · 2.12 KB
/
gen-i386-whitelist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#! /bin/python3
import os, errno
import json
import subprocess
import apt
import numpy as np
import threading
def silentremove(filename):
try:
os.remove(filename)
except OSError as e: # this would be "except OSError, e:" before Python 2.6
if e.errno != errno.ENOENT: # errno.ENOENT = no such file or directory
raise # re-raise exception if a different error occurred
def pharse_build_tree(pkg_arr, current_path, pkgname_lines):
for pkgname in pkg_arr:
print("Parsing dep tree for: " + pkgname)
result = subprocess.run([current_path + '/get_depend_tree.sh', pkgname], stdout=subprocess.PIPE)
stdout = result.stdout.decode('utf-8')
for line in stdout.splitlines():
if line != "":
pkgname_lines.append(line)
current_path = os.path.dirname(os.path.realpath(__file__))
global whitelist_arr
whitelist_arr = np.array([])
thread_arr = []
pkgname_lines = []
srcname_lines = []
srcnames_clean = []
file = open(current_path + "/i386_whitelist_bins", "r")
for line in file.readlines():
pkgname = line.strip()
if pkgname != "" and not pkgname.endswith("-udeb"):
pkgname_lines.append(pkgname)
whitelist_arr = np.append(whitelist_arr, [pkgname])
file.close()
newarr = np.array_split(whitelist_arr, 20)
for array in newarr:
t0 = threading.Thread(target=pharse_build_tree, args=(array, current_path, pkgname_lines,))
thread_arr.append(t0)
for thread_proc in thread_arr:
thread_proc.start()
for thread_proc in thread_arr:
thread_proc.join()
c = apt.Cache()
for pkgname in pkgname_lines:
try:
src_name = c[pkgname].candidate.source_name
if src_name:
srcname_lines.append(src_name)
except:
pass
for i in srcname_lines:
if i not in srcnames_clean and i + "-dmo" not in srcnames_clean:
srcnames_clean.append(i)
src_data = {
'i386_whitelist': [source_name for source_name in srcnames_clean],
}
silentremove("i386_src_whitelist.json")
with open("i386_src_whitelist.json", "w") as twitterDataFile:
twitterDataFile.write(
json.dumps(src_data, indent=4)
)