-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
61 lines (49 loc) · 1.94 KB
/
install.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
from yapsy.PluginManager import PluginManager
from yapsy.IPlugin import IPlugin
from abc import abstractmethod
from prefix import Prefix
import logging
import os
class InstallManager(object):
def __init__(self, manager):
self.manager = manager
def install(self, port):
logging.debug('Installing Port {PORTNAME} into {PREFIX}'.format(PORTNAME=port.portname, PREFIX=Prefix.print()))
if not hasattr(port, 'is_installed'):
# Same for the build plugins
for plugin in self.manager.getPluginsOfCategory('Installing'):
plugin.plugin_object.main(port)
class IInstallPlugin(IPlugin):
def __init__(self):
super(IInstallPlugin, self).__init__()
self.does_apply = False
self.port = None
self.savedPath = None
self.filename = None
self.build_bits = ['32', '64']
def check(self):
if os.path.exists(os.path.join(getattr(self.port, 'build_dir_64'), self.filename)) or os.path.exists(
os.path.join(getattr(self.port, 'build_dir_32'), self.filename)):
self.does_apply = True
@abstractmethod
def run(self):
pass
def getConfigureOptionsEnvironment(self):
string = ""
for key, value in self.port.getEnvironmentOptions().items():
string += " {0}={1}".format(key, value)
return string
def main(self, port):
self.port = port
self.check()
if self.does_apply:
for bits in self.build_bits:
try:
self.savedPath = os.getcwd()
os.chdir(getattr(self.port, 'build_dir_{0}'.format(bits)))
except:
raise Exception("Error: port source dir {0} does not exist".format(self.port.build_dir))
self.port.updateEnvironmentVariable('BITS', bits)
self.run()
self.port.is_built = True
os.chdir(self.savedPath)