Beispiel #1
0
def main(argv):
    # Get treeish
    if len(argv) != 2:
        print """\
usage: %s <treeish>

where <treeish> is a valid git branch or tag (eg release_1.1.0).""" % (prog_name)
        sys.exit(1)
    treeish = argv[1]

    # Determine root of repo (this repo) on which to operate
    try:
        # First try from cwd
        root, _ = chk_pcores.get_base_pkg( os.getcwd() )
    except ValueError:
        # None found, so use package this script is a part of
        root = os.path.abspath( os.path.join( os.path.dirname(__file__), '..', '..' ) )
    # Add base path to hw_lib_dir and projects_dir

    # Prepare tree
    print '+ cd %s' % root
    os.chdir( root )
    print
    cmd = 'git checkout %s' % treeish
    print '+ %s' % cmd
    if 0 != subprocess.call( cmd.split() ):
        sys.exit(1)
    print

    # Make path list
    pcores_avail  = chk_pcores.scan_pcores( os.path.join( 'lib', 'hw' ) )
    pcores_needed = set()
    for project, mhs in chk_pcores.scan_projects( 'projects' ):
        # Include pcores for each project whose hardware directory is included.
        # `project` is of the form <project>/hw, so take off the 'hw' and
        # prepend 'project' to match against STATIC_PATHLIST.
        if os.path.join( 'projects', os.path.dirname( project ) ) not in STATIC_PATHLIST:
            continue
        for inst in mhstools.instances(mhs):
            paths, errors = chk_pcores.resolve_pcore( pcores_avail, inst.core_name(),
                                                      mhstools.get_parameter( inst, 'HW_VER' ) )
            pcores_needed = pcores_needed.union( paths )
    pathlist = STATIC_PATHLIST + list( pcores_needed )

    # Create tarball
    tarball = os.path.join( '..', TARBALL_NAME % treeish.replace('/','_') )
    gzip = subprocess.Popen( ['gzip'], stdin=subprocess.PIPE, stdout=open( tarball, 'w' ) )
    try:
        cmd = 'git archive --prefix=%s/ %s' % (TAR_PREFIX, treeish)
        print '+ %s (paths) | gzip > %s' % (cmd, tarball)
        rc = subprocess.call( cmd.split() + pathlist, stdout=gzip.stdin )
    except OSError, e:
        if e.errno == os.errno.E2BIG:
            print """\
%s: list of paths (%d in %d bytes) to include in tarball is
%s: too large for this platform (max %d bytes)""" % (prog_name, len(pathlist), len(' '.join(pathlist)),
                                                     prog_name, os.sysconf('SC_ARG_MAX'))
            sys.exit(1)
        else:
            raise e
def print_project_pcore_version_report( projects_dir, pcores ):
    """
    Scan all projects, resolve pcore instances, and print reports: missing pcores, out-of-date pcores;
    Also writes out list of pcores used.
    """
    # Collect data
    errors = {}
    cores_used = {}
    for project, mhs in scan_projects( projects_dir ):
        for inst in mhstools.instances(mhs):
            inst.paths, inst.errors = resolve_pcore( pcores, inst.core_name(),
                                                     mhstools.get_parameter( inst, 'HW_VER' ) )
        cores_used[project] = set( sum( (inst.paths  for inst in mhstools.instances(mhs)), [] ) )
        errors[project]     =      sum( (inst.errors for inst in mhstools.instances(mhs)), [] )
    # Print reports
    print '2.  Project missing and out-of-date pcore report:'
    for project, errors in errors.iteritems():
        if errors:
                print "\tProject '%s':\n\t\t%s\n" % (project, '\n\t\t'.join(errors) )
    print '3.  Project pcore use report: written to %s' % PCORE_MANIFEST
    with open( os.path.expanduser( PCORE_MANIFEST ), 'w' ) as f:
        print >>f, '\n'.join( '%s,%s' % (project, pcore) for project in cores_used for pcore in cores_used[project] )
Beispiel #3
0
def main(argv):
    # Get treeish
    if len(argv) != 2:
        print """\
usage: %s <treeish>

where <treeish> is a valid git branch or tag (eg release_1.1.0).""" % (
            prog_name)
        sys.exit(1)
    treeish = argv[1]

    # Determine root of repo (this repo) on which to operate
    try:
        # First try from cwd
        root, _ = chk_pcores.get_base_pkg(os.getcwd())
    except ValueError:
        # None found, so use package this script is a part of
        root = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..', '..'))
    # Add base path to hw_lib_dir and projects_dir

    # Prepare tree
    print '+ cd %s' % root
    os.chdir(root)
    print
    cmd = 'git checkout %s' % treeish
    print '+ %s' % cmd
    if 0 != subprocess.call(cmd.split()):
        sys.exit(1)
    print

    # Make path list
    pcores_avail = chk_pcores.scan_pcores(os.path.join('lib', 'hw'))
    pcores_needed = set()
    for project, mhs in chk_pcores.scan_projects('projects'):
        # Include pcores for each project whose hardware directory is included.
        # `project` is of the form <project>/hw, so take off the 'hw' and
        # prepend 'project' to match against STATIC_PATHLIST.
        if os.path.join('projects',
                        os.path.dirname(project)) not in STATIC_PATHLIST:
            continue
        for inst in mhstools.instances(mhs):
            paths, errors = chk_pcores.resolve_pcore(
                pcores_avail, inst.core_name(),
                mhstools.get_parameter(inst, 'HW_VER'))
            pcores_needed = pcores_needed.union(paths)
    pathlist = STATIC_PATHLIST + list(pcores_needed)

    # Create tarball
    tarball = os.path.join('..', TARBALL_NAME % treeish.replace('/', '_'))
    gzip = subprocess.Popen(['gzip'],
                            stdin=subprocess.PIPE,
                            stdout=open(tarball, 'w'))
    try:
        cmd = 'git archive --prefix=%s/ %s' % (TAR_PREFIX, treeish)
        print '+ %s (paths) | gzip > %s' % (cmd, tarball)
        rc = subprocess.call(cmd.split() + pathlist, stdout=gzip.stdin)
    except OSError, e:
        if e.errno == os.errno.E2BIG:
            print """\
%s: list of paths (%d in %d bytes) to include in tarball is
%s: too large for this platform (max %d bytes)""" % (
                prog_name, len(pathlist), len(
                    ' '.join(pathlist)), prog_name, os.sysconf('SC_ARG_MAX'))
            sys.exit(1)
        else:
            raise e