2011-01-18 07:42:49 +08:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'ERB'
|
2012-06-26 16:17:42 +08:00
|
|
|
require 'fileutils' #I know, no underscore is not ruby-like
|
|
|
|
include FileUtils
|
2011-01-18 07:42:49 +08:00
|
|
|
|
|
|
|
$osgLibs = ['osgFX', 'osgParticle', 'osg', 'osgGA', 'osgText', 'osgUtil', 'osgSim', 'osgViewer', 'osgDB']
|
2018-10-05 20:12:29 +08:00
|
|
|
$osgPlugins = ['ac', 'osg', 'freetype', 'imageio', 'rgb', 'txf', 'mdl', '3ds', 'dds']
|
2011-01-18 07:42:49 +08:00
|
|
|
|
2015-09-01 06:29:35 +08:00
|
|
|
# from http://drawingablank.me/blog/ruby-boolean-typecasting.html
|
|
|
|
class String
|
|
|
|
def to_bool
|
|
|
|
return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)
|
|
|
|
return false if self == false || self.blank? || self =~ (/^(false|f|no|n|0)$/i)
|
|
|
|
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class NilClass
|
|
|
|
def to_bool; false; end
|
|
|
|
end
|
|
|
|
|
2011-01-18 07:42:49 +08:00
|
|
|
def runOsgVersion(option)
|
|
|
|
env = "export DYLD_LIBRARY_PATH=#{Dir.pwd}/dist/lib"
|
|
|
|
bin = Dir.pwd + "/dist/bin/osgversion"
|
|
|
|
return `#{env}; #{bin} --#{option}`.chomp
|
|
|
|
end
|
|
|
|
|
|
|
|
osgVersion = runOsgVersion('version-number')
|
|
|
|
$osgSoVersion=runOsgVersion('so-number')
|
|
|
|
$openThreadsSoVersion=runOsgVersion('openthreads-soversion-number')
|
|
|
|
|
2012-08-13 21:26:33 +08:00
|
|
|
$codeSignIdentity = ENV['FG_CODESIGN_IDENTITY']
|
2020-03-18 00:33:27 +08:00
|
|
|
$keychain = ENV['FG_KEYCHAIN']
|
|
|
|
|
2012-08-13 21:26:33 +08:00
|
|
|
puts "Code signing identity is #{$codeSignIdentity}"
|
2011-01-18 07:42:49 +08:00
|
|
|
puts "osgVersion=#{osgVersion}, so-number=#{$osgSoVersion}"
|
|
|
|
|
2015-09-01 06:29:35 +08:00
|
|
|
$isRelease = ENV['FG_IS_RELEASE'].to_bool
|
|
|
|
puts "Is-release? : ##{$isRelease}"
|
|
|
|
|
2012-08-08 21:43:45 +08:00
|
|
|
$prefixDir=Dir.pwd + "/dist"
|
2011-01-18 07:42:49 +08:00
|
|
|
dmgDir=Dir.pwd + "/image"
|
|
|
|
srcDir=Dir.pwd + "/flightgear"
|
2017-12-25 05:20:24 +08:00
|
|
|
qmlDir=srcDir + "/src/GUI/qml"
|
2011-01-18 07:42:49 +08:00
|
|
|
puts "Erasing previous image dir"
|
|
|
|
`rm -rf #{dmgDir}`
|
|
|
|
|
2015-02-24 19:41:58 +08:00
|
|
|
bundle=dmgDir + "/FlightGear.app"
|
|
|
|
|
|
|
|
# run macdeployt before we rename the bundle, otherwise it
|
|
|
|
# can't find the bundle executable
|
2018-02-01 17:31:09 +08:00
|
|
|
# also note if adding options here, the bundle path has to be
|
|
|
|
# the first argument to macdeployqt
|
2015-02-24 19:41:58 +08:00
|
|
|
puts "Running macdeployqt on the bundle to copy Qt libraries"
|
2018-02-01 17:31:09 +08:00
|
|
|
`macdeployqt #{$prefixDir}/fgfs.app -qmldir=#{qmlDir}`
|
2015-02-24 19:41:58 +08:00
|
|
|
|
2019-11-12 23:16:01 +08:00
|
|
|
puts "Copying & renaming app bundle"
|
2015-02-24 19:41:58 +08:00
|
|
|
`mkdir -p #{dmgDir}`
|
2019-11-12 23:16:01 +08:00
|
|
|
`rsync --archive --quiet #{$prefixDir}/fgfs.app/ #{bundle}`
|
2015-02-24 19:41:58 +08:00
|
|
|
|
2011-01-18 07:42:49 +08:00
|
|
|
contents=bundle + "/Contents"
|
|
|
|
macosDir=contents + "/MacOS"
|
2012-08-08 21:43:45 +08:00
|
|
|
$frameworksDir=contents +"/Frameworks"
|
2011-01-18 07:42:49 +08:00
|
|
|
resourcesDir=contents+"/Resources"
|
2015-02-24 19:43:51 +08:00
|
|
|
osgPluginsDir=contents+"/PlugIns/osgPlugins"
|
2011-01-18 07:42:49 +08:00
|
|
|
|
2012-08-28 20:47:37 +08:00
|
|
|
# for writing copyright year to Info.plist
|
|
|
|
t = Time.new
|
|
|
|
fgCurrentYear = t.year
|
2020-04-03 05:21:20 +08:00
|
|
|
fgBundleIdentifier = "org.flightgear.mac"
|
2011-01-18 07:42:49 +08:00
|
|
|
|
2011-01-18 22:24:31 +08:00
|
|
|
fgVersion = File.read("#{srcDir}/version").strip
|
|
|
|
volName="\"FlightGear #{fgVersion}\""
|
|
|
|
|
2015-09-01 06:29:35 +08:00
|
|
|
if $isRelease
|
|
|
|
dmgPath = "" # no 'lite' build for release candidates
|
|
|
|
dmgFullPath = Dir.pwd + "/output/FlightGear-#{fgVersion}.dmg"
|
|
|
|
else
|
|
|
|
dmgPath = Dir.pwd + "/output/FlightGear-#{fgVersion}-nightly.dmg"
|
|
|
|
dmgFullPath = Dir.pwd + "/output/FlightGear-#{fgVersion}-nightly-full.dmg"
|
2020-04-03 05:21:20 +08:00
|
|
|
fgBundleIdentifier = "org.flightgear.mac-nightly"
|
2015-09-01 06:29:35 +08:00
|
|
|
end
|
2011-01-18 07:42:49 +08:00
|
|
|
|
|
|
|
puts "Creating directory structure"
|
|
|
|
`mkdir -p #{macosDir}`
|
2012-08-08 21:43:45 +08:00
|
|
|
`mkdir -p #{$frameworksDir}`
|
2011-01-18 07:42:49 +08:00
|
|
|
`mkdir -p #{resourcesDir}`
|
|
|
|
`mkdir -p #{osgPluginsDir}`
|
|
|
|
|
2015-02-24 19:41:58 +08:00
|
|
|
|
|
|
|
puts "Copying auxilliary binaries"
|
|
|
|
bins = ['fgjs', 'fgcom']
|
2011-01-18 07:42:49 +08:00
|
|
|
bins.each do |b|
|
2012-08-08 21:43:45 +08:00
|
|
|
if !File.exist?("#{$prefixDir}/bin/#{b}")
|
|
|
|
next
|
|
|
|
end
|
2015-02-24 19:41:58 +08:00
|
|
|
|
2012-08-08 21:43:45 +08:00
|
|
|
outPath = "#{macosDir}/#{b}"
|
|
|
|
`cp #{$prefixDir}/bin/#{b} #{outPath}`
|
2011-01-18 07:42:49 +08:00
|
|
|
end
|
|
|
|
|
2020-03-30 20:32:57 +08:00
|
|
|
puts "Copying OSG libraries"
|
2011-01-18 07:42:49 +08:00
|
|
|
$osgLibs.each do |l|
|
|
|
|
libFile = "lib#{l}.#{$osgSoVersion}.dylib"
|
2012-08-08 21:43:45 +08:00
|
|
|
`cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
|
2011-01-18 07:42:49 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# and not forgetting OpenThreads
|
|
|
|
libFile = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
|
2012-08-08 21:43:45 +08:00
|
|
|
`cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
|
2011-01-18 07:42:49 +08:00
|
|
|
|
2020-04-29 15:32:15 +08:00
|
|
|
# DBus and libEvent needed for SWIFT
|
|
|
|
# Sentry is crash reporting
|
|
|
|
otherLibs = ['dbus-1.3', 'event_core-2.2.1', 'sentry']
|
2020-03-30 20:32:57 +08:00
|
|
|
otherLibs.each do |l|
|
|
|
|
`cp #{$prefixDir}/lib/lib#{l}.dylib #{$frameworksDir}`
|
|
|
|
end
|
|
|
|
|
2011-01-18 07:42:49 +08:00
|
|
|
$osgPlugins.each do |p|
|
2015-02-24 19:43:51 +08:00
|
|
|
pluginFile = "osgdb_#{p}.dylib"
|
|
|
|
`cp #{$prefixDir}/lib/osgPlugins/#{pluginFile} #{osgPluginsDir}`
|
2011-01-18 07:42:49 +08:00
|
|
|
end
|
|
|
|
|
2012-08-08 23:27:04 +08:00
|
|
|
if File.exist?("#{$prefixDir}/bin/fgcom-data")
|
|
|
|
puts "Copying FGCom data files"
|
|
|
|
`ditto #{$prefixDir}/bin/fgcom-data #{resourcesDir}/fgcom-data`
|
|
|
|
end
|
|
|
|
|
2011-01-18 07:42:49 +08:00
|
|
|
# Info.plist
|
2011-01-18 22:24:31 +08:00
|
|
|
template = File.read("Info.plist.in")
|
2011-01-18 07:42:49 +08:00
|
|
|
output = ERB.new(template).result(binding)
|
|
|
|
|
|
|
|
File.open("#{contents}/Info.plist", 'w') { |f|
|
|
|
|
f.write(output)
|
|
|
|
}
|
|
|
|
|
|
|
|
`cp #{srcDir}/package/mac/FlightGear.icns #{resourcesDir}/FlightGear.icns`
|
|
|
|
`cp #{srcDir}/COPYING #{dmgDir}`
|
2012-08-02 17:34:00 +08:00
|
|
|
|
2013-01-30 23:46:15 +08:00
|
|
|
# move documentation to a public place
|
2015-09-01 06:29:35 +08:00
|
|
|
`cp fgdata/Docs/FGShortRef.pdf "#{dmgDir}/Quick Reference.pdf"`
|
|
|
|
`cp fgdata/Docs/getstart.pdf "#{dmgDir}/Getting Started.pdf"`
|
2013-01-30 23:46:15 +08:00
|
|
|
|
2015-09-01 06:29:35 +08:00
|
|
|
createArgs = "-format UDBZ -imagekey bzip2-level=9 -quiet -volname #{volName}"
|
2011-01-18 07:42:49 +08:00
|
|
|
|
2020-03-18 00:33:27 +08:00
|
|
|
# enable the hardened runtime and timestamp options, so notarization works
|
|
|
|
codeSignArgs = "--deep --options=runtime --timestamp"
|
2012-08-14 17:46:00 +08:00
|
|
|
|
2015-09-01 06:29:35 +08:00
|
|
|
if !$isRelease
|
|
|
|
# create the 'lite' DMG without the base files
|
2011-01-18 07:42:49 +08:00
|
|
|
|
2020-03-18 00:33:27 +08:00
|
|
|
|
2015-09-01 06:29:35 +08:00
|
|
|
# code sign the entire bundle once complete - v2 code-signing
|
|
|
|
puts "Signing #{bundle}"
|
2020-03-18 20:41:42 +08:00
|
|
|
`codesign #{codeSignArgs} --keychain #{$keychain} -s "#{$codeSignIdentity}" #{bundle}`
|
2019-11-12 23:16:01 +08:00
|
|
|
puts "Creating DMG without base-files"
|
2015-03-08 09:01:03 +08:00
|
|
|
|
2018-07-17 16:54:59 +08:00
|
|
|
`rm -f #{dmgPath}`
|
2015-09-01 06:29:35 +08:00
|
|
|
`hdiutil create -srcfolder #{dmgDir} #{createArgs} #{dmgPath}`
|
2019-11-12 23:16:01 +08:00
|
|
|
|
|
|
|
puts "Notarizing DMG #{dmgPath}"
|
|
|
|
`xcrun altool --notarize-app \
|
2020-04-03 05:21:20 +08:00
|
|
|
--primary-bundle-id "#{fgBundleIdentifier}" \
|
2019-11-12 23:16:01 +08:00
|
|
|
--username "zakalawe@mac.com" \
|
|
|
|
--password "@keychain:FlightGearAppStoreConnectUserName" \
|
|
|
|
--file #{dmgPath}`
|
2015-03-08 09:01:03 +08:00
|
|
|
|
2020-04-03 05:21:20 +08:00
|
|
|
|
2020-05-01 19:00:59 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
puts "Creating full image with data"
|
2015-03-08 09:01:03 +08:00
|
|
|
|
|
|
|
`rsync -a fgdata/ #{resourcesDir}/data`
|
|
|
|
|
2020-04-03 05:21:20 +08:00
|
|
|
# sign the entire bundle
|
|
|
|
puts "Signing full app: #{bundle}"
|
2020-03-18 20:41:42 +08:00
|
|
|
`codesign --force #{codeSignArgs} --keychain #{$keychain} -s "#{$codeSignIdentity}" #{bundle}`
|
2015-03-08 09:01:03 +08:00
|
|
|
|
2018-07-17 16:54:59 +08:00
|
|
|
`rm -f #{dmgFullPath}`
|
2015-03-08 09:01:03 +08:00
|
|
|
`hdiutil create -srcfolder #{dmgDir} #{createArgs} #{dmgFullPath}`
|
2019-11-12 23:16:01 +08:00
|
|
|
|
|
|
|
puts "Notarizing DMG #{dmgFullPath}"
|
|
|
|
|
|
|
|
`xcrun altool --notarize-app \
|
2020-04-03 05:21:20 +08:00
|
|
|
--primary-bundle-id "#{fgBundleIdentifier}" \
|
2019-11-12 23:16:01 +08:00
|
|
|
--username "zakalawe@mac.com" \
|
|
|
|
--password "@keychain:FlightGearAppStoreConnectUserName" \
|
|
|
|
--file #{dmgFullPath}`
|
2020-04-03 05:21:20 +08:00
|
|
|
|
2019-11-12 23:16:01 +08:00
|
|
|
|
|
|
|
puts "Packaging complete"
|
|
|
|
|