from __future__ import with_statement
import os
+import re
import base64
import shutil
from collections import namedtuple
'squash_patches_until': '',
'buildroot': '~/GBS-ROOT/',
'packaging_dir': 'packaging',
+ 'work_dir': '.',
},
}
cfgparser = BrainConfigParser()
try:
cfgparser.read_one(fpath)
+ if cfgparser.has_section('general') and \
+ cfgparser.has_option('general', 'work_dir'):
+ cfgparser.set('general', 'work_dir',
+ os.path.abspath(os.path.dirname(fpath)))
except Error, err:
raise errors.ConfigError('config file error:%s' % err)
self._cfgparsers.append(cfgparser)
"""
paths = []
+
+ def lookfor_tizen_conf(start_dir):
+ """ Search topdir of tizen source code cloned using repo tool,
+ if .gbs.conf exists under that dir, then return it
+ """
+ cur_dir = os.path.abspath(start_dir)
+ while True:
+ cur_dir = os.path.dirname(cur_dir)
+ if cur_dir == '/':
+ break
+ if os.path.exists(os.path.join(cur_dir, '.repo')) and \
+ os.path.exists(os.path.join(cur_dir, '.gbs.conf')):
+ return os.path.join(cur_dir, '.gbs.conf')
+ return None
+
+ tizen_conf = lookfor_tizen_conf(os.getcwd())
+ if tizen_conf:
+ paths.append(tizen_conf)
for path in (os.path.abspath('.gbs.conf'),
os.path.expanduser('~/.gbs.conf'),
'/etc/gbs.conf'):
self.repos = []
self.obs = None
self.buildroot = None
+ self.buildconf = None
def add_repo(self, repoconf):
'''add a repo to repo list of the profile'''
'''config manager which handles high level conception, such as profile info
'''
+
+ def _interpolate(self, value):
+ '''do string interpolation'''
+
+ general_keys = {}
+
+ for opt in self.DEFAULTS['general']:
+ if opt == 'work_dir' and self.get(opt, 'general') == '.':
+ general_keys[opt] = os.getcwd()
+ else:
+ general_keys[opt] = self.get(opt, 'general')
+
+ value = re.sub(r'\$\{([^}]+)\}', r'%(\1)s', value)
+ value = value % general_keys
+ return value
+
def is_profile_oriented(self):
'''return True if config file is profile oriented'''
return self.get_optional_item('general', 'profile') is not None
def _get_url_options(self, section_id):
'''get url/user/passwd from a section'''
- url = self.get('url', section_id)
+ url = os.path.expanduser(self._interpolate(self.get('url', section_id)))
user = self.get_optional_item(section_id, 'user')
password = self.get_optional_item(section_id, 'passwd')
return URL(url, user, password)
profile.add_repo(repoconf)
profile.buildroot = self.get_optional_item(name, 'buildroot')
-
+ if self.get_optional_item(name, 'buildconf'):
+ profile.buildconf = os.path.expanduser(self._interpolate(
+ self.get_optional_item(name,
+ 'buildconf')))
return profile
def _parse_build_repos(self):