From 9effd91f62d8dbb2e732519c045c3a435fedd42c Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Thu, 2 Apr 2020 22:21:20 +0100
Subject: [PATCH] macOS: Use different bundle identifiers for nightly builds
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Also switch so nightly builds are always ‘lite’ (not full) to save
bandwidth / computational load on Jenkins
---
 Info.plist.in                 |  2 +-
 hudson_mac_package_release.rb | 19 ++++++++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/Info.plist.in b/Info.plist.in
index 0278e77..5778f9e 100644
--- a/Info.plist.in
+++ b/Info.plist.in
@@ -15,7 +15,7 @@
 	<key>CFBundleExecutable</key>
 	<string>fgfs</string>
 	<key>CFBundleIdentifier</key>
-	<string>org.flightgear.FlightGear</string>
+	<string><%= fgBundleIdentifier %></string>
 	<key>CFBundleVersion</key>
 	<string><%= fgVersion %></string>
 	<key>CFBundleShortVersionString</key>
diff --git a/hudson_mac_package_release.rb b/hudson_mac_package_release.rb
index 445a775..cc49fdb 100755
--- a/hudson_mac_package_release.rb
+++ b/hudson_mac_package_release.rb
@@ -43,7 +43,6 @@ $prefixDir=Dir.pwd + "/dist"
 dmgDir=Dir.pwd + "/image"
 srcDir=Dir.pwd + "/flightgear"
 qmlDir=srcDir + "/src/GUI/qml"
-
 puts "Erasing previous image dir"
 `rm -rf #{dmgDir}`
 
@@ -69,6 +68,7 @@ osgPluginsDir=contents+"/PlugIns/osgPlugins"
 # for writing copyright year to Info.plist
 t = Time.new
 fgCurrentYear = t.year
+fgBundleIdentifier = "org.flightgear.mac"
 
 fgVersion = File.read("#{srcDir}/version").strip
 volName="\"FlightGear #{fgVersion}\""
@@ -79,6 +79,7 @@ if $isRelease
 else
   dmgPath = Dir.pwd + "/output/FlightGear-#{fgVersion}-nightly.dmg"
   dmgFullPath = Dir.pwd + "/output/FlightGear-#{fgVersion}-nightly-full.dmg"
+  fgBundleIdentifier = "org.flightgear.mac-nightly"
 end
 
 puts "Creating directory structure"
@@ -159,18 +160,19 @@ if !$isRelease
 
   puts "Notarizing DMG #{dmgPath}"
   `xcrun altool --notarize-app \
-              --primary-bundle-id "org.flightgear.mac"  \
+              --primary-bundle-id "#{fgBundleIdentifier}"  \
               --username "zakalawe@mac.com" \
               --password "@keychain:FlightGearAppStoreConnectUserName" \
               --file #{dmgPath}`
-end
 
-puts "Creating full image with data"
+
+else
+  puts "Creating full image with data"
 
 `rsync -a fgdata/ #{resourcesDir}/data`
 
-# re-sign the entire bundle
-puts "Re-signing full app: #{bundle}"
+# sign the entire bundle
+puts "Signing full app: #{bundle}"
 `codesign --force #{codeSignArgs} --keychain #{$keychain} -s "#{$codeSignIdentity}" #{bundle}`
 
 `rm -f #{dmgFullPath}`
@@ -179,10 +181,13 @@ puts "Re-signing full app: #{bundle}"
 puts "Notarizing DMG #{dmgFullPath}"
 
 `xcrun altool --notarize-app  \
-  --primary-bundle-id "org.flightgear.mac" \
+  --primary-bundle-id "#{fgBundleIdentifier}"  \
   --username "zakalawe@mac.com" \
   --password "@keychain:FlightGearAppStoreConnectUserName" \
   --file #{dmgFullPath}`
+end
+
+
 
 puts "Packaging complete"