def sources(b): logging.info('searching for software built from source') for pathname, negate in ignore.cache['source']: if negate and os.path.isdir(pathname) and not ignore.source(pathname): # Note before creating a working directory within pathname what # it's atime and mtime should be. s = os.lstat(pathname) # Create a working directory within pathname to avoid potential # EXDEV when creating the shallow copy and tarball. try: with context_managers.mkdtemp(pathname) as c: # Restore the parent of the working directory to its # original atime and mtime, as if pretending the working # directory never actually existed. os.utime(pathname, (s.st_atime, s.st_mtime)) # Create the shallow copy and possibly tarball of the # relevant parts of pathname. _source(b, pathname, c.cwd) # Once more restore the atime and mtime after the working # directory is destroyed. os.utime(pathname, (s.st_atime, s.st_mtime)) # If creating the temporary directory fails, bail with a warning. except OSError as e: logging.warning('{0} caused {1} - try running as root'. format(pathname, errno.errorcode[e.errno])) if 0 < len(b.sources): b.arch = util.arch()
def sources(b, r): logging.info('searching for software built from source') for pathname, negate in r['source']: if negate and os.path.isdir(pathname) \ and not r.ignore_source(pathname): # Note before creating a working directory within pathname what # it's atime and mtime should be. s = os.lstat(pathname) # Create a working directory within pathname to avoid potential # EXDEV when creating the shallow copy and tarball. try: with context_managers.mkdtemp(pathname) as c: # Restore the parent of the working directory to its # original atime and mtime, as if pretending the working # directory never actually existed. os.utime(pathname, (s.st_atime, s.st_mtime)) # Create the shallow copy and possibly tarball of the # relevant parts of pathname. _source(b, r, pathname, c.cwd) # Once more restore the atime and mtime after the working # directory is destroyed. os.utime(pathname, (s.st_atime, s.st_mtime)) # If creating the temporary directory fails, bail with a warning. except OSError as e: logging.warning('{0} caused {1} - try running as root'. format(pathname, errno.errorcode[e.errno])) if 0 < len(b.sources): b.arch = util.arch()
def create(options, args): """ Instantiate and return a Blueprint object from either standard input or by reverse-engineering the system. """ try: with context_managers.mkdtemp(): if not os.isatty(sys.stdin.fileno()): try: b = blueprint.Blueprint.load(sys.stdin, args[0]) except ValueError: logging.error( 'standard input contains invalid blueprint JSON') sys.exit(1) else: b = blueprint.Blueprint.create(args[0]) b.commit(options.message or '') return b except blueprint.NameError: logging.error('invalid blueprint name') sys.exit(1)