Ticket #3292: modern-tap2rpm-3292-2.patch
| File modern-tap2rpm-3292-2.patch, 3.9 KB (added by Screwtape, 3 years ago) |
|---|
-
twisted/scripts/tap2rpm.py
diff --git a/twisted/scripts/tap2rpm.py b/twisted/scripts/tap2rpm.py index a3888a7..3f55840 100755
a b 167 167 168 168 ########################## 169 169 def makeBuildDir(baseDir): 170 '''Set up the temporary directory for building RPMs. 171 Returns: Tuple: ( buildDir, rpmrcFile ) 170 ''' 171 Set up the temporary directory for building RPMs. 172 173 Returns: buildDir, a randomly-named subdirectory of baseDir. 172 174 ''' 173 175 import random, string 174 176 … … 189 191 os.makedirs(os.path.join(tmpDir, 'SOURCES')) 190 192 os.makedirs(os.path.join(tmpDir, 'SRPMS')) 191 193 192 # set up rpmmacros file 193 macroFile = os.path.join(tmpDir, 'rpmmacros') 194 rcFile = os.path.join(tmpDir, 'rpmrc') 195 rpmrcData = open('/usr/lib/rpm/rpmrc', 'r').read() 196 rpmrcData = string.replace(rpmrcData, '~/.rpmmacros', macroFile) 197 fp = open(macroFile, 'w') 198 fp.write('%%_topdir %s\n' % tmpDir) 199 fp.close() 200 201 # set up the rpmrc file 202 fp = open(rcFile, 'w') 203 fp.write(rpmrcData) 204 fp.close() 205 206 return(( tmpDir, rcFile )) 194 return tmpDir 207 195 208 196 209 197 ########## … … 236 224 maintainer = 'tap2rpm' 237 225 238 226 # create source archive directory 239 tmp_dir , rpmrc_file= makeBuildDir('/var/tmp')227 tmp_dir = makeBuildDir('/var/tmp') 240 228 source_dir = os.path.join(tmp_dir, directory) 241 229 os.makedirs(source_dir) 242 230 … … 257 245 print 'Starting build...' 258 246 print '=' * 70 259 247 sys.stdout.flush() 260 os.system('rpmbuild - ta --rcfile "%s" %s' % ( rpmrc_file, tarfile_name ))248 os.system('rpmbuild --define "_topdir %s" -ta %s' % ( tmp_dir, tarfile_name )) 261 249 print 'Done with build...' 262 250 print '=' * 70 263 251 -
twisted/scripts/test/test_tap2rpm.py
diff --git a/twisted/scripts/test/test_tap2rpm.py b/twisted/scripts/test/test_tap2rpm.py index 0f8863d..d4ac41a 100644
a b 7 7 from os.path import exists 8 8 from twisted.trial.unittest import TestCase, SkipTest 9 9 from twisted.python import log, procutils 10 from twisted.python.failure import Failure 10 11 from twisted.internet import utils 11 12 from twisted.scripts import tap2rpm 12 13 … … 80 81 81 82 return res 82 83 84 def checkErrorResult(failure): 85 # The current rpm packages on Debian and Ubuntu don't properly set up 86 # the RPM database, which causes rpm to print a harmless warning to 87 # stderr. Unfortunately, .getProcessOutput() assumes all warnings are 88 # catastrophic and panics whenever it sees one. 89 # 90 # See also: 91 # http://twistedmatrix.com/trac/ticket/3292#comment:42 92 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=551669 93 # http://rpm.org/ticket/106 94 95 failure.trap(IOError) 96 97 # Depending on kernel scheduling, we might read the whole error 98 # message, or only the first few bytes. 99 if str(failure.value).startswith("got stderr: 'error: "): 100 newFailure = Failure(SkipTest("rpm is missing its package " 101 "database. Run 'sudo rpm -qa > /dev/null' to create one.")) 102 else: 103 # Not the exception we were looking for; we should report the 104 # original failure. 105 newFailure = failure 106 107 # We don't want to raise the exception right away; we want to wait for 108 # the process to exit, otherwise we'll get extra useless errors 109 # reported. 110 d = failure.value.processEnded 111 d.addBoth(lambda _: newFailure) 112 return d 113 83 114 d = utils.getProcessOutput("rpm", 84 115 ("-q", "--queryformat", queryFormat, "-p", rpmfile)) 85 d.addCallback (parseTagValues)116 d.addCallbacks(parseTagValues, checkErrorResult) 86 117 return d 87 118 88 119
