From 02c1cd2d509a9aa2cfad7f1afd2d6d90403390d3 Mon Sep 17 00:00:00 2001
From: Stephen Birarda <commit@birarda.com>
Date: Thu, 19 Apr 2018 18:46:45 -0700
Subject: [PATCH] optionally use campaign serverless content during install

---
 INSTALL.md                       |  1 +
 cmake/templates/NSIS.template.in | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/INSTALL.md b/INSTALL.md
index ac210c887f..90e8712b19 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -20,6 +20,7 @@ To produce an executable installer on Windows, the following are required:
 - [Inetc Plug-in for Nullsoft](http://nsis.sourceforge.net/Inetc_plug-in) - 1.0
 - [NSISpcre Plug-in for Nullsoft](http://nsis.sourceforge.net/NSISpcre_plug-in) - 1.0
 - [nsisSlideshow Plug-in for Nullsoft](http://nsis.sourceforge.net/NsisSlideshow_plug-in) - 1.7
+- [Nsisunz plug-in for Nullsoft](http://nsis.sourceforge.net/Nsisunz_plug-in)
 
 Run the `package` target to create an executable installer using the Nullsoft Scriptable Install System.
 
diff --git a/cmake/templates/NSIS.template.in b/cmake/templates/NSIS.template.in
index bfedccdd2e..fc9b9ab03d 100644
--- a/cmake/templates/NSIS.template.in
+++ b/cmake/templates/NSIS.template.in
@@ -1005,6 +1005,23 @@ Function HandlePostInstallOptions
   ${EndIf}
 FunctionEnd
 
+Function OptionallyDownloadCampaignServerless
+  ${If} $CampaignName != ""
+    InitPluginsDir
+
+    NSISdl::download_quiet http://cdn.highfidelity.com/installer/serverless/$CampaignName.zip $PLUGINSDIR\$CampaignName.zip
+
+    ${If} ${FileExists} $PLUGINSDIR\$CampaignName.zip
+      ; replace the installed serverless content with the campaign content
+
+      RMDir /r "$INSTDIR\resources\serverless"
+      CreateDirectory "$INSTDIR\resources\serverless"
+      nsisunz::Unzip "$PLUGINSDIR\$CampaignName.zip" "$INSTDIR\resources\serverless"
+    ${EndIf}
+
+  ${Endif}
+FunctionEnd
+
 ;--------------------------------
 ;Installer Sections
 
@@ -1158,6 +1175,9 @@ Section "-Core installation"
 
   @CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
 
+  ; see if we have a campaign that we might need to grab special content for
+  Call OptionallyDownloadCampaignServerless
+
   ; Handle whichever post install options were set
   Call HandlePostInstallOptions