Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/environ.py
blob: 9130984fed8890ecd07196f57f64f8093fb06b22 (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
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
from distutils import sysconfig
import os

from devbot import config


def add_path(name, path):
    if not path.endswith("/"):
        path = "%s/" % path

    if name not in os.environ:
        os.environ[name] = path
        return

    splitted = os.environ[name].split(":")
    if path not in splitted:
        splitted.insert(0, path)

    os.environ[name] = ":".join(splitted)


def setup_variables():
    add_path("LD_LIBRARY_PATH", config.lib_dir)
    add_path("PATH", config.bin_dir)

    add_path("XCURSOR_PATH",
             os.path.join(config.share_dir, "icons"))
    add_path("PKG_CONFIG_PATH",
             os.path.join(config.lib_dir, "pkgconfig"))
    add_path("GST_PLUGIN_PATH",
             os.path.join(config.lib_dir, "gstreamer-1.0"))
    add_path("PYTHONPATH",
             sysconfig.get_python_lib(prefix=config.prefix_dir))
    add_path("PYTHONPATH",
             sysconfig.get_python_lib(prefix=config.prefix_dir,
                                      plat_specific=True))
    add_path("PYTHONPATH",
             os.path.dirname(os.path.dirname(__file__)))

    add_path("ACLOCAL_PATH", "/usr/share/aclocal")
    add_path("ACLOCAL_FLAGS", "-I /usr/share/aclocal")

    add_path("XDG_DATA_DIRS", "/usr/share")
    add_path("XDG_DATA_DIRS", config.share_dir)

    add_path("XDG_CONFIG_DIRS", "/etc/xdg")
    add_path("XDG_CONFIG_DIRS", os.path.join(config.etc_dir, "xdg"))

    for system_lib_dir in config.system_lib_dirs:
        modules_path = os.path.join(system_lib_dir, "gio", "modules")
        if os.path.exists(modules_path):
            add_path("GIO_EXTRA_MODULES", modules_path)

        typelib_path = os.path.join(system_lib_dir, "girepository-1.0")
        if os.path.exists(typelib_path):
            add_path("GI_TYPELIB_PATH", typelib_path)

    add_path("GI_TYPELIB_PATH",
             os.path.join(config.lib_dir, "girepository-1.0"))

    os.environ["GTK_DATA_PREFIX"] = config.prefix_dir
    os.environ["GTK_PATH"] = os.path.join(config.lib_dir, "gtk-2.0")
    os.environ["CC"] = "ccache gcc"

    os.environ["GCONF_DEFAULT_SOURCE_PATH"] = _get_gconf_path()
    os.environ["GCONF_SCHEMA_INSTALL_SOURCE"] = \
        "xml:merged:" + os.path.join(_get_gconf_dir(), "gconf.xml.defaults")


def setup_gconf():
    gconf_dir = _get_gconf_dir()
    gconf_path_dir = _get_gconf_path_dir()
    gconf_path = _get_gconf_path()

    if not os.path.exists(gconf_path_dir):
        os.makedirs(gconf_path_dir)

    if not os.path.exists(gconf_path):
        input = open("/etc/gconf/2/path")
        output = open(gconf_path, "w")

        for line in input.readlines():
            if "/etc/gconf" in line:
                output.write(line.replace("/etc/gconf", gconf_dir))
            output.write(line)

        output.close()
        input.close()


def _get_gconf_dir():
    return os.path.join(config.etc_dir, "gconf")


def _get_gconf_path_dir():
    return os.path.join(_get_gconf_dir(), "2")


def _get_gconf_path():
    return os.path.join(_get_gconf_path_dir(), "path.jhbuild")