mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
Move debdiff into SourcePackage
This commit is contained in:
parent
cdd93a4cd8
commit
ed91b960e2
8
debian/copyright
vendored
8
debian/copyright
vendored
@ -194,10 +194,10 @@ Files: doc/pull-debian-debdiff.1,
|
||||
ubuntutools/update_maintainer.py,
|
||||
update-maintainer,
|
||||
wrap-and-sort
|
||||
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||
2010, Evan Broder <evan@ebroder.net>
|
||||
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||
2010, Stefano Rivera <stefanor@ubuntu.com>
|
||||
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||
2010, Evan Broder <evan@ebroder.net>
|
||||
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||
2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||
License: ISC
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -2,7 +2,7 @@
|
||||
# pull-debian-debdiff - find and download a specific version of a Debian
|
||||
# package and its immediate parent to generate a debdiff.
|
||||
#
|
||||
# Copyright (C) 2010, Stefano Rivera <stefanor@ubuntu.com>
|
||||
# Copyright (C) 2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||
# Inspired by a tool of the same name by Kees Cook.
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
@ -105,19 +105,7 @@ def main():
|
||||
Logger.error(str(e))
|
||||
sys.exit(1)
|
||||
oldpkg.unpack()
|
||||
|
||||
cmd = ['debdiff', oldpkg.dsc_name, newpkg.dsc_name]
|
||||
difffn = newpkg.dsc_name[:-3] + 'debdiff'
|
||||
Logger.command(cmd + ['> %s' % difffn])
|
||||
debdiff_file = open(difffn, 'w')
|
||||
if subprocess.call(cmd, stdout=debdiff_file) > 2:
|
||||
Logger.error('Debdiff failed.')
|
||||
sys.exit(1)
|
||||
debdiff_file.close()
|
||||
cmd = ('diffstat', '-p0', difffn)
|
||||
Logger.command(cmd)
|
||||
subprocess.check_call(cmd)
|
||||
print 'file://' + os.path.abspath(difffn)
|
||||
print 'file://' + oldpkg.debdiff(newpkg, diffstat=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,7 +1,7 @@
|
||||
# archive.py - Functions for dealing with Debian source packages, archives,
|
||||
# and mirrors.
|
||||
#
|
||||
# Copyright (C) 2010, Stefano Rivera <stefanor@ubuntu.com>
|
||||
# Copyright (C) 2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
@ -27,6 +27,8 @@ Approach:
|
||||
3. Verify checksums.
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import hashlib
|
||||
import os.path
|
||||
import subprocess
|
||||
@ -74,13 +76,12 @@ class Dsc(debian.deb822.Dsc):
|
||||
if os.path.getsize(pathname) != size:
|
||||
return False
|
||||
hash_func = getattr(hashlib, alg)()
|
||||
f = open(pathname, 'rb')
|
||||
while True:
|
||||
buf = f.read(hash_func.block_size)
|
||||
if buf == '':
|
||||
break
|
||||
hash_func.update(buf)
|
||||
f.close()
|
||||
with open(pathname, 'rb') as f:
|
||||
while True:
|
||||
buf = f.read(hash_func.block_size)
|
||||
if buf == '':
|
||||
break
|
||||
hash_func.update(buf)
|
||||
return hash_func.hexdigest() == digest
|
||||
return False
|
||||
|
||||
@ -270,16 +271,15 @@ class SourcePackage(object):
|
||||
except urllib2.HTTPError:
|
||||
return False
|
||||
|
||||
out = open(pathname, 'wb')
|
||||
while True:
|
||||
block = in_.read(10240)
|
||||
if block == '':
|
||||
break
|
||||
out.write(block)
|
||||
Logger.stdout.write('.')
|
||||
Logger.stdout.flush()
|
||||
with open(pathname, 'wb') as out:
|
||||
while True:
|
||||
block = in_.read(10240)
|
||||
if block == '':
|
||||
break
|
||||
out.write(block)
|
||||
Logger.stdout.write('.')
|
||||
Logger.stdout.flush()
|
||||
in_.close()
|
||||
out.close()
|
||||
Logger.stdout.write(' done\n')
|
||||
Logger.stdout.flush()
|
||||
if self.dsc and not url.endswith('.dsc'):
|
||||
@ -313,6 +313,24 @@ class SourcePackage(object):
|
||||
Logger.command(cmd)
|
||||
subprocess.check_call(cmd, cwd=self.workdir)
|
||||
|
||||
def debdiff(self, newpkg, diffstat=False):
|
||||
"""Write a debdiff comparing this src pkg to a newer one.
|
||||
Optionally print diffstat.
|
||||
Return the debdiff filename.
|
||||
"""
|
||||
cmd = ['debdiff', self.dsc_name, newpkg.dsc_name]
|
||||
difffn = newpkg.dsc_name[:-3] + 'debdiff'
|
||||
Logger.command(cmd + ['> %s' % difffn])
|
||||
with open(difffn, 'w') as f:
|
||||
if subprocess.call(cmd, stdout=f, cwd=self.workdir) > 2:
|
||||
Logger.error('Debdiff failed.')
|
||||
sys.exit(1)
|
||||
if diffstat:
|
||||
cmd = ('diffstat', '-p1', difffn)
|
||||
Logger.command(cmd)
|
||||
subprocess.check_call(cmd)
|
||||
return os.path.abspath(difffn)
|
||||
|
||||
|
||||
class DebianSourcePackage(SourcePackage):
|
||||
"Download / unpack a Debian source package"
|
||||
|
Loading…
x
Reference in New Issue
Block a user