Example #1
0
def ensureHasDependency(content, package):
    """
        Ensures if the direct dependencies/inclusions are present
        or not in the provided string (= CMakeLists.txt file content).
    """
    Any.requireIsTextNonEmpty(content)
    ProjectProperties.requireIsCanonicalPath(package)

    logging.debug('Validating CMakeLists.txt')

    category, name, version = ProjectProperties.splitPath(package)
    pkgNoVersion = os.path.join(category, name)
    found = False

    for dep in getDependencies(content):
        if dep.find(pkgNoVersion) > 0:
            found = True
            logging.debug('%s dependency already present', pkgNoVersion)

    if found:
        return content

    else:
        logging.debug('inserting dependency to: %s', package)

        return insertDependency(content, package)
Example #2
0
    def create(self):
        """
            Creates a new SVN repository.

            If the repository shall be on another server than 'localhost',
            SSH will be used to tunnel the execution of commands.
        """
        from ToolBOSCore.Packages import ProjectProperties

        tmp1 = parse.urlsplit(self.url)
        server = tmp1.netloc
        repoDir = tmp1.path

        server = None if server is '' else server

        if server:  # if not set create on localhost
            Any.requireIsTextNonEmpty(server)

        Any.requireIsTextNonEmpty(repoDir)

        repoRoot, category, packageName = ProjectProperties.splitPath(repoDir)
        repoParent = os.path.dirname(repoDir)

        logging.debug('repoRoot:     %s', repoRoot)
        logging.debug('repoParent:   %s', repoParent)
        logging.debug('repoDir:      %s', repoDir)
        logging.debug('category:     %s', category)
        logging.debug('package name: %s', packageName)
        logging.debug('server:       %s', server)

        logging.info('creating directory structure')
        cmd = "mkdir -p %s" % repoDir
        FastScript.execProgram(cmd, host=server, workingDir='/')

        logging.info('creating new repository')
        cmd = "svnadmin create --fs-type fsfs %s" % packageName
        FastScript.execProgram(cmd, host=server, workingDir=repoParent)

        # verify that it exists now
        Any.requireMsg(self.exists(),
                       "failed to create repository (reason is unclear)")

        # As decided by HRI-EU's Security Group in April 2009, new SVN
        # repositories will be protected from world access by default.
        # Beside the owner, only the same group can access repositories.
        # Manual interference is necessary to change this upon demand.

        if server:
            groupName = FastScript.getCurrentGroupName()

            logging.info('granting group read-permission (%s)' % groupName)
            cmd = "chmod 2770 db db/transactions db/revs db/revprops && " + \
                "chmod 660 db/write-lock && chmod 750 hooks && "        + \
                "chmod 770 locks && chmod o-r * && chmod o-w * && "     + \
                "chmod o-x * && chmod -R g-w db && chmod 0750 ."

            FastScript.execProgram(cmd, host=server, workingDir=repoDir)
        else:
            logging.warning( 'setting repository permissions on local ' + \
                             'filesystem not implemented, yet' )
Example #3
0
def getIndexFileName(canonicalPath):
    """
        Returns the RTMaps index filename for the package.

        Example:  'Horp_ToolBOS_1.0.pck'
    """
    ProjectProperties.requireIsCanonicalPath(canonicalPath)

    tmp = ProjectProperties.splitPath(canonicalPath)
    result = '%s_%s.pck' % (tmp[1], tmp[2])
    Any.requireIsTextNonEmpty(result)

    return result
Example #4
0
def makeCategoryWriteable(sitPath, project, groupName='hriall', mode=0o0775):
    """
        Changes the group and permissions of all directories between
        'sitPath' up to the project version (the project's main directory
        will also be group-writeable so that different developers could
        install different versions.

        Mind to provide an octal number as 'mode'!)
    """
    from ToolBOSCore.Packages import ProjectProperties

    Any.requireIsDir(sitPath)
    Any.requireIsTextNonEmpty(project)
    Any.requireIsTextNonEmpty(groupName)
    Any.requireIsIntNotZero(mode)  # <mode> must be an octal number
    ProjectProperties.requireIsCanonicalPath(project)

    # The current HRI-EU install procedure is implemented in a way that it always
    # attempts to change ownership of the category INCLUDING the SIT root
    # directory. Instead of fixing this there (time-consuming, error-prone) we
    # always set it here as a shortcut.
    FastScript.setGroupPermission(sitPath, groupName, mode)

    # cut off the project version
    tmp = ProjectProperties.splitPath(project)
    mainDir = os.path.join(tmp[0], tmp[1])
    tokens = mainDir.split(os.sep)

    # the current path we are operating on with chmod+chgrp, starting from
    # sitPath
    curPath = sitPath

    # for each token in category do a chmod+chgrp
    for token in tokens:
        curPath = os.path.join(curPath, token)
        FastScript.setGroupPermission(curPath, groupName, mode)
# revision to fetch
if args['global']:
    try:
        revision = PkgInfo.getSVNRevision(package)

        Any.requireIsInt(revision)
        Any.require(revision != -1)
        logging.info('SVN revision = %d' % revision)

    except (AssertionError, IOError):
        logging.error('')
        logging.error('unable to detect last globally installed revision')
        logging.error('falling back to HEAD revision')
        logging.error('')

projectName = ProjectProperties.splitPath(package)[1]
Any.requireIsTextNonEmpty(projectName)

# create directory with name of package when downloading a particular version,
# and cd into it
if not fetchAll:
    FastScript.mkdir(projectName)
    FastScript.changeDirectory(projectName)

repo = SVN.SVNRepository(url)
repo.checkIsOnMasterServer()

try:
    if userName:
        repo.setUserName(userName)
    else: