Example #1
0
def init():
    import fs
    setupdir = fs.setup()
    fs.assure(setupdir)
    # Note, we use the setup directory name as the base name for
    # top-level setup files, this is just coincidence/convention
    dump_sh(setupdir)
    dump_csh(setupdir)
Example #2
0
def setup():
    'Add CMT setup scripts to the setup directory.'
    setup = srcdir() + '/mgr/setup'
    fs.assure(fs.setup())
    fs.goto(fs.setup())
    def do_link(ext):
        if os.path.exists('00_cmt'+ext): 
            os.remove('00_cmt'+ext)
        import shutil
        shutil.copy(setup+ext,'00_cmt'+ext)
    for ext in ['.sh','.csh']:
        do_link(ext)
    return fs.setup() + '/00_cmt.sh'
Example #3
0
    def init_project(self, deps=None):
        if deps is None: deps = list()
        import fs
        fs.assure(self.proj_dir()+'/cmt')
        fp = open(self.proj_dir()+'/cmt/project.cmt', 'w')
        fp.write('project %s\n'%self.name)
        for dep in deps: fp.write('use %s\n'%dep)
        fp.write('''
build_strategy with_installarea
structure_strategy with_no_version_directory
setup_strategy root\n''')
        fp.write('container %s'%self.rel_pkg())
        fp.close()
        return
Example #4
0
def setup():
    "Add GIT setup scripts to the setup directory."
    fs.assure(fs.setup())
    fs.goto(fs.setup())
    for export, letter, equals in [("export", "", "="), ("setenv", "c", " ")]:
        ss = open("00_git.%ssh" % letter, "w")
        ss.write(
            """#!/bin/%ssh
%s PATH%s%s:${PATH}
"""
            % (letter, export, equals, os.path.join(prefix(), "bin"))
        )
        ss.close()
    return fs.setup() + "/00_git.sh"
Example #5
0
def get_svn(url,target,overwrite):
    cmd = 'co'
    if os.path.exists(target):
        if overwrite:
            cmd = 'up'
        else:
            log.info('Pre-existing file found, not re-getting %s'%target)
            return target

    fs.assure(target)
    import svn
    if cmd == 'up':
        fs.goto(target)
        svn.svncmd('up')
    else:
        svn.svncmd('%s %s %s'%(cmd,url,target))
    return target
Example #6
0
def get_cvs(url,module,tag,target,overwrite):
    cmd = 'co'
    if os.path.exists(target+'/CVS'):
        if overwrite:
            cmd = 'up'
        else:
            log.info('Pre-existing file found, not re-getting %s'%target)
            return target

    fs.assure(target)
    import cvs
    if cmd == 'up':
        fs.goto(target)
        cvs.cvscmd('up')
    else:
        tagflag = ""
        if tag: tagflag = "-r "+tag
        cvs.cvscmd('-d %s %s %s %s %s'%(url,cmd,tagflag,module,target))
    return target
Example #7
0
    def init_project(self,deps=None):
        'Initialize the LCGCMT project'
        import fs,os
        from ConfigParser import NoOptionError
        setupdir = fs.setup()
        fs.assure(setupdir)

        base = fs.setup()

        tags = ['garpi']
        try:
            extra_tags = eval(self.get_config('extra_tags'))
            tags += extra_tags
        except NoOptionError:
            pass

        tags = ','.join(tags)
        #print 'setting extra tags =',tags

        values = (os.path.dirname(fs.projects()),
                  os.path.basename(fs.projects()),tags)

        # Bourne Shell
        sh = open(os.path.join(base,'10_lcgcmt.sh'),'w')
        sh.write('''#!/bin/sh
SITEROOT=%s
export SITEROOT
CMTPROJECTPATH=$SITEROOT/%s
export CMTPROJECTPATH
CMTEXTRATAGS=%s
export CMTEXTRATAGS
'''%values)
        sh.close()

        # C(rappy) Shell
        csh = open(os.path.join(base,'10_lcgcmt.csh'),'w')
        csh.write('''#!/bin/csh
setenv SITEROOT %s
setenv CMTPROJECTPATH %s
setenv CMTEXTRATAGS %s
        '''%values)
        csh.close()
        return
Example #8
0
    def build_package(self,pkg,cmds = None):
        '''
    for cmd in get config make install
    do
        echo "$pkg: running \"cmt pkg_$cmd\""
        cmt pkg_$cmd
        check_cmd
    done
        '''
        import fs
        fs.assure(os.path.join(fs.external(),'tarFiles'))
        fs.assure(os.path.join(fs.external(),'build/LCG'))
        
        bdir = self.builder_directory(pkg)
        from exception import InconsistentState
        if bdir is None: 
            raise InconsistentState('No builder directory for "%s"'%pkg)
        
        if not cmds:
            print 'Building %s in %s'%(pkg,bdir)

        pkg = os.path.basename(bdir)
        cmtdir = os.path.join(bdir,'cmt')

        envdir = os.path.join('LCG_Builders',pkg)
        environ = self.env(envdir)

        import fs
        fs.goto(cmtdir)
        
        import cmt
        if not cmds: cmds = ['get','config','make','install']
        for what in cmds:
            print '\t%s'%what
            cmt.cmt('pkg_%s'%what, environ=environ, dir=cmtdir)

        
        fs.goback()
        return
Example #9
0
    #print 'openning',url

    try:
        res = urlopen(url)
    except HTTPError, e:
        print e.__class__, e 
        raise IOError,'Failed to get '+url
    except URLError, e:
        print e.__class__, e 
        raise IOError,'Failed to get '+url


    dirname = os.path.dirname(target)
    if dirname:
        fs.assure(dirname)
    else:
        dirname = '.'
    filename = os.path.basename(url)
    targetfile = os.path.join(dirname,filename)
    targetfp = open(targetfile,"w")
    shutil.copyfileobj(res,targetfp)
    targetfp.close()

    return target


def uriparse(uri):
    '''
    Split the URI scheme://hostname/path into [scheme,hostname,path]
    '''