Exemplo n.º 1
0
    def test_findProxyInstallations(self):
        # check if user has a valid proxy:
        sitRootPath = SIT.getParentPath()
        sitProxyPath = SIT.getPath()

        Any.requireIsDir(sitRootPath)
        Any.requireIsDir(sitProxyPath)
        ProxyDir.requireIsProxyDir(sitProxyPath)

        # create a fake package directory within the proxy...
        packageName = 'UnittestABCDEF123'
        goodNameDir = os.path.join(sitProxyPath, 'Libraries', packageName)
        goodVersionDir = os.path.join(goodNameDir, '42.0')
        badVersionDir = os.path.join(goodNameDir, '21.0')
        FastScript.mkdir(goodVersionDir)

        resultList = ProxyDir.findProxyInstallations()
        self.assertTrue(
            len(resultList) >= 1
        )  # may be greater if developer has real software installed in proxy

        self.assertTrue(goodVersionDir in resultList)
        self.assertFalse(badVersionDir in resultList)

        # clean-up
        FastScript.remove(goodNameDir)
Exemplo n.º 2
0
def _linkNewPackagesIntoProxy(sitRootPkgList, sitProxyPkgList, sitRoot,
                              sitProxy, dryRun):
    """
        Creates a symlink in the proxy for each newly globally installed
        package.
    """
    Any.requireIsListNonEmpty(sitRootPkgList)
    Any.requireIsListNonEmpty(sitProxyPkgList)
    Any.requireIsDir(sitRoot)
    Any.requireIsDir(sitProxy)

    proxyChanged = False
    diffList = _getTreeDifferences(sitRootPkgList, sitProxyPkgList)
    diffList.sort()

    for project in diffList:
        pkgRootPath = os.path.join(sitRoot, project)
        pkgProxyPath = os.path.join(sitProxy, project)
        pkgBaseDir = os.path.dirname(pkgProxyPath)

        # make directory if it does not exist
        if not os.path.exists(pkgBaseDir):
            FastScript.mkdir(pkgBaseDir)

        try:
            os.symlink(pkgRootPath, pkgProxyPath)
            logging.info('linking %s' % project)
            proxyChanged = True
        except OSError:
            pass  # after linking one path, the other one might be inside

    return proxyChanged
Exemplo n.º 3
0
def mkdir(path, verbose=False):
    """
        Creates the directory "path", with all intermediate directories to
        this path if they do not exist, yet (like the "mkdir -p <path>" on
        the GNU/Linux shell).

        This is a convenience wrapper around os.makedirs(): If the directory
        already exists this function returns silently.

        If the directory can't be created, an exception will be thrown.
    """
    Any.requireIsText(path)

    if not path:
        return

    if verbose:
        logging.info('mkdir -p %s', path)
    else:
        logging.debug('mkdir -p %s', path)

    try:
        os.makedirs(path)
    except (AssertionError, OSError) as details:

        if details.errno == 17:  # 17 = directory exists
            # ensure it's really a directory and not a file
            Any.requireIsDir(path)
        else:
            raise
Exemplo n.º 4
0
def _checkProxyLinkTarget(sitRootPkgList, sitProxyPkgList, sitRoot, sitProxy,
                          dryRun):
    """
        Checks for each package in the list if the equivalent proxy symlink
        points into the SIT root directory or outside (e.g. group proxy)

        'projectList' must be a list containing canonical path names such
        as ['Libraries/Serialize/3.0'].
    """
    Any.requireIsListNonEmpty(sitRootPkgList)
    Any.requireIsListNonEmpty(sitProxyPkgList)
    Any.requireIsDir(sitRoot)
    Any.requireIsDir(sitProxy)

    for project in sitProxyPkgList:
        pkgProxyPath = os.path.join(sitProxy, project)

        if os.path.islink(pkgProxyPath):
            # check if version symlink points into root SIT
            try:
                proxyLinkTarget = os.readlink(pkgProxyPath)
                if proxyLinkTarget[0] == '/' and \
                   not proxyLinkTarget.startswith( sitRoot ):
                    logging.warning('%s: points to %s' %
                                    (pkgProxyPath, proxyLinkTarget))
            except OSError:
                logging.warning('invalid symlink: please check %s' %
                                pkgProxyPath)

    return False  # proxy was not altered by this
Exemplo n.º 5
0
    def getRepoRelativePath(self, path=None):
        """
            Returns the relative path from the repository root to the
            provided path, e.g. to locate a package's top-level-directory.

            If path is omitted (None) assume the current working directory.
        """
        if not path:
            path = os.getcwd()

        Any.requireIsDir(path)

        repoRoot = self.detectRepositoryRoot()

        if repoRoot is None:
            raise ValueError('unable to detect repository root')
        else:
            Any.requireIsDir(repoRoot)

        relPath = path.replace(repoRoot, '')
        Any.requireIsText(relPath)

        # remove leading slash (untypical for relative paths)
        if relPath.startswith('/'):
            relPath = relPath[1:]

        return relPath
Exemplo n.º 6
0
def copyModuleIndex(srcRoot, dstRoot):
    """
        Copies all <srcDIT>/Modules/Index/*.def and <srcDIT>/Modules/Index/*.py files to
                   <dstSIT>/Modules/Index/
    """
    Any.requireIsDir(srcRoot)
    Any.requireIsDir(dstRoot)

    srcDir = os.path.join(srcRoot, 'Modules', 'Index')
    dstDir = os.path.join(dstRoot, 'Modules', 'Index')

    # For the case that srcRoot is an SIT proxy: Some people do not have
    # any files in their Index directory, furthermore the directory could
    # be entirely missing if never a BBCM had been installed into the
    # user's proxy
    #
    # Any.requireIsDirNonEmpty( srcDir )
    FastScript.mkdir(dstDir)

    for srcFile in FastScript.getFilesInDir(srcDir):
        if srcFile.endswith(".def") or srcFile.endswith(".py"):

            fileName = os.path.basename(srcFile)
            srcPath = os.path.join(srcDir, fileName)
            dstPath = os.path.join(dstDir, fileName)

            FastScript.copy(srcPath, dstPath)
Exemplo n.º 7
0
    def detectRepositoryRoot(self, path=None):
        """
            From any given path that points *within* a repo, this function
            tries to find the root directory by searching the current
            and parent directories for a '.git' subdirectory.

            If path is omitted (None), search starts at the current working
            directory.
        """
        if not path:
            path = os.getcwd()

        Any.requireIsDir(path)

        gitDirPath = os.path.join(path, '.git')

        if os.path.exists(gitDirPath):
            return path

        if path == '' or path == '/':
            result = None
        else:
            result = self.detectRepositoryRoot(os.path.split(path)[0])

        return result
def makeShellfiles(projectRoot):
    """
        Creates all the various BashSrc, pkgInfo.py etc. files.

        If <topLevelDir>/<fileName> exists it will be copied instead of
        auto-generated. This allows writing fully handcrafted files if
        necessary.

        'topLevelDir' is assumed to be a source code working copy
        (including the version, e.g. "/home/foo/mycode/Spam/42.0")

    """
    Any.requireIsDir(projectRoot)

    oldcwd = os.getcwd()
    FastScript.changeDirectory(projectRoot)

    # collect package details once (this function is internally multi-threaded)

    try:
        details = PackageDetector(projectRoot)
        details.retrieveMakefileInfo()
        details.retrieveVCSInfo()
    except AttributeError:
        raise ValueError('Unable to create shellfiles in path="%s", is this '
                         'a package directory?' % projectRoot)
    except ValueError as details:
        raise ValueError(details)

    FastScript.mkdir('./install')

    if os.path.exists('BashSrc'):
        logging.info('cp BashSrc ./install/')
        shutil.copy2('BashSrc', './install/BashSrc')
    else:
        BashSrcWriter(details).write('./install/BashSrc')

    if os.path.exists('CmdSrc.bat'):
        logging.info('cp CmdSrc.bat ./install/')
        shutil.copy2('CmdSrc.bat', './install/CmdSrc.bat')
    else:
        CmdSrcWriter(details).write('./install/CmdSrc.bat')

    # Note: pkgInfo.py is always generated (merged)
    PkgInfoWriter(details).write('./install/pkgInfo.py')

    if os.path.exists('packageVar.cmake'):
        logging.info('cp packageVar.cmake ./install/')
        shutil.copy2('packageVar.cmake', './install/packageVar.cmake')
    else:
        # try to generate a reasonable file (put explicitly under ./install/
        # to indicate it's a installation-temporary file
        #
        # if the user wants to handcraft it, he could move this
        # auto-generated file to ./packageVar.cmake and add it to VCS
        PackageVarCmakeWriter(details).write('./install/packageVar.cmake')

    FastScript.changeDirectory(oldcwd)
Exemplo n.º 9
0
def isInstalled(sitRootPath):
    """
        Returns a boolean whether or not RTMaps is available in SIT.
    """
    Any.requireIsDir(sitRootPath)

    installBaseDir = os.path.join(sitRootPath, 'External', 'RTMaps')

    return os.path.exists(installBaseDir)
    def test_proxyInstallation(self):
        oldcwd = os.getcwd()
        packageName = 'ExamplePackage'
        packageVersion = '1.0'
        category = 'Applications'
        projectRoot = os.path.join('.', packageName, packageVersion)
        output = StringIO() if Any.getDebugLevel() <= 3 else None
        platform = Platforms.getHostPlatform()
        sitPath = SIT.getPath()

        # build + install package
        FastScript.changeDirectory(projectRoot)

        bst = BuildSystemTools()
        bst.setStdOut(output)
        bst.setStdErr(output)
        bst.compile()

        Any.requireIsDirNonEmpty('build')
        Any.requireIsDirNonEmpty(os.path.join('build', platform))
        Any.requireIsDirNonEmpty('examples')
        Any.requireIsDirNonEmpty(os.path.join('examples', platform))

        for fileName in ('ThreadingExampleAtomicOperation',
                         'ThreadingExampleJoin', 'ThreadingExampleTraps'):
            Any.requireIsFileNonEmpty(os.path.join('bin', platform, fileName))

        if not ProxyDir.isProxyDir(sitPath):
            self.skip("%s: Is not a proxy directory" % sitPath)

        bst.makeDocumentation()
        bst.proxyInstall()
        installRoot = os.path.join(sitPath, category, packageName,
                                   packageVersion)

        # check result
        Any.requireIsDir(installRoot)
        Any.requireIsDirNonEmpty(os.path.join(installRoot, 'bin', platform))
        Any.requireIsDirNonEmpty(os.path.join(installRoot, 'doc/html'))
        Any.requireIsFileNonEmpty(
            os.path.join(installRoot, 'doc/html/index.html'))
        Any.requireIsFileNonEmpty(os.path.join(installRoot, 'pkgInfo.py'))
        Any.requireIsFileNonEmpty(os.path.join(installRoot,
                                               'packageVar.cmake'))

        for fileName in ('ThreadingExampleAtomicOperation',
                         'ThreadingExampleJoin', 'ThreadingExampleTraps'):
            Any.requireIsFileNonEmpty(
                os.path.join(installRoot, 'bin', platform, fileName))

        # clean-up
        bst.uninstall(cleanGlobalInstallation=False)
        bst.distclean()

        self.assertFalse(os.path.exists(installRoot))

        FastScript.changeDirectory(oldcwd)
Exemplo n.º 11
0
    def run(self):
        if not 'buildRules' in self.values:

            # When using default build rules, allow customization of
            # file search patterns (TBCORE-971)

            if not 'srcFilesPattern' in self.values:
                self.values['srcFilesPattern'] = 'src/*.c src/*.cpp'

            if not 'exeFilesPattern' in self.values:
                self.values[
                    'exeFilesPattern'] = '''bin/*.c bin/*.cpp examples/*.c examples/*.cpp
                    test/*.c test/*.cpp'''

            Any.requireIsTextNonEmpty(self.values['srcFilesPattern'])
            Any.requireIsTextNonEmpty(self.values['exeFilesPattern'])

            buildRules = '''file(GLOB SRC_FILES %(srcFilesPattern)s)

bst_build_libraries("${SRC_FILES}" "${PROJECT_NAME}" "${BST_LIBRARIES_SHARED}")


file(GLOB EXE_FILES %(exeFilesPattern)s)

bst_build_executables("${EXE_FILES}" "${BST_LIBRARIES_SHARED}")''' % \
                         { 'srcFilesPattern': self.values[ 'srcFilesPattern' ],
                           'exeFilesPattern': self.values[ 'exeFilesPattern' ] }

            # Add custom pre-/post-build rules if specified (TBCORE-971)

            if 'preBuildRules' in self.values:
                Any.requireIsTextNonEmpty(self.values['preBuildRules'])
                buildRules = self.values['preBuildRules'] + '\n\n' + buildRules

            if 'postBuildRules' in self.values:
                Any.requireIsTextNonEmpty(self.values['postBuildRules'])
                buildRules = buildRules + '\n\n' + self.values['postBuildRules']

            self.values.update({'buildRules': buildRules})

        if not 'category' in self.values:
            logging.info('please check BST_INSTALL_CATEGORY in CMakeLists.txt')
            self.values.update({'category': 'Libraries'})

        if not 'dependencies' in self.values:
            self.values['dependencies'] = []

        srcDir = os.path.join(self.templateDir_core, 'master')
        dstDir = self.dstDir

        Any.requireIsDir(srcDir)

        self.templatize(os.path.join(srcDir, 'CMakeLists.txt.mako'),
                        os.path.join(dstDir, 'CMakeLists.txt'))

        self.copyVerbatim(os.path.join(srcDir, 'unittest.sh'),
                          os.path.join(dstDir, 'unittest.sh'))
Exemplo n.º 12
0
    def __init__(self, details, sitPath, stdout=None, stderr=None):
        Any.requireIsInstance(details, PackageDetector)

        self.details = details
        self.sitPath = sitPath
        self.docDir = os.path.join(self.details.topLevelDir, 'doc')
        self.stdout = stdout
        self.stderr = stderr

        Any.requireIsDir(self.details.topLevelDir)
Exemplo n.º 13
0
def _checkDefFiles(sitRootPkgList, sitProxyPkgList, sitRoot, sitProxy, dryRun):
    """
        Checks that there are no orphaned *.def files in the proxy,
        f.i. leftovers from previous proxy-installations that have been
        deleted in the meanwhile.

        Superfluous *.def files might be a really hard-to-track source of
        errors: In case they don't match the actual interface of the
        (globally) installed component, it might be very difficult to find
        out why certain inputs/outputs/references do / don't appear in DTBOS.
    """
    from ToolBOSCore.Packages.ProjectProperties import isCanonicalPath
    from ToolBOSCore.Packages.ProjectProperties import splitPath

    Any.requireIsListNonEmpty(sitRootPkgList)
    Any.requireIsListNonEmpty(sitProxyPkgList)
    Any.requireIsDir(sitRoot)
    Any.requireIsDir(sitProxy)

    proxyPackages = findProxyInstallations()  # list of absolute paths
    Any.requireIsList(proxyPackages)
    proxyPackages = map(SIT.strip, proxyPackages)

    # filter-out 3-digit version numbers, as *.def files by convention
    # are for 2-digit versions only
    proxyPackages = filter(isCanonicalPath, proxyPackages)

    # create a corresponding fake-index for each proxy installation, for easy
    # string-based matching later
    #
    fakeDefs = []

    for package in proxyPackages:
        (category, packageName, packageVersion) = splitPath(package)
        fakeDefs.append('%s_%s.def' % (packageName, packageVersion))

    indexDir = os.path.join(sitProxy, 'Modules/Index')
    defPathList = glob.glob(os.path.join(indexDir, '*.def'))
    proxyChanged = False

    for defPath in defPathList:
        defFile = os.path.basename(defPath)

        # delete superfluous *.def files
        if defFile not in fakeDefs:
            collapsed = SIT.collapseHGR(defPath)

            if dryRun:
                logging.info('-- DRY RUN --   found superfluous %s' %
                             collapsed)
            else:
                logging.info('deleting %s', defPath)
                FastScript.remove(defPath)

    return proxyChanged
Exemplo n.º 14
0
    def setSourceAndBinaryTree( self, sourceTree, binaryTree ):
        Any.requireIsDirNonEmpty( sourceTree )
        Any.requireIsDir( binaryTree )

        self._sourceTree = sourceTree
        self._binaryTree = binaryTree
        self._buildDir   = binaryTree
        self._outOfTree  = sourceTree and binaryTree

        self._detectBuildDir()
        self._detectModulePath()
Exemplo n.º 15
0
def findProxyInstallations(checkLinks=False):
    """
        Returns a list of packages installed within the proxy SIT.

        A ValueError will be raised if the current SIT is not a proxy.

        If 'checkLinks' == True, each version symlink will also be tested
        if it really points into the root SIT. For example, it might be
        difficult to localize a manually changed link that points e.g. in
        another group proxy or so.
    """
    resultList = []
    sit = SIT.getPath()
    sitParent = SIT.getParentPath()  # support cascaded proxies
    excludePattern = re.compile('^(parentTree|\d+\.\d+.*)$')
    criteria = re.compile("^(\d+)\.(\d+)(.*)")

    Any.requireIsDir(sit)
    Any.requireIsDir(sitParent)
    requireIsProxyDir(sit)

    # find all entries within the proxy that seem to be a version number
    dirList = FastScript.getDirsInDirRecursive(
        sit,
        excludePattern=excludePattern,
        onError=FastScript.printPermissionDenied)

    # check each found entry if it is a version directory, if so we
    # can expect that this is a local project installation
    for project in dirList:
        for entry in os.listdir(project):
            joinedPath = os.path.join(project, entry)

            # only perform test on version numbers
            if criteria.search(entry):

                # don't use os.path.isdir() as it follows symlinks!
                fileType = os.lstat(joinedPath).st_mode

                if checkLinks == True and stat.S_ISLNK(fileType) == True:
                    # test if symlink points into root SIT
                    target = os.readlink(joinedPath)

                    if target[0] == '/' and not target.startswith(sitParent):
                        logging.warning(joinedPath + ': points to ' + target)

                elif stat.S_ISDIR(fileType):
                    # we found a proxy installation
                    resultList.append(joinedPath)

    return resultList
Exemplo n.º 16
0
    def __init__(self,
                 projectRoot,
                 sitPath=None,
                 stdout=None,
                 stderr=None,
                 details=None):

        Any.requireIsDir(projectRoot)

        self.projectRoot = projectRoot
        logging.debug('topLevelDir=%s' % projectRoot)

        if details is None:
            details = PackageDetector(projectRoot)

            try:
                details.retrieveMakefileInfo()
            except EnvironmentError as e:
                logging.warning(e)  # e.g. $SIT not defined in environment

        else:
            Any.requireIsInstance(details, PackageDetector)

        if sitPath is None:
            sitPath = SIT.getPath()

        if FastScript.getEnv('MAKEFILE_DOC') == 'FALSE':
            handler = NullBackend
        elif details.docTool == 'doxygen':
            handler = DoxygenBackend
        elif details.docTool == 'matdoc':
            handler = MatlabBackend
        elif details.docTool == '':
            handler = NullBackend
        elif details.isMatlabPackage():

            # [CIA-1131] matdoc no longer works on xenial64
            #
            # On Ubuntu 16.04 disable documentation creation
            # (do not use doxygen either to not overwrite the
            # correct matdoc-output from Ubuntu 14.04 machines)

            if getHostPlatform().startswith('xenial'):
                handler = NullBackend
            else:
                handler = MatlabBackend

        else:
            handler = DoxygenBackend

        self.backend = handler(details, sitPath, stdout, stderr)
Exemplo n.º 17
0
def getVersionsAvailable(sitRootPath):
    """
        Returns a list of strings with the RTMaps versions installed
        in the specified SIT, e.g. ['4.20', '4.21']
    """
    Any.requireIsDir(sitRootPath)

    installBaseDir = os.path.join(sitRootPath, 'External', 'RTMaps')
    Any.requireIsDirNonEmpty(installBaseDir)

    resultList = FastScript.getDirsInDir(installBaseDir)
    Any.requireIsListNonEmpty(resultList)

    return resultList
Exemplo n.º 18
0
    def run(self):
        if not 'category' in self.values:
            self.values['category'] = 'External'

        if not 'buildRules' in self.values:
            self.values[
                'buildRules'] = '''# This is a dummy file needed by various aux. scripts.
#
# The actual build instructions can be found in the compile.sh.
'''

        self.createMainPackage()

        srcDir = os.path.join(self.templateDir, 'External_without_compilation')
        dstDir = self.dstDir

        for fileName in FastScript.getFilesInDir(srcDir, '.php'):
            srcFile = os.path.join(srcDir, fileName)
            dstFile = os.path.join(dstDir, fileName)
            self.copyVerbatim(srcFile, dstFile)

        self.copyVerbatim(os.path.join(srcDir, 'pkgInfo.py'),
                          os.path.join(dstDir, 'pkgInfo.py'))

        FastScript.remove(os.path.join(dstDir, 'unittest.sh'))

        # create exemplarily (fake-)tarball file, and interface-symlink to it
        tarball = os.path.join(dstDir, 'src',
                               'Example-1.0-precompiled.tar.bz2')
        symlink = os.path.join(dstDir, 'src', 'package.tar.bz2')

        logging.info('processing %s' % tarball)
        FastScript.setFileContent(tarball, '')

        logging.info('processing %s' % symlink)
        os.symlink('Example-1.0-precompiled.tar.bz2', symlink)

        # create basic packageVar.cmake
        #
        # Note: for some reason calling FastScript.changeDirectory() with rel. path failed,
        # continuing with absolute path as workaround
        dstDir = os.path.abspath(dstDir)
        Any.requireIsDir(dstDir)

        details = PackageDetector(dstDir)
        details.retrieveMakefileInfo()

        fileName = os.path.join(dstDir, 'packageVar.cmake')
        PackageVarCmakeWriter(details).write(fileName)
Exemplo n.º 19
0
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)
Exemplo n.º 20
0
def getCanonicalPaths(sitPath):
    """
        Returns a sorted list of all installed packages
        (major.minor versions only).
    """
    from ToolBOSCore.Packages.ProjectProperties import isCanonicalPath

    Any.requireIsDir(sitPath)

    sitPackages = []
    getProjectsWithErrorHandling(sitPath, sitPackages)

    canonicalPaths = list(filter(isCanonicalPath, sitPackages))
    canonicalPaths.sort()

    return canonicalPaths
Exemplo n.º 21
0
def registerNormalPackages(sitPath, dryRun=False):
    """
        Searches the SIT for RTMaps packages and invokes
        registerHondaPackage() for each of them.
    """
    Any.requireIsDir(sitPath)
    Any.requireIsBool(dryRun)

    sitProxyPath = SIT.getPath()
    ProxyDir.requireIsProxyDir(sitProxyPath)

    searchBaseDir = os.path.join(sitPath, 'Modules', 'RTMaps')
    # Any.requireIsTextNonEmpty( searchBaseDir ) # dir. might not exist
    Any.requireIsTextNonEmpty(searchBaseDir)

    indexBaseDir = getIndexBaseDir(sitProxyPath)
    # Any.requireIsDir( indexBaseDir )           # dir. might not exist
    Any.requireIsTextNonEmpty(indexBaseDir)

    logging.debug('SIT path:       %s', sitPath)
    logging.debug('search basedir: %s', searchBaseDir)
    logging.debug('index basedir:  %s', indexBaseDir)

    # find *.pck files
    logging.debug('scanning %s...', searchBaseDir)
    pckPaths = FastScript.findFiles(searchBaseDir, ext='.pck')
    Any.requireIsList(pckPaths)

    logging.debug('found HORP files:')
    logging.debug(pckPaths)

    # process each *.pck file (tokenize path and create symlink)
    for pckPath in pckPaths:

        # the *.pck file is located on the 3rd subdirectory level relative
        # to the installRoot, so compute the installRoot based on this
        tokens = pckPath.split(os.path.sep)
        installRoot = os.path.sep.join(tokens[:-3])
        package = SIT.strip(installRoot)

        Any.requireIsDir(installRoot)
        Any.requireIsTextNonEmpty(package)

        try:
            registerNormalPackage(package, sitProxyPath, indexBaseDir, dryRun)
        except ValueError as e:
            logging.error(e)
Exemplo n.º 22
0
    def __init__( self, appName , appRoot ):
        Any.requireIsTextNonEmpty( appName )
        Any.requireIsDir( appRoot )

        self._addPaths        = []
        self._appName         = appName
        self._appRoot         = appRoot
        self._settingsFile    = appName + '.conf'

        defaultConfDir        = os.path.join( self._appRoot, 'etc' )
        userConfDir           = os.path.join( os.path.expanduser( '~' ), '.HRI', self._appName )
        cwdConfDir            = os.getcwd()
        machineConfDir        = '/etc'

        self._defaultConfPath = os.path.join( defaultConfDir, self._settingsFile )
        self._userConfPath    = os.path.join( userConfDir,    self._settingsFile )
        self._machineConfPath = os.path.join( machineConfDir, self._settingsFile )
        self._cwdConfPath     = os.path.join( cwdConfDir,     self._settingsFile )
Exemplo n.º 23
0
def getProjects(path, keepPath=True, onError=None):
    """
        Recursively searches for projects installed in the specified
        directory.

        If 'keepPath' is True, the specified "path" will be part of the
        strings returned. If False, only the part of the path behind 'path'
        will be returned, e.g.:

             getProjects( '/hri/sit/latest' )

             True:
                   [ '/hri/sit/latest/Libraries/Serialize/3.0', ... ]
             False:
                   [ 'Libraries/Serialize/3.0', ... ]

        You may pass a function callback that will be called upon errors,
        e.g. permission denied. This function needs to take a single
        path parameter. If omitted, an OSError will be raised upon errors.
    """
    Any.requireIsDir(path)

    path = os.path.normpath(path)
    projectList = []
    excludePattern = re.compile("(parentTree|^\d+\.\d+)|.svn")
    criteria = re.compile("^(\d+)\.(\d+)(.*)")

    for directory in FastScript.getDirsInDirRecursive(path,
                                                      excludePattern,
                                                      onError=onError):
        for subDir in FastScript.getDirsInDir(directory,
                                              onError=FastScript.ignore):

            if keepPath:
                pathToAdd = os.path.join(directory, subDir)
            else:
                pathToAdd = os.path.join(directory.replace(path + '/', ''),
                                         subDir)

            if criteria.search(subDir):
                projectList.append(pathToAdd)

    return projectList
Exemplo n.º 24
0
def getProjectsWithErrorHandling(path, resultList):
    """
        This is a tiny wrapper of 'getProjects()' which also prints some
        logging info and handles errors such as permission denied.

        The data will be appended to the provided resultList instead of
        using a return value. This allows using this function in a thread.
    """
    Any.requireIsDir(path)
    Any.requireIsList(resultList)

    logging.info('scanning %s...' % path)

    resultList.extend(
        getProjects(path,
                    keepPath=False,
                    onError=FastScript.printPermissionDenied))

    Any.requireIsListNonEmpty(resultList)
Exemplo n.º 25
0
    def test_bootstrapSIT(self):
        basePkgList = SIT.getMinRequirements()
        outputDir = tempfile.mkdtemp(prefix='test-')

        # create test SIT
        copyFilter = CopyTreeFilter.CopyTreeFilter([])  # skip copying binaries
        copyFilter.filterDocu = True
        SIT.bootstrap(outputDir, True, True, copyFilter.callback, False)

        # check if all essential packages are available
        for package in basePkgList:
            Any.requireIsFile(
                os.path.join(outputDir, package, 'packageVar.cmake'))

        # check for Module-Index directory
        Any.requireIsDir(os.path.join(outputDir, 'Modules', 'Index'))

        # clean-up
        FastScript.remove(outputDir)
Exemplo n.º 26
0
def _getInterfaceFile(projectName, srcDir):
    Any.requireIsTextNonEmpty(projectName)
    Any.requireIsDir(srcDir)

    r = r'^(I{}\.[x,bb]ml)$'.format(projectName)
    files = []

    for f in os.listdir(srcDir):
        match = re.match(r, f)
        if match:
            files.append(os.path.join(srcDir, match.group(1)))

    Any.requireIsListNonEmpty(files)
    Any.requireMsg(
        len(files) == 1,
        'More than one valid interface file was found for VirtualModule {}: {}'
        .format(projectName, files))

    return files[0]
Exemplo n.º 27
0
    def run(self):
        if not 'category' in self.values:
            self.values['category'] = 'External'

        self.createMainPackage()

        srcDir = os.path.join(self.templateDir,
                              'External_CMake_out_of_tree_build')
        dstDir = self.dstDir

        for fileName in FastScript.getFilesInDir(srcDir, '.php'):
            srcFile = os.path.join(srcDir, fileName)
            dstFile = os.path.join(dstDir, fileName)
            self.copyVerbatim(srcFile, dstFile)

        self.copyVerbatim(os.path.join(srcDir, 'pkgInfo.py'),
                          os.path.join(dstDir, 'pkgInfo.py'))

        FastScript.remove(os.path.join(dstDir, 'unittest.sh'))

        # create exemplarily (fake-)tarball file, and interface-symlink to it
        tarball = os.path.join(dstDir, 'src', 'Example-1.0-src.tar.bz2')
        symlink = os.path.join(dstDir, 'src', 'sources.tar.bz2')

        logging.info('processing %s' % tarball)
        FastScript.setFileContent(tarball, '')

        logging.info('processing %s' % symlink)
        os.symlink('Example-1.0-src.tar.bz2', symlink)

        # create basic packageVar.cmake
        #
        # Note: for some reason calling FastScript.changeDirectory() with rel. path failed,
        # continuing with absolute path as workaround
        dstDir = os.path.abspath(dstDir)
        Any.requireIsDir(dstDir)

        details = PackageDetector(dstDir)
        details.retrieveMakefileInfo()

        fileName = os.path.join(dstDir, 'packageVar.cmake')
        PackageVarCmakeWriter(details).write(fileName)
Exemplo n.º 28
0
def registerDistributionPackages(sitRootPath, sitProxyPath, dryRun=False):
    """
        Searches the SIT for packages shipped with RTMaps itself
        (by Intempora).
    """
    Any.requireIsDir(sitRootPath)
    ProxyDir.requireIsProxyDir(sitProxyPath)
    Any.requireIsBool(dryRun)

    platformList = getPlatformNames()
    rtmapsVersions = getVersionsAvailable(sitRootPath)

    Any.requireIsListNonEmpty(platformList)
    Any.requireIsListNonEmpty(rtmapsVersions)

    installBaseDir = os.path.join(sitRootPath, 'External', 'RTMaps')

    indexBaseDir = getIndexBaseDir(sitProxyPath)
    # Any.requireIsDir( indexBaseDir )           # dir. might not exist
    Any.requireIsTextNonEmpty(indexBaseDir)

    # find *.pck files shipped with RTMaps
    for rtmapsVersion in rtmapsVersions:
        logging.debug('searching for packages shipped with RTMaps %s',
                      rtmapsVersion)

        for platform in platformList:
            searchPath = os.path.join(installBaseDir, rtmapsVersion, platform,
                                      'packages')

            pckPaths = FastScript.findFiles(searchPath, ext='.pck')
            Any.requireIsList(pckPaths)

            for pckPath in pckPaths:
                pckFile = os.path.basename(pckPath)
                Any.requireIsTextNonEmpty(pckFile)

                symlink = os.path.join(indexBaseDir, rtmapsVersion, platform,
                                       pckFile)
                target = pckPath

                FastScript.link(target, symlink, dryRun)
Exemplo n.º 29
0
def setupLegacyMSVC(configDir):
    from ToolBOSCore.Storage.SIT import getPath

    sitRootPath = getPath()
    packageName = 'Data/wine.net/0.1'
    handmadeDir = os.path.join(sitRootPath, packageName, 'config')
    userName = FastScript.getCurrentUserName()

    if not os.path.exists(handmadeDir):
        raise AssertionError('%s: No such package in SIT' % packageName)

    if not userName:
        raise AssertionError('Unable to query username :-(')

    # replace 'Program Files' and 'windows' directories in configDir by
    # symlinks to handmade directories in SIT

    for item in ('Program Files', 'windows'):
        path = os.path.join(configDir, 'drive_c', item)
        Any.requireIsDir(path)
        FastScript.remove(path)

        target = os.path.join(handmadeDir, 'drive_c', item)
        FastScript.link(target, path)

    # copy all the handmade *.reg files
    regFiles = glob.glob("%s/*.reg" % handmadeDir)
    Any.requireIsListNonEmpty(regFiles)

    for srcFilePath in regFiles:
        fileName = os.path.basename(srcFilePath)
        dstFilePath = os.path.join(configDir, fileName)

        logging.debug('cp %s %s', srcFilePath, dstFilePath)
        shutil.copyfile(srcFilePath, dstFilePath)
        Any.requireIsFileNonEmpty(dstFilePath)

        # replace occurrences of 'roberto' by username
        oldContent = FastScript.getFileContent(dstFilePath)
        newContent = oldContent.replace('roberto', userName)
        FastScript.setFileContent(dstFilePath, newContent)
Exemplo n.º 30
0
def setupMSVC2017(configDir):
    """
        Configures the Microsoft Visual Compiler to be used with Wine
        from the ToolBOS build system.

        You may provide a path to the directory where your Wine
        configuration is. If omitted, the path returned from getWineConfigDir()
        will be used.
    """
    from ToolBOSCore.Storage.SIT import getPath

    if not os.path.exists(os.path.join(configDir, 'user.reg')):
        setupWineDotNet(configDir, msvc=2017)

    Any.requireIsDir(configDir)

    logging.info('Setting up Visual Studio...')

    sitPath = getPath()
    packageName = 'Data/wine.net/1.1'
    msvcDir = os.path.join(sitPath, packageName, 'config')

    linkPath = os.path.join(configDir, 'drive_c', 'BuildTools')
    linkTarget = os.path.join(msvcDir, 'drive_c', 'BuildTools')
    FastScript.remove(linkPath)
    FastScript.link(linkTarget, linkPath)

    linkPath = os.path.join(configDir, 'drive_c', 'Program Files',
                            'Microsoft SDKs')
    linkTarget = os.path.join(msvcDir, 'drive_c', 'Program Files',
                              'Microsoft SDKs')
    FastScript.remove(linkPath)
    FastScript.link(linkTarget, linkPath)

    linkPath = os.path.join(configDir, 'drive_c', 'Program Files',
                            'Windows Kits')
    linkTarget = os.path.join(msvcDir, 'drive_c', 'Program Files',
                              'Windows Kits')
    FastScript.remove(linkPath)
    FastScript.link(linkTarget, linkPath)