def _execTask( self, name, corefunc ): Any.requireIsTextNonEmpty( name ) Any.requireIsCallable( corefunc ) logging.debug( 'Build System Tools: "%s" step started', name ) status = self._runScript( 'pre-%s' % name ) if status: self._switchToTargetEnv() coreScript = self._assembleScriptCmd( name )[0] if os.path.exists( coreScript ): status = self._runScript( name ) else: status = corefunc() self._switchToHostEnv() if status: status = self._runScript( 'post-%s' % name ) logging.debug( 'Build System Tools: "%s" step finished', name ) return status
def bootstrap(dstPath, buildSDK=False, verbose=True, ignore=None, resolveLTS=False, cacheDir=None): """ Creates a new software installation tree by copying the most basic packages from the current tree. This will be sufficient to execute ToolBOS applications. If 'buildSDK' is set to True, also packages for compiling / building software will be copied into the dstPath. 'ignore' might be a callable that will be given to shutil.copytree() for filtering-out undesired content. 'resolveLTS' indicates whether or not symlinks to LTS packages shall be resolved: True = copy content of LTS packages (resolve symlinks) False = keep LTS symlinks as they are """ Any.requireIsTextNonEmpty(dstPath) Any.requireIsBool(buildSDK) Any.requireIsBool(verbose) Any.requireIsBool(resolveLTS) if ignore is not None: Any.requireIsCallable(ignore) if cacheDir is not None: Any.requireIsDirNonEmpty(cacheDir) srcRoot = getRootPath() dstRoot = dstPath # Any.RequireIsDir( srcRoot ) # not useful error reporting if not os.path.isdir(srcRoot): msg = "%s: Source SIT path does not exist (can't bootstrap from there)" % srcRoot raise RuntimeError(msg) FastScript.mkdir(dstRoot) # create if it does not exist, yet if buildSDK: packageList = getBuildRequirements() else: packageList = getMinRequirements() Any.requireIsListNonEmpty(packageList) copyBasePackages(srcRoot, dstRoot, packageList, verbose, ignore, resolveLTS, cacheDir) # make directory for component description files (*.def) modulesDir = os.path.join(dstRoot, 'Modules') indexDir = os.path.join(dstRoot, 'Modules', 'Index') FastScript.mkdir(indexDir) # will implicitely create the modulesDir os.chmod(modulesDir, 0o0777) os.chmod(indexDir, 0o0777)
def add(self, task, *args, **kwargs): """ Add new tasks as threads to the ThreadPool. """ Any.requireIsCallable(task) _thread = threading.Thread(target=task, args=args, kwargs=kwargs) self._threads.add(_thread)
def copyBasePackages(srcRoot, dstRoot, packageList, verbose=True, ignore=None, resolveLTS=False, cacheDir=None): """ Copies all packages in the 'packageList' from the current srcRoot into dstRoot. Use the 'verbose' parameter to see/suppress a little progress information. 'ignore' might be a callable that will be given to shutil.copytree() for filtering-out undesired content. 'resolveLTS' indicates whether or not symlinks to LTS packages shall be resolved: True = copy content of LTS packages (resolve symlinks) False = keep LTS symlinks as they are If 'cacheDir' points to a SIT-like directory, packages aren't copied but instead linked there to speed-up, e.g. while debugging. """ Any.requireIsDir(srcRoot) Any.requireIsDir(dstRoot) Any.requireIsBool(verbose) Any.requireIsBool(resolveLTS) if ignore is not None: Any.requireIsCallable(ignore) if cacheDir is not None: Any.requireIsDirNonEmpty(cacheDir) for package in packageList: if cacheDir: symlink = os.path.join(dstRoot, package) target = os.path.join(cacheDir, package) FastScript.link(target, symlink) else: src = os.path.join(srcRoot, package) dst = os.path.join(dstRoot, package) _copyBasePackage(src, dst, verbose, ignore, resolveLTS)
def setOutputFilter(self, func): """ Callback to be invoked before printing the command output to the terminal widget. Could be used to perform some textual replacements before displaying. The function will receive the original output as text parameter and is supposed to return the modified text. Use None to disable output filtering (= display original output). """ if func is not None: Any.requireIsCallable(func) self._outputFilter = func
def __init__(self, serializeFunc): Any.requireIsCallable(serializeFunc) self._lowLevelSerializer = None self._toolbosLib = DynamicLoader.loadLibrary('ToolBOSLib') self._serFunc = serializeFunc Any.requireIsNotNone(self._toolbosLib) Any.requireIsNotNone(self._serFunc) self._toolbosLib.CalcSizeSerializer_new.restype = ctypes.c_void_p self._toolbosLib.CalcSizeSerializer_init.argtypes = [ctypes.c_void_p] self._toolbosLib.CalcSizeSerializer_open.restype = ctypes.c_void_p self._toolbosLib.CalcSizeSerializer_open.argtypes = [ ctypes.c_void_p, ctypes.c_char_p ] self._toolbosLib.CalcSizeSerializer_getTotalSize.restype = ctypes.c_long self._toolbosLib.CalcSizeSerializer_getTotalSize.argtypes = [ ctypes.c_void_p ]
def addPackage( self, canonicalPath, recursive, filterFunc ): """ Runs 'filterFunc' on the specified package. Does the same for all dependent packages if 'recursive=True'. """ Any.requireIsTextNonEmpty( canonicalPath ) Any.requireIsBool( recursive ) Any.requireIsCallable( filterFunc ) canonicalPath = strip( canonicalPath ) installRoot = self.sitPath + os.sep + canonicalPath if canonicalPath in self.pkgList: # avoid duplicates return if canonicalPath.startswith( 'deb://' ): # ignore Debian packages return if self._showProgress: logging.info( 'processing %s', canonicalPath ) if os.path.exists( installRoot + os.sep + 'SkipLibIndex' ): logging.debug( '%s: SkipLibIndex found' % canonicalPath ) else: filterFunc( self, canonicalPath ) if recursive: deps = getDependencies( project = canonicalPath, recursive = True, cache = self._depCache, systemPackages = False, sitPath = getPath() ) shortDepList = FastScript.reduceList( deps ) for package in shortDepList: if package not in self.pkgList: self.addPackage( package, False, filterFunc )
def addPackageList( self, pkgList, recursive, filterFunc ): """ Like addPackage(), but for a list of packages. pkgList = ( 'Basics/Any/2.2', 'Basics/Time/1.1' ) LibIndex.createFromList( pkgList, 'MyLibIndex' ) """ Any.requireIsList( pkgList ) Any.requireIsCallable( filterFunc ) pkgFileDependecies = [] for pkg in pkgList: deps = getDependencies( project = pkg, recursive = True, cache = self._depCache, systemPackages = False, sitPath = getPath() ) shortDeps = FastScript.reduceList( deps ) for shortDep in shortDeps: path = splitPath( pkg ) Any.requireIsTuple( path ) dependency = splitPath( shortDep ) Any.requireIsTuple( dependency ) mod = strip( path[ 1 ] ) lib = strip( dependency[ 1 ] ) vers = strip( dependency[ 2 ] ) pkgFileDependecies.append( ( mod, lib, vers ) ) conflictDeps = [] #returns the list of conflicting dependencies, if empty there are no conflicts for deps in pkgFileDependecies: mod = deps[ 0 ] lib = deps[ 1 ] vers = deps[ 2 ] #we build the list where the lib library appears in other versions listDep = [ x for x in pkgFileDependecies if x[ 1 ] == lib and not x[ 2 ] == vers ] for dep in listDep: module = dep[ 0 ] lib = dep[ 1 ] version = dep[ 2 ] #check for duplicates if not ( module, mod, lib, version, vers ) in conflictDeps: conflictDeps.append( ( mod, module, lib, vers, version ) ) textError = 'ERROR:\n' text = '{} {} used by {} \n is in conflict with \n{} {} used by {}\n\n' for dep in conflictDeps: mod1 = dep[ 0 ] # first module mod2 = dep[ 1 ] # second module lib = dep[ 2 ] # library vers1 = dep[ 3 ] # first version vers2 = dep[ 4 ] # second version textError = textError + text.format( lib, vers1, mod1, lib, vers2, mod2 ) Any.requireMsg( not conflictDeps, '\n %s' % textError ) for pkg in pkgList: self.addPackage( pkg, recursive, filterFunc )