-
Notifications
You must be signed in to change notification settings - Fork 4
/
fabfile.py
119 lines (99 loc) · 2.89 KB
/
fabfile.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env python
import os
import glob
import yaml
import re
from fabric.api import task, run, sudo, local, cd, lcd, put, reboot, execute, env, settings, hide
from fabric.contrib.project import rsync_project
from fabric.contrib.files import exists
from fabric.context_managers import warn_only
top_srcdir = os.path.abspath(".")
env_file = os.path.join(top_srcdir, "env.yaml")
if not os.path.exists(env_file):
raise Exception("configure your environment in env.yaml file (see env.yaml.example)")
config = {}
with open(env_file, "r") as f:
config = yaml.load(f)
env.hosts = config["host"]
env.user = config["user"]
@task
def check_config():
if not os.path.exists(config["linux_dir"]):
raise Exception("error: linux sources not found, create a symlink to your sources with: ln -sf ../linux")
@task
def build():
local("make KDIR={linux_dir} CONFIG_KUNWIND_DEBUG=m".format(**config))
@task
def clean():
local("make KDIR={linux_dir} clean".format(**config))
@task
def rebuild():
execute(clean)
execute(build)
@task
def hello():
run("date")
@task
def push():
mods = glob.glob("*.ko")
for mod in mods:
put(mod, "")
@task
def load():
mods = glob.glob("*.ko")
for mod in mods:
sudo("insmod {}".format(mod))
@task
def unload():
r = re.compile("(?P<mod>[\w-]+)\.ko")
mods = glob.glob("*.ko")
for mod in mods:
name = r.match(mod).group("mod")
with settings(warn_only=True):
with hide('output', 'warnings'):
sudo("rmmod {}".format(name))
@task
def reload():
execute(unload)
execute(load)
@task
def test():
patterns = [
"libkunwind/bootstrap",
"libkunwind/*/*.h",
"libkunwind/*/*.c",
"libkunwind/*/*.cpp",
"libkunwind/*/Makefile.am",
"libkunwind/Makefile.am",
"include/*.h",
]
# the real test here is to copy the file if it is newer
configure_script = "libkunwind/configure.ac"
if not exists(configure_script):
dest = os.path.dirname(configure_script)
run("mkdir -p \"{}\"".format(dest))
put(configure_script, dest)
for pattern in patterns:
matches = glob.glob(pattern)
for match in matches:
dest = os.path.dirname(match)
if not exists(dest):
run("mkdir -p \"{}\"".format(dest))
put(match, dest, mirror_local_mode=True)
with cd("libkunwind"):
if not exists("configure"):
run("./bootstrap")
if not exists("Makefile"):
run("./configure")
with settings(warn_only=True):
result = run("make check")
if result.return_code != 0:
run("cat tests/test-suite.log")
@task
def check():
execute(build)
execute(push)
execute(reload)
@task
def setup():
sudo("apt-get install -q -y libunwind8-dev rsync build-essential autoconf libtool libtool-bin")