예제 #1
0
def download_build_data(build_identifier, output_dir='/metadata'):
    """
    Download the JSON data associated with a build.

    :param str/int build_identifier: the string of the builds NVR or the integer of the build ID
    :param str output_dir: the path to download the brew info to
    """
    # Make sure the Koji command is installed
    _assert_command('koji')
    koji = get_koji_session()
    build = koji.getBuild(build_identifier)
    write_file(build, output_dir, Analyzer.BUILD_FILE)

    # get task info
    if 'task_id' in build and build['task_id']:
        task = koji.getTaskInfo(build['task_id'])
        write_file(task, output_dir, Analyzer.TASK_FILE)

    # get maven info
    maven = koji.getMavenBuild(build_identifier)
    if maven:
        write_file(maven, output_dir, Analyzer.MAVEN_FILE)

    # get rpms
    rpms = koji.listRPMs(build_identifier)
    if rpms:
        write_file(rpms, output_dir, Analyzer.RPM_FILE)

    # get archives
    archives = koji.listArchives(build_identifier)
    if archives:
        write_file(archives, output_dir, Analyzer.ARCHIVE_FILE)

    # get rpms in each image
    image_rpms = {}
    for archive in archives:
        if 'btype' in archive and archive['btype'] == 'image':
            aid = archive['id']
            image_rpms[aid] = koji.listRPMs(imageID=aid)

    if image_rpms:
        write_file(image_rpms, output_dir, Analyzer.IMAGE_RPM_FILE)

    # get rpms in the buildroots
    buildroot_ids = set()
    for artifact in rpms + archives:
        bid = artifact['buildroot_id']
        if bid:
            buildroot_ids.add(bid)

    buildroot_components = {}
    for bid in sorted(buildroot_ids):
        buildroot_components[bid] = koji.getBuildrootListing(bid)

    if buildroot_components:
        write_file(buildroot_components, output_dir, Analyzer.BUILDROOT_FILE)
예제 #2
0
파일: brew.py 프로젝트: smanjara/nexus
 def get_tagged(self, item, conf_dict):
     """
     This function constructs the download build URL for each rpm and
     creates a list of all the rpms in each build. This rpms list is then
     passed on to threads along with download_rpms().
     """
     if item is None:
         builds = brew.listTagged(self.brew_tag,
                                  latest=True,
                                  type=None,
                                  inherit=True)
     else:
         builds = brew.listTagged(self.brew_tag,
                                  latest=True,
                                  package=item,
                                  type=None,
                                  inherit=True)
     for build in builds:
         buildpath = pathinfo.build(build)
         arches_noarch = (self.brew_arch, "noarch")
         for arches in arches_noarch:
             rpms = brew.listRPMs(build['id'], arches=arches)
             rpms_list = []
             for rpm in rpms:
                 rpmpath = pathinfo.rpm(rpm)
                 rpmurl = os.path.join(buildpath, rpmpath)
                 rpms_list.append(rpmurl)
                 self.download_rpms(rpmurl)
                 logger.log.info("Downloading %s" % rpmurl)
예제 #3
0
파일: brew.py 프로젝트: lulinqing/nexus
 def get_tagged(self, item, conf_dict):
     """
     This function constructs the download build URL for each rpm and
     creates a list of all the rpms in each build. This rpms list is then
     passed on to threads along with download_rpms().
     """
     if item is None:
         builds = brew.listTagged(self.brew_tag, latest=True, type=None,
                                  inherit=True)
     else:
         builds = brew.listTagged(self.brew_tag, latest=True, package=item,
                                  type=None, inherit=True)
     for build in builds:
         buildpath = pathinfo.build(build)
         arches_noarch = (self.brew_arch, "noarch")
         for arches in arches_noarch:
             rpms = brew.listRPMs(build['id'], arches=arches)
             rpms_list = []
             for rpm in rpms:
                 rpmpath = pathinfo.rpm(rpm)
                 rpmurl = os.path.join(buildpath, rpmpath)
                 rpms_list.append(rpmurl)
                 self.download_rpms(rpmurl)
                 logger.log.info("Downloading %s" % rpmurl)
예제 #4
0
arch = args.arch

download_dir = args.location
if not os.path.exists(download_dir):
    os.makedirs(download_dir)

# Lists the latest build for the koji tag and package name provided as
# arguments
builds = koji.listTagged(tag, latest=True, package=pkg, type=None,
inherit=True)

for build in builds:
    buildpath = pathinfo.build(build)

    # Lists latest RPMs
    rpms = koji.listRPMs(build['id'], arches=arch)

    for rpm in rpms:
        rpmpath = pathinfo.rpm(rpm)
        rpmurl = os.path.join(buildpath, rpmpath)
        print rpmurl
        rpmname = os.path.join(download_dir,rpmurl.split('/')[-1])

        # Download latest RPMs
        u = urllib2.urlopen(rpmurl)
        f = open(rpmname, 'wb')
        f.write(u.read())
        f.close()

        # Print information
        meta = u.info()
예제 #5
0
arch = args.arch

download_dir = args.location
if not os.path.exists(download_dir):
    os.makedirs(download_dir)

# Lists the latest build for the brew tag and package name provided as
# arguments
builds = brew.listTagged(tag, latest=True, package=pkg, type=None,
inherit=True)

for build in builds:
    buildpath = pathinfo.build(build)

    # Lists latest RPMs
    rpms = brew.listRPMs(build['id'], arches=arch)

    for rpm in rpms:
        rpmpath = pathinfo.rpm(rpm)
        rpmurl = os.path.join(buildpath, rpmpath)
        rpmname = os.path.join(download_dir,rpmurl.split('/')[-1])

        # Download latest RPMs
        u = urllib2.urlopen(rpmurl)
        f = open(rpmname, 'wb')
        f.write(u.read())
        f.close()

        # Print information
        meta = u.info()
        file_size = int(meta.getheaders("Content-Length")[0])
예제 #6
0
pkg = args.pkg
arch = args.arch

download_dir = args.location
if not os.path.exists(download_dir):
    os.makedirs(download_dir)

# Lists the latest build for the koji tag and package name provided as
# arguments
builds = koji.listTagged(tag, latest=True, package=pkg, type=None, inherit=True)

for build in builds:
    buildpath = pathinfo.build(build)

    # Lists latest RPMs
    rpms = koji.listRPMs(build["id"], arches=arch)

    for rpm in rpms:
        rpmpath = pathinfo.rpm(rpm)
        rpmurl = os.path.join(buildpath, rpmpath)
        print rpmurl
        rpmname = os.path.join(download_dir, rpmurl.split("/")[-1])

        # Download latest RPMs
        u = urllib2.urlopen(rpmurl)
        f = open(rpmname, "wb")
        f.write(u.read())
        f.close()

        # Print information
        meta = u.info()