--- euca2ools-1.3.1/bin/euca-bundle-image.shasum 2010-12-15 22:59:08.139192364 -0600 +++ euca2ools-1.3.1/bin/euca-bundle-image 2010-12-15 22:58:41.043367327 -0600 @@ -217,12 +217,11 @@ def main(): print 'Invalid ec2cert' sys.exit(1) - (image_size, sha_image_digest) = euca.check_image(image_path, - destination_path) + image_size = euca.check_image(image_path, destination_path) if not prefix: prefix = euca.get_relative_filename(image_path) try: - tgz_file = euca.tarzip_image(prefix, image_path, + (tgz_file, sha_tar_digest) = euca.tarzip_image(prefix, image_path, destination_path) except NotFoundError: sys.exit(1) @@ -252,7 +251,7 @@ def main(): target_arch, image_size, bundled_size, - sha_image_digest, + sha_tar_digest, user, kernel, ramdisk, --- euca2ools-1.3.1/bin/euca-bundle-vol.shasum 2010-12-15 22:59:08.144192516 -0600 +++ euca2ools-1.3.1/bin/euca-bundle-vol 2010-12-15 23:01:41.884873455 -0600 @@ -400,12 +400,11 @@ def main(): cleanup(image_path) sys.exit(1) - (image_size, sha_image_digest) = euca.check_image(image_path, - destination_path) + image_size = euca.check_image(image_path, destination_path) if not prefix: prefix = euca.get_relative_filename(image_path) try: - tgz_file = euca.tarzip_image(prefix, image_path, + (tgz_file, sha_tar_digest) = euca.tarzip_image(prefix, image_path, destination_path) except NotFoundError: sys.exit(1) @@ -430,7 +429,7 @@ def main(): target_arch, image_size, bundled_size, - sha_image_digest, + sha_tar_digest, user, kernel, ramdisk, --- euca2ools-1.3.1/euca2ools/euca2ools/__init__.py.shasum 2010-12-15 22:59:08.195194068 -0600 +++ euca2ools-1.3.1/euca2ools/euca2ools/__init__.py 2010-12-15 23:10:47.687550654 -0600 @@ -43,6 +43,7 @@ from hashlib import sha1 as sha from M2Crypto import BN, EVP, RSA, X509 from binascii import hexlify, unhexlify from subprocess import * +import subprocess import platform import urllib import urlparse @@ -684,7 +685,7 @@ class Euca2ool: number_parts += 1 bytes_read = 0 for i in range(0, number_parts, 1): - filename = '%s.%d' % (file, i) + filename = '%s.%02d' % (file, i) part_digest = sha() file_part = open(filename, 'wb') print 'Part:', self.get_relative_filename(filename) @@ -712,14 +713,7 @@ class Euca2ool: image_size = os.path.getsize(image_file) if self.debug: print 'Image Size:', image_size, 'bytes' - in_file = open(image_file, 'rb') - sha_image = sha() - while 1: - buf = in_file.read(IMAGE_IO_CHUNK) - if not buf: - break - sha_image.update(buf) - return (image_size, hexlify(sha_image.digest())) + return image_size def tarzip_image( self, @@ -729,25 +723,35 @@ class Euca2ool: ): Util().check_prerequisite_command('tar') - print 'Tarring image' - tar_file = '%s.tar.gz' % os.path.join(path, prefix) - outfile = open(tar_file, 'wb') - file_path = self.get_file_path(file) + targz = '%s.tar.gz' % os.path.join(path, prefix) + targzfile = open(targz, 'w') + + # make process pipes tar_cmd = ['tar', 'ch', '-S'] + file_path = self.get_file_path(file) if file_path: tar_cmd.append('-C') tar_cmd.append(file_path) tar_cmd.append(self.get_relative_filename(file)) else: tar_cmd.append(file) - p1 = Popen(tar_cmd, stdout=PIPE) - p2 = Popen(['gzip'], stdin=p1.stdout, stdout=outfile) - p2.communicate() - outfile.close - if os.path.getsize(tar_file) <= 0: - print 'Could not tar image' + tarproc = subprocess.Popen(tar_cmd, stdout=subprocess.PIPE) + zipproc = subprocess.Popen(['gzip'], stdin=subprocess.PIPE, stdout=targzfile) + + # pass tar output to digest and gzip + sha_image = sha() + buf=os.read(tarproc.stdout.fileno(), 8196) + while buf: + zipproc.stdin.write(buf) + sha_image.update(buf) + buf=os.read(tarproc.stdout.fileno(), 8196) + + zipproc.stdin.close(); + targzfile.close() + if os.path.getsize(targz) <= 0: + print 'Could not tar/compress image' raise CommandFailed - return tar_file + return (targz, hexlify(sha_image.digest())) def hexToBytes(self, hexString): bytes = []