Bug 809806 - Make createprecomplete.py more importable. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 13 Nov 2012 08:19:43 +0100
changeset 117707 d55265a9730401d794c02f029507b551c0109c67
parent 117706 6d47e2bedc07475b59f32cbc49dc30f70e0116f6
child 117708 a1e3296bcd218d8e284e800acbe71325eaeab0b1
push idunknown
push userunknown
push dateunknown
reviewersted
bugs809806
milestone19.0a1
Bug 809806 - Make createprecomplete.py more importable. r=ted
config/createprecomplete.py
--- a/config/createprecomplete.py
+++ b/config/createprecomplete.py
@@ -36,22 +36,21 @@ def get_build_entries(root_path):
 
     rel_file_path_list = list(rel_file_path_set)
     rel_file_path_list.sort(reverse=True)
     rel_dir_path_list = list(rel_dir_path_set)
     rel_dir_path_list.sort(reverse=True)
 
     return rel_file_path_list, rel_dir_path_list
 
-def generate_precomplete():
+def generate_precomplete(root_path):
     """ Creates the precomplete file containing the remove and rmdir
-        application update instructions. The current working directory is used
+        application update instructions. The given directory is used
         for the location to enumerate and to create the precomplete file.
     """
-    root_path = os.getcwd()
     # If inside a Mac bundle use the root of the bundle for the path.
     if os.path.basename(root_path) == "MacOS":
         root_path = os.path.abspath(os.path.join(root_path, '../../'))
 
     rel_file_path_list, rel_dir_path_list = get_build_entries(root_path)
     precomplete_file_path = os.path.join(root_path,"precomplete")
     # open in binary mode to prevent OS specific line endings.
     precomplete_file = open(precomplete_file_path, "wb")
@@ -59,9 +58,9 @@ def generate_precomplete():
         precomplete_file.writelines("remove \""+rel_file_path+"\"\n")
 
     for rel_dir_path in rel_dir_path_list:
         precomplete_file.writelines("rmdir \""+rel_dir_path+"\"\n")
 
     precomplete_file.close()
 
 if __name__ == "__main__":
-    generate_precomplete()
+    generate_precomplete(os.getcwd())