summaryrefslogtreecommitdiff
path: root/buildstream/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* utils.py: Add UtilErrorTristan Van Berkom2017-12-201-38/+82
| | | | | | | | | | | | | | | | | Report UtilError instead of OSError and similar python errors. Also ensure we catch system errors and raise UtilError with descriptive text instead; for the user experience; this is the difference between: o A FAILURE message with a description as to what went wrong (exception handled with UtilError) o A BUG message with the unhandled system error printed with a stack trace (exception left unhandled) Also, UtilsError and ProgramNotFoundError are now public exceptions declared in utils.py, where they will appear in the documentation.
* utils._tempdir: don't leak on exceptionsAngelos Evripiotis2017-12-131-4/+5
|
* Remove unused importsGökçen Nurlu2017-12-071-12/+13
|
* utils.py: Removing safe_move() and move_files() APIsTristan Van Berkom2017-12-051-65/+0
| | | | | These are not used anywhere internally and are not really desirable to use, as usually you need only care about moving a toplevel directory.
* utils: Expand file copying to optionally report files writtenJonathan Maw2017-12-011-7/+23
|
* utils.py: Fix variable name typoGökçen Nurlu2017-11-171-1/+1
|
* Switch old-style string formattings to new '.format()'Gökçen Nurlu2017-11-171-8/+8
|
* utils.py: Make {copy,link,move}_files use keyword argsJonathan Maw2017-11-141-3/+3
|
* utils.py: Make safe copy/link/move use keyword argsJonathan Maw2017-11-141-3/+3
| | | | | | The 'result' field is optional, and currently used only by the internals of {copy,move,link}_files. I think it makes sense to mandate that it's called as a keyword arg in future.
* Refactoring: Move exceptions module to be privateTristan Van Berkom2017-11-061-1/+1
| | | | Hide all of buildstream's internal exceptions from the API surface.
* utils.list_relative_paths: Clarify empty dirs noteAngelos Evripiotis2017-10-301-1/+2
|
* utils.list_relative_paths: avoid os.path.relpathAngelos Evripiotis2017-10-301-6/+9
| | | | | | | | | | Profiling suggested that the cumulative time spent in os.path.relpath() was the dominant cost of utils.list_relative_paths(). Try to call this only once per directory walked. In Python 3.5, we can optimise further by using os.scandir() and maintaining relative paths as we go.
* utils.py: Fix regression, build directories not being removed.Tristan Van Berkom2017-10-211-3/+3
| | | | | utils._force_rmtree() was overwriting it's path directory, and then only recursively removing the last entry which was walked.
* Ensure that artifact file permissions are set in the right orderTristan Maat2017-10-131-5/+26
|
* utils.py: Fix missing psutil referenceTristan Maat2017-09-281-1/+1
|
* utils.py: Added sha256sum utilityTristan Van Berkom2017-09-121-0/+21
| | | | | This little bit of code was being repeated a bunch of times already throughout buildstream, looks sane enough to offer a utility.
* documentation: Set page titles manually in python modules.Tristan Van Berkom2017-08-311-0/+4
|
* utils.py: Added get_bst_version() APITristan Van Berkom2017-08-301-0/+15
| | | | Fetches the numeric major/minor version of the BuildStream package.
* utils.py: Document exceptions from file operationsTristan Van Berkom2017-07-131-1/+25
|
* utils.py: Fix _tempdir for python3.4Jonathan Maw2017-07-101-1/+1
| | | | | | | Support for prefix=None and suffix=None was added in python 3.5. The default for suffix happens to be "", and the prefix happens to be "tmp" (though that's an implementation detail), but it's sufficient, and simpler than writing conditionals that omit certain args.
* utils.py: Adding _tempdir() utility context managerTristan Van Berkom2017-07-091-0/+32
| | | | | A temporary directory context manager which cleans itself out on sigterm.
* Fix symlink generation being confused by symlinks to the sandbox root44-symlinks-in-the-sandbox-are-broken-by-the-path-to-the-buildstream-cache-containing-symlinksJonathan Maw2017-07-041-1/+1
|
* utils.py: Fixed recent _set_deterministic_user() addition to not follow ↵Tristan Van Berkom2017-07-041-2/+2
| | | | | | | | | | | symlinks. We want to change ownership of the symlinks, not their targets. When doing this on an ostree checkout with symlinks to absolute paths, it will make an attempt to modify ownership of files outside the sandbox, and usually fail when building as the regular user (otherwise it will harm the system when running as root).
* Ensure element permissions are set to euid and egid after stagingTristan Maat2017-07-041-0/+20
|
* utils.py: Optional 'terminate' argument to _call() private function.Tristan Van Berkom2017-07-031-16/+32
| | | | | | | | By default we brutally murder subprocess trees, but sometimes we know the nature of the tool we are using and know that it handles sigterm gracefully. This patch allows those cases to have a chance at graceful termination.
* utils.py: Rewording some docstrings for new glob() apiTristan Van Berkom2017-06-301-7/+7
|
* utils.py: Use proper reStructuredText notes in API docsTristan Van Berkom2017-06-301-15/+15
|
* utils.py: Improved glob() functionTristan Van Berkom2017-06-301-6/+98
| | | | | | | | | | | | | | | | | Instead of using PurePath from pathlib, we use a modified version of fnmatch.translate() to generate a regular expression. This has multiple advantages: * The private usage of regular expressions allows the Element internal splitting rules to more easily adapt to the new globbing syntax for split rules * With the glob function under our control, we can document it more clearly * We have support for bash 'globstar' mode, which allows recursive globs with double asterisk.
* utils.py: Add missing signal importJürg Billeter2017-06-291-0/+1
| | | | Fixes: 10a0b98d ("utils.py: Add _call()")
* utils.py: Added glob() utility.Tristan Van Berkom2017-06-291-0/+27
| | | | | | | | | The glob module from the standard library only allows glob pattern matching where there is a backing filesystem. This utility allows glob matching on a simple list of paths, and as such can be used to match things from an unextracted artifact or an unextracted tarball.
* utils.py: Better API for file list operationsTristan Van Berkom2017-06-291-40/+69
| | | | | | | | Instead of returning a tuple of two lists, return the new FileListResult object. This is better because it will allow us to enhance the result over time without breaking API.
* Revert "utils.py: Additional fix to _relative_symlink_target()"Tristan Van Berkom2017-06-291-6/+1
| | | | This reverts commit 9ae1e1a290f67628d4e68632618b0aa9aa92b4e3.
* utils.py: Additional fix to _relative_symlink_target()Tristan Van Berkom2017-06-281-1/+6
| | | | | | | | | | Since we merged MR 29 with a fix for resolving symlinks to realpaths, we should also use the real path of the staging directory to produce a relative path properly. If we are considering that staged symlinks link to symlinked paths inside the staging target, we must also consider that the staging area itself can be in a symliked directory.
* utils.py: Fix corner case in relative_symlink_path() that breaks buildsSam Thursfield2017-06-281-1/+1
| | | | | | | | | | | | | | | The goal of turning absolute symlink paths into relative ones is a noble one -- we want to avoid any chance of corrupting stuff on the host system. Symlinks pointing to /lib/ld.so or whatever can be dangerous (although by not running BuildStream as 'root' you are mostly protected anyway). Some Baserock builds were broken by this as it didn't take into account that the path to a symlink may itself contain symlinks. Adding an extra os.realpath() call is enough to fix this case. This was breaking the Baserock armv8l64 stage2 sysroot, where /lib/ld-linux-aarch64.so is a symlink (to /tools/lib/ld-linux-aarch64.so.1) and /lib is also a symlink (to /usr/lib).
* utils.py: Add _call()Jürg Billeter2017-06-271-0/+59
| | | | | subprocess.call() wrapper supporting suspend and resume based on plugin.__call().
* utils.py: Added _kill_proc_tree()Tristan Van Berkom2017-06-131-0/+26
| | | | A brutally murderous function to kill a process and all of it's children.
* utils.py: Removed the old signal handling routines in favor of _signals.pyTristan Van Berkom2017-04-071-78/+0
|
* Untangling _yaml and utils modules.Tristan Van Berkom2017-04-071-57/+3
| | | | | These had a circular import, which is only supported > python 3.5 but undesirable anyway.
* utils.py: Use os._exit() when exiting in SIGTERM in child forks.Tristan Van Berkom2017-03-161-1/+4
|
* utils.py: Documentation fixesTristan Van Berkom2017-03-161-18/+35
|
* utils.py: Some file processing related utility enhancementsTristan Van Berkom2017-03-151-59/+185
| | | | | | | | | | | | o list_relative_files no longer has include_directories which was always True, and now is better defined. o Added move_files() function to compliment copy_files() and link_files() o Added safe_remove() utility to remove a path, only if it exists, regardless of whether it is a directory or not, but not remove non-empty directories.
* utils.py: Spelling/wording fix in commentTristan Van Berkom2017-03-071-2/+2
|
* utils.py: Use SIGSTOP on self process, dont introduce more SIGTSTPTristan Van Berkom2017-03-061-4/+2
| | | | | This avoids any confusion as to if the master process can receive SIGTSTP events it wants to handle, from child processes.
* utils.py: Added _suspendable() context manager.Tristan Van Berkom2017-03-061-0/+30
| | | | | | | | | This takes care of handling SIGTSTP and SIGCONT, allowing the caller to pass one suspend() and one resume() function. This should be used in the core where we launch sub processes which will not go to sleep with the scheduler job, so that the handlers in place can manually put these child processes to sleep and wake them up later.
* utils.py: Added _terminator() context manager.Tristan Van Berkom2017-03-051-1/+47
| | | | | Parts of the core use this to perform some minimal cleanup and ensure proper process termination whenever a task is forcefully quit.
* utils.py: Use ChainMap properlyTristan Van Berkom2017-02-261-1/+5
| | | | | | | | | | When creating an overlay in which we can perform composites, it's important to create it with: copy = ChainMap({}, original) Modifications will occur in the first mapping in the chain, we must provide that first mapping with the prefixed {}.
* utils.py: Added _node_chain_copy() and _list_chain_copy()Tristan Van Berkom2017-02-261-1/+25
| | | | | These use collections.ChainMap and should be used in place of copy.deepcopy() as much as possible.
* utils.py: Ensure symlink targets exist while stagingTristan Van Berkom2017-02-221-3/+37
|
* utils.py: Fixes regarding staging of symlinksTristan Van Berkom2017-02-221-17/+35
| | | | | | | | | | | o When removing a file that is in the way, dont recursively nuke non-empty directories, warn instead o When staging a symlink, stage a relative path; so that when we stage files across the symlink boundary they never refer to the host o Fix list_relative_paths() to also report symlinks to directories
* Remove apostrophes from grammatically incorrect instances of "it's"Paul Sherwood2017-02-111-3/+3
|