예제 #1
0
def updateComponentIndex(sitRootPath, sitProxyPath, dryRun):
    """
        Cleans the index directory and creates all symlinks from scratch.
    """
    Any.requireIsDir(sitRootPath)
    Any.requireIsDir(sitProxyPath)
    Any.requireIsBool(dryRun)

    ProxyDir.requireIsProxyDir(sitProxyPath)

    indexBaseDir = getIndexBaseDir(sitProxyPath)

    # We would like to start with a fresh indexBaseDir, however cannot delete
    # it because it also contains the DTBOS *.def files. Hence we only remove
    # subdirectories (corresponding to the RTMaps versions) within this
    # directories and keep *.def files as they are. See TBCORE-974).
    #
    #FastScript.remove( indexBaseDir )

    for subDir in FastScript.getDirsInDir(indexBaseDir):
        path = os.path.join(indexBaseDir, subDir)
        FastScript.remove(path)

    for version in getVersionsAvailable(sitRootPath):
        dstDir = os.path.join(indexBaseDir, version)
        logging.debug('mkdir %s', dstDir)

        if not dryRun:
            FastScript.mkdir(dstDir)

    logging.debug('updating RTMaps component index...')

    registerDistributionPackages(sitRootPath, sitProxyPath, dryRun)
    registerNormalPackages(sitRootPath, dryRun)
    registerNormalPackages(sitProxyPath, dryRun)
예제 #2
0
    def execute(self):
        logging.info('running matdoc...')

        prog = self._findMatdoc()
        cmd = '%s %s' % (prog, self.details.packageName)
        msg = 'matdoc not found'

        if not os.path.exists(prog):
            logging.error('%s: No such file')
            logging.error(msg)
            return

        try:
            FastScript.execProgram(cmd, stdout=self.stdout, stderr=self.stderr)
        except OSError as details:
            logging.debug(details)
            logging.error(msg)
            return

        oldName = os.path.join(self.details.topLevelDir, 'doc', 'auto/html')
        newName = os.path.join(self.details.topLevelDir, 'doc', 'html')
        FastScript.remove(newName)

        try:
            os.rename(oldName, newName)
        except OSError as details:
            logging.debug(details)
            logging.error(msg)
            return

        FastScript.remove(os.path.join(self.details.topLevelDir, 'doc',
                                       'auto'))
예제 #3
0
def _removeProxyInstallations(sitRootPkgList, sitProxyPkgList, sitRoot,
                              sitProxy, dryRun):
    """
        ATTENTION: Unless dryRun=True, this function removes all packages
                   that have been installed locally to your proxy!
                   Use with caution!
    """
    requireIsProxyDir(sitProxy)

    toDelete = findProxyInstallations()  # list of absolute paths into proxy
    Any.requireIsList(toDelete)

    if len(toDelete) == 0:
        logging.info('no proxy installations to be deleted')
        result = 0
    else:
        if dryRun:
            logging.info('-- DRY RUN --   not deleting anything')
            result = 0
        else:
            logging.info('deleting all proxy-installations as requested:')
            result = len(toDelete)

        for installRoot in toDelete:
            if dryRun:
                logging.info('-- DRY RUN --   normally would now delete %s' %
                             installRoot)
            else:
                logging.info('deleting %s' % installRoot)
                FastScript.remove(installRoot)

    return result
예제 #4
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)
    def run(self):
        if not 'category' in self.values:
            self.values['category'] = 'DeviceIO'

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

        if not 'buildRules' in self.values:
            self.values[
                'buildRules'] = '''# invoke kbuild for the actual building
add_custom_target(${PACKAGE_NAME} ALL make
                  WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY})'''

        self.createMainPackage()

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

        self.templatize(os.path.join(srcDir, 'packageName.c.mako'),
                        os.path.join(dstDir, 'src', '%s.c' % self.packageName))

        self.templatize(os.path.join(srcDir, 'Makefile'),
                        os.path.join(dstDir, 'Makefile'))

        FastScript.remove(os.path.join(dstDir, 'unittest.sh'))
def delUserConfigOption(varName):
    """
        Removes a certain config option from the user's configfile.
    """
    Any.requireIsTextNonEmpty(varName)

    # read current settings (if any)
    config = getUserConfigOptions()

    # remove setting
    try:
        del config[varName]
        logging.debug('deleted config option: %s', varName)

        # delete entire file if there are no settings left
        if config:
            _setUserConfigOptions(config)
        else:
            fileName = getSettingsFile_user()
            logging.debug('deleting empty configfile')
            logging.debug('rm %s', fileName)
            FastScript.remove(fileName)

    except KeyError:
        logging.debug('%s: No such user config option', varName)
    def test_addGlobalInstallLog( self ):
        msgType  = 'NEW'
        message  = 'Test message (unittest)'


        # create log entry
        logEntry = GlobalInstallLog( ToolBOSSettings.canonicalPath,
                                     isFirstInstall=False,
                                     msgType=msgType,
                                     message=message )
        fileName = tempfile.mkstemp( prefix='test-' )[1]
        logEntry.setFileName( fileName )
        logEntry.writeFile()

        Any.requireIsFileNonEmpty( fileName )
        content  = FastScript.getFileContent( fileName )


        # check result
        self.assertTrue( content.find( msgType ) > 0, "log file incorrect" )
        self.assertTrue( content.find( message ) > 0, "log file incorrect" )


        # clean-up
        FastScript.remove( fileName )
    def run(self):
        if not 'category' in self.values:
            self.values['category'] = 'Modules/RTMaps'

        if not 'dependencies' in self.values:
            self.values['dependencies'] = ['External/RTMaps/4.2']

        if not 'buildRules' in self.values:
            self.values[
                'buildRules'] = '''file(GLOB SRC_FILES src/*.c src/*.cpp)

bst_build_rtmaps_package("${SRC_FILES}" "${PROJECT_NAME}" "${BST_LIBRARIES_SHARED}")'''

        self.createMainPackage()

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

        self.copyVerbatim(
            os.path.join(srcDir, 'packageName.pckinfo'),
            os.path.join(dstDir, '%s.pckinfo' % self.packageName))

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

        # TBCORE-1837 Create empty 'src' directory
        FastScript.mkdir(os.path.join(dstDir, 'src'))
예제 #9
0
def setupProxy(sitRootPath=None, sitProxyPath=None):
    """
        Convenience-wrapper to create a default proxy directory.

        WARNING: If a proxy already exists, it will be DELETED !

        You may specify the absolute paths for the SIT root- and/or
        proxy directories. If omitted, typical defaults will be used.
    """
    from ToolBOSCore.Storage import ProxyDir
    from ToolBOSCore.Storage import SIT

    if not sitRootPath:
        sitRootPath = SIT.getDefaultRootPath()

    if not sitProxyPath:
        sitProxyPath = SIT.getDefaultProxyPath()

    Any.requireIsTextNonEmpty(sitRootPath)
    Any.requireIsTextNonEmpty(sitProxyPath)
    Any.requireIsDir(sitRootPath)

    # delete existing proxy if it exists, it might be screwed up
    if os.path.exists(sitProxyPath):
        logging.info('cleaning existing proxy in %s' % sitProxyPath)
        FastScript.remove(sitProxyPath)

    logging.info('creating proxy directory... (this may take some time)')
    logging.info('SIT Root:  %s' % sitRootPath)
    logging.info('SIT Proxy: %s' % sitProxyPath)
    ProxyDir.createProxyDir(sitRootPath, sitProxyPath, verbose=False)
예제 #10
0
    def _distclean_outOfTree( self ):

        # Safety check (TBCORE-1635):
        #
        # We experienced that switching directories within Midnight
        # Commander and invoking a sub-shell with "BST.py -d" could lead
        # to an incorrect assumption that we perform an out-of-tree build
        # although it is a normal in-tree-build.
        #
        # In this case, the current package is considered to be a build
        # directory and deleted at "BST.py -d" -- effectively destroying
        # work results that have not been committed, yet.
        #
        # To prevent deletion in such cornercase we check for files and
        # directories that could indicate such cornercase:

        for candidate in ( 'CMakeLists.txt', 'packageVar.cmake',
                             'pkgInfo.py', 'src', 'build' ):

            if os.path.exists( candidate ):
                msg = 'TBCORE-1635 CORNERCASE DETECTED, PERFORMING EMERGENCY EXIT!'
                raise SystemExit( msg )

        logging.debug( 'passed safety check' )

        for entry in os.listdir( self._binaryTree ):
            try:
                FastScript.remove( entry )
            except ( IOError, OSError ) as details:
                logging.error( details )

        return True
예제 #11
0
    def save(self):
        """
            Writes the user-settings in ASCII yet Pythonic style to the user's
            configfile, so that it can be edited manually and read-in using
            FastScript.execFile().

            If there are no user-settings at all the fill be removed
            (if present).
        """
        if self._userSettings:

            from ToolBOSCore.Packages.CopyrightHeader import getCopyrightHeader

            content = getCopyrightHeader('python', 'User preferences')

            for key, value in sorted(self._userSettings.items()):
                if Any.isText(value):
                    value = "'%s'" % value  # write Python string, not just value

                content += '%s = %s\n\n' % (key, str(value))

            content += '\n# EOF\n'

            logging.debug('writing %s', self._userFile)
            FastScript.setFileContent(self._userFile, content)

        else:
            # delete entire file if there are no settings left

            logging.debug('deleting empty configfile')
            FastScript.remove(self._userFile)
    def run(self):
        if not 'category' in self.values:
            self.values['category'] = 'Libraries'

        if not 'dependencies' in self.values:
            self.values['dependencies'] = ['External/AllPython/2.7']

        self.createMainPackage()

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

        FastScript.remove(os.path.join(dstDir, 'include'))

        self.copyVerbatim(
            os.path.join(srcDir, '__init__.py'),
            os.path.join(dstDir, 'include', self.packageName, '__init__.py'))

        self.copyVerbatim(
            os.path.join(srcDir, 'HelloWorld.py'),
            os.path.join(dstDir, 'include', self.packageName, 'HelloWorld.py'))

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

        self.copyVerbatim(os.path.join(srcDir, 'unittest.sh'),
                          os.path.join(dstDir, 'unittest.sh'))

        self.templatize(os.path.join(srcDir, 'Unittest_HelloWorld.py.mako'),
                        os.path.join(dstDir, 'test', 'Unittest_HelloWorld.py'))
    def test_makeDocumentation( self ):
        tmpDir         = tempfile.mkdtemp( prefix='test-' )
        packageName    = 'HelloWorld'
        packageVersion = '42.0'
        projectRoot    = os.path.join( tmpDir, packageName, packageVersion )


        # create package on-the-fly
        PackageCreator_C_Library( packageName, packageVersion,
                                  outputDir=tmpDir ).run()

        Any.requireIsDirNonEmpty( tmpDir )

        # create docu
        output = StringIO() if Any.getDebugLevel() <= 3 else None
        d = DocumentationCreator( projectRoot, stdout=output, stderr=output )
        d.generate()


        # check result
        Any.requireIsDirNonEmpty(  os.path.join( projectRoot, 'doc' ) )
        Any.requireIsDirNonEmpty(  os.path.join( projectRoot, 'doc/html' ) )
        Any.requireIsFileNonEmpty( os.path.join( projectRoot, 'doc/html/index.html' ) )
        Any.requireIsFileNonEmpty( os.path.join( projectRoot, 'doc/html/doxygen.css' ) )
        Any.requireIsFileNonEmpty( os.path.join( projectRoot, 'doc/html/doxygen.png' ) )

        FastScript.remove( tmpDir )
예제 #14
0
def _removeList( pathList, verbose, dryRun ):
    # pathList was just detected via glob.glob(), avoid additional check
    # if file exists (for speed-up reasons, but also this check would fail
    # in case of broken links)
    for path in pathList:
        if dryRun:
            logging.info( '-- DRY RUN --   not really deleting %s' % path )
        else:
            FastScript.remove( path )
예제 #15
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
예제 #16
0
def checkExecutable(executablePath, details, stdout=None, stderr=None):

    tmpFile = tempfile.mktemp()

    cmd = VALGRIND % (tmpFile, executablePath)

    FastScript.execProgram(cmd, stdout=stdout, stderr=stderr)

    failed, numErrors = parseOutput(tmpFile, details)

    FastScript.remove(tmpFile)

    return failed, numErrors
    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)
예제 #18
0
    def test_wineMSVC( self ):
        oldcwd         = os.getcwd()
        tmpDir         = tempfile.mkdtemp( prefix='test-' )
        packageName    = 'HelloWorld'
        packageVersion = '42.0'
        projectRoot    = os.path.join( tmpDir, packageName, packageVersion )
        output         = StringIO() if Any.getDebugLevel() <= 3 else None
        hostPlatform   = Platforms.getHostPlatform()
        targetPlatform = 'windows-amd64-vs2012'

        if targetPlatform not in CrossCompilation.getSwitchEnvironmentList( hostPlatform ):
            self.skipTest( '%s to %s cross-compilation not supported' % \
                           ( hostPlatform, targetPlatform ) )


        # create package on-the-fly
        PackageCreator_C_Library( packageName, packageVersion,
                                  outputDir=tmpDir ).run()


        # build package
        FastScript.changeDirectory( projectRoot )

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


        # check result
        Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'build' ) )
        Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'build', targetPlatform ) )
        Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'lib' ) )
        Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'lib', targetPlatform ) )
        Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'src' ) )
        Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'test' ) )
        Any.requireIsDirNonEmpty( os.path.join( projectRoot, 'test', targetPlatform ) )


        # clean-up
        bst.distclean()
        self.assertFalse( os.path.exists( os.path.join( projectRoot, 'build' ) ) )
        self.assertFalse( os.path.exists( os.path.join( projectRoot, 'lib' ) ) )
        FastScript.remove( tmpDir )
        FastScript.changeDirectory( oldcwd )
예제 #19
0
def _cleanHomeDirectory(sitRootPkgList, sitProxyPkgList, sitRoot, sitProxy,
                        dryRun):
    """
        Clean-up really old / unused files under ~/.HRI
    """
    configDir = os.path.expanduser('~/.HRI')

    if not os.path.isdir(configDir):
        logging.debug('%s: No such directory', configDir)
    else:
        logging.debug('cleaning up %s', configDir)

        for item in ('CMBOS', 'HappyPorting2009', 'HRI',
                     'ToolBOS/PythonConsole', 'ToolBOS/VFSTelnet.conf'):
            FastScript.remove(os.path.join(configDir, item))

    return False
예제 #20
0
    def test_serializeUtility_convert(self):
        tcRoot = FastScript.getEnv('TOOLBOSCORE_ROOT')
        platform = Platforms.getHostPlatform()
        exe = os.path.join(tcRoot, 'bin', platform, 'ConvertSerializedData')
        inFile = 'BBDMArrayBlockF32-binary.ser'
        outFile = tempfile.mkstemp(prefix='test-')[1]
        cmd = '%s -i %s -f Ascii -o %s' % (exe, inFile, outFile)
        tmp = StringIO()

        try:
            FastScript.execProgram(cmd, stdout=tmp, stderr=tmp)
        except OSError:
            raise RuntimeError("Please compile this package first!")

        output = tmp.getvalue()

        # typical error could be:
        #
        # [... SerializeUtility.c:809 Error] Could not load data library
        # 'BBDMArrayBlockF32' (libBBDMArrayBlockF32.so): Reason
        # 'libBBDMArrayBlockF32.so: cannot open shared object file:
        # No such file or directory'
        #
        # [... SerializeUtility.c:653 Error] The input file
        # 'test/miscInputFiles/BBDMArrayBlockF32-binary.ser'
        # does not contain valid data

        # check result
        self.assertTrue(output.find('libBBDMArrayBlockF32.so') == -1)
        self.assertTrue(output.find('Could not load data library') == -1)
        self.assertTrue(output.find('No such file or directory') == -1)
        self.assertTrue(
            output.find('Aborting serialization function') > 0)  # at EOF
        self.assertTrue(output.find('does not contain valid data') == -1)

        Any.requireIsFileNonEmpty(outFile)
        content = FastScript.getFileContent(outFile)

        # there must be 3x "HRIS" in the ASCII representation of this file
        matches = re.findall('HRIS', content)
        self.assertTrue(len(matches) == 3)

        # clean-up
        FastScript.remove(outFile)
예제 #21
0
    def test_serializeUtility_createSerializedData(self):
        random.seed(self)

        tcRoot = FastScript.getEnv('TOOLBOSCORE_ROOT')
        platform = Platforms.getHostPlatform()
        exe = os.path.join(tcRoot, 'bin', platform, 'CreateSerializedData')
        count = random.randint(3, 20)
        outFile = tempfile.mkstemp(prefix='test-')[1]
        cmd = '%s -t BBDMArrayBlockF32 -c %d -r -f Ascii -o %s' % (exe, count,
                                                                   outFile)
        tmp = StringIO()

        try:
            FastScript.execProgram(cmd, stdout=tmp, stderr=tmp)
        except OSError:
            raise RuntimeError("Please compile this package first!")

        output = tmp.getvalue()

        # typical error could be:
        #
        # [... SerializeUtility.c:809 Error] Could not load data library
        # 'BBDMBaseF32' (libBBDMBaseF32.so): Reason 'libBBDMBaseF32.so:
        # cannot open shared object file: No such file or directory'
        #
        # SerializeUtility.c:1083 BBDMBaseF32: unsupported datatype
        # (BBDMBaseF32_new() not found)

        # check result
        self.assertTrue(output.find('libBBDMArrayBlockF32.so') == -1)
        self.assertTrue(output.find('cannot open shared object file') == -1)
        self.assertTrue(output.find('No such file or directory') == -1)
        self.assertTrue(output.find('unsupported datatype') == -1)

        Any.requireIsFileNonEmpty(outFile)
        content = FastScript.getFileContent(outFile)

        # we must find "count"-times the keyword "HRIS" inside the file
        matches = re.findall('HRIS', content)
        self.assertTrue(len(matches) == count)

        # clean-up
        FastScript.remove(outFile)
예제 #22
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)
예제 #23
0
def setupShell():
    """
        Configures the user's shell environment to use the ToolBOS SDK.

        It tries to detect if the shell was already once configured
        (by this script or manually) and attempts to reset it to the
        default state.
    """
    fileName = os.path.expanduser('~/.bash_login')
    content = '''if [ `basename -- "$0"` != Xsession ] ; then
  source .bashrc
fi
'''

    # remove it, because could be an existing file / symlink
    FastScript.remove(fileName)

    logging.info('creating %s' % fileName)
    FastScript.setFileContent(fileName, content)
예제 #24
0
    def _distclean_inTree( self ):
        from ToolBOSCore.Storage import VersionControl

        requireTopLevelDir( os.getcwd() )

        excludeSVN = re.compile( '.svn' )
        subDirList = FastScript.getDirsInDirRecursive( excludePattern=excludeSVN )
        subDirList.append( '.' )

        # do not cache those variables as their change would not be reflected
        # in such case (interactive sessions will continue to use the value
        # as it was at module loading time)
        verbose = True if os.getenv( 'VERBOSE' ) == 'TRUE' else False
        dryRun  = True if os.getenv( 'DRY_RUN' ) == 'TRUE' else False

        patternList = _getDistcleanPatterns()

        for subDir in subDirList:
            _cleanDir( subDir, patternList, verbose, dryRun )


        # specifically check for empty directories (mind the ".svn"):
        for candidate in ( 'doc', 'install', 'lib', 'obj' ):
            if os.path.isdir( candidate ):
                content = os.listdir( candidate )

                if not content:
                    FastScript.remove( candidate )  # does not contain ".svn"
                elif content == [ '.svn' ]:

                    # With recent versions of SVN there are no more ".svn"
                    # directories in all the various paths, instead of a
                    # single one in top-level directory. Therefore most
                    # likely this code is dead.

                    try:
                        vcs = VersionControl.auto()
                        vcs.remove( candidate )
                    except subprocess.CalledProcessError:
                        pass                        # keep it (safety first)

        return True
    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)
예제 #26
0
def silentUpgrade():
    """
        Upgrade the user's environment settings if certain settings or
        file locations change.
    """
    dirName = os.path.expandvars('${HOME}/.HRI')

    # clean-up no longer needed files / directories
    FastScript.remove(os.path.join(dirName, 'DTBOS'))
    FastScript.remove(os.path.join(dirName, 'ToolBOSCore'))

    # move settings file to new location
    oldFile = os.path.join(dirName, 'LocalSettings.py')
    newDir = os.path.join(dirName, 'ToolBOS')
    newFile = os.path.join(newDir, 'ToolBOS.conf')

    if os.path.exists(oldFile) and not os.path.exists(newFile):
        logging.debug('mv %s %s', oldFile, newFile)
        FastScript.mkdir(newDir)
        os.rename(oldFile, newFile)
예제 #27
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)
예제 #28
0
    def test_createProxyDir(self):
        sitProxyPath = tempfile.mkdtemp(prefix='test-')
        sitRootPath = SIT.getRootPath()
        canonicalPath = ToolBOSSettings.canonicalPath

        Any.requireIsDir(sitRootPath)

        # proxy directory must not exist, yet (function would refuse otherwise)
        FastScript.remove(sitProxyPath)
        ProxyDir.createProxyDir(sitRootPath, sitProxyPath)

        Any.requireIsDir(os.path.join(sitProxyPath, 'Libraries'))
        Any.requireIsDir(os.path.join(sitProxyPath, 'Modules/BBCM'))
        Any.requireIsDir(os.path.join(sitProxyPath, 'Libraries'))

        self.assertTrue(
            os.path.islink(os.path.join(sitProxyPath, canonicalPath)))
        self.assertTrue(
            os.path.islink(os.path.join(sitProxyPath, 'External/java/1.8')))

        FastScript.remove(sitProxyPath)
예제 #29
0
def _checkProxyLinkedVersion(sitRootPkgList, sitProxyPkgList, sitRoot,
                             sitProxy, dryRun):
    """
        Checks if the two-digit version in the proxy points to the most
        recent version. Otherwise this can happen:

          * Developer A installs "Serialize/3.0.100" into his proxy, the
            2-digit link "3.0" points into the proxy to version 3.0.100.

          * Developer B installs "Serialize/3.0.101" globally.

          * Now the 3.0-symlink of developer A is outdated.
    """
    Any.requireIsListNonEmpty(sitRootPkgList)
    Any.requireIsListNonEmpty(sitProxyPkgList)
    Any.requireIsDir(sitRoot)
    Any.requireIsDir(sitProxy)

    proxyChanged = False

    for project in sitProxyPkgList:
        localPatchlevel = SIT.getActiveRevision(sitProxy, project)
        globalPatchlevel = SIT.getActiveRevision(sitRoot, project)

        if localPatchlevel is None or globalPatchlevel is None:
            continue

        if localPatchlevel < globalPatchlevel:
            logging.info('updating %s' % project)

            pkgProxyPath = os.path.join(sitProxy, project)
            pkgRootPath = os.path.join(sitRoot, project)

            FastScript.remove(pkgProxyPath)
            os.symlink(pkgRootPath, pkgProxyPath)
            proxyChanged = True

    return proxyChanged
예제 #30
0
    def _patchCIA988( self, dryRun=False ):
        """
            Removes legacy PHP files from repository.
        """
        candidates = ( 'packageVar.php',
                       self.details.packageName + '.php' )  # in old BBCMs

        result     = []

        for fileName in candidates:
            if os.path.exists( fileName ):

                if not dryRun:
                    try:
                        vcs = VersionControl.auto()
                        vcs.remove( fileName )
                    except subprocess.CalledProcessError:
                        # maybe using git
                        FastScript.remove( fileName )

                result.append( fileName )

        return result