summaryrefslogtreecommitdiffstats
path: root/tools/export_tarball
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-17 18:13:15 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-17 18:13:15 +0000
commitf3aea71ac44157b90f5ec5f839e4defa826ae658 (patch)
tree21ab45f3b5093b3d9b52260470e3aba42c5462a9 /tools/export_tarball
parent1d9223b4db07d294f55e65dfb5ad064ba5153860 (diff)
downloadchromium_src-f3aea71ac44157b90f5ec5f839e4defa826ae658.zip
chromium_src-f3aea71ac44157b90f5ec5f839e4defa826ae658.tar.gz
chromium_src-f3aea71ac44157b90f5ec5f839e4defa826ae658.tar.bz2
Fix removing unnecessary files in export_tarball.py
TEST=none BUG=29044 Review URL: http://codereview.chromium.org/619007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39238 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/export_tarball')
-rw-r--r--tools/export_tarball/export_tarball.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/tools/export_tarball/export_tarball.py b/tools/export_tarball/export_tarball.py
index 9c356f8..8faeaed 100644
--- a/tools/export_tarball/export_tarball.py
+++ b/tools/export_tarball/export_tarball.py
@@ -41,9 +41,20 @@ def GetSourceDirectory():
# Workaround lack of the exclude parameter in add method in python-2.4.
# TODO(phajdan.jr): remove the workaround when it's not needed on the bot.
class MyTarFile(tarfile.TarFile):
+ def set_remove_nonessential_files(self, remove):
+ self.__remove_nonessential_files = remove
+
def add(self, name, arcname=None, recursive=True, exclude=None):
- if exclude is not None and exclude(name):
+ head, tail = os.path.split(name)
+ if tail in ('.svn', '.git'):
return
+
+ if self.__remove_nonessential_files:
+ for nonessential_dir in NONESSENTIAL_DIRS:
+ dir_path = os.path.join(GetSourceDirectory(), nonessential_dir)
+ if name.startswith(dir_path):
+ return
+
tarfile.TarFile.add(self, name, arcname=arcname, recursive=recursive)
def main(argv):
@@ -66,23 +77,10 @@ def main(argv):
output_fullname = args[0] + '.tar.bz2'
output_basename = os.path.basename(args[0])
- def ShouldExcludePath(path):
- head, tail = os.path.split(path)
- if tail in ('.svn', '.git'):
- return True
-
- if not options.remove_nonessential_files:
- return False
- for nonessential_dir in NONESSENTIAL_DIRS:
- if path.startswith(os.path.join(GetSourceDirectory(), nonessential_dir)):
- return True
-
- return False
-
archive = MyTarFile.open(output_fullname, 'w:bz2')
+ archive.set_remove_nonessential_files(options.remove_nonessential_files)
try:
- archive.add(GetSourceDirectory(), arcname=output_basename,
- exclude=ShouldExcludePath)
+ archive.add(GetSourceDirectory(), arcname=output_basename)
finally:
archive.close()