diff options
author | Chris Johns <chrisj@rtems.org> | 2012-11-04 15:16:53 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2012-11-04 15:16:53 +1100 |
commit | 8f84a6b3a0bc7cbce09605f39329d3832682bf63 (patch) | |
tree | ffa6a75342192bc7252ff72a9563f3a7678409fb | |
parent | Fix long options. (diff) | |
download | rtems-source-builder-8f84a6b3a0bc7cbce09605f39329d3832682bf63.tar.bz2 |
Add checking support to make sure a host is setup correctly.
-rw-r--r-- | sb-check | 29 | ||||
-rw-r--r-- | sb/build.py | 3 | ||||
-rw-r--r-- | sb/check.py | 143 | ||||
-rw-r--r-- | sb/config.py | 2 | ||||
-rw-r--r-- | sb/darwin.py | 26 | ||||
-rw-r--r-- | sb/defaults.py | 228 | ||||
-rw-r--r-- | sb/freebsd.py | 26 | ||||
-rw-r--r-- | sb/linux.py | 28 | ||||
-rw-r--r-- | sb/path.py | 3 | ||||
-rw-r--r-- | sb/setbuilder.py | 9 | ||||
-rw-r--r-- | sb/windows.py | 59 |
11 files changed, 389 insertions, 167 deletions
diff --git a/sb-check b/sb-check new file mode 100644 index 0000000..43aae67 --- /dev/null +++ b/sb-check @@ -0,0 +1,29 @@ +#! /usr/bin/env python +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2012 Chris Johns (chrisj@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +import sys, os +base = os.path.dirname(sys.argv[0]) +sys.path.insert(0, base + '/sb') +try: + import check + check.run() +except ImportError: + print >> sys.stderr, "Incorrect Set Bulder installation" + sys.exit(1) diff --git a/sb/build.py b/sb/build.py index 5af1178..44473ca 100644 --- a/sb/build.py +++ b/sb/build.py @@ -183,7 +183,8 @@ class build: if not path.isfile(local): raise error.general('source is not a file: %s' % (path.host(local))) return - raise error.general('downloading %s: all paths have failed, giving up' % (url)) + if not self.opts.dry_run(): + raise error.general('downloading %s: all paths have failed, giving up' % (url)) def parse_url(self, url, pathkey): # diff --git a/sb/check.py b/sb/check.py new file mode 100644 index 0000000..66e8ff4 --- /dev/null +++ b/sb/check.py @@ -0,0 +1,143 @@ +# +# RTEMS Tools Project (http://www.rtems.org/) +# Copyright 2010-2012 Chris Johns (chrisj@rtems.org) +# All rights reserved. +# +# This file is part of the RTEMS Tools package in 'rtems-tools'. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +# +# Check the defaults for a specific host. +# + +import os + +import defaults +import error +import execute +import log +import path + +# +# Version of Sourcer Builder Check. +# +version = '0.1' + +def _notice(opts, text): + if not opts.quiet() and log.default and not log.default.has_stdout(): + print text + log.output(text) + log.flush() + +# +# Basic sanity check. All executables and directories must exist. +# + +def host_setup(_opts, _defaults): + + checks = { 'none': _check_none, + 'triplet': _check_triplet, + 'dir': _check_dir, + 'exe': _check_exe } + + sane = True + + for d in _defaults: + try: + (test, constraint, value) = _defaults[d] + except: + raise error.general('invalid default: %s [%r]' % (d, _defaults[d])) + if _opts.trace(): + _notice(_opts, '%15s: %r -> "%s"' % (d, _defaults[d], value)) + if test is not 'none': + value = _opts.expand(value, _defaults) + if test not in checks: + raise error.general('invalid check test: %s' % (test)) + if sane and not checks[test](_opts, d, value, constraint): + sane = False + + return sane + +def run(): + import sys + try: + _opts, _defaults = defaults.load(args = sys.argv) + if host_setup(_opts, _defaults): + print 'Source Builder environent is ok' + else: + print 'Source Builder environent is not correctly set up' + except error.general, gerr: + print gerr + sys.exit(1) + except error.internal, ierr: + print ierr + sys.exit(1) + sys.exit(0) + +def _check_none(_opts, macro, value, constraint): + return True + +def _check_triplet(_opts, macro, value, constraint): + return True + +def _check_dir(_opts, macro, value, constraint): + if constraint != 'none' and not path.isdir(value): + if constraint == 'required': + _notice(_opts, 'error: dir: not found: (%s) %s' % (macro, value)) + return False + if _opts.warn_all(): + _notice(_opts, 'warning: dir: not found: (%s) %s' % (macro, value)) + return True + +def _check_exe(_opts, macro, value, constraint): + + if len(value) == 0 or constraint == 'none': + return True + + orig_value = value + + if path.isabspath(value): + if path.isfile(value): + return True + if os.name == 'nt': + if path.isfile('%s.exe' % (value)): + return True + value = path.basename(value) + absexe = True + else: + absexe = False + + paths = os.environ['PATH'].split(os.pathsep) + + if _check_paths(value, paths): + if absexe: + _notice(_opts, + 'warning: exe: absolute exe found in path: (%s) %s' % (macro, orig_value)) + return True + + _notice(_opts, 'error: exe: not found: (%s) %s' % (macro, orig_value)) + return False + +def _check_paths(name, paths): + for p in paths: + exe = path.join(p, name) + if path.isfile(exe): + return True + if os.name == 'nt': + if path.isfile('%s.exe' % (exe)): + return True + return False + +if __name__ == '__main__': + run() diff --git a/sb/config.py b/sb/config.py index 318dc5c..88a8148 100644 --- a/sb/config.py +++ b/sb/config.py @@ -187,7 +187,7 @@ class file: self.sf = re.compile(r'%\([^\)]+\)') self.default_defines = {} for d in _defaults: - self.default_defines[self._label(d)] = _defaults[d] + self.default_defines[self._label(d)] = _defaults[d][2] for arg in self.opts.args: if arg.startswith('--with-') or arg.startswith('--without-'): label = arg[2:].lower().replace('-', '_') diff --git a/sb/darwin.py b/sb/darwin.py index 9bb16a8..fbea40f 100644 --- a/sb/darwin.py +++ b/sb/darwin.py @@ -37,19 +37,19 @@ def load(): else: smp_mflags = '' defines = { - '_os': 'darwin', - '_host': uname[4] + '-apple-darwin' + uname[2], - '_host_vendor': 'apple', - '_host_os': 'darwin', - '_host_cpu': uname[4], - '_host_alias': '%{nil}', - '_host_arch': uname[4], - '_usr': '/opt/local', - '_var': '/opt/local/var', - 'optflags': '-O2', - '_smp_mflags': smp_mflags, - '__xz': '/usr/local/bin/xz', - 'with_zlib': '--with-zlib=no', + '_os': ('none', 'none', 'darwin'), + '_host': ('triplet', 'required', uname[4] + '-apple-darwin' + uname[2]), + '_host_vendor': ('none', 'none', 'apple'), + '_host_os': ('none', 'none', 'darwin'), + '_host_cpu': ('none', 'none', uname[4]), + '_host_alias': ('none', 'none', '%{nil}'), + '_host_arch': ('none', 'none', uname[4]), + '_usr': ('dir', 'optionsl', '/opt/local'), + '_var': ('dir', 'optional', '/opt/local/var'), + 'optflags': ('none', 'none', '-O2'), + '_smp_mflags': ('none', 'none', smp_mflags), + '__xz': ('exe', 'required', '/usr/local/bin/xz'), + 'with_zlib': ('none', 'none', '--with-zlib=no') } return defines diff --git a/sb/defaults.py b/sb/defaults.py index 30f9660..ec2fe21 100644 --- a/sb/defaults.py +++ b/sb/defaults.py @@ -36,106 +36,121 @@ basepath = 'sb' # All paths in defaults must be Unix format. Do not store any Windows format # paths in the defaults. # +# Every entry must describe the type of checking a host must pass. +# defaults = { # Nothing -'nil': '', +'nil': ('none', 'none', ''), # Set to invalid values. -'_host': '', -'_build': '%{_host}', -'_target': '', +'_bset': ('none', 'none', ''), +'name': ('none', 'none', ''), +'version': ('none', 'none', ''), +'release': ('none', 'none', ''), + +# GNU triples needed to build packages +'_host': ('triplet', 'required', ''), +'_build': ('triplet', 'required', '%{_host}'), +'_target': ('none', 'optional', ''), # Paths -'_host_platform': '%{_host_cpu}-%{_host_vendor}-%{_host_os}%{?_gnu}', -'_build': '%{_host}', -'_arch': '%{_host_arch}', -'_sbdir': '', -'_topdir': path.shell(os.getcwd()), -'_configdir': '%{_topdir}/config:%{_sbdir}/config', -'_tardir': '%{_topdir}/tar', -'_sourcedir': '%{_topdir}/sources', -'_patchdir': '%{_sbdir}/patches', -'_builddir': '%{_topdir}/build/%{name}-%{version}-%{release}', -'_docdir': '%{_defaultdocdir}', -'_tmppath': '%{_topdir}/build/tmp', -'_tmproot': '%{_tmppath}/source-build-%(%{__id_u} -n)/%{_bset}', -'buildroot:': '%{_tmppath}/%{name}-root-%(%{__id_u} -n)', +'_host_platform': ('none', 'none', '%{_host_cpu}-%{_host_vendor}-%{_host_os}%{?_gnu}'), +'_build': ('none', 'none', '%{_host}'), +'_arch': ('none', 'none', '%{_host_arch}'), +'_sbdir': ('none', 'none', ''), +'_topdir': ('dir', 'required', path.shell(os.getcwd())), +'_configdir': ('dir', 'optional', '%{_topdir}/config:%{_sbdir}/config'), +'_tardir': ('dir', 'optional', '%{_topdir}/tar'), +'_sourcedir': ('dir', 'optional', '%{_topdir}/sources'), +'_patchdir': ('dir', 'required', '%{_sbdir}/patches'), +'_builddir': ('dir', 'optional', '%{_topdir}/build/%{name}-%{version}-%{release}'), +'_docdir': ('dir', 'none', '%{_defaultdocdir}'), +'_tmppath': ('dir', 'none', '%{_topdir}/build/tmp'), +'_tmproot': ('dir', 'none', '%{_tmppath}/source-build-%(%{__id_u} -n)/%{_bset}'), +'buildroot:': ('dir', 'none', '%{_tmppath}/%{name}-root-%(%{__id_u} -n)'), +'_datadir': ('dir', 'none', '%{_prefix}/share'), +'_defaultdocdir': ('dir', 'none', '%{_prefix}/share/doc'), +'_exeext': ('none', 'none', ''), +'_exec_prefix': ('dir', 'none', '%{_prefix}'), +'_bindir': ('dir', 'none', '%{_exec_prefix}/bin'), +'_sbindir': ('dir', 'none', '%{_exec_prefix}/sbin'), +'_libexecdir': ('dir', 'none', '%{_exec_prefix}/libexec'), +'_datarootdir': ('dir', 'none', '%{_prefix}/share'), +'_datadir': ('dir', 'none', '%{_datarootdir}'), +'_sysconfdir': ('dir', 'none', '%{_prefix}/etc'), +'_sharedstatedir': ('dir', 'none', '%{_prefix}/com'), +'_localstatedir': ('dir', 'none', '%{prefix}/var'), +'_includedir': ('dir', 'none', '%{_prefix}/include'), +'_lib': ('dir', 'none', 'lib'), +'_libdir': ('dir', 'none', '%{_exec_prefix}/%{_lib}'), +'_libexecdir': ('dir', 'none', '%{_exec_prefix}/libexec'), +'_mandir': ('dir', 'none', '%{_datarootdir}/man'), +'_infodir': ('dir', 'none', '%{_datarootdir}/info'), +'_localedir': ('dir', 'none', '%{_datarootdir}/locale'), +'_localedir': ('dir', 'none', '%{_datadir}/locale'), +'_localstatedir': ('dir', 'none', '%{_prefix}/var'), +'_prefix': ('dir', 'none', '%{_usr}'), +'_usr': ('dir', 'none', '/usr/local'), +'_usrsrc': ('dir', 'none', '%{_usr}/src'), +'_var': ('dir', 'none', '/usr/local/var'), +'_varrun': ('dir', 'none', '%{_var}/run'), # Defaults, override in platform specific modules. -'___setup_shell': '/bin/sh', -'__aclocal': 'aclocal', -'__ar': 'ar', -'__arch_install_post': '%{nil}', -'__as': 'as', -'__autoconf': 'autoconf', -'__autoheader': 'autoheader', -'__automake': 'automake', -'__awk': 'awk', -'__bash': '/bin/bash', -'__bzip2': '/usr/bin/bzip2', -'__cat': '/bin/cat', -'__cc': '/usr/bin/gcc', -'__chgrp': '/usr/bin/chgrp', -'__chmod': '/bin/chmod', -'__chown': '/usr/sbin/chown', -'__cp': '/bin/cp', -'__cpio': '/usr/bin/cpio', -'__cpp': '/usr/bin/gcc -E', -'__cxx': '/usr/bin/g++', -'__grep': '/usr/bin/grep', -'__gzip': '/usr/bin/gzip', -'__id': '/usr/bin/id', -'__id_u': '%{__id} -u', -'__install': '/usr/bin/install', -'__install_info': '/usr/bin/install-info', -'__ld': '/usr/bin/ld', -'__ldconfig': '/sbin/ldconfig', -'__ln_s': 'ln -s', -'__make': 'make', -'__mkdir': '/bin/mkdir', -'__mkdir_p': '/bin/mkdir -p', -'__mv': '/bin/mv', -'__nm': '/usr/bin/nm', -'__objcopy': '%{_bindir}/objcopy', -'__objdump': '%{_bindir}/objdump', -'__patch': '/usr/bin/patch', -'__perl': 'perl', -'__perl_provides': '%{_usrlibrpm}/perl.prov', -'__perl_requires': '%{_usrlibrpm}/perl.req', -'__ranlib': 'ranlib', -'__remsh': '%{__rsh}', -'__rm': '/bin/rm', -'__rsh': '/usr/bin/rsh', -'__sed': '/usr/bin/sed', -'__setup_post': '%{__chmod} -R a+rX,g-w,o-w .', -'__sh': '/bin/sh', -'__tar': '/usr/bin/tar', -'__tar_extract': '%{__tar} -xvvf', -'__unzip': '/usr/bin/unzip', -'__xz': '/usr/bin/xz', -'_datadir': '%{_prefix}/share', -'_defaultdocdir': '%{_prefix}/share/doc', -'_exeext': '', -'_exec_prefix': '%{_prefix}', -'_lib': 'lib', -'_libdir': '%{_exec_prefix}/%{_lib}', -'_libexecdir': '%{_exec_prefix}/libexec', -'_localedir': '%{_datadir}/locale', -'_localstatedir': '%{_prefix}/var', -'_prefix': '%{_usr}', -'_usr': '/usr/local', -'_usrsrc': '%{_usr}/src', -'_var': '/usr/local/var', -'_varrun': '%{_var}/run', +'___setup_shell': ('exe', 'required', '/bin/sh'), +'__aclocal': ('exe', 'optional', 'aclocal'), +'__ar': ('exe', 'required', 'ar'), +'__arch_install_post': ('exe', 'none', '%{nil}'), +'__as': ('exe', 'required', 'as'), +'__autoconf': ('exe', 'required', 'autoconf'), +'__autoheader': ('exe', 'required', 'autoheader'), +'__automake': ('exe', 'required', 'automake'), +'__awk': ('exe', 'required', 'awk'), +'__bash': ('exe', 'optional', '/bin/bash'), +'__bzip2': ('exe', 'required', '/usr/bin/bzip2'), +'__cat': ('exe', 'required', '/bin/cat'), +'__cc': ('exe', 'required', '/usr/bin/gcc'), +'__chgrp': ('exe', 'required', '/usr/bin/chgrp'), +'__chmod': ('exe', 'required', '/bin/chmod'), +'__chown': ('exe', 'required', '/usr/sbin/chown'), +'__cp': ('exe', 'required', '/bin/cp'), +'__cpp': ('exe', 'none', '%{__cc} -E'), +'__cxx': ('exe', 'required', '/usr/bin/g++'), +'__grep': ('exe', 'required', '/usr/bin/grep'), +'__gzip': ('exe', 'required', '/usr/bin/gzip'), +'__id': ('exe', 'required', '/usr/bin/id'), +'__id_u': ('exe', 'none', '%{__id} -u'), +'__install': ('exe', 'required', '/usr/bin/install'), +'__install_info': ('exe', 'optional', '/usr/bin/install-info'), +'__ld': ('exe', 'required', '/usr/bin/ld'), +'__ldconfig': ('exe', 'required', '/sbin/ldconfig'), +'__ln_s': ('exe', 'none', 'ln -s'), +'__make': ('exe', 'required', 'make'), +'__mkdir': ('exe', 'required', '/bin/mkdir'), +'__mkdir_p': ('exe', 'none', '/bin/mkdir -p'), +'__mv': ('exe', 'required', '/bin/mv'), +'__nm': ('exe', 'required', '/usr/bin/nm'), +'__objcopy': ('exe', 'required', '%{_bindir}/objcopy'), +'__objdump': ('exe', 'required', '%{_bindir}/objdump'), +'__patch': ('exe', 'required', '/usr/bin/patch'), +'__perl': ('exe', 'optional', 'perl'), +'__ranlib': ('exe', 'required', 'ranlib'), +'__rm': ('exe', 'required', '/bin/rm'), +'__sed': ('exe', 'required', '/usr/bin/sed'), +'__setup_post': ('exe', 'none', '%{__chmod} -R a+rX,g-w,o-w .'), +'__sh': ('exe', 'required', '/bin/sh'), +'__tar': ('exe', 'required', '/usr/bin/tar'), +'__tar_extract': ('exe', 'none', '%{__tar} -xvvf'), +'__unzip': ('exe', 'required', '/usr/bin/unzip'), +'__xz': ('exe', 'required', '/usr/bin/xz'), # Shell Build Settings. -'___build_args': '-e', -'___build_cmd': '%{?_sudo:%{_sudo} }%{?_remsh:%{_remsh} %{_remhost} }%{?_remsudo:%{_remsudo} }%{?_remchroot:%{_remchroot} %{_remroot} }%{___build_shell} %{___build_args}', -'___build_post': 'exit 0', +'___build_args': ('none', 'none', '-e'), +'___build_cmd': ('none', 'none', '%{?_sudo:%{_sudo} }%{?_remsh:%{_remsh} %{_remhost} }%{?_remsudo:%{_remsudo} }%{?_remchroot:%{_remchroot} %{_remroot} }%{___build_shell} %{___build_args}'), +'___build_post': ('none', 'none', 'exit 0'), # Prebuild set up script. -'___build_pre': '''# ___build_pre in as set up in defaults.py +'___build_pre': ('none', 'none', '''# ___build_pre in as set up in defaults.py # Directories SB_SOURCE_DIR="%{_sourcedir}" SB_BUILD_DIR="%{_builddir}" @@ -163,14 +178,14 @@ LANG=C export LANG unset DISPLAY || : umask 022 -cd "%{_builddir}"''', -'___build_shell': '%{?_buildshell:%{_buildshell}}%{!?_buildshell:/bin/sh}', -'___build_template': '''#!%{___build_shell} +cd "%{_builddir}"'''), +'___build_shell': ('none', 'none', '%{?_buildshell:%{_buildshell}}%{!?_buildshell:/bin/sh}'), +'___build_template': ('none', 'none', '''#!%{___build_shell} %{___build_pre} -%{nil}''', +%{nil}'''), # Configure command -'configure': ''' +'configure': ('none', 'none', ''' CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; @@ -189,7 +204,7 @@ FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; --localstatedir=%{_localstatedir} \ --sharedstatedir=%{_sharedstatedir} \ --mandir=%{_mandir} \ - --infodir=%{_infodir}''' + --infodir=%{_infodir}''') } class command_line: @@ -271,8 +286,8 @@ class command_line: self.args = argv[1:] self.defaults = {} for to in command_line._long_true_opts: - self.defaults[command_line._long_true_opts[to]] = '0' - self.defaults['_sbdir'] = path.shell(self.command_path) + self.defaults[command_line._long_true_opts[to]] = ('none', 'none', '0') + self.defaults['_sbdir'] = ('dir', 'required', path.shell(self.command_path)) self._process() def __str__(self): @@ -329,14 +344,14 @@ class command_line: command_line._long_true_opts, self.args) if lo: - self.defaults[macro] = '1' + self.defaults[macro] = ('none', 'none', '1') self.opts[lo[2:]] = '1' else: lo, macro, value, i = _process_lopt(a, i, command_line._long_opts, self.args, True) if lo: - self.defaults[macro] = value + self.defaults[macro] = ('none', 'none', value) self.opts[lo[2:]] = value else: # @@ -357,7 +372,7 @@ class command_line: if exit_code == 0: value = output print macro, value - self.defaults[macro] = value + self.defaults[macro] = ('triplet', 'none', value) self.opts[lo[2:]] = value _arch = macro + '_cpu' _vendor = macro + '_vendor' @@ -375,9 +390,9 @@ class command_line: value = value[dash + 1:] if len(value): _os_value = value - self.defaults[_arch] = _arch_value - self.defaults[_vendor] = _vendor_value - self.defaults[_os] = _os_value + self.defaults[_arch] = ('none', 'none', _arch_value) + self.defaults[_vendor] = ('none', 'none', _vendor_value) + self.defaults[_os] = ('none', 'none', _os_value) if not lo: raise error.general('invalid argument: ' + a) else: @@ -395,8 +410,8 @@ class command_line: def _post_process(self, _defaults): if self.no_smp(): - _defaults['_smp_mflags'] = _defaults['nil'] - if _defaults['_host'] == _defaults['nil']: + _defaults['_smp_mflags'] = ('none', 'none', _defaults['nil']) + if _defaults['_host'][2] == _defaults['nil'][2]: raise error.general('host not set') return _defaults @@ -409,7 +424,7 @@ class command_line: for m in mf.findall(s): name = m[2:-1] if name in _defaults: - s = s.replace(m, _defaults[name]) + s = s.replace(m, _defaults[name][2]) expanded = True else: raise error.general('cannot process default macro: ' + m) @@ -452,6 +467,9 @@ class command_line: # # Convert to shell paths and return shell paths. # + # @fixme should this use a passed in set of defaults and not + # not the initial set of values ? + # config = path.shell(config) if config.find('*') >= 0 or config.find('?'): configdir = path.dirname(config) @@ -459,7 +477,7 @@ class command_line: if len(configbase) == 0: configbase = '*' if len(configdir) == 0: - configdir = self.expand(defaults['_configdir'], defaults) + configdir = self.expand(defaults['_configdir'][2], defaults) hostconfigdir = path.host(configdir) if not os.path.isdir(hostconfigdir): raise error.general('configdir is not a directory or does not exist: %s' % (hostconfigdir)) diff --git a/sb/freebsd.py b/sb/freebsd.py index fce4629..4f88266 100644 --- a/sb/freebsd.py +++ b/sb/freebsd.py @@ -46,19 +46,19 @@ def load(): if version.find('-') > 0: version = version.split('-')[0] defines = { - '_os': 'freebsd', - '_host': cpu + '-freebsd' + version, - '_host_vendor': 'pc', - '_host_os': 'freebsd', - '_host_cpu': cpu, - '_host_alias': '%{nil}', - '_host_arch': cpu, - '_usr': '/usr/local', - '_var': '/usr/local/var', - 'optflags': '-O2 -I/usr/local/include -L/usr/local/lib', - '_smp_mflags': smp_mflags, - '__xz': '/usr/bin/xz', - '__make': 'gmake', + '_os': ('none', 'none', 'freebsd'), + '_host': ('triplet', 'required', cpu + '-freebsd' + version), + '_host_vendor': ('none', 'none', 'pc'), + '_host_os': ('none', 'none', 'freebsd'), + '_host_cpu': ('none', 'none', cpu), + '_host_alias': ('none', 'none', '%{nil}'), + '_host_arch': ('none', 'none', cpu), + '_usr': ('dir', 'required', '/usr/local', + '_var': ('dir', 'required', '/usr/local/var'), + 'optflags': ('none', 'none', '-O2 -I/usr/local/include -L/usr/local/lib'), + '_smp_mflags': ('none', 'none', smp_mflags), + '__xz': ('exe', 'optional', '/usr/bin/xz'), + '__make': ('exe', 'required', 'gmake') } return defines diff --git a/sb/linux.py b/sb/linux.py index 135f6a2..cbc1cb9 100644 --- a/sb/linux.py +++ b/sb/linux.py @@ -42,20 +42,20 @@ def load(): if cpus > 0:
smp_mflags = '-j%d' % (cpus)
defines = {
- '_os': 'linux',
- '_host': uname[4] + '-linux-gnu',
- '_host_vendor': 'gnu',
- '_host_os': 'linux',
- '_host_cpu': uname[4],
- '_host_alias': '%{nil}',
- '_host_arch': uname[4],
- '_usr': '/usr',
- '_var': '/usr/var',
- 'optflags': '-O2 -fasynchronous-unwind-tables',
- '_smp_mflags': smp_mflags,
- '__bzip2': '/usr/bin/bzip2',
- '__gzip': '/bin/gzip',
- '__tar': '/bin/tar'
+ '_os': ('none', 'none', 'linux'),
+ '_host': ('triplet', 'required', uname[4] + '-linux-gnu'),
+ '_host_vendor': ('none', 'none', 'gnu'),
+ '_host_os': ('none', 'none', 'linux'),
+ '_host_cpu': ('none', 'none', uname[4]),
+ '_host_alias': ('none', 'none', '%{nil}'),
+ '_host_arch': ('none', 'none', uname[4]),
+ '_usr': ('dir', 'required', '/usr'),
+ '_var': ('dir', 'required', '/usr/var'),
+ 'optflags': ('none', 'none', '-O2 -fasynchronous-unwind-tables'),
+ '_smp_mflags': ('none', 'none', smp_mflags),
+ '__bzip2': ('exe', 'required', '/usr/bin/bzip2'),
+ '__gzip': ('exe', 'required', '/bin/gzip'),
+ '__tar': ('exe', 'required', '/bin/tar')
}
return defines
@@ -75,6 +75,9 @@ def isdir(path): def isfile(path): return os.path.isfile(host(path)) +def isabspath(path): + return path[0] == '/' + if __name__ == '__main__': print host('/a/b/c/d-e-f') print host('//a/b//c/d-e-f') diff --git a/sb/setbuilder.py b/sb/setbuilder.py index 313607e..f8be2a0 100644 --- a/sb/setbuilder.py +++ b/sb/setbuilder.py @@ -27,6 +27,7 @@ import operator import os import build +import check import defaults import error import log @@ -119,7 +120,7 @@ class buildset: exbset = self.opts.expand(self.bset, self.defaults) - self.defaults['_bset'] = exbset + self.defaults['_bset'] = ('none', 'none', exbset) root, ext = path.splitext(exbset) @@ -161,11 +162,11 @@ class buildset: ls = l.split(':') if ls[0].strip() == 'package': self.bset_pkg = self.opts.expand(ls[1].strip(), self.defaults) - self.defaults['package'] = self.bset_pkg + self.defaults['package'] = ('none', 'none', self.bset_pkg) elif l[0] == '%': if l.startswith('%define'): ls = l.split() - self.defaults[ls[1].strip()] = ls[2].strip() + self.defaults[ls[1].strip()] = ('none', 'none', ls[2].strip()) else: raise error.general('invalid directive in build set files: %s' % (l)) else: @@ -216,6 +217,8 @@ def run(): opts, _defaults = defaults.load(sys.argv) log.default = log.log(opts.logfiles()) _notice(opts, 'Source Builder - Set Builder, v%s' % (version)) + if not check.host_setup(opts, _defaults): + raise error.general('host build environment is not set up correctly') for bset in opts.params(): c = buildset(bset, _defaults = _defaults, opts = opts) c.make() diff --git a/sb/windows.py b/sb/windows.py index d3f0972..50f2052 100644 --- a/sb/windows.py +++ b/sb/windows.py @@ -42,23 +42,48 @@ def load(): 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', - '__id': 'id', - '_buildshell': '%{__sh}', - '___setup_shell': '%{__sh}', - # Build flags - 'optflags': '-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -mms-bitfields' + '_os': ('none', 'none', 'win32'), + '_host': ('triplet', 'required', hosttype + '-pc-' + system), + '_host_vendor': ('none', 'none', 'microsoft'), + '_host_os': ('none', 'none', 'win32'), + '_host_cpu': ('none', 'none', hosttype), + '_host_alias': ('none', 'none', '%{nil}'), + '_host_arch': ('none', 'none', hosttype), + '_usr': ('dir', 'optional', '/opt/local'), + '_var': ('dir', 'optional', '/opt/local/var'), + '_smp_mflags': ('none', 'none', smp_mflags), + '__bash': ('exe', 'required', 'bash'), + '__bzip2': ('exe', 'required', 'bzip2'), + '__cat': ('exe', 'required', 'cat'), + '__cc': ('exe', 'required', 'gcc'), + '__chgrp': ('exe', 'required', 'chgrp'), + '__chmod': ('exe', 'required', 'chmod'), + '__chown': ('exe', 'required', 'chown'), + '__cp': ('exe', 'required', 'cp'), + '__cxx': ('exe', 'required', 'g++'), + '__grep': ('exe', 'required', 'grep'), + '__gzip': ('exe', 'required', 'gzip'), + '__id': ('exe', 'required', 'id'), + '__install': ('exe', 'required', 'install'), + '__install_info': ('exe', 'required', 'install-info'), + '__ld': ('exe', 'required', 'ld'), + '__ldconfig': ('exe', 'none', ''), + '__mkdir': ('exe', 'required', 'mkdir'), + '__mv': ('exe', 'required', 'mv'), + '__nm': ('exe', 'required', 'nm'), + '__nm': ('exe', 'required', 'nm'), + '__objcopy': ('exe', 'required', 'objcopy'), + '__objdump': ('exe', 'required', 'objdump'), + '__patch': ('exe', 'required', 'patch'), + '__rm': ('exe', 'required', 'rm'), + '__sed': ('exe', 'required', 'sed'), + '__sh': ('exe', 'required', 'sh'), + '__tar': ('exe', 'required', 'bsdtar'), + '__unzip': ('exe', 'required', 'unzip'), + '__xz': ('exe', 'required', 'xz'), + '_buildshell': ('exe', 'required', '%{__sh}'), + '___setup_shell': ('exe', 'required', '%{__sh}'), + 'optflags': ('none', 'none', '-O2 -pipe'), } return defines |