def test_epel7_tags(self): el7 = Release(name='EPEL-7', long_name='Fedora EPEL 7', id_prefix='FEDORA-EPEL', dist_tag='epel7') assert el7.get_version() == 7 assert el7.candidate_tag == 'epel7-testing-candidate' assert el7.testing_tag == 'epel7-testing' assert el7.stable_tag == 'epel7' assert el7.stable_repo == 'epel7'
def get_rel(): rel = None try: rel = Release.byName('fc7') except SQLObjectNotFound: rel = Release(name='fc7', long_name='Fedora 7', id_prefix='FEDORA', dist_tag='dist-fc7') return rel
def _get_epel_release(self): rel = Release.select(Release.q.name=='EL5') if rel.count(): rel = rel[0] else: rel = Release(name='EL5', long_name='Fedora EPEL 5', id_prefix='FEDORA-EPEL', dist_tag='dist-5E-epel') return rel
def import_releases(): """ Import the releases """ from bodhi.model import Release print "\nInitializing Release table" progress = ProgressBar(maxValue=len(releases)) for release in releases: rel = Release(name=release['name'], long_name=release['long_name'], id_prefix=release['id_prefix'], dist_tag=release['dist_tag']) progress()
def test_epel_id(self): """ Make sure we can handle id_prefixes that contain dashes. eg: FEDORA-EPEL """ # Create a normal Fedora update first update = self.get_update() update.assign_id() assert update.updateid == 'FEDORA-%s-0001' % time.localtime()[0] update = self.get_update(name='TurboGears-2.1-1.el5') release = Release(name='EL-5', long_name='Fedora EPEL 5', dist_tag='dist-5E-epel', id_prefix='FEDORA-EPEL') update.release = release update.assign_id() assert update.updateid == 'FEDORA-EPEL-%s-0001' % time.localtime()[0] update = self.get_update(name='TurboGears-2.2-1.el5') update.release = release update.assign_id() assert update.updateid == '%s-%s-0002' % (release.id_prefix, time.localtime()[0]), update.updateid
def test_id(self): update = self.get_update() update.assign_id() assert update.updateid == '%s-%s-0001' % (update.release.id_prefix, time.localtime()[0]) assert update.date_pushed update = self.get_update(name='TurboGears-0.4.4-8.fc7') update.assign_id() assert update.updateid == '%s-%s-0002' % (update.release.id_prefix, time.localtime()[0]) # Create another update for another release that has the same # Release.id_prefix. This used to trigger a bug that would cause # duplicate IDs across Fedora 10/11 updates. update = self.get_update(name='nethack-3.4.5-1.fc11') otherrel = Release(name='fc11', long_name='Fedora 11', id_prefix='FEDORA', dist_tag='dist-fc11') update.release = otherrel update.assign_id() assert update.updateid == '%s-%s-0003' % (update.release.id_prefix, time.localtime()[0]) # 10k bug update.updateid = 'FEDORA-%s-9999' % YEAR newupdate = self.get_update(name='nethack-2.5.6-1.fc10') newupdate.assign_id() assert newupdate.updateid == 'FEDORA-%s-10000' % YEAR newerupdate = self.get_update(name='nethack-2.5.7-1.fc10') newerupdate.assign_id() assert newerupdate.updateid == 'FEDORA-%s-10001' % YEAR # test updates that were pushed at the same time. assign_id should # be able to figure out which one has the highest id. now = datetime.utcnow() newupdate.date_pushed = now newerupdate.date_pushed = now newest = self.get_update(name='nethack-2.5.8-1.fc10') newest.assign_id() assert newest.updateid == 'FEDORA-%s-10002' % YEAR
def test_extended_metadata_updating(self): # grab the name of a build in updates-testing, and create it in our db koji = get_session() builds = koji.listTagged('dist-f13-updates-testing', latest=True) # Create all of the necessary database entries release = Release(name='F13', long_name='Fedora 13', id_prefix='FEDORA', dist_tag='dist-f13') package = Package(name=builds[0]['package_name']) update = PackageUpdate(title=builds[0]['nvr'], release=release, submitter=builds[0]['owner_name'], status='testing', notes='foobar', type='bugfix') build = PackageBuild(nvr=builds[0]['nvr'], package=package) update.addPackageBuild(build) bug = Bugzilla(bz_id=1) bug.title = u'test bug' update.addBugzilla(bug) cve = CVE(cve_id="CVE-2007-0000") update.addCVE(cve) update.assign_id() ## Initialize our temporary repo temprepo = join(tempfile.mkdtemp('bodhi'), 'f7-updates-testing') print "Inserting updateinfo into temprepo: %s" % temprepo mkmetadatadir(join(temprepo, 'i386')) repodata = join(temprepo, 'i386', 'repodata') assert exists(join(repodata, 'repomd.xml')) ## Generate the XML md = ExtendedMetadata(temprepo) ## Insert the updateinfo.xml into the repository md.insert_updateinfo() updateinfo = join(repodata, 'updateinfo.xml.gz') assert exists(updateinfo) ## Read an verify the updateinfo.xml.gz uinfo = UpdateMetadata() uinfo.add(updateinfo) notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc13')) assert not notice notice = uinfo.get_notice(get_nvr(update.title)) assert notice assert notice['status'] == update.status assert notice['updated'] == update.date_modified assert notice['from'] == str(config.get('bodhi_email')) assert notice['description'] == update.notes assert notice['issued'] != None assert notice['update_id'] == update.updateid cve = notice['references'][0] assert cve['type'] == 'cve' assert cve['href'] == update.cves[0].get_url() assert cve['id'] == update.cves[0].cve_id bug = notice['references'][1] assert bug['href'] == update.bugs[0].get_url() assert bug['id'] == '1' assert bug['type'] == 'bugzilla' assert bug['title'] == 'test bug' # FC6's yum update metadata parser doesn't know about some stuff from yum import __version__ if __version__ >= '3.0.6': assert notice['title'] == update.title assert notice['release'] == update.release.long_name assert cve['title'] == None ## Test out updateinfo.xml updating via our ExtendedMetadata md = ExtendedMetadata(temprepo, updateinfo) md.insert_updateinfo() updateinfo = join(repodata, 'updateinfo.xml.gz') assert exists(updateinfo) ## Read an verify the updateinfo.xml.gz uinfo = UpdateMetadata() uinfo.add(updateinfo) notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc13')) assert not notice notice = uinfo.get_notice(get_nvr(update.title)) assert notice assert notice['status'] == update.status assert notice['updated'] == update.date_modified assert notice['from'] == str(config.get('bodhi_email')) assert notice['description'] == update.notes assert notice['issued'] != None assert notice['update_id'] == update.updateid cve = notice['references'][0] assert cve['type'] == 'cve' assert cve['href'] == update.cves[0].get_url() assert cve['id'] == update.cves[0].cve_id bug = notice['references'][1] assert bug['href'] == update.bugs[0].get_url() assert bug['id'] == '1' assert bug['type'] == 'bugzilla' assert bug['title'] == 'test bug', bug # FC6's yum update metadata parser doesn't know about some stuff from yum import __version__ if __version__ >= '3.0.6': assert notice['title'] == update.title assert notice['release'] == update.release.long_name assert cve['title'] == None ## Clean up shutil.rmtree(temprepo)
def get_release(self): return Release(name='fc7', long_name='Fedora 7', id_prefix='FEDORA', dist_tag='dist-fc7')
def load_db(): print "\nLoading pickled database %s" % sys.argv[2] db = file(sys.argv[2], 'r') data = pickle.load(db) # Legacy format was just a list of update dictionaries # Now we'll pull things out into an organized dictionary: # {'updates': [], 'releases': []} if isinstance(data, dict): for release in data['releases']: try: Release.byName(release['name']) except SQLObjectNotFound: Release(**release) data = data['updates'] progress = ProgressBar(maxValue=len(data)) for u in data: try: release = Release.byName(u['release'][0]) except SQLObjectNotFound: release = Release(name=u['release'][0], long_name=u['release'][1], id_prefix=u['release'][2], dist_tag=u['release'][3]) ## Backwards compatbility request = u['request'] if u['request'] == 'move': request = 'stable' elif u['request'] == 'push': request = 'testing' elif u['request'] == 'unpush': request = 'obsolete' if u['approved'] in (True, False): u['approved'] = None if u.has_key('update_id'): u['updateid'] = u['update_id'] if not u.has_key('date_modified'): u['date_modified'] = None try: update = PackageUpdate.byTitle(u['title']) except SQLObjectNotFound: update = PackageUpdate(title=u['title'], date_submitted=u['date_submitted'], date_pushed=u['date_pushed'], date_modified=u['date_modified'], release=release, submitter=u['submitter'], updateid=u['updateid'], type=u['type'], status=u['status'], pushed=u['pushed'], notes=u['notes'], karma=u['karma'], request=request, approved=u['approved']) ## Create Package and PackageBuild objects for pkg, nvr in u['builds']: try: package = Package.byName(pkg) except SQLObjectNotFound: package = Package(name=pkg) try: build = PackageBuild.byNvr(nvr) except SQLObjectNotFound: build = PackageBuild(nvr=nvr, package=package) update.addPackageBuild(build) ## Create all Bugzilla objects for this update for bug_num, bug_title, security, parent in u['bugs']: try: bug = Bugzilla.byBz_id(bug_num) except SQLObjectNotFound: bug = Bugzilla(bz_id=bug_num, security=security, parent=parent) bug.title = bug_title update.addBugzilla(bug) ## Create all CVE objects for this update for cve_id in u['cves']: try: cve = CVE.byCve_id(cve_id) except SQLObjectNotFound: cve = CVE(cve_id=cve_id) update.addCVE(cve) for timestamp, author, text, karma, anonymous in u['comments']: comment = Comment(timestamp=timestamp, author=author, text=text, karma=karma, update=update, anonymous=anonymous) progress()
def test_extended_metadata_updating_with_old_stable_security(self): testutil.capture_log(['bodhi.metadata']) koji = get_session() del (koji.__untag__[:]) assert not koji.__untag__, koji.__untag__ builds = koji.listTagged('dist-f7-updates', latest=True) # Create all of the necessary database entries release = Release(name='F17', long_name='Fedora 17', id_prefix='FEDORA', dist_tag='dist-f17') package = Package(name='TurboGears') update = PackageUpdate(title='TurboGears-1.0.2.2-2.fc7', release=release, submitter=builds[0]['owner_name'], status='stable', notes='foobar', type='security') build = PackageBuild(nvr='TurboGears-1.0.2.2-2.fc7', package=package) update.addPackageBuild(build) update.assign_id() assert update.updateid ## Initialize our temporary repo temprepo = join(tempfile.mkdtemp('bodhi'), 'f7-updates') print "Inserting updateinfo into temprepo: %s" % temprepo mkmetadatadir(join(temprepo, 'i386')) repodata = join(temprepo, 'i386', 'repodata') assert exists(join(repodata, 'repomd.xml')) ## Generate the XML md = ExtendedMetadata(temprepo) ## Insert the updateinfo.xml into the repository md.insert_updateinfo() updateinfo = self.__verify_updateinfo(repodata) # Create a new non-security update for the same package newbuild = 'TurboGears-1.0.2.2-3.fc7' update = PackageUpdate(title=newbuild, release=release, submitter=builds[0]['owner_name'], status='stable', notes='foobar', type='enhancement') build = PackageBuild(nvr=newbuild, package=package) update.addPackageBuild(build) update.assign_id() koji.__untag__.append('TurboGears-1.0.2.2-2.fc7') ## Test out updateinfo.xml updating via our ExtendedMetadata md = ExtendedMetadata(temprepo, updateinfo) md.insert_updateinfo() updateinfo = self.__verify_updateinfo(repodata) ## Read an verify the updateinfo.xml.gz uinfo = UpdateMetadata() uinfo.add(updateinfo) print(testutil.get_log()) assert len(uinfo.get_notices()) == 2, len(uinfo.get_notices()) assert uinfo.get_notice(get_nvr('TurboGears-1.0.2.2-2.fc7')) notice = uinfo.get_notice(get_nvr(update.title)) assert notice, 'Cannot find update for %r' % get_nvr(update.title) assert notice['status'] == update.status assert notice['updated'] == update.date_modified assert notice['from'] == str(config.get('bodhi_email')) assert notice['description'] == update.notes assert notice['issued'] is not None assert notice['update_id'] == update.updateid ## Clean up shutil.rmtree(temprepo) del (koji.__untag__[:])
def test_extended_metadata_updating_with_edited_updates(self): testutil.capture_log(['bodhi.metadata']) # grab the name of a build in updates-testing, and create it in our db koji = get_session() builds = koji.listTagged('dist-f13-updates-testing', latest=True) # Create all of the necessary database entries release = Release(name='F13', long_name='Fedora 13', id_prefix='FEDORA', dist_tag='dist-f13') package = Package(name=builds[0]['package_name']) update = PackageUpdate(title=builds[0]['nvr'], release=release, submitter=builds[0]['owner_name'], status='testing', notes='foobar', type='bugfix') build = PackageBuild(nvr=builds[0]['nvr'], package=package) update.addPackageBuild(build) update.assign_id() ## Initialize our temporary repo temprepo = join(tempfile.mkdtemp('bodhi'), 'f13-updates-testing') print "Inserting updateinfo into temprepo: %s" % temprepo mkmetadatadir(join(temprepo, 'i386')) repodata = join(temprepo, 'i386', 'repodata') assert exists(join(repodata, 'repomd.xml')) ## Generate the XML md = ExtendedMetadata(temprepo) ## Insert the updateinfo.xml into the repository md.insert_updateinfo() updateinfo = self.__verify_updateinfo(repodata) ## Read an verify the updateinfo.xml.gz uinfo = UpdateMetadata() uinfo.add(updateinfo) notice = uinfo.get_notice(('mutt', '1.5.14', '1.fc13')) assert not notice notice = uinfo.get_notice(get_nvr(update.title)) assert notice assert notice['status'] == update.status assert notice['updated'] == update.date_modified assert notice['from'] == str(config.get('bodhi_email')) assert notice['description'] == update.notes assert notice['issued'] is not None assert notice['update_id'] == update.updateid assert notice['title'] == update.title assert notice['release'] == update.release.long_name ## Edit the update and bump the build revision nvr = 'TurboGears-1.0.2.2-3.fc7' newbuild = PackageBuild(nvr=nvr, package=package) update.removePackageBuild(build) update.addPackageBuild(newbuild) update.title = nvr update.date_modified = datetime.utcnow() # Pretend -2 was unpushed assert len(koji.__untag__) == 0 koji.__untag__.append('TurboGears-1.0.2.2-2.fc7') ## Test out updateinfo.xml updating via our ExtendedMetadata md = ExtendedMetadata(temprepo, updateinfo) md.insert_updateinfo() updateinfo = self.__verify_updateinfo(repodata) ## Read an verify the updateinfo.xml.gz uinfo = UpdateMetadata() uinfo.add(updateinfo) print(testutil.get_log()) notice = uinfo.get_notice(('TurboGears', '1.0.2.2', '2.fc7')) assert not notice, "Old TG notice did not get pruned: %s" % notice notice = uinfo.get_notice(('TurboGears', '1.0.2.2', '3.fc7')) assert notice, uinfo assert notice['title'] == update.title num_notices = len(uinfo.get_notices()) assert num_notices == 1, num_notices ## Clean up shutil.rmtree(temprepo) del (koji.__untag__[:])