diff options
author | Chris Johns <chrisj@rtems.org> | 2019-09-12 20:09:13 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2019-09-16 08:21:40 +1000 |
commit | 4b7af073000d612b21b9dece538d2bcc85c0c240 (patch) | |
tree | 06d63a8d5a04974af5af8215d547d261ebd073d9 /source-builder/sb | |
parent | sb/setbuilder: Add a trace to help installing. (diff) | |
download | rtems-source-builder-4b7af073000d612b21b9dece538d2bcc85c0c240.tar.bz2 |
5/llvm: Add LLVM as a package for RTEMS.
- Add '%source download <source>' to only download the source
and do not unpack and prep. This can used when a package
internally needs another source package.
- Install the staging root only if it is present. A package
may internally build another package that is not staged as it
is not suitable for installing.
Updates #3250
Updatew #3797
Diffstat (limited to 'source-builder/sb')
-rw-r--r-- | source-builder/sb/build.py | 99 | ||||
-rw-r--r-- | source-builder/sb/darwin.py | 1 | ||||
-rw-r--r-- | source-builder/sb/freebsd.py | 1 | ||||
-rw-r--r-- | source-builder/sb/options.py | 2 | ||||
-rw-r--r-- | source-builder/sb/setbuilder.py | 54 | ||||
-rw-r--r-- | source-builder/sb/sources.py | 27 |
6 files changed, 112 insertions, 72 deletions
diff --git a/source-builder/sb/build.py b/source-builder/sb/build.py index abc50c0..69f95cf 100644 --- a/source-builder/sb/build.py +++ b/source-builder/sb/build.py @@ -203,7 +203,7 @@ class build: not _disable_installing and \ not _canadian_cross - def source(self, name, strip_components): + def source(self, name, strip_components, download_only): # # Return the list of sources. Merge in any macro defined sources as # these may be overridden by user loaded macros. @@ -238,31 +238,37 @@ class build: if o.startswith('--rsb-file'): os_ = o.split('=') if len(os_) != 2: - raise error.general('invalid --rsb-file option: %s' % (' '.join(args))) + raise error.general('invalid --rsb-file option: %s' % \ + (' '.join(args))) if os_[0] != '--rsb-file': - raise error.general('invalid --rsb-file option: %s' % (' '.join(args))) + raise error.general('invalid --rsb-file option: %s' % \ + (' '.join(args))) file_override = os_[1] opts = [o for o in opts if not o.startswith('--rsb-')] url = self.config.expand(' '.join(url)) - src = download.parse_url(url, '_sourcedir', self.config, self.opts, file_override) + src = download.parse_url(url, '_sourcedir', + self.config, self.opts, file_override) download.get_file(src['url'], src['local'], self.opts, self.config) - if strip_components > 0: - tar_extract = '%%{__tar_extract} --strip-components %d' % (strip_components) - else: - tar_extract = '%{__tar_extract}' - if 'symlink' in src: - sname = name.replace('-', '_') - src['script'] = '%%{__ln_s} %s ${source_dir_%s}' % (src['symlink'], sname) - elif 'compressed' in src: - # - # Zip files unpack as well so do not use tar. - # - src['script'] = '%s %s' % (src['compressed'], src['local']) - if src['compressed-type'] != 'zip': - src['script'] += ' | %s -f -' % (tar_extract) - else: - src['script'] = '%s -f %s' % (tar_extract, src['local']) - srcs += [src] + if not download_only: + if strip_components > 0: + tar_extract = '%%{__tar_extract} --strip-components %d' % \ + (strip_components) + else: + tar_extract = '%{__tar_extract}' + if 'symlink' in src: + sname = name.replace('-', '_') + src['script'] = '%%{__ln_s} %s ${source_dir_%s}' % \ + (src['symlink'], sname) + elif 'compressed' in src: + # + # Zip files unpack as well so do not use tar. + # + src['script'] = '%s %s' % (src['compressed'], src['local']) + if src['compressed-type'] != 'zip': + src['script'] += ' | %s -f -' % (tar_extract) + else: + src['script'] = '%s -f %s' % (tar_extract, src['local']) + srcs += [src] return srcs def source_setup(self, package, args): @@ -270,7 +276,7 @@ class build: setup_name = args[1] args = args[1:] try: - opts, args = getopt.getopt(args[1:], 'qDcn:bas:') + opts, args = getopt.getopt(args[1:], 'qDcn:bas:g') except getopt.GetoptError as ge: raise error.general('source setup error: %s' % str(ge)) quiet = False @@ -282,6 +288,7 @@ class build: changed_dir = False strip_components = 0 opt_name = None + download_only = False for o in opts: if o[0] == '-q': quiet = True @@ -297,30 +304,37 @@ class build: unpack_before_chdir = False elif o[0] == '-s': if not o[1].isdigit(): - raise error.general('source setup error: invalid strip count: %s' % (o[1])) + raise error.general('source setup error: invalid strip count: %s' % \ + (o[1])) strip_components = int(o[1]) + elif o[0] == '-g': + download_only = True name = None - for source in self.source(setup_name, strip_components): + for source in self.source(setup_name, strip_components, download_only): if name is None: if opt_name is None: if source: opt_name = source['name'] else: - raise error.general('setup source tag not found: %d' % (source_tag)) + raise error.general('setup source tag not found: %d' % \ + (source_tag)) else: name = opt_name - self.script_build.append(self.config.expand('cd %{_builddir}')) - if not deleted_dir and delete_before_unpack: - self.script_build.append(self.config.expand('%{__rm} -rf ' + name)) - deleted_dir = True - if not created_dir and create_dir: - self.script_build.append(self.config.expand('%{__mkdir_p} ' + name)) - created_dir = True - if not changed_dir and (not unpack_before_chdir or create_dir): - self.script_build.append(self.config.expand('cd ' + name)) - changed_dir = True - self.script_build.append(self.config.expand(source['script'])) - if not changed_dir and (unpack_before_chdir and not create_dir): + if not download_only: + self.script_build.append(self.config.expand('cd %{_builddir}')) + if not deleted_dir and delete_before_unpack and name is not None: + self.script_build.append(self.config.expand('%{__rm} -rf ' + name)) + deleted_dir = True + if not created_dir and create_dir and name is not None: + self.script_build.append(self.config.expand('%{__mkdir_p} ' + name)) + created_dir = True + if not changed_dir and (not unpack_before_chdir or create_dir) and \ + name is not None: + self.script_build.append(self.config.expand('cd ' + name)) + changed_dir = True + self.script_build.append(self.config.expand(source['script'])) + if not changed_dir and (unpack_before_chdir and not create_dir) and \ + name is not None and not download_only: self.script_build.append(self.config.expand('cd ' + name)) changed_dir = True self.script_build.append(self.config.expand('%{__setup_post}')) @@ -345,7 +359,7 @@ class build: else: url += [pp] if len(url) == 0: - raise error.general('patch URL not found: %s' % (' '.join(args))) + raise error.general('patch URL not found: %s' % (' '.join(opts))) # # Look for --rsb-file as an option we use as a local file name. # This can be used if a URL has no reasonable file name the @@ -357,9 +371,11 @@ class build: if o.startswith('--rsb-file'): os_ = o.split('=') if len(os_) != 2: - raise error.general('invalid --rsb-file option: %s' % (' '.join(args))) + raise error.general('invalid --rsb-file option: %s' % \ + (' '.join(opts))) if os_[0] != '--rsb-file': - raise error.general('invalid --rsb-file option: %s' % (' '.join(args))) + raise error.general('invalid --rsb-file option: %s' % \ + (' '.join(opts))) file_override = os_[1] opts = [o for o in opts if not o.startswith('--rsb-')] if len(opts) == 0: @@ -371,7 +387,8 @@ class build: # # Parse the URL first in the source builder's patch directory. # - patch = download.parse_url(url, '_patchdir', self.config, self.opts, file_override) + patch = download.parse_url(url, '_patchdir', self.config, + self.opts, file_override) # # Download the patch # diff --git a/source-builder/sb/darwin.py b/source-builder/sb/darwin.py index d79cf47..a21a6bc 100644 --- a/source-builder/sb/darwin.py +++ b/source-builder/sb/darwin.py @@ -52,6 +52,7 @@ def load(): '_var': ('dir', 'optional', '/usr/local/var'), '_prefix': ('dir', 'optional', '%{_usr}'), '__ldconfig': ('exe', 'none', ''), + '__cmake': ('exe', 'optional', 'cmake'), '__cvs': ('exe', 'optional', 'cvs'), '__xz': ('exe', 'required', 'xz'), 'with_zlib': ('none', 'none', '--with-zlib=no'), diff --git a/source-builder/sb/freebsd.py b/source-builder/sb/freebsd.py index decd1c9..8fc7db1 100644 --- a/source-builder/sb/freebsd.py +++ b/source-builder/sb/freebsd.py @@ -63,6 +63,7 @@ def load(): '_var': ('dir', 'optional', '/usr/local/var'), '__bash': ('exe', 'optional', '/usr/local/bin/bash'), '__bison': ('exe', 'required', '/usr/local/bin/bison'), + '__cmake': ('exe', 'optional', '/usr/local/bin/cmake'), '__git': ('exe', 'required', '/usr/local/bin/git'), '__svn': ('exe', 'optional', '/usr/local/bin/svn'), '__unzip': ('exe', 'optional', '/usr/local/bin/unzip'), diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py index 9fe0269..8063734 100644 --- a/source-builder/sb/options.py +++ b/source-builder/sb/options.py @@ -293,6 +293,8 @@ class command_line: '--without-log', '--without-error-report', '--without-release-url'] + if a == '--dry-run': + self.args += ['--without-error-report'] arg += 1 def post_process(self, logfile = True): diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py index 380fa00..3d10d58 100644 --- a/source-builder/sb/setbuilder.py +++ b/source-builder/sb/setbuilder.py @@ -405,18 +405,6 @@ class buildset: if nesting_count != 1: if self.installing(): self.macros['install_mode'] = 'staging' - # - # Prepend staging areas, bin directory tothe - # path. Lets the later package depend on the eailier - # ones. - # - pathprepend = ['%{stagingroot}/bin'] + \ - macro_expand(self.macros, '%{_pathprepend}').split(':') - pathprepend = [pp for pp in pathprepend if len(pp)] - if len(pathprepend) == 1: - self.macros['_pathprepend'] = pathprepend[0] - else: - self.macros['_pathprepend'] = ':'.join(pathprepend) # # Only the outter build set can have staging to install. Get the staging @@ -430,6 +418,20 @@ class buildset: log.trace('_bset: %2d: %s: configs: %s' % (nesting_count, self.bset, ', '.join(configs))) + if nesting_count == 1 and len(configs) > 1: + # + # Prepend staging areas, bin directory to the + # path. Lets the later package depend on the earlier + # ones. + # + pathprepend = ['%{stagingroot}/bin'] + \ + macro_expand(self.macros, '%{_pathprepend}').split(':') + pathprepend = [pp for pp in pathprepend if len(pp)] + if len(pathprepend) == 1: + self.macros['_pathprepend'] = pathprepend[0] + else: + self.macros['_pathprepend'] = ':'.join(pathprepend) + sizes_valid = False builds = [] for s in range(0, len(configs)): @@ -519,7 +521,7 @@ class buildset: log.trace('_bset: %2d: %s: builds: %s' % \ (nesting_count, self.install_mode(), ', '.join([b.name() for b in builds]))) - if deps is None and not have_errors: + if deps is None and not self.opts.no_install() and not have_errors: for b in builds: log.trace('_bset: : %s: %r' % (self.install_mode(), b.installable())) @@ -586,18 +588,22 @@ class buildset: # If builds have been staged install into the finaly prefix. # if have_staging and not self.opts.no_install() and not have_errors: - log.trace('_bset: %2d: install staging' % (nesting_count)) stagingroot = macro_expand(self.macros, '%{stagingroot}') - prefix = macro_expand(self.macros, '%{_prefix}') - self.install(self.install_mode(), self.bset, stagingroot, prefix) - staging_size = path.get_size(stagingroot) - if not self.opts.no_clean() or self.opts.always_clean(): - log.notice('clean staging: %s' % (self.bset)) - log.trace('removing: %s' % (stagingroot)) - if not self.opts.dry_run(): - if path.exists(stagingroot): - path.removeall(stagingroot) - log.notice('Staging Size: %s' % (build.humanize_number(staging_size, 'B'))) + have_stagingroot = path.exists(stagingroot) + log.trace('_bset: %2d: install staging, present: %s' % \ + (nesting_count, have_stagingroot)) + if have_stagingroot: + prefix = macro_expand(self.macros, '%{_prefix}') + self.install(self.install_mode(), self.bset, stagingroot, prefix) + staging_size = path.get_size(stagingroot) + if not self.opts.no_clean() or self.opts.always_clean(): + log.notice('clean staging: %s' % (self.bset)) + log.trace('removing: %s' % (stagingroot)) + if not self.opts.dry_run(): + if path.exists(stagingroot): + path.removeall(stagingroot) + log.notice('Staging Size: %s' % \ + (build.humanize_number(staging_size, 'B'))) except error.general as gerr: if not build_error: log.stderr(str(gerr)) diff --git a/source-builder/sb/sources.py b/source-builder/sb/sources.py index 967becc..c5f0037 100644 --- a/source-builder/sb/sources.py +++ b/source-builder/sb/sources.py @@ -49,8 +49,8 @@ def add(label, args, macros, error): def set(label, args, macros, error): args = _args(args) if len(args) < 2: - error('%%%s requires at least 2 arguments' % (label)) - return + error('%%%s set requires at least 2 arguments' % (label)) + return [] _map = '%s-%s' % (label, args[0]) macros.create_map(_map) key = _make_key(label, 0) @@ -63,12 +63,26 @@ def set(label, args, macros, error): def setup(label, args, macros, error): args = _args(args) if len(args) < 2: - error('%%%s requires at least 2 arguments: %s' % (label, ' '.join(args))) + error('%%%s setup requires at least 2 arguments: %s' % (label, ' '.join(args))) ss = '%%setup %s %s' % (label, ' '.join(args)) _map = '%s-%s' % (label, args[0]) if 'setup' in macros.map_keys(_map): error('%%%s already setup source: %s' % (label, ' '.join(args))) - return + return [] + macros.set_write_map(_map) + macros.define('setup', ss) + macros.unset_write_map() + return [ss] + +def download(label, args, macros, error): + args = _args(args) + if len(args) != 1: + error('%%%s download requires 1 argument: %s' % (label, ' '.join(args))) + ss = '%%setup %s %s -g' % (label, ' '.join(args)) + _map = '%s-%s' % (label, args[0]) + if 'setup' in macros.map_keys(_map): + error('%%%s already setup source: %s' % (label, ' '.join(args))) + return [] macros.set_write_map(_map) macros.define('setup', ss) macros.unset_write_map() @@ -79,15 +93,14 @@ def process(label, args, macros, error): error('invalid source type: %s' % (label)) args = _args(args) log.trace('sources: %s' % (' '.join(args))) - if len(args) < 3: - error('%%%s requires at least 3 arguments: %s' % (label, ' '.join(args))) - return if args[0] == 'set': return set(label, args[1:], macros, error) elif args[0] == 'add': return add(label, args[1:], macros, error) elif args[0] == 'setup': return setup(label, args[1:], macros, error) + elif args[0] == 'download': + return download(label, args[1:], macros, error) error('invalid %%%s command: %s' % (label, args[0])) def hash(args, macros, error): |