[svn] r5366 - trunk/tools/dar

packagers at lists.rpmforge.net packagers at lists.rpmforge.net
Fri May 4 13:33:12 CEST 2007


Author: dag
Date: 2007-05-04 13:33:12 +0200 (Fri, 04 May 2007)
New Revision: 5366

Modified:
   trunk/tools/dar/dar-perl.py
Log:
Added BuildRequires handling, name check and general cleanup.

Modified: trunk/tools/dar/dar-perl.py
===================================================================
--- trunk/tools/dar/dar-perl.py	2007-05-04 10:47:45 UTC (rev 5365)
+++ trunk/tools/dar/dar-perl.py	2007-05-04 11:33:12 UTC (rev 5366)
@@ -3,18 +3,17 @@
 ### This python scripts automatically generates an RPMforge SPEC files
 ### for Perl modules.
 
+### Example modules:
+###	perl-Tree-Simple		tests META.yml
+###	perl-Tree-Simple-Visitor	tests sub-modules
+
 ### TODO:
-###	- Check that module name is distribution !!
 ###	- Improve docfiles handling (case-insensitive matching, deflates list)
-###	- Get build dependencies from META.yml if available
-###	- Compare name and version with META.yml
 
 import sys, os, time, getopt, urllib2, gzip, re, syck
 import cElementTree as ElementTree
 import tarfile
 
-tmppath = '/dar/tmp'
-
 args = sys.argv[1:]
 try:
 	logname = os.getlogin()
@@ -25,6 +24,7 @@
 realversion = None
 author = ''
 email = ''
+tmppath = '/var/tmp'
 
 docfiles = ('Announce', 'ANNOUNCE', 'Artistic', 'ARTISTIC', 'Artistic.txt', 'AUTHORS', 'Bugs', 'BUGS', 'Changelog', 'ChangeLog', 'CHANGELOG', 'Changes', 'CHANGES', 'Changes.pod', 'CHANGES.TXT', 'Copying', 'COPYING', 'COPYRIGHT', 'Credits', 'CREDITS', 'CREDITS.txt', 'FAQ', 'GNU_GPL.txt', 'GNU_LGPL.txt', 'GNU_LICENSE', 'HACKING', 'HISTORY', 'INFO', 'INSTALL', 'INSTALLING', 'INSTALL.txt', 'LICENCE', 'LICENSE', 'MANIFEST', 'META.yml', 'NEWS', 'NOTES', 'NOTICE', 'PORTING', 'readme', 'README', 'readme.txt', 'README.txt', 'README.TXT', 'RELEASE_NOTES', 'SIGNATURE', 'THANKS', 'TODO', 'UPGRADE', 'VERSION', '.txt')
 
@@ -39,7 +39,7 @@
 }
 
 def download(url):
-	filename = os.path.join('/dar/tmp', os.path.basename(url))
+	filename = os.path.join(tmppath, os.path.basename(url))
 	if not os.path.exists(filename):
 		try:
 			req = urllib2.Request(url)
@@ -55,7 +55,7 @@
 	opts, args = getopt.getopt (args, 'dhnv',
 		['debug', 'help', 'version'])
 except getopt.error, exc:
-	print 'dar-perl: %s, try dstat -h for a list of all the options' % str(exc)
+	print 'dar-perl: %s, try dar-perl.py -h for a list of all the options' % str(exc)
 	sys.exit(1)
 
 for opt, arg in opts:
@@ -167,42 +167,37 @@
 	### Remove Name-Version/ from filename
 	l = file.split(base+'/')
 	shortfile = l[1]
+
+	### Check if this is a noarch or arch package
 	if file.endswith('.c') or file.endswith('.h') or file.endswith('.cc') or file.endswith('.xs'):
 		noarch = False
+
+	### Create %docs list
 	for docfile in docfiles:
 		if shortfile == docfile:
 			docs.append(shortfile)
+
 	### Parse META.yml (http://module-build.sourceforge.net/META-spec-v1.2.html)
-### Example:
-#name -> SVN-Notify-Mirror
-#license -> perl
-#author -> ['John Peacock <jpeacock at cpan.org>']
-#meta-spec -> {'url': 'http://module-build.sourceforge.net/META-spec-v1.2.html', 'version': 1.2}
-#abstract -> Keep a mirrored working copy of a repository path
-#generated_by -> Module::Build version 0.2806
-#version -> 0.036
-#provides -> {'SVN::Notify::Mirror::Rsync': {'version': '', 'file': 'lib/SVN/Notify/Mirror/Rsync.pm'}, 'SVN::Notify::Mirror::SSH': {'version': '', 'file': 'lib/SVN/Notify/Mirror/SSH.pm'}, 'SVN::Notify::Mirror': {'version': 0.035999999999999997, 'file': 'lib/SVN/Notify/Mirror.pm'}}
-#requires -> {'Module::Build': 0.28050000000000003, 'SVN::Notify': 2.6200000000000001}
-#resources -> {'license': 'http://dev.perl.org/licenses/'}
-
 	if shortfile == 'META.yml':
 		member = distfd.getmember(file)
 		meta = syck.load(distfd.extractfile(member).read())
+		if debug:
+			print >>sys.stderr, 'META.yml contains the following info:'
+			for key in meta.keys():
+				print >>sys.stderr, '   %s: %s' % (key, meta[key])
 
-		for key in meta.keys():
-		        print >>sys.stderr, key, '->', meta[key]
+docs.sort()
 
-	### Parse README
-#	if shortfile == 'README':
-#		member = distfd.getmember(file)
-#		meta = distfd.extractfile(member)
-#		for line in meta.readlines():
-#			print >>sys.stderr, line
+if os.path.isfile(archive):
+	os.remove(archive)
 
-docs.sort()
+if meta.has_key('name') and meta['name'] != module:
+	print >>sys.stderr, 'Module %s is part of distribution %s. Please us that instead.' % (module, meta['name'])
+	sys.exit(1)
 
-#if os.path.isfile(archive):
-#	os.remove(archive)
+if meta.has_key('version') and str(meta['version']) != version:
+	print >>sys.stderr, 'Module %s has version mismatch between archive (%s) and META.yml (%s).' % (module, version, meta['version'])
+	print repr(version), repr(meta['version'])
 
 if meta.has_key('author') and not email or not author:
 	author = meta['author']
@@ -223,9 +218,8 @@
 		print >>sys.stderr, 'License could not be determined.'
 
 if meta.has_key('abstract'):
-	meta['abstract'] = meta['abstract'][0].lower() + meta['abstract'][1:]
-	summary = "Perl module to %s" % meta['abstract']
-	description = "perl-%s is a Perl module to %s." % (module, meta['abstract'])
+	summary = "%s" % meta['abstract']
+	description = "%s." % meta['abstract']
 else:
 	summary = "Perl module named %s" % module
 	description = "perl-%s is a Perl module." % module
@@ -244,8 +238,6 @@
 	for file in distfd.getnames():
 		print >>sys.stderr, '  ', file
 
-#print >>sys.stderr, "http://search.cpan.org/dist/%s/" % module
-
 print '# $Id$'
 print '# Authority:', logname
 
@@ -279,16 +271,26 @@
 	print "BuildArch: noarch"
 
 ### FIXME: Add BuildRequires from Makefile.PL
-print "BuildRequires: perl"
-#print "Requires: perl"
+if meta.has_key('requires') and meta['requires'].has_key('perl'):
+	print "BuildRequires: perl >= %s " % meta['requires']['perl']
+else:
+	print "BuildRequires: perl"
 
 ### Requires are extracted by RPM itself
+#print "Requires: perl"
 #if meta.has_key('requires'):
 #	for key in meta['requires']:
 #		if meta['requires'][key]:
 #			print "Requires: perl(%s) >= %s" % (key, meta['requires'][key])
 #		else:
 #			print "Requires: perl(%s)" % key
+
+if meta.has_key('build_requires'):
+	for key in meta['build_requires']:
+		if meta['build_requires'][key]:
+			print "BuildRequires: perl(%s) >= %s" % (key, meta['build_requires'][key])
+		else:
+			print "BuildRequires: perl(%s)" % key
 print
 
 print "%description"




More information about the commits mailing list