示例#1
0
文件: get.py 项目: brettviren/garpi
def get_git(scheme,url,target,overwrite,tag):
    import git

    if os.path.exists(target + '/.git'):
        if not overwrite: return
    else:
        if len(scheme) == 1: giturl = url
        else: giturl = url[4:]
        git.clone(giturl,target)

    fs.goto(target)
    git.fetch()
    out = git.branch()
    for line in out.split('\n'):
        if not line: continue
        if line[0] != '*': continue
        out = line.split()[1]
        break
    #print out,tag
    if out != tag:
        lbranches,rbranches = git.branches()
        if tag in lbranches:
            git.checkout(tag)
        else:
            # git 1.5 does not put remotes/ like 1.6 does
            from exception import CommandFailure
            try:
                git.checkout('origin/'+tag,tag)
            except CommandFailure:
                git.checkout('remotes/origin/'+tag,tag)
    git.pull()
    fs.goback()
    return
示例#2
0
文件: cmt.py 项目: brettviren/garpi
def build():
    'Build CMT in previously unpacked cmt.srcdir().'
    log.info('building cmt')

    fs.goto(os.path.join(srcdir(),'mgr/'))

    from command import cmd,make,source

    def stupid_hack():
        # quick hack for v1r22.  this really doesn't belong here!
        fp = open("../source/cmt_std.h")
        for line in fp:
            if 'climits' in line: return
            continue
        fp.close()
        fp = open("../source/cmt_std.h","a")
        fp.write("#include <climits>\n")
        fp.close()
        return
    stupid_hack()

    # always run this in case user does something silly like move the
    # installation somewhere else 
    cmd('./INSTALL')

    environ = env()
    cmtexe = '%s/%s/cmt'%(srcdir(),environ['CMTCONFIG'])
    if os.path.exists(cmtexe):
        log.info('CMT appears to already have been built: %s'%cmtexe)
    else:
        log.info('CMT rebuild, not found at: %s'%cmtexe)
        make(env=environ)
    return cmtexe
示例#3
0
    def download(self):
        '''Download missing or update pre-existing project files.  As
        a side effect the program will be in the projects directory
        that contains the downloaded project'''
        log.info(self.name +' download')
        import fs, ConfigParser
        projdir = fs.projects()
        fs.goto(projdir, True)
        from get import get

        try:
            tag = self.tag()
        except ConfigParser.NoOptionError:
            tag = None

        #print 'url="%s" name="%s" tag="%s"'%(self.url(), self.name, tag)
        get(self.url(), self.name, True, tag=tag)
        tarfile = os.path.basename(self.url())
        if '.tgz' in tarfile or '.tar' in tarfile:
            untar(tarfile)
            dot = tarfile.find('.')
            dirname = tarfile[:dot]
            import shutil
            shutil.move(dirname, self.name)
            pass        

        fs.goback
        return
示例#4
0
文件: cmt.py 项目: brettviren/garpi
def unpack():
    'Unpack the previously downloaded tarfile'
    log.info('unpacking cmt source')
    target = srcdir()
    if os.path.exists(target):
        log.info('CMT appears to already be unpacked in %s'%(target))
        return target
    fs.goto(fs.external(),True)
    untar(tgz())
    return target
示例#5
0
文件: git.py 项目: brettviren/garpi
def unpack():
    "Unpack the previously downloaded tarfile"
    log.info("unpacking git source")
    target = srcdir()
    if os.path.exists(target):
        log.info("git appears to already be unpacked in %s" % (target))
        return target
    fs.goto(fs.external(), True)
    untar(tgz())
    return target
示例#6
0
 def _fix_projects(self):
     import fs,os,cmt
     from command import source
     fs.goto(os.path.join(self.dstdir,'projects'))
     environ = source('./setup.sh')
     for pobj in self.project_objects:
         pdir = os.path.join(self.dstdir,'projects',pobj.name,pobj.rel_pkg(),'cmt')
         cmt.cmt("config",environ=environ,dir=pdir)
         pkgenv = source('./setup.sh',env=environ,dir=pdir)
         cmt.cmt("br cmt config",environ=pkgenv,dir=pdir)
     fs.goback()
示例#7
0
文件: gaudi.py 项目: brettviren/garpi
    def _git_checkout(self,tag,pkg=""):
        import fs,git
        fs.goto(os.path.join(fs.projects(),'gaudi',pkg))

        lbranches,rbranches = git.branches()
        if tag in lbranches:
            git.checkout(tag)
        else:
            git.checkout('origin/'+tag,tag)

        fs.goback()
        return
示例#8
0
文件: cmt.py 项目: brettviren/garpi
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'
示例#9
0
def cmd(cmdstr,env=None,dir=None,output=False,loglevel=log.INFO):
    '''
    Run an arbitrary command given by first non-optional argument.  If
    it is a full command line string it will be broken down via a
    split() on spaces.  If spaces are meaningful, pass in a list of
    strings.

    If env is defined it will be set the environment in which the
    command is run.

    If dir is set the command will be run after going to that
    directory.

    If output is True, the stdout/stderr will be returned as a string.

    Passing loglevel to set at what level the output should be logged.

    Avoid calling this function in favor of specific command function
    '''
    out = []

    # Convert to list if given a string
    if type(cmdstr) == type(""):
        cmdstr = cmdstr.strip()
        cmds = cmdstr.split()
        if len(cmds) > 1: cmdstr = cmds

    if not env: env = os.environ

    from subprocess import Popen, PIPE, STDOUT

    if dir: fs.goto(dir)

    log.info('running: "%s" in %s'%(cmdstr,os.getcwd()))

    # Must update this explicitly since env is not tied to this
    # application's env.
    env['PWD'] = os.getcwd()

    #log.info('\n'.join(map(lambda x: '"%s" --> "%s"'%x, env.iteritems())))

    # Start the command
    #print 'cmdstr="%s", env=%s'%(cmdstr,env)

    try:
        proc = Popen(cmdstr,stdout=PIPE,stderr=STDOUT,universal_newlines=True,env=env)
    except OSError,err:
        if dir: fs.goback()
        log.error_notrace(err)
        log.error_notrace('In directory %s'%os.getcwd())
        raise
示例#10
0
文件: git.py 项目: brettviren/garpi
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"
示例#11
0
文件: get.py 项目: brettviren/garpi
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
示例#12
0
文件: gaudi.py 项目: brettviren/garpi
    def _git_clone(self,url,submodules=False):
        import fs,git
        target = fs.projects()+'/gaudi'
        if os.path.exists(target):
            log.info('Directory already exists, skipping clone to: %s'%target)
            return

        fs.goto(fs.projects(),True)
        git.clone(url,'gaudi')
        fs.goback()

        if submodules:
            fs.goto(os.path.join(fs.projects(),'gaudi'),True)
            git.submodule('init')
            git.submodule('update')
            fs.goback()

        return
示例#13
0
文件: get.py 项目: brettviren/garpi
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
示例#14
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
示例#15
0
文件: git.py 项目: brettviren/garpi
def build():
    "Build git in previously unpacked git.srcdir()."
    log.info("building git")

    fs.goto(srcdir())

    from command import cmd, make

    instpath = prefix()

    if not os.path.exists("config.status"):
        log.info("configuring git")
        cmd("./configure --prefix=%s" % instpath)

    if os.path.exists("git"):
        log.info("git appears to already have been built")
    else:
        make()

    if os.path.exists(instpath):
        log.info("git appears to already have been installed to %s" % instpath)
    else:
        make("install")
    return