2011-02-22 Chris Johns <chrisj@rtems.org>

* specbuilder/sb-versions, specbuilder/specbuilder/version.py:
        New. Print a suitable version message for automatic documentation
        updating from the spec files in CVS.

        * specbuilder/specbuilder/build.py: Add xz support. Add a function
        to return the name of a package.

        * specbuilder/specbuilder/crossgcc.py: Use the build name in the
        tmp path.

        * specbuilder/specbuilder/darwin.py: Add xz support.

        * specbuilder/specbuilder/defaults.py: Add xz support. Add Windows
        and Linux support.

        * specbuilder/specbuilder/setup.py: Reference the correct shell
        opts. Use the shell setup in the version probe command. Fix the
        version check. Add autotools to the list of spec files to
        install.

        * specbuilder/specbuilder/spec.py: Add changelog and configure
        tests. Manage sub-packages better.

        * specbuilder/specbuilder/version.py,
        specbuilder/specbuilder/windows.py: New.
This commit is contained in:
Chris Johns 2011-02-22 03:46:44 +00:00
parent 31d4e80320
commit faa8181015
10 changed files with 282 additions and 28 deletions

View File

@ -1,3 +1,31 @@
2011-02-22 Chris Johns <chrisj@rtems.org>
* specbuilder/sb-versions, specbuilder/specbuilder/version.py:
New. Print a suitable version message for automatic documentation
updating from the spec files in CVS.
* specbuilder/specbuilder/build.py: Add xz support. Add a function
to return the name of a package.
* specbuilder/specbuilder/crossgcc.py: Use the build name in the
tmp path.
* specbuilder/specbuilder/darwin.py: Add xz support.
* specbuilder/specbuilder/defaults.py: Add xz support. Add Windows
and Linux support.
* specbuilder/specbuilder/setup.py: Reference the correct shell
opts. Use the shell setup in the version probe command. Fix the
version check. Add autotools to the list of spec files to
install.
* specbuilder/specbuilder/spec.py: Add changelog and configure
tests. Manage sub-packages better.
* specbuilder/specbuilder/version.py,
specbuilder/specbuilder/windows.py: New.
2010-08-31 Chris Johns <chrisj@rtems.org>
* specbuilder/specbuilder/linux.py: Add Linux support. Can be

33
specbuilder/sb-versions Executable file
View File

@ -0,0 +1,33 @@
#! /usr/bin/env python
#
# $Id$
#
# RTEMS Tools Project (http://www.rtems.org/)
# Copyright 2010 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
# RTEMS Tools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RTEMS Tools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RTEMS Tools. If not, see <http://www.gnu.org/licenses/>.
#
import sys, os
base = os.path.dirname(sys.argv[0])
sys.path.insert(0, base + '/specbuilder')
try:
import version
version.run()
except ImportError:
print >> sys.stderr, "Incorrect SpecBulder installation"
sys.exit(1)

View File

@ -190,6 +190,8 @@ class build:
source['compressed'] = '%{__bzip2} -dc'
elif esl[-1:][0] == 'bz2':
source['compressed'] = '%{__zip} -u'
elif esl[-1:][0] == 'xz':
source['compressed'] = '%{__xz} -dc'
source['script'] = ''
return source
@ -389,6 +391,11 @@ class build:
if not self.opts.no_clean():
self.cleanup()
def name(self):
packages = self.spec.packages()
package = packages['main']
return package.name() + '-' + package.version()
def run(args):
try:
opts, _defaults = defaults.load(args)

View File

@ -72,8 +72,8 @@ class crossgcc:
raise error.general('coping tree: ' + what + ': ' + str(err))
def first_package(self, _build):
path = os.path.join(_build.spec.abspath('%{_tmppath}'),
_build.spec.expand('crossgcc-%(%{__id_u} -n)'))
what = _build.spec.expand('crossgcc-%(%{__id_u} -n)-' + _build.name())
path = os.path.join(_build.spec.abspath('%{_tmppath}'), what)
_build.rmdir(path)
_build.mkdir(path)
prefix = os.path.join(_build.spec.expand('%{_prefix}'), 'bin')

View File

@ -51,7 +51,8 @@ def load():
'_usr': '/opt/local',
'_var': '/opt/local/var',
'optflags': '-O2 -fasynchronous-unwind-tables',
'_smp_mflags': smp_mflags
'_smp_mflags': smp_mflags,
'__xz': '/usr/local/bin/xz',
}
return defines

View File

@ -135,6 +135,7 @@ cd "%{_builddir}"''',
'__tar': '/usr/bin/tar',
'__tar_extract': '%{__tar} -xvvf',
'__unzip': '/usr/bin/unzip',
'__xz': '/usr/bin/xz',
'_datadir': '%{_prefix}/share',
'_defaultdocdir': '%{_prefix}/share/doc',
'_exeext': '',
@ -415,13 +416,17 @@ def load(args):
"""
d = defaults
overrides = None
uname = os.uname()
if uname[0] == 'Darwin':
import darwin
overrides = darwin.load()
elif uname[0] == 'Linux':
import linux
overrides = linux.load()
if os.name == 'nt':
import windows
overrides = windows.load()
else:
uname = os.uname()
if uname[0] == 'Darwin':
import darwin
overrides = darwin.load()
elif uname[0] == 'Linux':
import linux
overrides = linux.load()
if overrides is None:
raise error.general('no hosts defaults found; please add')
for k in overrides:
@ -451,3 +456,5 @@ if __name__ == '__main__':
sys.exit(1)
sys.exit(0)

View File

@ -88,7 +88,8 @@ class setup:
def run(self, command, shell_opts = '', cwd = None):
e = execute.capture_execution(log = log.default, dump = self.opts.quiet())
cmd = self.opts.expand('%{__setup_shell} -ex ' + shell_opts + ' ' + command, self.defaults)
cmd = self.opts.expand('%{___setup_shell} -ex ' + \
shell_opts + ' ' + command, self.defaults)
self._output('run: ' + cmd)
exit_code, proc, output = e.shell(cmd, cwd = cwd)
if exit_code != 0:
@ -96,19 +97,22 @@ class setup:
def check_version(self, cmd, macro):
vcmd = cmd + ' --version'
vcmd = self.opts.expand('%{___setup_shell} -e ' + vcmd, self.defaults)
e = execute.capture_execution()
exit_code, proc, output = e.shell(vcmd)
if exit_code != 0 and len(output) != 0:
raise error.general('shell cmd failed: ' + vcmd)
version = output.split('\n')[0].split(' ')
version = output.split('\n')[0].split(' ')[-1:][0]
need = self.opts.expand(macro, self.defaults)
if version < need:
_notice(self.opts, 'warning: ' + cmd + ' version is invalid, need ' + need + ' or higher')
_notice(self.opts, 'warning: ' + cmd + \
' version is invalid, need ' + need + ' or higher, found ' + version)
return False
return True
def get_specs(self, path):
return self._get_file_list(path, 'rtems', 'spec')
return self._get_file_list(path, 'autotools', 'spec') + \
self._get_file_list(path, 'rtems', 'spec')
def get_patches(self, path):
return self._get_file_list(path, 'patches', 'diff')
@ -127,7 +131,7 @@ class setup:
dst = os.path.join(path, d)
self.mkdir(dst)
except os.error, oerr:
if oerr[0] != errno.EEXIST:
if oerr[0] != errno.EEXIST and oerr[0] != 183:
raise error.general('OS error: ' + str(oerr))
if d == 'RPMLIB':
files = []
@ -141,7 +145,7 @@ class setup:
crossrpms = os.path.join(rtemssrc, 'contrib', 'crossrpms')
if not os.path.isdir(crossrpms):
raise error.general('no crossrpms directory found under: ' + crossrpms)
if 'rebuild' in self.opts.opts:
if self.opts.rebuild():
if self.check_version('autoconf', '%{__setup_autoconf}'):
self.run('../../bootstrap -c', '-c', crossrpms)
self.run('../../bootstrap', '-c', crossrpms)
@ -173,3 +177,5 @@ def run():
if __name__ == "__main__":
run()

View File

@ -76,7 +76,11 @@ class package:
infos = {}
for i in self.infos:
il = i.lower()
if il.startswith(label) and il[len(label):].isdigit():
if il.startswith(label):
if il == label:
il = label + '0'
elif not il[len(label):].isdigit():
continue
infos[il] = self.infos[i]
return infos
@ -146,6 +150,7 @@ class file:
"""Parse a spec file."""
_directive = [ '%description',
'%changelog',
'%prep',
'%build',
'%check',
@ -156,6 +161,7 @@ class file:
'%files' ]
_ignore = [ re.compile('%setup'),
re.compile('%configure'),
re.compile('%doc'),
re.compile('%dir'),
re.compile('%ghost'),
@ -609,15 +615,7 @@ class file:
if isvalid:
for d in self._directive:
if ls[0].strip() == d:
if len(ls) == 1:
package = 'main'
elif len(ls) == 2:
package = ls[1].strip()
else:
if ls[1].strip() != '-n':
self._warning("unknown directive option: '" + ls[1] + "'")
package = ls[2].strip()
return ('directive', ls[0].strip(), package)
return ('directive', ls[0].strip(), ls[1:])
self._warning("unknown directive: '" + ls[0] + "'")
return ('data', [l])
else:
@ -679,11 +677,23 @@ class file:
break
self._warning("unexpected '" + r[1] + "'")
elif r[0] == 'directive':
self._set_package(r[2])
new_data = []
if r[1] == '%description':
new_data = [' '.join(r[2])]
else:
if len(r[2]) == 0:
_package = 'main'
elif len(r[2]) == 1:
_package = r[2][0]
else:
if r[2][0].strip() != '-n':
self._warning("unknown directive option: '" + ' '.join(r[2]) + "'")
_package = r[2][1].strip()
self._set_package(_package)
if dir and dir != r[1]:
self._directive_extend(dir, data)
dir = r[1]
data = []
data = new_data
elif r[0] == 'data':
for l in r[1]:
l = self._expand(l)

View File

@ -0,0 +1,95 @@
#
# $Id$
#
# RTEMS Tools Project (http://www.rtems.org/)
# Copyright 2010 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
# RTEMS Tools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RTEMS Tools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RTEMS Tools. If not, see <http://www.gnu.org/licenses/>.
#
#
# Extract the status of the spec files found in the SPECS directory.
# The status is the name, source and patches.
#
import os
import defaults
import error
import spec
class versions:
"""Return the versions of packages given a spec file."""
def __init__(self, name, _defaults, opts):
self.opts = opts
self.spec = spec.file(name, _defaults = _defaults, opts = opts)
def __str__(self):
def str_package(package):
sources = package.sources()
patches = package.patches()
version = package.version()
release = package.release()
buildarch = package.buildarch()
s = '\nNAME="' + package.name() + '"'
if buildarch:
s += '\nARCH="' + buildarch + '"'
if version:
s += '\nVERSION="' + version + '"'
if release:
s += '\nRELEASE="' + release + '"'
if len(sources):
s += '\nSOURCES=%d' % (len(sources))
c = 1
for i in sources:
s += '\nSOURCE%d="' % (c) + sources[i][0] + '"'
c += 1
s += '\nPATCHES=%d' % (len(patches))
c = 1
for i in patches:
s += '\nPATCH%d="' % (c) + patches[i][0] + '"'
c += 1
return s
packages = self.spec.packages()
s = 'SPEC=' + os.path.basename(self.spec.name) + \
str_package(packages['main'])
for p in packages:
if p != 'main':
s += str_package(packages[p])
return s + '\n'
def run():
import sys
try:
opts, _defaults = defaults.load(sys.argv)
for spec_file in opts.spec_files():
s = versions(spec_file, _defaults = _defaults, opts = opts)
print s
del s
except error.general, gerr:
print gerr
sys.exit(1)
except error.internal, ierr:
print ierr
sys.exit(1)
sys.exit(0)
if __name__ == "__main__":
run()

View File

@ -0,0 +1,67 @@
#
# $Id$
#
# RTEMS Tools Project (http://www.rtems.org/)
# Copyright 2010 Chris Johns (chrisj@rtems.org)
# All rights reserved.
#
# This file is part of the RTEMS Tools package in 'rtems-tools'.
#
# RTEMS Tools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RTEMS Tools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RTEMS Tools. If not, see <http://www.gnu.org/licenses/>.
#
#
# Windows specific support and overrides.
#
import pprint
import os
import execute
def load():
uname = 'win32'
if os.environ.has_key('NUMBER_OF_PROCESSORS'):
ncpus = int(os.environ['NUMBER_OF_PROCESSORS'])
else:
ncpus = 0
if ncpus > 1:
smp_mflags = '-j' + str(ncpus)
else:
smp_mflags = ''
if os.environ.has_key('HOSTTYPE'):
hosttype = os.environ['HOSTTYPE']
else:
hosttype = 'i686'
system = 'mingw32'
defines = {
'_os': 'win32',
'_host': hosttype + '-pc-' + system,
'_host_vendor': 'microsoft',
'_host_os': 'win32',
'_host_cpu': hosttype,
'_host_alias': '%{nil}',
'_host_arch': hosttype,
'_usr': '/opt/local',
'_var': '/opt/local/var',
'optflags': '-O2 -fasynchronous-unwind-tables',
'_smp_mflags': smp_mflags,
'__sh': 'sh',
'_buildshell': '%{__sh}',
'___setup_shell': '%{__sh}'
}
return defines
if __name__ == '__main__':
pprint.pprint(load())