Пример #1
0
 def __download_cpio_archive(self, apiurl, project, repo, arch, package,
                             **pkgs):
     if not pkgs:
         return
     query = ['binary=%s' % quote_plus(i) for i in pkgs]
     query.append('view=cpio')
     tmparchive = tmpfile = None
     try:
         (fd, tmparchive) = tempfile.mkstemp(prefix='osc_build_cpio')
         (fd, tmpfile) = tempfile.mkstemp(prefix='osc_build')
         url = makeurl(apiurl, ['build', project, repo, arch, package],
                       query=query)
         sys.stdout.write("preparing download ...\r")
         sys.stdout.flush()
         self.gr.urlgrab(url,
                         filename=tmparchive,
                         text='fetching packages for \'%s\'' % project)
         archive = cpio.CpioRead(tmparchive)
         archive.read()
         for hdr in archive:
             # XXX: we won't have an .errors file because we're using
             # getbinarylist instead of the public/... route (which is
             # routed to getbinaries (but that won't work for kiwi products))
             if hdr.filename == '.errors':
                 archive.copyin_file(hdr.filename)
                 raise oscerr.APIError(
                     'CPIO archive is incomplete (see .errors file)')
             if package == '_repository':
                 n = re.sub(r'\.pkg\.tar\..z$', '.arch', hdr.filename)
                 pac = pkgs[n.rsplit('.', 1)[0]]
             else:
                 # this is a kiwi product
                 pac = pkgs[hdr.filename]
             archive.copyin_file(hdr.filename, os.path.dirname(tmpfile),
                                 os.path.basename(tmpfile))
             self.move_package(tmpfile, pac.localdir, pac)
             # check if we got all packages... (because we've no .errors file)
         for pac in pkgs.itervalues():
             if not os.path.isfile(pac.fullfilename):
                 raise oscerr.APIError('failed to fetch file \'%s\': ' \
                     'does not exist in CPIO archive' % pac.repofilename)
     except URLGrabError, e:
         if e.errno != 14 or e.code != 414:
             raise
         # query str was too large
         keys = pkgs.keys()
         if len(keys) == 1:
             raise oscerr.APIError(
                 'unable to fetch cpio archive: server always returns code 414'
             )
         n = len(pkgs) / 2
         new_pkgs = dict([(k, pkgs[k]) for k in keys[:n]])
         self.__download_cpio_archive(apiurl, project, repo, arch, package,
                                      **new_pkgs)
         new_pkgs = dict([(k, pkgs[k]) for k in keys[n:]])
         self.__download_cpio_archive(apiurl, project, repo, arch, package,
                                      **new_pkgs)
Пример #2
0
Файл: build.py Проект: uaoh/osc
    def __init__(self, node, buildarch, pacsuffix, apiurl, localpkgs = []):

        self.mp = {}
        for i in ['binary', 'package',
                  'version', 'release',
                  'project', 'repository',
                  'preinstall', 'vminstall', 'noinstall', 'runscripts',
                  'cbinstall', 'cbpreinstall', 'sb2install',
                 ]:
            self.mp[i] = node.get(i)

        self.mp['buildarch']  = buildarch
        self.mp['pacsuffix']  = pacsuffix

        self.mp['arch'] = node.get('arch') or self.mp['buildarch']
        self.mp['name'] = node.get('name') or self.mp['binary']

        # this is not the ideal place to check if the package is a localdep or not
        localdep = self.mp['name'] in localpkgs and not self.mp['noinstall']
        if not localdep and not (node.get('project') and node.get('repository')):
            raise oscerr.APIError('incomplete information for package %s, may be caused by a broken project configuration.'
                                  % self.mp['name'] )

        if not localdep:
            self.mp['extproject'] = node.get('project').replace(':', ':/')
            self.mp['extrepository'] = node.get('repository').replace(':', ':/')
        self.mp['repopackage'] = node.get('package') or '_repository'
        self.mp['repoarch'] = node.get('repoarch') or self.mp['buildarch']

        if pacsuffix == 'deb' and not (self.mp['name'] and self.mp['arch'] and self.mp['version']):
            raise oscerr.APIError(
                "buildinfo for package %s/%s/%s is incomplete"
                    % (self.mp['name'], self.mp['arch'], self.mp['version']))

        self.mp['apiurl'] = apiurl

        if pacsuffix == 'deb':
            filename = debquery.DebQuery.filename(self.mp['name'], self.mp['version'], self.mp['release'], self.mp['arch'])
        elif pacsuffix == 'arch':
            filename = archquery.ArchQuery.filename(self.mp['name'], self.mp['version'], self.mp['release'], self.mp['arch'])
        else:
            filename = rpmquery.RpmQuery.filename(self.mp['name'], self.mp['version'], self.mp['release'], self.mp['arch'])

        self.mp['filename'] = node.get('binary') or filename
        if self.mp['repopackage'] == '_repository':
            self.mp['repofilename'] = self.mp['name']
        else:
            # OBS 2.3 puts binary into product bdeps (noinstall ones)
            self.mp['repofilename'] = self.mp['filename']

        # make the content of the dictionary accessible as class attributes
        self.__dict__.update(self.mp)
Пример #3
0
 def __fetch_cpio(self, apiurl):
     from urllib import quote_plus
     for prpap, pkgs in self.cpio.iteritems():
         project, repo, arch, package = prpap.split('/', 3)
         query = ['binary=%s' % quote_plus(i) for i in pkgs.keys()]
         query.append('view=cpio')
         tmparchive = tmpfile = None
         try:
             (fd, tmparchive) = tempfile.mkstemp(prefix='osc_build_cpio')
             (fd, tmpfile) = tempfile.mkstemp(prefix='osc_build')
             url = makeurl(apiurl, ['build', project, repo, arch, package],
                           query=query)
             sys.stdout.write("preparing download ...\r")
             sys.stdout.flush()
             self.gr.urlgrab(url,
                             filename=tmparchive,
                             text='fetching packages for \'%s\'' % project)
             archive = cpio.CpioRead(tmparchive)
             archive.read()
             for hdr in archive:
                 # XXX: we won't have an .errors file because we're using
                 # getbinarylist instead of the public/... route (which is
                 # routed to getbinaries (but that won't work for kiwi products))
                 if hdr.filename == '.errors':
                     archive.copyin_file(hdr.filename)
                     raise oscerr.APIError(
                         'CPIO archive is incomplete (see .errors file)')
                 if package == '_repository':
                     pac = pkgs[hdr.filename.rsplit('.', 1)[0]]
                 else:
                     # this is a kiwi product
                     pac = pkgs[hdr.filename]
                 archive.copyin_file(hdr.filename, os.path.dirname(tmpfile),
                                     os.path.basename(tmpfile))
                 self.move_package(tmpfile, pac.localdir, pac)
                 # check if we got all packages... (because we've no .errors file)
             for pac in pkgs.itervalues():
                 if not os.path.isfile(pac.fullfilename):
                     raise oscerr.APIError('failed to fetch file \'%s\': ' \
                         'does not exist in CPIO archive' % pac.repofilename)
         finally:
             if not tmparchive is None and os.path.exists(tmparchive):
                 os.unlink(tmparchive)
             if not tmpfile is None and os.path.exists(tmpfile):
                 os.unlink(tmpfile)
Пример #4
0
def verify_pacs(bi):
    """Take a list of rpm filenames and verify their signatures.

       In case of failure, exit.
       """

    pac_list = [i.fullfilename for i in bi.deps]
    if not conf.config['builtin_signature_check']:
        return verify_pacs_old(pac_list)

    if not pac_list:
        return

    if not bi.keys:
        raise oscerr.APIError("can't verify packages due to lack of GPG keys")

    print "using keys from", ', '.join(bi.prjkeys)

    import checker
    failed = False
    checker = checker.Checker()
    try:
        checker.readkeys(bi.keys)
        for pkg in pac_list:
            try:
                checker.check(pkg)
            except Exception, e:
                failed = True
                print pkg, ':', e
    except:
        checker.cleanup()
        raise

    if failed:
        checker.cleanup()
        sys.exit(1)

    checker.cleanup()