Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/scripts/dn-build
blob: abee34537becf43bed27d31a14656159e7ab527a (plain)
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
#!/usr/bin/python

import json
import os
import sys
import subprocess

scripts_dir = os.path.abspath(os.path.dirname(__file__))
base_dir = os.path.dirname(scripts_dir)
install_dir = os.path.join(base_dir, "install")
source_dir = os.path.join(base_dir, "source")
activities_dir = os.path.join(source_dir, "activities")
modules_dir = os.path.join(scripts_dir, "modules")

def get_module_dir(module):
    return os.path.join(activities_dir, module["name"])

def pull_source(module):
    if not os.path.exists(activities_dir):
        os.mkdir(activities_dir)

    module_dir = get_module_dir(module)

    if os.path.exists(module_dir):
        os.chdir(module_dir)
        subprocess.check_call(["git", "pull"])
    else:
        os.chdir(activities_dir)
        subprocess.check_call(["git", "clone", module["repo"], module["name"]])
        os.chdir(module_dir)

    branch = module.get("branch", "master")
    subprocess.check_call(["git", "checkout", branch])

def build(module):
    os.chdir(get_module_dir(module))
    subprocess.check_call(["./setup.py", "install", "--prefix", install_dir])

def main():
    modules = json.load(open(os.path.join(modules_dir, "activities.json")))

    for module in modules:
        print "\n=== Building %s ===\n" % module["name"]

        try:
            pull_source(module)
            build(module)
        except subprocess.CalledProcessError:
            sys.exit(1)

main()