-
Notifications
You must be signed in to change notification settings - Fork 616
/
make_deb_package.py
executable file
·93 lines (67 loc) · 2.44 KB
/
make_deb_package.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
79
80
81
82
83
84
85
86
#! /usr/bin/python
import os
import shutil
import platform
import time
from subprocess import Popen, PIPE
def execAndWait(cli_str):
print '*** Executing:', cli_str[:60], '...'
process = Popen(cli_str, shell=True)
while process.poll() == None:
time.sleep(0.5)
print '*** Finished executing'
def dir(path='.'):
allpaths = os.listdir(path)
fileList = filter(lambda a: os.path.isfile(a), allpaths)
dirList = filter(lambda a: os.path.isdir(a), allpaths)
return [fileList, dirList]
def cd(path):
os.chdir(path)
def pwd():
return os.getcwd()
if pwd().split('/')[-1]=='dpkgfiles':
cd('..')
if not os.path.exists('./armoryengine/ArmoryUtils.py') or \
not os.path.exists('./ArmoryQt.py'):
print '***ERROR: Must run this script from the root Armory directory!'
exit(1)
# Must get current Armory version from armoryengine.py
# I desperately need a better way to store/read/increment version numbers
vstr = ''
with open('armoryengine/ArmoryUtils.py') as f:
for line in f.readlines():
if line.startswith('BTCARMORY_VERSION'):
vstr = line[line.index('(')+1:line.index(')')]
vquad = tuple([int(v) for v in vstr.replace(' ','').split(',')])
print vquad, len(vquad)
vstr = '%d.%02d' % vquad[:2]
if (vquad[2] > 0 or vquad[3] > 0):
vstr += '.%d' % vquad[2]
if vquad[3] > 0:
vstr += '.%d' % vquad[3]
break
pkgdir = 'armory-%s' % (vstr,)
pkgdir_ = 'armory_%s' % (vstr,)
if not vstr:
print '***ERROR: Could not deduce version from ArmoryUtils.py. '
print ' There is no good reason for this to happen. Ever! :('
exit(1)
# Copy the correct control file (for 32-bit or 64-bit OS)
osBits = platform.architecture()[0][:2]
shutil.copy('dpkgfiles/control%s' % (osBits), 'dpkgfiles/control')
dpkgfiles = ['control', 'copyright', 'postinst', 'postrm', 'rules']
# Start pseudo-bash-script
origDir = pwd().split('/')[-1]
execAndWait('make clean')
cd('..')
execAndWait('rm -rf %s' % pkgdir)
execAndWait('rm -f %s*' % pkgdir)
execAndWait('rm -f %s*' % pkgdir_)
shutil.copytree(origDir, pkgdir)
execAndWait('tar -zcf %s.tar.gz %s' % (pkgdir, pkgdir))
cd(pkgdir)
execAndWait('export DEBFULLNAME="Armory Technologies, Inc."; dh_make -s -e support@bitcoinarmory.com -f ../%s.tar.gz' % pkgdir)
for f in dpkgfiles:
shutil.copy('dpkgfiles/%s' % f, 'debian/%s' % f)
# Finally, all the magic happens here
execAndWait('dpkg-buildpackage -rfakeroot')