From b582736375218e8944b3ce3daac667c7910a7e73 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Fri, 9 Sep 2011 18:41:53 +0200 Subject: [PATCH] XO_Packager: package files that are in git and the locale folder, OLPC #11217 There had been reports about Activities that had unexpected files in the xo bundle (e.g. patches). There have been a recent change that the support for the MANIFEST has been removed from the bundle builder. The MANIFEST 'controlled' which files were bundled. The code did include all the files present in the folder (which includes patches etc). The patch does use git-ls to get a list of files to include (like the tarball packager). Furthermore the locale folder is included which has been generated. Due to the API freeze we made '_get_files_in_git' a private method which adds a bit of duplication to the 'get_files' method in the tarball packager. A patch for master which will implement Builder.get_files_git(), that can be used by XOPackager and SourcePackager. Signed-off-by: Simon Schampijer Reviewed-By: Daniel Drake --- src/sugar/activity/bundlebuilder.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/sugar/activity/bundlebuilder.py b/src/sugar/activity/bundlebuilder.py index 5fd92c1e..82632398 100644 --- a/src/sugar/activity/bundlebuilder.py +++ b/src/sugar/activity/bundlebuilder.py @@ -170,12 +170,30 @@ class XOPackager(Packager): bundle_zip = zipfile.ZipFile(self.package_path, 'w', zipfile.ZIP_DEFLATED) - for f in self.builder.get_files(): + for f in self._get_files_in_git(): bundle_zip.write(os.path.join(self.config.source_dir, f), os.path.join(self.config.bundle_root_dir, f)) + locale_dir = os.path.join(self.config.source_dir, 'locale') + locale_files = list_files(locale_dir, IGNORE_DIRS, IGNORE_FILES) + for f in locale_files: + bundle_zip.write(os.path.join(locale_dir, f), + os.path.join(self.config.bundle_root_dir, + 'locale', f)) bundle_zip.close() + def _get_files_in_git(self): + git_ls = subprocess.Popen(['git', 'ls-files'], stdout=subprocess.PIPE, + cwd=self.config.source_dir) + stdout, _ = git_ls.communicate() + if git_ls.returncode: + # Fall back to filtered list + return list_files(self.config.source_dir, + IGNORE_DIRS, IGNORE_FILES) + + # pylint: disable=E1103 + return [path.strip() for path in stdout.strip('\n').split('\n')] + class SourcePackager(Packager):