From a207b24d331539e16bd66ca09df3c585529c99f0 Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Fri, 26 Jul 2013 10:42:13 -0400
Subject: [PATCH] CHOP-955: Include app_settings/settings_install.xml in
 file_list. viewer_manifest.py uses its base-class
 llmanifest.LLManifest.put_in_file() method to create several different files
 in the install image being marshalled. I based the logic to create
 settings_install.xml on that example. Unfortunately I failed to notice that
 after every existing call, the script also explicitly appended the
 newly-created file to self.file_list... which only matters on Windows.
 file_list is fed to the NSIS installer. Change put_in_file() method to
 implicitly append to self.file_list. Change every existing viewer_manifest.py
 call to pass new put_in_file(src=) param instead of explicitly appending to
 self.file_list.

---
 indra/lib/python/indra/util/llmanifest.py | 18 ++++++++++++----
 indra/newview/viewer_manifest.py          | 25 +++++++++++++----------
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/indra/lib/python/indra/util/llmanifest.py b/indra/lib/python/indra/util/llmanifest.py
index 9cb830a2dbd..54049b5545b 100755
--- a/indra/lib/python/indra/util/llmanifest.py
+++ b/indra/lib/python/indra/util/llmanifest.py
@@ -392,11 +392,21 @@ def created_path(self, path):
             raise ManifestError, "Should be something at path " + path
         self.created_paths.append(path)
 
-    def put_in_file(self, contents, dst):
+    def put_in_file(self, contents, dst, src=None):
         # write contents as dst
-        f = open(self.dst_path_of(dst), "wb")
-        f.write(contents)
-        f.close()
+        dst_path = self.dst_path_of(dst)
+        f = open(dst_path, "wb")
+        try:
+            f.write(contents)
+        finally:
+            f.close()
+
+        # Why would we create a file in the destination tree if not to include
+        # it in the installer? The default src=None (plus the fact that the
+        # src param is last) is to preserve backwards compatibility.
+        if src:
+            self.file_list.append([src, dst_path])
+        return dst_path
 
     def replace_in(self, src, dst=None, searchdict={}):
         if dst == None:
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 827a8f44c36..b9da6c92807 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -71,13 +71,13 @@ def construct(self):
                 # include the entire shaders directory recursively
                 self.path("shaders")
                 # include the extracted list of contributors
-                contributor_names = self.extract_names("../../doc/contributions.txt")
-                self.put_in_file(contributor_names, "contributors.txt")
-                self.file_list.append(["../../doc/contributions.txt",self.dst_path_of("contributors.txt")])
+                contributions_path = "../../doc/contributions.txt"
+                contributor_names = self.extract_names(contributions_path)
+                self.put_in_file(contributor_names, "contributors.txt", src=contributions_path)
                 # include the extracted list of translators
-                translator_names = self.extract_names("../../doc/translations.txt")
-                self.put_in_file(translator_names, "translators.txt")
-                self.file_list.append(["../../doc/translations.txt",self.dst_path_of("translators.txt")])
+                translations_path = "../../doc/translations.txt"
+                translator_names = self.extract_names(translations_path)
+                self.put_in_file(translator_names, "translators.txt", src=translations_path)
                 # include the list of Lindens (if any)
                 #   see https://wiki.lindenlab.com/wiki/Generated_Linden_Credits
                 linden_names_path = os.getenv("LINDEN_CREDITS")
@@ -91,10 +91,9 @@ def construct(self):
                     else:
                          # all names should be one line, but the join below also converts to a string
                         linden_names = ', '.join(linden_file.readlines())
-                        self.put_in_file(linden_names, "lindens.txt")
+                        self.put_in_file(linden_names, "lindens.txt", src=linden_names_path)
                         linden_file.close()
                         print "Linden names extracted from '%s'" % linden_names_path
-                        self.file_list.append([linden_names_path,self.dst_path_of("lindens.txt")])
 
                 # ... and the entire windlight directory
                 self.path("windlight")
@@ -113,14 +112,18 @@ def construct(self):
                     # no sourceid, no settings_install.xml file
                     pass
                 else:
-                    if len(sourceid) > 0:
-                        print "Using sourceid: " + sourceid
+                    if sourceid:
                         # Single-entry subset of the LLSD content of settings.xml
                         content = dict(sourceid=dict(Comment='Identify referring agency to Linden web servers',
                                                      Persist=1,
                                                      Type='String',
                                                      Value=sourceid))
-                        self.put_in_file(llsd.format_pretty_xml(content), "settings_install.xml")
+                        # put_in_file(src=) need not be an actual pathname; it
+                        # only needs to be non-empty
+                        settings_install = self.put_in_file(llsd.format_pretty_xml(content),
+                                                            "settings_install.xml",
+                                                            src="environment")
+                        print "Put sourceid '%s' in %s" % (sourceid, settings_install)
 
                 self.end_prefix("app_settings")
 
-- 
GitLab