270 |
|
|
271 |
assert(os.path.exists(os.path.join(head,"debian/control"))) |
assert(os.path.exists(os.path.join(head,"debian/control"))) |
272 |
|
|
273 |
|
# apply patches so that dpkg-buildpackage can come and detect them |
274 |
|
|
275 |
|
print "LOOKING FOR PATCHES" |
276 |
|
os.chdir(os.path.join(maindir,head)) |
277 |
|
if os.path.exists("debian/patches"): |
278 |
|
print "PATCH DIR FOUND" |
279 |
|
patches = glob.glob("debian/patches/*.patch") |
280 |
|
for p in patches: |
281 |
|
print "PATCH %s" % p |
282 |
|
pf = open(p,"r") |
283 |
|
po = subprocess.Popen(["patch","-p1"],stdin = pf,executable="/usr/bin/patch") |
284 |
|
po.communicate() |
285 |
|
pf.close() |
286 |
|
if 0==po.returncode: |
287 |
|
print "PATCH %s APPLIED OK" % p |
288 |
|
os.unlink(p) |
289 |
|
else: |
290 |
|
raise RuntimeError("Error applying patch '%s': is it in 'patch -p1' format?" % p) |
291 |
|
os.rmdir("debian/patches") |
292 |
|
os.chdir(maindir) |
293 |
|
|
294 |
# copy original tarball (recompressing to .gz/reheading if required?) |
# copy original tarball (recompressing to .gz/reheading if required?) |
295 |
|
|
296 |
unzip = None |
unzip = None |
326 |
tar.close() |
tar.close() |
327 |
assert(os.path.exists(temptz)) |
assert(os.path.exists(temptz)) |
328 |
|
|
329 |
elif ext != "gz": |
elif ext != "gz" and ext != "bz2": |
330 |
print "Source tarball needs to be re-zipped to gzip format." |
print "Source tarball needs to be re-zipped to gzip format." |
331 |
temptar = "%s_%s.orig.tar" % (control['Source'],changes.upstream_version) |
temptar = "%s_%s.orig.tar" % (control['Source'],changes.upstream_version) |
332 |
temptz = "%s.%s"%(temptar,ext) |
temptz = "%s.%s"%(temptar,ext) |
339 |
subprocess.call(['gzip',temptar]) |
subprocess.call(['gzip',temptar]) |
340 |
|
|
341 |
else: |
else: |
342 |
origname = "%s_%s.orig.tar.gz" % (control['Source'],changes.upstream_version) |
origname = "%s_%s.orig.tar.%s" % (control['Source'],changes.upstream_version,ext) |
343 |
print "Original tarball is in gzip format" |
print "Original tarball is in %s format" % unzip[0] |
344 |
shutil.copyfile(ffull, origname) |
shutil.copyfile(ffull, origname) |
345 |
|
|
346 |
print "Checking for correct original tarball name..." |
print "Checking for correct original tarball name..." |
347 |
origname = "%s_%s.orig.tar.gz" % (control['Source'],changes.upstream_version) |
origname = "%s_%s.orig.tar.%s" % (control['Source'],changes.upstream_version,ext) |
348 |
assert(os.path.exists(origname)) |
assert(os.path.exists(origname)) |
349 |
|
|
350 |
t1 = t |
t1 = t |
361 |
os.chdir(debianname) |
os.chdir(debianname) |
362 |
if buildsource: |
if buildsource: |
363 |
print "Building source package..." |
print "Building source package..." |
364 |
_cmd = ["dpkg-buildpackage","-S","-rfakeroot","-sa"] |
_cmd = ["dpkg-buildpackage","-i","-S","-rfakeroot","-sa"] |
365 |
res = subprocess.call(_cmd) |
res = subprocess.call(_cmd) |
366 |
else: |
else: |
367 |
print "Building binary package..." |
print "Building binary package..." |
368 |
_cmd = ["dpkg-buildpackage","-rfakeroot","-sa"] |
_cmd = ["dpkg-buildpackage","-i","-rfakeroot","-sa"] |
369 |
if parallel: |
if parallel: |
370 |
_cmd += [parallel] |
_cmd += [parallel] |
371 |
res = subprocess.call(_cmd) |
res = subprocess.call(_cmd) |
374 |
raise RuntimeError("dpkg-buildpackage returned error code %s" % res) |
raise RuntimeError("dpkg-buildpackage returned error code %s" % res) |
375 |
|
|
376 |
except Exception, e: |
except Exception, e: |
377 |
print "ERROR DURING DPKG-BUILDPACKAGE: %s"% str(e) |
print "ERROR IN DTAR: %s"% str(e) |
378 |
print "Temporary files can be inspected in %s" % maindir |
print "Temporary files can be inspected in %s" % maindir |
379 |
sys.exit(1) |
sys.exit(1) |
380 |
|
|