From 3fa7ede5e2216e6a919580905bbf4435e195443f Mon Sep 17 00:00:00 2001 From: Piotr Zalewa Date: Tue, 18 Oct 2011 12:40:04 +0200 Subject: [PATCH] Compare created and original XPI. Copy all not existing main dir files from original into created one. branch bug-690872-copy_all_files --- apps/repackage/helpers.py | 18 +++++++++++++++--- apps/repackage/tests/test_helpers.py | 2 -- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/repackage/helpers.py b/apps/repackage/helpers.py index 00b89655..92bece7e 100644 --- a/apps/repackage/helpers.py +++ b/apps/repackage/helpers.py @@ -182,12 +182,24 @@ class Repackage(object): response = xpi_utils.build(sdk_dir, os.path.join(sdk_dir, 'packages', self.manifest['name']), self.manifest['name'], hashtag, options=options) - log.debug("[%s] Done rebuilding XPI; cleaning up" % hashtag) - # clean up (sdk_dir is already removed) - self.cleanup() + # here find the created XPI and compare main dir list # if not the same - copy the files from original XPI + target = os.path.join(settings.XPI_TARGETDIR, '%s.xpi' % hashtag) + target_zip = zipfile.ZipFile(target, 'a') + target_namelist = target_zip.namelist() + for f in self.xpi_zip.namelist(): + if len(f.split('/')) == 1 and f not in target_namelist: + log.debug(f) + # export file from original xpi and pack file into target xpi + with tempfile.NamedTemporaryFile() as extr_file: + extr_file.write(self.xpi_zip.open(f).read()) + target_zip.write(extr_file.name, f) + target_zip.close() + # clean up (sdk_dir is already removed) + log.debug("[%s] Done rebuilding XPI; cleaning up" % hashtag) + self.cleanup() return response def get_manifest(self, package_overrides={}): diff --git a/apps/repackage/tests/test_helpers.py b/apps/repackage/tests/test_helpers.py index a37fc3ff..ecdc52e7 100644 --- a/apps/repackage/tests/test_helpers.py +++ b/apps/repackage/tests/test_helpers.py @@ -81,8 +81,6 @@ class RepackageTest(TestCase): xpi.close() assert 'icon.png' in filenames assert 'icon64.png' in filenames - raise SkipTest() - # I've got no idea how to copy icon16.png to main dir of the XPI assert 'icon16.png' in filenames def test_version_increment(self):