Beispiel #1
0
def project_bootnewproject(opts, args):
    if len(args) != 0:
        SCRAM.scramfatal("Error parsing arguments. See \"scram -help\" for usage info.")
    areaname = ''
    bootstrapfile = opts.bootstrap
    installarea = opts.install_base_dir
    bs = BootStrapProject(installarea)
    area = bs.boot(bootstrapfile)
    XX = """
Beispiel #2
0
def tool_remove(args, area):
    if len(args) < 1:
        SCRAM.scramfatal("No tool name given: see \"scram tool -help\" for usage info.")

    toolname = args[0].lower()
    toolmanager = ToolManager(area)
    if not toolmanager.hastool(toolname):
        SCRAM.errormsg(">>>> Tool %s is not defined for this project area. <<<<" % toolname)
    SCRAM.printmsg("Removing tool %s from current project area configuration." % toolname)
    toolmanager.remove_tool(toolname)
    return True
Beispiel #3
0
def cmd_unsetenv(args):
    print(args)
    from SCRAM.Core.RuntimeEnv import RUNTIME_SHELLS
    print(RUNTIME_SHELLS)
    if (len(args) != 1) or (args[0] not in RUNTIME_SHELLS):
        SCRAM.scramfatal("Error parsing arguments. See \"scram -help\" for usage info.")
    from SCRAM.Core.RuntimeEnv import RuntimeEnv
    area = Core()
    area.checklocal()
    rt = RuntimeEnv(area.localarea())
    rt.unsetenv(RUNTIME_SHELLS[args[0]])
    return True
Beispiel #4
0
def cmd_project(args):
    parser = ArgumentParser(add_help=False)
    parser.add_argument('-l', '--log',
                        dest='log',
                        action='store_true',
                        default=False,
                        help='See the detail log message while creating a dev area')
    parser.add_argument('-s', '--symlinks',
                        dest='symlinks',
                        action='store_true',
                        default=False,
                        help='Creates symlinks for various product build directories.')
    parser.add_argument('-u', '--update',
                        dest='update',
                        action='store_true',
                        default=False,
                        help='Command-line argument -u|--update is no more supported.')
    parser.add_argument('-d', '--dir',
                        dest='install_base_dir',
                        type=str,
                        default=None,
                        help='Project installation base directory.')
    parser.add_argument('-b', '--boot',
                        dest='bootstrap',
                        type=str,
                        default=None,
                        help='Creates a release area using the bootstrap file')
    parser.add_argument('-n', '--name',
                        dest='install_name',
                        type=str,
                        default=None,
                        help='Specify the name of the SCRAM-base development area directory.')
    opts, args = parser.parse_known_args(args)
    SCRAM.INTERACTIVE = True if opts.log else False

    if opts.bootstrap:
        return project_bootnewproject(opts, args)
    if len(args) == 0:
        SCRAM.scramfatal("Error parsing arguments. See \"scram -help\" for usage info.")
    project = args[0]
    version = args[1] if len(args) > 1 else None
    releasePath = None
    if version is None:
        if isdir(project) and project.startswith('/'):
            area = ConfigArea(SCRAM.FORCED_ARCH)
            releasePath = area.searchlocation(project)
            if not releasePath:
                SCRAM.scramerror("Not a valid scram-based release area: %s" % project)
            project = basename(releasePath)
        version = project
        project = project.split('_', 1)[0]
    return project_bootfromrelease(project.upper(), version, releasePath, opts)
Beispiel #5
0
def tool_tag(args, area):
    if len(args) < 1:
        SCRAM.scramfatal("No tool name given: see \"scram tool -help\" for usage info.")

    toolmanager = ToolManager(area)
    toolname = args[0].lower()
    tool = toolmanager.gettool(toolname)
    if not tool:
        SCRAM.scramerror(">>>> Tool %s is not setup for this project area. <<<<" % toolname)
    tag = None if len(args) == 1 else args[1]
    msg = ToolFile.get_feature(tool, tag)
    if msg:
        SCRAM.printmsg(msg)
    return True
Beispiel #6
0
def cmd_setup(args):
    parser = ArgumentParser(add_help=False)
    parser.add_argument('-i', '--interactive',
                        dest='interactive',
                        action='store_true',
                        default=False,
                        help='Obsolete command-line argument')
    opts, args = parser.parse_known_args(args)
    if len(args) > 1:
        SCRAM.scramfatal("Error parsing arguments. See \"scram -help\" for usage info.")
    area = Core()
    area.checklocal()
    area.init_env()
    larea = area.localarea()
    toolmanager = ToolManager(larea)
    tool = ''
    if args:
        tool = args[0]
    if tool:
        if not exists(tool):
            toolname = tool.lower()
            if toolname != 'self':
                toolbox = larea.toolbox()
                tool = join(toolbox, 'selected', '%s.xml' % toolname)
                if not exists(tool):
                    tool = join(toolbox, 'available', '%s.xml' % toolname)
                    if not exists(tool):
                        SCRAM.scramfatal('Can not setup tool "%s" because of missing "%s.xml" '
                                         'file under %s directory."' % (toolname, toolname, toolbox))
            else:
                tool = toolname
        else:
            tool = abspath(tool)
    toolmanager = ToolManager(larea)
    _init_self_env(toolmanager, tool)
    if tool:
        if tool != 'self':
            toolmanager.coresetup(tool)
    else:
        SCRAM.printmsg("Setting up all tools in current area")
        if not isdir(larea.toolcachename()):
            create_productstores(larea)
            toolmanager.setupself()
        toolmanager.setupalltools()
    return True
Beispiel #7
0
def tool_info(args, area):
    if not args:
        SCRAM.scramfatal("No tool name given: see \"scram tool -help\" for usage info.")

    toolmanager = ToolManager(area)
    toolname = args[0].lower()
    tool = toolmanager.gettool(toolname)
    if not tool:
        SCRAM.scramerror(">>>> Tool %s is not setup for this project area. <<<<" % toolname)
    msg = "Tool info as configured in location %s" % area.location()
    msglen = len(msg)
    msg += "\n%s\n" % ("+" * len(msg))
    msg += "Name : %s\n" % toolname
    msg += "Version : %s\n" % tool['TOOLVERSION']
    msg += "%s\n" % ("+" * 20)
    SCRAM.printmsg(msg)
    tooldata = ToolFile.summarize_tool(tool)
    for tag in sorted(tooldata):
        SCRAM.printmsg('%s=%s' % (tag, tooldata[tag]))
    SCRAM.printmsg("")
    return True
Beispiel #8
0
def cmd_tool(args):
    area = Core()
    area.checklocal()
    if not args or args[0].lower() not in ['list', 'info', 'tag', 'remove']:
        SCRAM.scramfatal("Error parsing arguments. See \"scram -help\" for usage info.")
    return eval('tool_%s' % args[0].lower())(args[1:], area.localarea())
Beispiel #9
0
def project_bootfromrelease(project, version, releasePath, opts):
    installdir = opts.install_base_dir if opts.install_base_dir else getcwd()
    installname = opts.install_name if opts.install_name else version
    relarea = None
    if not (project and version):
        SCRAM.scramfatal("Insufficient arguments: see \"scram project -help\" for usage info.")
    db = ProjectDB()
    relarea = None
    if releasePath:
        relarea = db.getAreaObject([project, version, releasePath, None], SCRAM.FORCED_ARCH)
    else:
        relarea = db.getarea(project, version, force=SCRAM.COMMANDS_OPTS.force)
    xarch = environ['SCRAM_ARCH']
    if not relarea or not isdir(relarea.archdir()):
        if db.deprecated:
            return False
        archs = list(db.listcache)
        errmsg = 'ERROR: Project "%s" version "%s" is not available for arch %s.\n' % (project, version, xarch)
        if len(archs) > 1:
            errmsg += '       "%s" is currently available for following archs.\n' % (project)
            errmsg += '       Please set SCRAM_ARCH properly and re-run the command.\n    %s' % '\n    '.join(archs)
        else:
            errmsg += '       Please make sure you have used the correct name/version.\n'
            errmsg += '       You can run \"scram list $projectname\" to get the list of available versions.'
        SCRAM.printerror(errmsg)
        return False
    arch = relarea.arch()
    SCRAM.FORCED_ARCH = arch
    environ['SCRAM_ARCH'] = arch
    if isdir(join(installdir, installname, relarea.admindir(), arch)):
        SCRAM.printerror("WARNING: There already exists %s/%s area for SCRAM_ARCH %s." %
                         (installdir, installname, arch))
        return True

    # Re-run if different SCRAM version is needed to bootstrap the area.
    # remote_versioncheck(relarea)

    SCRAM.printmsg("Creating a developer area based on project %s version %s"
                   % (project, version), SCRAM.INTERACTIVE)
    environ['RELEASETOP'] = relarea.location()
    localarea = Core()
    symlink = 1 if opts.symlinks else 0
    area = relarea.satellite(installdir, installname, symlink, localarea.localarea())
    chdir(area.location())
    c = Core()
    c.init_env()
    create_productstores(c.localarea())
    if relarea.basedir:
        with open(join(area.config(), 'scram_basedir'), 'w') as ref:
            ref.write(relarea.basedir)
    XXX = """
    my $toolmanager = $self->toolmanager($area);
    $toolmanager->update ($area);

    # Write the cached info:
    $toolmanager->writecache();

        my $temp=$area->location()."/".$area->{admindir}."/".$ENV{SCRAM_ARCH};
        if (-f "${temp}/MakeData/Tools.mk")
           {
           my $t1=(stat("${temp}/MakeData/Tools.mk"))[9];
           utime $t1-1,$t1-1,"${temp}/MakeData/Tools.mk";
           if (-f "${temp}/timestamps/self")
              {
              utime $t1,$t1,"${temp}/timestamps/self";
              }
           }
"""
    SCRAM.printmsg("\n\nInstallation procedure complete.", SCRAM.INTERACTIVE)
    SCRAM.printmsg("Developer area located at:\n\n\t\t%s\n\n" % area.location(), SCRAM.INTERACTIVE)
    if xarch != arch:
        SCRAM.printmsg("WARNING: Release %s is not available for architecture %s" %
                       (version, xarch))
        SCRAM.printmsg("         Developer's area is created for available architecture %s." %
                       (arch))
    os = cmsos()
    if not arch.startswith(os):
        SCRAM.printmsg("WARNING: Developer's area is created for architecture %s while your current OS is %s." %
                       (arch, os))
    if not SCRAM.COMMANDS_OPTS.force:
        os = db.productionArch(project, version, area.location())
        if os and os != arch:
            msg = "WARNING: Developer's area is created for non-production architecture %s. " \
                  "Production architecture for this release is %s" % (arch, os)
            SCRAM.printmsg(msg)
    tc = db.getProjectModule(project)
    if tc:
        tc.getData(version, relarea.location())
    if 'SCRAM_IGNORE_PROJECT_HOOK' not in environ:
        proj_hook = join(area.config(), 'SCRAM', 'hooks', 'project-hook')
        if exists(proj_hook):
            SCRAM.run_command(proj_hook)
    if '/afs/cern.ch/' in environ['SCRAM_TOOL_HOME']:
        msg = "****************************** WARNING ******************************\n" \
              "You are using CMSSW from CERN AFS space. Please note that, by the start of 2017, " \
              "new CMSSW releases shall only be available via CVMFS.\n" \
              "See the announcement https://hypernews.cern.ch/HyperNews/CMS/get/swDevelopment/3374.html"
        SCRAM.printmsg(msg)
    return True
Beispiel #10
0
 def checklocal(self):
     if not self.islocal():
         SCRAM.scramfatal("Unable to locate the top of local release. "
                          "Please run this command from a SCRAM-based area.")