diff options
author | Chris Johns <chrisj@rtems.org> | 2013-04-15 10:05:23 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2013-04-15 10:05:23 +1000 |
commit | 9994530920e2ea9d80c81d9414e5cd575b9bb116 (patch) | |
tree | 73d5c28a0e900a16187ec37290dcf4f9dbedd19a | |
parent | PR 2115 - Fixed the exception on no 'what'. (diff) | |
download | rtems-source-builder-9994530920e2ea9d80c81d9414e5cd575b9bb116.tar.bz2 |
PR 2115 - Check prefix path write access before starting to build.
Added a check in the options post processing to check is the
prefix path allows writes. No actual write check is made. just
the permissions are checked. If the --no-install options is
used the check is not made.
Moved the --no-install option from the set builder to the options
module.
-rw-r--r-- | source-builder/sb/options.py | 11 | ||||
-rw-r--r-- | source-builder/sb/path.py | 3 | ||||
-rw-r--r-- | source-builder/sb/setbuilder.py | 3 |
3 files changed, 15 insertions, 2 deletions
diff --git a/source-builder/sb/options.py b/source-builder/sb/options.py index 78a6e4c..ed7430e 100644 --- a/source-builder/sb/options.py +++ b/source-builder/sb/options.py @@ -64,6 +64,7 @@ class command_line: '--no-clean' : ('_no_clean', self._lo_bool, False, '0', True), '--keep-going' : ('_keep_going', self._lo_bool, False, '0', True), '--always-clean' : ('_always_clean', self._lo_bool, False, '0', True), + '--no-install' : ('_no_install', self._lo_bool, False, '0', True), '--host' : ('_host', self._lo_triplets, True, None, False), '--build' : ('_build', self._lo_triplets, True, None, False), '--target' : ('_target', self._lo_triplets, True, None, False), @@ -202,6 +203,7 @@ class command_line: print '--log file : Log file where all build out is written too' print '--url url[,url] : URL to look for source' print '--no-download : Disable the source downloader' + print '--no-install : Do not install the packages to the prefix' print '--targetcflags flags : List of C flags for the target code' print '--targetcxxflags flags : List of C++ flags for the target code' print '--libstdcxxflags flags : List of C++ flags to build the target libstdc++ code' @@ -239,8 +241,10 @@ class command_line: arg += 1 def post_process(self): + # Must have a host if self.defaults['_host'] == self.defaults['nil']: raise error.general('host not set') + # Handle the jobs for make if '_ncpus' not in self.defaults: raise error.general('host number of CPUs not set') ncpus = self.jobs(self.defaults['_ncpus']) @@ -248,6 +252,7 @@ class command_line: self.defaults['_smp_mflags'] = '-j %d' % (ncpus) else: self.defaults['_smp_mflags'] = self.defaults['nil'] + # Load user macro files um = self.user_macros() if um: checked = path.exists(um) @@ -255,6 +260,9 @@ class command_line: raise error.general('macro file not found: %s' % (um[checked.index(False)])) for m in um: self.defaults.load(m) + # Check the prefix permission + if not self.no_install() and not path.iswritable(self.defaults['_prefix']): + raise error.general('prefix is not writable: %s' % (path.host(self.defaults['_prefix']))) def command(self): return path.join(self.command_path, self.command_name) @@ -286,6 +294,9 @@ class command_line: def always_clean(self): return self.opts['always-clean'] != '0' + def no_install(self): + return self.opts['no-install'] != '0' + def user_macros(self): # # Return something even if it does not exist. diff --git a/source-builder/sb/path.py b/source-builder/sb/path.py index aa48578..35907e4 100644 --- a/source-builder/sb/path.py +++ b/source-builder/sb/path.py @@ -89,6 +89,9 @@ def isfile(path): def isabspath(path): return path[0] == '/' +def iswritable(path): + return os.access(host(path), os.W_OK) + def mkdir(path): path = host(path) if exists(path): diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py index 41cce62..e0e942d 100644 --- a/source-builder/sb/setbuilder.py +++ b/source-builder/sb/setbuilder.py @@ -310,7 +310,7 @@ class buildset: builds += [b] else: raise - if deps is None and not self.opts.get_arg('--no-install'): + if deps is None and not self.opts.no_install(): for b in builds: self.install(b.name(), b.config.expand('%{buildroot}'), @@ -352,7 +352,6 @@ def run(): optargs = { '--list-configs': 'List available configurations', '--list-bsets': 'List available build sets', '--list-deps': 'List the dependent files.', - '--no-install': 'Do not install the packages to the prefix.', '--no-report': 'Do not create a package report.', '--report-format': 'The report format (text, html, asciidoc).', '--bset-tar-file': 'Create a build set tar file', |