示例#1
0
    def _update_package_data(self, crash_id, pkg_data):
        log_debug(1, "_update_package_data: %s, %s" % (crash_id, pkg_data))
        # Older versions of abrt used to store the package info in a single 'package' file
        if pkg_data and 'package' in pkg_data:
            (n, e, v, r) = parseRPMName(pkg_data['package'])
            if not all((n, e, v, r)):
                return 0

            h = rhnSQL.prepare(_query_update_pkg_data1)
            r = h.execute(
                crash_id=crash_id,
                pkg_name=n,
                pkg_epoch=e,
                pkg_version=v,
                pkg_release=r)
            rhnSQL.commit()

            return r

        for item in ['pkg_name', 'pkg_epoch', 'pkg_version', 'pkg_release', 'pkg_arch']:
            if not (item in pkg_data and pkg_data[item]):
                return 0

        h = rhnSQL.prepare(_query_update_pkg_data2)
        r = h.execute(
            crash_id=crash_id,
            pkg_name=pkg_data['pkg_name'],
            pkg_epoch=pkg_data['pkg_epoch'],
            pkg_version=pkg_data['pkg_version'],
            pkg_release=pkg_data['pkg_release'],
            pkg_arch=pkg_data['pkg_arch'])
        rhnSQL.commit()

        return r
示例#2
0
    def GetByPackage(self, pkg, osRel):
        """ Clients v1- Get errata for a package given "n-v-r" format
            IN:  pkg:   "n-v-r" (old client call)
                        or [n,v,r]
                 osRel: OS release
            RET: a hash by errata that applies to this package
                 (ie, newer packages are available). We also limit the scope
                 for a particular osRel.
        """
        if type(pkg) == type(''):  # Old client support.
            pkg = parseRPMName(pkg)
        log_debug(1, pkg, osRel)
        # Stuff the action in the headers:
        transport = rhnFlags.get('outputTransportOptions')
        transport['X-RHN-Action'] = 'GetByPackage'

        # now look up the errata
        if type(pkg[0]) != type(''):
            log_error("Invalid package name: %s %s" % (type(pkg[0]), pkg[0]))
            raise rhnFault(30, _("Expected a package name, not: %s") % pkg[0])
        # bug#186996:adding synopsis field to advisory info
        # client side changes are needed to access this data.
        h = rhnSQL.prepare("""
            select distinct
                    e.id            errata_id,
                    e.advisory_type errata_type,
                    e.advisory      advisory,
                    e.topic         topic,
                    e.description   description,
                    e.synopsis      synopsis
            from
                    rhnErrata e,
                    rhnPublicChannelFamily pcf,
                    rhnChannelFamilyMembers cfm,
                    rhnErrataPackage ep,
                    rhnChannelPackage cp,
                    rhnChannelErrata ce,
                    rhnDistChannelMap dcm,
                    rhnPackage p
            where    1=1
                and p.name_id = LOOKUP_PACKAGE_NAME(:name)
                -- map to a channel
                and p.id = cp.package_id
                and cp.channel_id = dcm.channel_id
                and dcm.release = :dist
                and dcm.org_id is null
                -- map to an errata as well
                and p.id = ep.package_id
                and ep.errata_id = e.id
                -- the errata and the channel have to be linked
                and ce.channel_id = cp.channel_id
                -- and the channel has to be public
                and cp.channel_id = cfm.channel_id
                and cfm.channel_family_id = pcf.channel_family_id
                -- and get the erratum
                and e.id = ce.errata_id
        """)
        h.execute(name=pkg[0], dist=str(osRel))
        return self._sanitize_result(h)
示例#3
0
def parseRPMFilename(pkgFilename):
    """
    IN: Package Name: xxx-yyy-ver.ver.ver-rel.rel_rel:e.ARCH.rpm (string)
    Understood rules:
       o Name can have nearly any char, but end in a - (well seperated by).
         Any character; may include - as well.
       o Version cannot have a -, but ends in one.
       o Release should be an actual number, and can't have any -'s.
       o Release can include the Epoch, e.g.: 2:4 (4 is the epoch)
       o Epoch: Can include anything except a - and the : seperator???
         XXX: Is epoch info above correct?
    OUT: [n,e,v,r, arch].
    """
    if type(pkgFilename) != type(''):
        raise rhnFault(21, str(pkgFilename))  # Invalid arg.

    pkgFilename = os.path.basename(pkgFilename)

    # Check that this is a package NAME (with arch.rpm) and strip
    # that crap off.
    pkg = string.split(pkgFilename, '.')

    dist = string.lower(pkg[-1])

    # 'rpm' at end?
    if dist not in ['rpm', 'deb']:
        raise rhnFault(21, 'neither an rpm nor a deb package name: %s' % pkgFilename)

    # Valid architecture next?
    if check_package_arch(pkg[-2]) is None:
        raise rhnFault(21, 'Incompatible architecture found: %s' % pkg[-2])

    _arch = pkg[-2]

    # Nuke that arch.rpm.
    pkg = string.join(pkg[:-2], '.')

    if dist == "deb":
        ret = list(parseDEBName(pkg))
    else:
        ret = list(parseRPMName(pkg))

    if ret:
        ret.append(_arch)
    return ret