-
Notifications
You must be signed in to change notification settings - Fork 0
/
dash_masternode_tool.spec
117 lines (95 loc) · 3.78 KB
/
dash_masternode_tool.spec
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# -*- mode: python -*-
import sys, stat
from os import path, chmod
import platform
block_cipher = None
os_type = sys.platform
no_bits = platform.architecture()[0].replace('bit','')
version_str = ''
base_dir = os.path.dirname(os.path.realpath('__file__'))
# look for version string
with open(os.path.join(base_dir, 'version.txt')) as fptr:
for line in fptr:
parts = [elem.strip() for elem in line.split('=')]
if len(parts) == 2 and parts[0].lower() == 'version_str':
version_str = parts[1].strip("'")
break
binary_files = []
data_files = [
('version.txt', '.')
]
def add_data_file(file: str, dest_dir: str):
global data_files
data_files.append((file, dest_dir))
print(f'Adding data file {file} to dest dir {dest_dir}')
def add_binary_file(file: str, dest_dir: str):
global bianry_files
binary_files.append((file, dest_dir))
print(f'Adding binary file {file} to dest dir {dest_dir}')
for f in os.listdir(os.path.join(base_dir, 'img')):
f_full = os.path.join(base_dir, 'img', f)
if os.path.isfile(f_full):
add_data_file('img/' + f, '/img')
lib_path = next(p for p in sys.path if 'site-packages' in p)
add_data_file(os.path.join(lib_path, 'bitcoin/english.txt'), '/bitcoin')
add_data_file(os.path.join(lib_path, 'mnemonic/wordlist/english.txt'), '/mnemonic/wordlist')
add_data_file(os.path.join(lib_path, 'trezorlib/coins.json'), '/trezorlib')
add_data_file(os.path.join(lib_path, 'trezorlib/transport'), 'trezorlib/transport')
if os_type == 'darwin':
add_binary_file('/usr/local/lib/libusb-1.0.dylib', '.')
elif os_type == 'win32':
import ctypes.util
l = ctypes.util.find_library('libusb-1.0.dll')
if l:
add_binary_file(l, '.')
a = Analysis(['src/dash_masternode_tool.py'],
pathex=[base_dir],
binaries=binary_files,
datas=data_files,
hiddenimports=['usb1', 'pkg_resources.py2_warn'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='firo-masternode-tool',
debug=False,
strip=False,
upx=False,
console=False,
icon=os.path.join('img',('firo-masternode-tool.%s' % ('icns' if os_type=='darwin' else 'ico'))))
if os_type == 'darwin':
app = BUNDLE(exe,
name='firo-masternode-tool.app',
icon='img/firo-masternode-tool.icns',
bundle_identifier=None,
info_plist={
'NSHighResolutionCapable': 'True'
}
)
dist_path = os.path.join(base_dir, DISTPATH)
all_bin_dir = os.path.join(dist_path, '..', 'all')
if not os.path.exists(all_bin_dir):
os.makedirs(all_bin_dir)
# zip archives
print(dist_path)
print(all_bin_dir)
os.chdir(dist_path)
if os_type == 'win32':
print('Compressing Windows executable')
os.system('"7z.exe" a %s %s -mx0' % (os.path.join(all_bin_dir, 'firo-masternode-tool-' + version_str + '.win' + no_bits + '.zip'), 'firo-masternode-tool.exe'))
elif os_type == 'darwin':
print('Compressing Mac executable')
os.chmod("firo-masternode-tool.app/Contents/MacOS/firo-masternode-tool", 0o754)
os.system('zip -r "%s" "%s"' % (os.path.join(all_bin_dir, 'firo-masternode-tool-' + version_str + '.mac.zip'), 'firo-masternode-tool.app'))
elif os_type == 'linux':
print('Compressing Linux executable')
os.system('tar -zcvf %s %s' % (os.path.join(all_bin_dir, 'firo-masternode-tool-' + version_str + '.linux.tar.gz'), 'firo-masternode-tool'))