-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild_extras.py
104 lines (89 loc) · 3.03 KB
/
build_extras.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import os
import sys
import subprocess as sub
import tarfile
from urllib.request import urlopen
FREEDESKTOP_URL = "https://gitlab.freedesktop.org/{0}/{0}/-/archive/"
GITHUB_URL = "https://github.com/{0}/releases/download/"
LIBDIR = "/usr/lib64" if sys.maxsize > 2 ** 32 else "/usr/lib"
extras = {
'pipewire': {
'version': "0.3.58",
'url': FREEDESKTOP_URL.format("pipewire") + "{0}/pipewire-{0}.tar.gz",
'build_cmds': [
['meson', 'setup', 'builddir',
'-Dprefix=/usr',
'-Dsession-managers=',
'-Dspa-plugins=disabled',
'-Dgstreamer=disabled',
'-Dpipewire-alsa=disabled',
'-Dalsa=disabled',
'-Djack-devel=true',
'-Dexamples=disabled',
'-Dtests=disabled',
],
['meson', 'compile', '-C', 'builddir'],
['meson', 'install', '-C', 'builddir'],
]
},
'libdecor': {
'version': "0.1.1",
'url': FREEDESKTOP_URL.format("libdecor") + "{0}/libdecor-{0}.tar.gz",
'build_cmds': [
['meson', 'build', '--buildtype', 'release', '-Dprefix=/usr'],
['meson', 'install', '-C', 'build'],
]
},
'sndio': {
'version': "1.9.0",
'url': "https://sndio.org/sndio-{0}.tar.gz",
'build_cmds': [
['./configure', '--prefix=/usr', f'--pkgconfdir={LIBDIR}/pkgconfig'],
['make'],
['make', 'install'],
['ldconfig'],
]
},
'jack1': {
'version': "0.126.0",
'url': GITHUB_URL.format("jackaudio/jack1") + "{0}/jack1-{0}.tar.gz",
'build_cmds': [
['./configure', '--prefix=/usr', f'--libdir={LIBDIR}'],
['make'],
['make', 'install'],
]
}
}
def fetch_source(liburl, outdir):
"""Downloads and decompresses the source code for a given library.
"""
# Download tarfile to temporary folder
srctar = urlopen(liburl)
srcfile = liburl.split("/")[-1]
outpath = os.path.join(outdir, srcfile)
with open(outpath, 'wb') as out:
out.write(srctar.read())
# Extract source from archive
with tarfile.open(outpath, 'r:gz') as z:
z.extractall(path=outdir)
return os.path.join(outdir, srcfile.replace(".tar.gz", ""))
# Actually run build script
libname = sys.argv[1]
if not libname in extras.keys():
e = "build_extras.py is not configured to build the '{0}' library"
raise RuntimeError(e.format(libname))
libdir = "lib_extra"
if not os.path.exists(libdir):
os.mkdir(libdir)
# Download and extract source code
info = extras[libname]
sourcedir = fetch_source(info['url'].format(info['version']), libdir)
# Enter source directory and build/install the library
os.chdir(sourcedir)
print("\n=== Building {0} {1} from source ===\n".format(libname, info['version']))
for cmd in info['build_cmds']:
p = sub.Popen(cmd, stdout=sys.stdout, stderr=sys.stderr)
p.communicate()
if p.returncode != 0:
success = False
break