#!/usr/bin/python """ Script which gets some data from a group of rpms """ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Copyright 2004 Dries Verachtert # this script gets the versionid, name and distroarchtag from an rpm # this only works if the versionid is added to the first line of the changelog import rpmfiletags import re, os, commands, posix, posixpath, string def getRpmData(rpmPath): name = None # this is NOT the version of the rpm, but the version known in the database of the spec file version = "0" distroarchtag = None if string.find(rpmPath,'fc3-i386') > 0 or string.find(rpmPath,'1.fc3.rf.i386') > 0 or (string.find(rpmPath,'1.fc3') > 0 and string.find(rpmPath,'i386') > 0): distroarchtag='fc3-i386' if string.find(rpmPath,'fc2-i386') > 0 or string.find(rpmPath,'1.fc2.rf.i386') > 0 or (string.find(rpmPath,'1.fc2') > 0 and string.find(rpmPath,'i386') > 0): distroarchtag='fc2-i386' if string.find(rpmPath,'fc1-i386') > 0 or string.find(rpmPath,'1.fc1.rf.i386') > 0 or (string.find(rpmPath,'fc1') > 0 and string.find(rpmPath,'i386') > 0): distroarchtag='fc1-i386' if string.find(rpmPath,'fc4-i386') > 0: distroarchtag='fc4-i386' if string.find(rpmPath,'fc4-x86_64') > 0: distroarchtag='fc4-x86_64' if string.find(rpmPath,'el4-i386') > 0 or string.find(rpmPath,'.el4.rf') > 0 and string.find(rpmPath,'i386') > 0: distroarchtag='el4-i386' if string.find(rpmPath,'el3-i386') > 0 or string.find(rpmPath,'.el3.') > 0 and string.find(rpmPath,'i386') > 0: distroarchtag='el3-i386' if string.find(rpmPath,'au1.92-sparc') > 0 or string.find(rpmPath,'au1.92.rf') > 0 or string.find(rpmPath,'au1.92.dries') > 0: distroarchtag='au1.92-sparc' if string.find(rpmPath,'au1.91-sparc') > 0 or string.find(rpmPath,'au1.91.rf') > 0 or string.find(rpmPath,'au1.91.dries') > 0: distroarchtag='au1.91-sparc' if string.find(rpmPath,'oss10.0beta4-i586') > 0 or string.find(rpmPath, '0.0.oss10.0beta4.rf') > 0: distroarchtag='oss10.0beta4-i586' if string.find(rpmPath,'fc5-i386') > 0: distroarchtag='fc5-i386' if string.find(rpmPath,'fc5-x86_64') > 0: distroarchtag='fc5-x86_64' if string.find(rpmPath,'el4-x86_64') > 0: distroarchtag='el4-x86_64' if string.find(rpmPath,'oss10.0-x86_64') > 0: distroarchtag='oss10.0-x86_64' if string.find(rpmPath,'oss10.0-i386') > 0: distroarchtag='oss10.0-i386' rf = rpmfiletags.RpmFileTags(rpmPath,'') # locationid : locationId # rpmname : fileName # path : rpmsDir name = rf.standardtags['NAME'] # specrpmname : specRpmName specRpmVersion = rf.standardtags['VERSION'] specRpmEpoch = rf.standardtags['EPOCH']; specRpmRelease = rf.standardtags['RELEASE'] # specrpmrelease : specRpmRelease fileMd5s = rf.standardtags['FILEMD5S'] # filemd5s : fileMd5s chlogLine = rf.standardtags['CHANGELOGNAME'] regexp = '.*#([0-9]*)$' regex = re.compile(regexp) result = regex.match(chlogLine) #specFileId = "null"; if result: version = result.group(1) return name, version, distroarchtag