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 | |
diff --git a/twisted/scripts/test/test_tap2rpm.py b/twisted/scripts/test/test_tap2rpm.py
index 0f8863d..7553592 100644
|
a
|
b
|
|
| 80 | 80 | |
| 81 | 81 | return res |
| 82 | 82 | |
| | 83 | def checkErrorResult(failure): |
| | 84 | # The current rpm packages on Debian and Ubuntu don't properly set up |
| | 85 | # the RPM database, which causes rpm to print a harmless warning to |
| | 86 | # stderr. Unfortunately, .getProcessOutput() assumes all warnings are |
| | 87 | # catastrophic and panics whenever it sees one. |
| | 88 | # |
| | 89 | # See also: |
| | 90 | # http://twistedmatrix.com/trac/ticket/3292#comment:42 |
| | 91 | # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=551669 |
| | 92 | # http://rpm.org/ticket/106 |
| | 93 | |
| | 94 | failure.trap(IOError) |
| | 95 | |
| | 96 | # Check whether this warning is the one symptomatic of Debian's RPM |
| | 97 | # problem. |
| | 98 | if str(failure.value) == ("got stderr: 'error: cannot open Name index " |
| | 99 | "using db3 - No such file or directory (2)\\n'"): |
| | 100 | raise SkipTest("rpm is missing its package database. " |
| | 101 | "Run 'sudo rpm -qa > /dev/null' to create one.") |
| | 102 | else: |
| | 103 | # Not the exception we were looking for; as you were. |
| | 104 | failure.raiseException() |
| | 105 | |
| 83 | 106 | d = utils.getProcessOutput("rpm", |
| 84 | 107 | ("-q", "--queryformat", queryFormat, "-p", rpmfile)) |
| 85 | | d.addCallback(parseTagValues) |
| | 108 | d.addCallbacks(parseTagValues, checkErrorResult) |
| 86 | 109 | return d |
| 87 | 110 | |
| 88 | 111 | |