summaryrefslogtreecommitdiffstats
path: root/source-builder/sb/config.py
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2013-03-04 18:04:00 +1100
committerChris Johns <chrisj@rtems.org>2013-03-04 18:04:00 +1100
commit3b0ce4e0fa52551aa0d33d5622cdab464c9a96d1 (patch)
treed5bdd35cd8fb0df5d03be1428bbe323df1d6c092 /source-builder/sb/config.py
parentProvide the main package as a function. (diff)
downloadrtems-source-builder-3b0ce4e0fa52551aa0d33d5622cdab464c9a96d1.tar.bz2
More info helpers, allow info to append and fix %{?} expansion.
Add URL and summary to the info helpers. Fix the package get_info and allow infos to be appended to. This lets a summary be on more than one line. Fix the %{?} expansion logic so %{?macro} expands to the macro if it exists.
Diffstat (limited to 'source-builder/sb/config.py')
-rw-r--r--source-builder/sb/config.py42
1 files changed, 27 insertions, 15 deletions
diff --git a/source-builder/sb/config.py b/source-builder/sb/config.py
index e5eb5c0..a92a0a5 100644
--- a/source-builder/sb/config.py
+++ b/source-builder/sb/config.py
@@ -92,12 +92,9 @@ class package:
self.infos[info].append(data)
def get_info(self, info):
- if not info in self.infos:
- raise error.general('no %s in package "%s"' % (info, self.name))
- return self.info
-
- def version(self):
- return self.get_info('Version')
+ if info in self.infos:
+ return self.infos[info]
+ return None
def extract_info(self, label):
infos = {}
@@ -129,6 +126,18 @@ class package:
return info[0]
return self._name
+ def summary(self):
+ info = self.find_info('summary')
+ if info:
+ return info[0]
+ return ''
+
+ def url(self):
+ info = self.find_info('url')
+ if info:
+ return info[0]
+ return ''
+
def version(self):
info = self.find_info('version')
if not info:
@@ -395,7 +404,7 @@ class file:
s = s.replace(m, m[start + colon + 1:-1])
expanded = True
mn = None
- else:
+ elif not istrue:
mn = '%{nil}'
else:
isfalse = True
@@ -589,7 +598,6 @@ class file:
# they match. This closes an opening '{' that is on another
# line.
#
-
for l in config:
self.lc += 1
l = _clean(l)
@@ -772,6 +780,7 @@ class file:
try:
dir = None
+ info = None
data = []
while True:
r = self._parse(config)
@@ -816,16 +825,19 @@ class file:
if self.opts.trace():
print '_tag: ', l, ls
if len(ls) > 1:
- i = ls[0]
- self._info_append(i, ls[1].strip())
+ info = ls[0].lower()
+ if info[-1] == ':':
+ info = info[:-1]
+ info_data = ls[1].strip()
+ else:
+ info_data = ls[0].strip()
+ if info is not None:
+ self._info_append(info, info_data)
# It seems like the info's also appear as
# defines or can be accessed via macros.
- if ls[0][len(ls[0]) - 1] == ':':
- ls[0] = ls[0][:-1]
- ls[0] = ls[0].lower()
- self._define(None, ('', ls[0], ls[1]))
+ self._define(None, ('', info, info_data))
else:
- self._warning("invalid format: '" + l[:-1] + "'")
+ self._warning("invalid format: '" + info_data[:-1] + "'")
else:
data.append(l)
else: