Example #1
0
 def test_changelog(self):
     if config.get('buildsystem') != 'koji': return
     update = self.get_update(name='yum-3.2.1-1.fc7')
     oldh = rpm_fileheader(update.builds[0].get_latest())
     oldtime = oldh[rpm.RPMTAG_CHANGELOGTIME]
     text = oldh[rpm.RPMTAG_CHANGELOGTEXT]
     oldtime = oldtime[0]
     changelog = update.builds[0].get_changelog(oldtime)
     assert changelog == '* Thu Jun 21 2007 Seth Vidal <skvidal at fedoraproject.org> - 3.2.1-1\n- bump to 3.2.1\n'
Example #2
0
 def test_changelog(self):
     if config.get('buildsystem') != 'koji': return
     update = self.get_update(name='yum-3.2.1-1.fc7')
     oldh = rpm_fileheader(update.builds[0].get_latest())
     oldtime = oldh[rpm.RPMTAG_CHANGELOGTIME]
     text = oldh[rpm.RPMTAG_CHANGELOGTEXT]
     oldtime = oldtime[0]
     changelog = update.builds[0].get_changelog(oldtime)
     assert changelog == '* Thu Jun 21 2007 Seth Vidal <skvidal at fedoraproject.org> - 3.2.1-1\n- bump to 3.2.1\n'
Example #3
0
def get_template(update, use_template='fedora_errata_template'):
    """
    Build the update notice for a given update.
    @param use_template: the template to generate this notice with
    """
    use_template = globals()[use_template]
    line = unicode('-' * 80) + '\n'
    templates = []

    for build in update.builds:
        h = build.get_rpm_header()
        info = {}
        info['date'] = str(update.date_pushed)
        info['name'] = h[rpm.RPMTAG_NAME]
        info['summary'] = h[rpm.RPMTAG_SUMMARY]
        info['version'] = h[rpm.RPMTAG_VERSION]
        info['release'] = h[rpm.RPMTAG_RELEASE]
        info['url']     = h[rpm.RPMTAG_URL]
        if update.status == 'testing':
            info['testing'] = ' Test'
            info['yum_repository'] = ' --enablerepo=updates-testing'
        else:
            info['testing'] = ''
            info['yum_repository'] = ''

        info['subject'] = u"%s%s%s Update: %s" % (
                update.type == 'security' and '[SECURITY] ' or '',
                update.release.long_name, info['testing'], build.nvr)
        info['updateid'] = update.updateid
        info['description'] = h[rpm.RPMTAG_DESCRIPTION]
        info['product'] = update.release.long_name
        info['notes'] = ""
        if update.notes and len(update.notes):
            info['notes'] = u"Update Information:\n\n%s\n" % update.notes
            info['notes'] += line

        # Add this updates referenced Bugzillas and CVEs
        i = 1
        info['references'] = ""
        if len(update.bugs) or len(update.cves):
            info['references'] = u"References:\n\n"
            parent = True in [bug.parent for bug in update.bugs]
            for bug in update.bugs:
                # Don't show any tracker bugs for security updates
                if update.type == 'security':
                    # If there is a parent bug, don't show trackers
                    if parent and not bug.parent:
                        log.debug("Skipping tracker bug %s" % bug)
                        continue
                title = (bug.title != 'Unable to fetch title' and
                         bug.title != 'Invalid bug number') and \
                        ' - %s' % bug.title or ''
                info['references'] += u"  [ %d ] Bug #%d%s\n        %s\n" % \
                                      (i, bug.bz_id, title, bug.get_url())
                i += 1
            for cve in update.cves:
                info['references'] += u"  [ %d ] %s\n        %s\n" % \
                                      (i, cve.cve_id, cve.get_url())
                i += 1
            info['references'] += line

        # Find the most recent update for this package, other than this one
        lastpkg = build.get_latest()
        #log.debug("lastpkg = %s" % lastpkg)

        # Grab the RPM header of the previous update, and generate a ChangeLog
        info['changelog'] = u""
        try:
            oldh = rpm_fileheader(lastpkg)
            oldtime = oldh[rpm.RPMTAG_CHANGELOGTIME]
            text = oldh[rpm.RPMTAG_CHANGELOGTEXT]
            del oldh
            if not text:
                oldtime = 0
            elif len(text) != 1:
                oldtime = oldtime[0]
            info['changelog'] = u"ChangeLog:\n\n%s%s" % \
                    (to_unicode(build.get_changelog(oldtime)), line)
        except RPMNotFound:
            log.error("Cannot find 'latest' RPM for generating ChangeLog: %s" %
                      lastpkg)
        except Exception, e:
            log.error("Unknown exception thrown during ChangeLog generation: %s"
                      % str(e))

        try:
            templates.append((info['subject'], use_template % info))
        except UnicodeDecodeError:
            # We can't trust the strings we get from RPM
            log.debug("UnicodeDecodeError! Will try again after decoding")
            for (key, value) in info.items():
                if value: info[key] = to_unicode(value)
            templates.append((info['subject'], use_template % info))
Example #4
0
def get_template(update, use_template='fedora_errata_template'):
    """
    Build the update notice for a given update.
    @param use_template: the template to generate this notice with
    """
    use_template = globals()[use_template]
    line = unicode('-' * 80) + '\n'
    templates = []

    for build in update.builds:
        h = build.get_rpm_header()
        info = {}
        info['date'] = str(update.date_pushed)
        info['name'] = h[rpm.RPMTAG_NAME]
        info['summary'] = h[rpm.RPMTAG_SUMMARY]
        info['version'] = h[rpm.RPMTAG_VERSION]
        info['release'] = h[rpm.RPMTAG_RELEASE]
        info['url']     = h[rpm.RPMTAG_URL]
        if update.status == 'testing':
            info['testing'] = ' Test'
            info['yum_repository'] = ' --enablerepo=updates-testing'
        else:
            info['testing'] = ''
            info['yum_repository'] = ''

        info['subject'] = u"%s%s%s Update: %s" % (
                update.type == 'security' and '[SECURITY] ' or '',
                update.release.long_name, info['testing'], build.nvr)
        info['updateid'] = update.updateid
        info['description'] = h[rpm.RPMTAG_DESCRIPTION]
        info['product'] = update.release.long_name
        info['notes'] = ""
        if update.notes and len(update.notes):
            info['notes'] = u"Update Information:\n\n%s\n" % update.notes
            info['notes'] += line

        # Add this updates referenced Bugzillas and CVEs
        i = 1
        info['references'] = ""
        if len(update.bugs) or len(update.cves):
            info['references'] = u"References:\n\n"
            parent = True in [bug.parent for bug in update.bugs]
            for bug in update.bugs:
                # Don't show any tracker bugs for security updates
                if update.type == 'security':
                    # If there is a parent bug, don't show trackers
                    if parent and not bug.parent:
                        log.debug("Skipping tracker bug %s" % bug)
                        continue
                title = (bug.title != 'Unable to fetch title' and
                         bug.title != 'Invalid bug number') and \
                        ' - %s' % bug.title or ''
                info['references'] += u"  [ %d ] Bug #%d%s\n        %s\n" % \
                                      (i, bug.bz_id, title, bug.get_url())
                i += 1
            for cve in update.cves:
                info['references'] += u"  [ %d ] %s\n        %s\n" % \
                                      (i, cve.cve_id, cve.get_url())
                i += 1
            info['references'] += line

        # Find the most recent update for this package, other than this one
        lastpkg = build.get_latest()
        #log.debug("lastpkg = %s" % lastpkg)

        # Grab the RPM header of the previous update, and generate a ChangeLog
        info['changelog'] = u""
        try:
            oldh = rpm_fileheader(lastpkg)
            oldtime = oldh[rpm.RPMTAG_CHANGELOGTIME]
            text = oldh[rpm.RPMTAG_CHANGELOGTEXT]
            del oldh
            if not text:
                oldtime = 0
            elif len(text) != 1:
                oldtime = oldtime[0]
            info['changelog'] = u"ChangeLog:\n\n%s%s" % \
                    (to_unicode(build.get_changelog(oldtime)), line)
        except RPMNotFound:
            log.error("Cannot find 'latest' RPM for generating ChangeLog: %s" %
                      lastpkg)
        except Exception, e:
            log.error("Unknown exception thrown during ChangeLog generation: %s"
                      % str(e))

        try:
            templates.append((info['subject'], use_template % info))
        except UnicodeDecodeError:
            # We can't trust the strings we get from RPM
            log.debug("UnicodeDecodeError! Will try again after decoding")
            for (key, value) in info.items():
                if value: info[key] = to_unicode(value)
            templates.append((info['subject'], use_template % info))