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,
|
ubuntutools/update_maintainer.py,
|
||||||
update-maintainer,
|
update-maintainer,
|
||||||
wrap-and-sort
|
wrap-and-sort
|
||||||
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
|
Copyright: 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
2010, Evan Broder <evan@ebroder.net>
|
2010, Evan Broder <evan@ebroder.net>
|
||||||
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
2008, Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
|
||||||
2010, Stefano Rivera <stefanor@ubuntu.com>
|
2010-2011, Stefano Rivera <stefanor@ubuntu.com>
|
||||||
License: ISC
|
License: ISC
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
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
|
# pull-debian-debdiff - find and download a specific version of a Debian
|
||||||
# package and its immediate parent to generate a debdiff.
|
# 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.
|
# Inspired by a tool of the same name by Kees Cook.
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and/or distribute this software for any
|
# Permission to use, copy, modify, and/or distribute this software for any
|
||||||
@ -105,19 +105,7 @@ def main():
|
|||||||
Logger.error(str(e))
|
Logger.error(str(e))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
oldpkg.unpack()
|
oldpkg.unpack()
|
||||||
|
print 'file://' + oldpkg.debdiff(newpkg, diffstat=True)
|
||||||
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)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# archive.py - Functions for dealing with Debian source packages, archives,
|
# archive.py - Functions for dealing with Debian source packages, archives,
|
||||||
# and mirrors.
|
# 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
|
# Permission to use, copy, modify, and/or distribute this software for any
|
||||||
# purpose with or without fee is hereby granted, provided that the above
|
# purpose with or without fee is hereby granted, provided that the above
|
||||||
@ -27,6 +27,8 @@ Approach:
|
|||||||
3. Verify checksums.
|
3. Verify checksums.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import with_statement
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import os.path
|
import os.path
|
||||||
import subprocess
|
import subprocess
|
||||||
@ -74,13 +76,12 @@ class Dsc(debian.deb822.Dsc):
|
|||||||
if os.path.getsize(pathname) != size:
|
if os.path.getsize(pathname) != size:
|
||||||
return False
|
return False
|
||||||
hash_func = getattr(hashlib, alg)()
|
hash_func = getattr(hashlib, alg)()
|
||||||
f = open(pathname, 'rb')
|
with open(pathname, 'rb') as f:
|
||||||
while True:
|
while True:
|
||||||
buf = f.read(hash_func.block_size)
|
buf = f.read(hash_func.block_size)
|
||||||
if buf == '':
|
if buf == '':
|
||||||
break
|
break
|
||||||
hash_func.update(buf)
|
hash_func.update(buf)
|
||||||
f.close()
|
|
||||||
return hash_func.hexdigest() == digest
|
return hash_func.hexdigest() == digest
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -270,16 +271,15 @@ class SourcePackage(object):
|
|||||||
except urllib2.HTTPError:
|
except urllib2.HTTPError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
out = open(pathname, 'wb')
|
with open(pathname, 'wb') as out:
|
||||||
while True:
|
while True:
|
||||||
block = in_.read(10240)
|
block = in_.read(10240)
|
||||||
if block == '':
|
if block == '':
|
||||||
break
|
break
|
||||||
out.write(block)
|
out.write(block)
|
||||||
Logger.stdout.write('.')
|
Logger.stdout.write('.')
|
||||||
Logger.stdout.flush()
|
Logger.stdout.flush()
|
||||||
in_.close()
|
in_.close()
|
||||||
out.close()
|
|
||||||
Logger.stdout.write(' done\n')
|
Logger.stdout.write(' done\n')
|
||||||
Logger.stdout.flush()
|
Logger.stdout.flush()
|
||||||
if self.dsc and not url.endswith('.dsc'):
|
if self.dsc and not url.endswith('.dsc'):
|
||||||
@ -313,6 +313,24 @@ class SourcePackage(object):
|
|||||||
Logger.command(cmd)
|
Logger.command(cmd)
|
||||||
subprocess.check_call(cmd, cwd=self.workdir)
|
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):
|
class DebianSourcePackage(SourcePackage):
|
||||||
"Download / unpack a Debian source package"
|
"Download / unpack a Debian source package"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user