Esempio n. 1
0
def test_tag_project():
    rep = connect(repo_url)

    # simple project
    assert rep.tag('Proj', 'v1r0', isProject=True) == 0
    rep = connect(repo_url)  # refresh infos
    assert rep._exists('Proj/tags/PROJ/PROJ_v1r0/cmt/project.cmt')

    # simple project (branch)
    assert rep.branch('Proj', 'v1b', isProject=True) == 0
    rep = connect(repo_url)  # refresh infos
    assert rep._exists('Proj/branches/PROJ/PROJ_v1b/cmt/project.cmt')

    # files expected in the CMake project tag/branch
    expected_files = [
        'cmt/project.cmt', 'CMakeLists.txt', 'cmake/SomeCMakeModule.cmake',
        'toolchain.cmake', 'configure'
    ]

    # CMake project
    assert rep.tag('ProjB', 'v1r0', isProject=True) == 0
    rep = connect(repo_url)  # refresh infos
    exists = lambda x: rep._exists('ProjB/tags/PROJB/PROJB_v1r0/' + x)
    assert all(map(exists,
                   expected_files)), rep._ls('ProjB/tags/PROJB/PROJB_v1r0/')

    # CMake project (branch)
    assert rep.branch('ProjB', 'v1b', isProject=True) == 0
    rep = connect(repo_url)  # refresh infos
    exists = lambda x: rep._exists('ProjB/branches/PROJB/PROJB_v1b/' + x)
    assert all(map(exists,
                   expected_files)), rep._ls('ProjB/branches/PROJB/PROJB_v1b/')
Esempio n. 2
0
def test_properties():
    rep = connect(repo_url)
    assert rep.repositoryVersion == ('2', '0'), rep.repositoryVersion
    assert rep.packages == [
        'Hat/NoBranch', 'ProjPkgA', 'ProjPkgB', 'ProjSys', 'SomePkg'
    ], rep.packages
    assert sorted(
        rep.projects) == ['BestProj', 'Proj', 'ProjB', 'obs',
                          'pkgs'], sorted(rep.projects)
Esempio n. 3
0
def test_checkout_cmake_project():
    rep = connect(repo_url)
    olddir = os.getcwd()
    workdir = mkdtemp()

    class check(object):
        def __init__(self, prefix):
            self.prefix = prefix

        def __call__(self, d):
            return exists(join(workdir, self.prefix, d))

    expected_files = [
        'cmt/project.cmt', 'CMakeLists.txt', 'cmake/SomeCMakeModule.cmake',
        'toolchain.cmake', 'configure'
    ]

    try:
        # plain
        os.chdir(workdir)
        rep.checkout('ProjB', project=True, vers_dir=True)
        os.chdir(olddir)

        assert all(map(check('PROJB/PROJB_head'), expected_files))

        rmtree(join(workdir, 'PROJB'), ignore_errors=True)

        # with dest
        rep.checkout('ProjB', project=True, dest=workdir, vers_dir=True)

        assert all(map(check('PROJB/PROJB_head'), expected_files))

        # trunk
        rep.checkout('ProjB',
                     'trunk',
                     project=True,
                     dest=workdir,
                     vers_dir=True)

        assert all(map(check('PROJB/PROJB_trunk'), expected_files))

        # tag
        rep.checkout('ProjB',
                     'v1r0',
                     project=True,
                     dest=workdir,
                     vers_dir=True)

        assert all(map(check('PROJB/PROJB_v1r0'), expected_files))

    finally:
        os.chdir(olddir)
        rmtree(workdir, ignore_errors=True)
Esempio n. 4
0
def test_tag_package():
    rep = connect(repo_url)

    retcode = rep.tag('ProjPkgA', 'v1r0')
    assert retcode == 0, 'Tagging ProjPkgA v1r0 -> %d' % retcode
    rep = connect(repo_url)  # refresh infos
    assert rep._exists('Proj/tags/ProjPkgA/v1r0/cmt/requirements')

    retcode = rep.branch('ProjPkgA', 'v1b')
    assert retcode == 0, 'Branching ProjPkgA v1b -> %d' % retcode
    rep = connect(repo_url)  # refresh infos
    assert rep._exists('Proj/branches/ProjPkgA/v1b/cmt/requirements')

    retcode = rep.branch('ProjPkgA', 'v1r0b', from_tag='v1r0')
    assert retcode == 0, 'Branching ProjPkgA v1r0b (from v1r0) -> %d' % retcode
    rep = connect(repo_url)  # refresh infos
    assert rep._exists('Proj/branches/ProjPkgA/v1r0b/cmt/requirements')

    retcode = rep.tag('ProjPkgA', 'v1r1', from_branch='v1b')
    assert retcode == 0, 'Tagging ProjPkgA v1r1 (from v1b) -> %d' % retcode
    rep = connect(repo_url)  # refresh infos
    assert rep._exists('Proj/tags/ProjPkgA/v1r1/cmt/requirements')

    retcode = rep.tag('Hat/NoBranch', 'v1r9')
    assert retcode == 0, 'Tagging Hat/NoBranch v1r9 -> %d' % retcode
    rep = connect(repo_url)  # refresh infos
    assert rep._exists('ProjB/tags/Hat/NoBranch/v1r9/cmt/requirements')
Esempio n. 5
0
def test_checkout_project():
    rep = connect(repo_url)
    olddir = os.getcwd()
    workdir = mkdtemp()

    def check(d):
        return exists(join(workdir, d))

    try:
        # plain
        os.chdir(workdir)
        rep.checkout('Proj', project=True, vers_dir=True)
        os.chdir(olddir)

        assert all(map(check, ['PROJ/PROJ_head/cmt/project.cmt']))

        rmtree(join(workdir, 'PROJ'), ignore_errors=True)

        # with dest
        rep.checkout('Proj', project=True, dest=workdir, vers_dir=True)

        assert all(map(check, ['PROJ/PROJ_head/cmt/project.cmt']))

        # trunk
        rep.checkout('Proj',
                     'trunk',
                     project=True,
                     dest=workdir,
                     vers_dir=True)

        assert all(map(check, ['PROJ/PROJ_trunk/cmt/project.cmt']))

        # tag
        rep.checkout('Proj', 'v1r0', project=True, dest=workdir, vers_dir=True)

        assert all(map(check, ['PROJ/PROJ_v1r0/cmt/project.cmt']))

    finally:
        os.chdir(olddir)
        rmtree(workdir, ignore_errors=True)
Esempio n. 6
0
def test_checkout_package_nobranch():
    rep = connect(repo_url)
    rep.useBranches = True
    olddir = os.getcwd()
    workdir = mkdtemp()

    def check(d):
        return exists(join(workdir, d))

    try:
        # tag
        rep.checkout('Hat/NoBranch', 'v1r9', dest=workdir)

        assert all(
            map(check, [
                'Hat/NoBranch/cmt/requirements', 'Hat/NoBranch/cmt/version.cmt'
            ]))
        assert open(join(
            workdir, 'Hat/NoBranch/cmt/version.cmt')).read().strip() == 'v1r9'

    finally:
        os.chdir(olddir)
        rmtree(workdir, ignore_errors=True)
#!/usr/bin/env python
"""
A script to add a project to the Software Configuration DB

"""
import logging
import sys

from LbConfiguration.Repository import getRepositories
from LbUtils.Script import Script
from LbRelease import rcs
from LbRelease.SoftConfDB.SoftConfDB import SoftConfDB

# SVN Repositories definition
url = str(getRepositories(protocol='anonymous')["lbsvn"])
lbsvn = rcs.connect(url)

gaudiurl = str(getRepositories(protocol='anonymous')["gaudi"])
gaudisvn = rcs.connect(gaudiurl)

class LbSdbAddPlatform(Script):
    """ Script to add platforms to a project in the Software
    Configuration DB. Use:
    LbSdbAddPlatform project version platform
    """

    def defineOpts(self):
        """ Script specific options """
        parser = self.parser
        parser.add_option("-d",
                          dest = "debug",
Esempio n. 8
0
def test_checkout_package():
    rep = connect(repo_url)
    olddir = os.getcwd()
    workdir = mkdtemp()

    def check(d):
        return exists(join(workdir, d))

    try:
        # plain
        os.chdir(workdir)
        rep.checkout('ProjPkgA')
        os.chdir(olddir)

        assert all(
            map(check,
                ['ProjPkgA/cmt/requirements', 'ProjPkgA/cmt/version.cmt']))
        assert open(join(workdir,
                         'ProjPkgA/cmt/version.cmt')).read().strip() == 'v1r0'

        rmtree(join(workdir, 'ProjPkgA'), ignore_errors=True)

        # with dest
        rep.checkout('ProjPkgA', dest=workdir)

        assert all(
            map(check,
                ['ProjPkgA/cmt/requirements', 'ProjPkgA/cmt/version.cmt']))
        assert open(join(workdir,
                         'ProjPkgA/cmt/version.cmt')).read().strip() == 'v1r0'

        # trunk
        rep.checkout('ProjPkgA', 'trunk', dest=workdir)

        assert all(
            map(check,
                ['ProjPkgA/cmt/requirements', 'ProjPkgA/cmt/version.cmt']))
        assert open(join(workdir,
                         'ProjPkgA/cmt/version.cmt')).read().strip() == 'v1r0'
        assert open(join(workdir,
                         'ProjPkgA/data.txt')).read().strip() == 'revision 12'

        # specific revision
        rep.checkout('ProjPkgA', 'r5', dest=workdir)

        assert all(
            map(check,
                ['ProjPkgA/cmt/requirements', 'ProjPkgA/cmt/version.cmt']))
        assert open(join(workdir,
                         'ProjPkgA/cmt/version.cmt')).read().strip() == 'v1r0'
        assert open(join(workdir,
                         'ProjPkgA/data.txt')).read().strip() == 'revision 5'

        # specific date
        #  the date must be without seconds
        rep.checkout('ProjPkgA', '{%s}' % test_rev_date, dest=workdir)

        assert all(
            map(check,
                ['ProjPkgA/cmt/requirements', 'ProjPkgA/cmt/version.cmt']))
        assert open(join(workdir,
                         'ProjPkgA/cmt/version.cmt')).read().strip() == 'v1r0'
        assert open(join(workdir,
                         'ProjPkgA/data.txt')).read().strip() == 'revision 9'

        # tag
        rep.checkout('ProjPkgA', 'v1r0', dest=workdir)

        assert all(
            map(check,
                ['ProjPkgA/cmt/requirements', 'ProjPkgA/cmt/version.cmt']))
        assert open(join(workdir,
                         'ProjPkgA/cmt/version.cmt')).read().strip() == 'v1r0'

        # branch
        rep = connect(repo_url)  # refresh infos
        rep.useBranches = True  # allow for branches lookup
        rep.checkout('ProjPkgA', 'v1r0b', dest=workdir)

        assert all(
            map(check,
                ['ProjPkgA/cmt/requirements', 'ProjPkgA/cmt/version.cmt']))
        assert open(join(workdir,
                         'ProjPkgA/cmt/version.cmt')).read().strip() == 'v1r0'

        # tag
        rep.checkout('ProjPkgA', 'v1r1', dest=workdir)

        assert all(
            map(check,
                ['ProjPkgA/cmt/requirements', 'ProjPkgA/cmt/version.cmt']))
        assert open(join(workdir,
                         'ProjPkgA/cmt/version.cmt')).read().strip() == 'v1r0'

        # tag with version directory
        rep.checkout('ProjPkgA', 'v1r1', dest=workdir, vers_dir=True)

        assert all(map(check, ['ProjPkgA/v1r1/cmt/requirements']))
        assert not exists(join(workdir, 'ProjPkgA/v1r1/cmt/version.cmt'))

    finally:
        os.chdir(olddir)
        rmtree(workdir, ignore_errors=True)
Esempio n. 9
0
"""

__all__ = [
    "getRequirements", "getNotes", "diffNotes", "checkOrDiff", "diffContainer",
    "getCMakeLists"
]

from LbConfiguration.Repository import getRepositories
from LbRelease import rcs
from LbUtils import LockOnPrintThread
from LbUtils.CMT.Parse import parseReq
import thread, Queue
from LbUtils.Processes import callCommand

url = str(getRepositories(protocol='anonymous')["lbsvn"])
lbsvn = rcs.connect(url)


def getRequirements(path):
    return callCommand('svn', 'cat', path + '/cmt/requirements')[0]
    #return commands.getoutput('svn cat '+path+'/cmt/requirements')


def getCMakeLists(path):
    return callCommand('svn', 'cat', path + '/CMakeLists.txt')[0]
    #return commands.getoutput('svn cat '+path+'/cmt/requirements')


def getNotes(path):
    return callCommand('svn', 'cat', path + '/doc/release.notes')[0]
    #return commands.getoutput('svn cat '+path+'/doc/release.notes')
Esempio n. 10
0
A script to add a project to the Software Configuration DB

"""
import logging
import os
import re

from LbConfiguration.Repository import getRepositories
from LbRelease import rcs
from LbRelease.SvnTools.Project import translateProject, getProjectCmt
from LbUtils.Processes import callCommand
from LbRelease.SoftConfDB.SoftConfDB import SoftConfDB

# SVN Repositories definition
url = str(getRepositories(protocol='anonymous')["lbsvn"])
lbsvn = rcs.connect(url)

gaudiurl = str(getRepositories(protocol='anonymous')["gaudi"])
gaudisvn = rcs.connect(gaudiurl)

diracurl = str(getRepositories(protocol='anonymous')["dirac"])
diracsvn = rcs.connect(diracurl)


def importerTranslateProject(p, v):
    ''' Function needed to prevent LCGCMT to be passed to translateProject
    as that does not work '''
    if p.lower() == "lcgcmt":
        return (p.upper(), v)
    else:
        return translateProject(p, v)