Exemple #1
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)
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)
Exemple #3
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)
Exemple #4
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)
def registerNormalPackage(package,
                          sitProxyPath=None,
                          indexBaseDir=None,
                          dryRun=False):
    """
        Creates a symlink to the *.pck file of 'package' within the RTMaps
        index.

        RTMAPS_VERSION is taken from the dependency list of the package.
    """
    if sitProxyPath is None:
        sitProxyPath = SIT.getPath()

    if indexBaseDir is None:
        indexBaseDir = getIndexBaseDir(sitProxyPath)

    ProjectProperties.requireIsCanonicalPath(package)
    Any.requireIsDir(sitProxyPath)
    Any.requireIsDir(indexBaseDir)
    Any.requireIsBool(dryRun)

    platformList = getPlatformNames()
    packageName = ProjectProperties.getPackageName(package)
    packageVersion = ProjectProperties.getPackageVersion(package)
    versionTokens = ProjectProperties.splitVersion(packageVersion)
    majorVersion = int(versionTokens[0])
    minorVersion = int(versionTokens[1])
    installRoot = os.path.join(sitProxyPath, package)

    Any.requireIsListNonEmpty(platformList)
    Any.requireIsTextNonEmpty(packageName)
    Any.requireIsTextNonEmpty(packageVersion)
    Any.requireIsDir(installRoot)

    deps = ProjectProperties.getDependencies(package)
    try:
        Any.requireIsListNonEmpty(deps)
    except AssertionError:
        logging.debug(
            'empty list of dependencies in RTMaps package is unplausible')
        msg = "%s: unable to retrieve dependencies, please check SIT installation" % package
        raise ValueError(msg)

    expr = re.compile('^sit://External/RTMaps/(\d+\.\d+)')

    # detect RTMaps version used by package
    rtmapsVersion = ''

    for dep in deps:
        tmp = expr.match(dep)

        if tmp:
            rtmapsVersion = tmp.group(1)
            break

    Any.requireIsTextNonEmpty(rtmapsVersion)
    logging.debug('%s depends on RTMaps %s', package, rtmapsVersion)

    libDir = os.path.join(installRoot, 'lib')
    pckFiles = FastScript.findFiles(libDir, ext='.pck')

    Any.requireMsg(
        len(pckFiles) > 0,
        package + ": No *.pck file found, forgot to compile?")

    for relPath in pckFiles:
        pckFileName = os.path.basename(relPath)
        pckPackage = os.path.splitext(pckFileName)[0]
        pckFileExt = os.path.splitext(pckFileName)[1]

        logging.debug('registering %s', pckPackage)

        for platform in platformList:
            pckPath = os.path.join(libDir, platform, pckFileName)
            dstDir = os.path.join(indexBaseDir, rtmapsVersion, platform)

            if os.path.exists(pckPath):
                symlinkFile = '%s_%d.%d%s' % (pckPackage, majorVersion,
                                              minorVersion, pckFileExt)
                symlinkPath = os.path.join(dstDir, symlinkFile)
                target = pckPath

                FastScript.link(target, symlinkPath, dryRun)
Exemple #6
0
def setupMSVC2012(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)

    Any.requireIsDir(configDir)

    if not os.path.exists(os.path.join(configDir, 'dosdevices')):
        setupWineDotNet(configDir)

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

    linkPath = os.path.join(configDir, 'dosdevices', 'c:')
    linkTarget = '../drive_c'
    FastScript.remove(linkPath)
    FastScript.link(linkTarget, linkPath)

    linkPath = os.path.join(configDir, 'dosdevices', 'z:')
    linkTarget = '/'
    FastScript.remove(linkPath)
    FastScript.link(linkTarget, linkPath)

    # create temp. directories
    driveC = os.path.join(configDir, 'drive_c')
    userName = FastScript.getCurrentUserName()
    userTempDir = os.path.join(driveC, 'users', userName, 'Temp')
    sysTempDir = os.path.join(driveC, 'temp')
    logging.debug('userTempDir=%s', userTempDir)
    FastScript.mkdir(userTempDir)
    FastScript.mkdir(sysTempDir)

    # ensure to NOT have the "h:" link, else wine would not find some links
    FastScript.remove(os.path.join(configDir, 'dosdevices', 'h:'))

    # replace "C:\Program Files" by symlink into SIT
    FastScript.remove(os.path.join(configDir, 'drive_c', 'Program Files'))

    sitPath = getPath()

    linkPath = os.path.join(configDir, 'drive_c', 'msvc-sdk')
    linkTarget = os.path.join(sitPath, 'External/MSVC/10.0/msvc-sdk')
    FastScript.remove(linkPath)
    FastScript.link(linkTarget, linkPath)

    linkPath = os.path.join(configDir, 'drive_c', 'Program Files')
    linkTarget = os.path.join(sitPath, 'External/MSVC/10.0/Program Files')
    FastScript.remove(linkPath)
    FastScript.link(linkTarget, linkPath)

    # copy a hancrafted system.reg
    srcFile = os.path.join(
        sitPath, 'External/MSVC/10.0/otherstuff/winevs2012/system.reg')
    dstFile = os.path.join(configDir, 'system.reg')
    shutil.copyfile(srcFile, dstFile)

    # force wine to use the MSVC native library
    userReg = os.path.join(configDir, 'user.reg')

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

    if content.find('1413877490') == -1:
        content += \
'''

[Software\\\\Wine\\\\DllOverrides] 1413877490
"mscoree"="native"
"msvcr110"="native"

'''
        logging.debug('updating %s', userReg)
        FastScript.setFileContent(userReg, content)