2011-01-17 23:42:49 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'ERB'
|
2012-06-26 08:17:42 +00:00
|
|
|
require 'fileutils' #I know, no underscore is not ruby-like
|
|
|
|
include FileUtils
|
2011-01-17 23:42:49 +00:00
|
|
|
|
|
|
|
$osgLibs = ['osgFX', 'osgParticle', 'osg', 'osgGA', 'osgText', 'osgUtil', 'osgSim', 'osgViewer', 'osgDB']
|
2012-08-08 13:43:45 +00:00
|
|
|
$osgPlugins = ['ac', 'osg', 'freetype', 'imageio', 'rgb', 'txf', 'mdl', '3ds']
|
2011-01-17 23:42:49 +00: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 13:26:33 +00:00
|
|
|
$codeSignIdentity = ENV['FG_CODESIGN_IDENTITY']
|
|
|
|
puts "Code signing identity is #{$codeSignIdentity}"
|
|
|
|
|
2011-01-17 23:42:49 +00:00
|
|
|
puts "osgVersion=#{osgVersion}, so-number=#{$osgSoVersion}"
|
|
|
|
|
2012-08-08 13:43:45 +00:00
|
|
|
$svnLibs = ['svn_client', 'svn_wc', 'svn_delta', 'svn_diff', 'svn_ra',
|
|
|
|
'svn_ra_local', 'svn_repos', 'svn_fs', 'svn_fs_fs', 'svn_fs_util',
|
2012-08-14 09:46:00 +00:00
|
|
|
'svn_ra_svn', 'svn_subr', 'svn_ra_neon']
|
2012-08-08 13:43:45 +00:00
|
|
|
|
2011-01-17 23:42:49 +00:00
|
|
|
def fix_install_names(object)
|
|
|
|
#puts "fixing install names for #{object}"
|
|
|
|
|
|
|
|
$osgLibs.each do |l|
|
|
|
|
oldName = "lib#{l}.#{$osgSoVersion}.dylib"
|
|
|
|
newName = "@executable_path/../Frameworks/#{oldName}"
|
|
|
|
`install_name_tool -change #{oldName} #{newName} #{object}`
|
|
|
|
end
|
|
|
|
|
|
|
|
oldName = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
|
|
|
|
newName= "@executable_path/../Frameworks/#{oldName}"
|
|
|
|
`install_name_tool -change #{oldName} #{newName} #{object}`
|
|
|
|
end
|
|
|
|
|
2012-08-08 13:43:45 +00:00
|
|
|
$prefixDir=Dir.pwd + "/dist"
|
2011-01-17 23:42:49 +00:00
|
|
|
dmgDir=Dir.pwd + "/image"
|
|
|
|
srcDir=Dir.pwd + "/flightgear"
|
|
|
|
|
2012-08-08 13:43:45 +00:00
|
|
|
def fix_svn_install_names(object)
|
|
|
|
$svnLibs.each do |l|
|
|
|
|
fileName = "lib#{l}-1.0.dylib"
|
|
|
|
newName = "@executable_path/../Frameworks/#{fileName}"
|
2012-08-22 21:34:27 +00:00
|
|
|
`install_name_tool -change #{fileName} #{newName} #{object}`
|
2012-08-08 13:43:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def copy_svn_libs()
|
|
|
|
puts "Copying Subversion client libraries"
|
|
|
|
$svnLibs.each do |l|
|
|
|
|
libFile = "lib#{l}-1.0.dylib"
|
|
|
|
path = "#{$frameworksDir}/#{libFile}"
|
|
|
|
`cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
|
|
|
|
fix_svn_install_names(path)
|
2012-08-22 21:34:27 +00:00
|
|
|
# `install_name_tool -id #{libFile} #{path}`
|
2012-08-08 13:43:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def code_sign(path)
|
|
|
|
puts "Signing #{path}"
|
2012-08-13 13:26:33 +00:00
|
|
|
`codesign -s "#{$codeSignIdentity}" #{path}`
|
2012-08-08 13:43:45 +00:00
|
|
|
end
|
|
|
|
|
2011-01-17 23:42:49 +00:00
|
|
|
|
|
|
|
puts "Erasing previous image dir"
|
|
|
|
`rm -rf #{dmgDir}`
|
|
|
|
|
|
|
|
bundle=dmgDir + "/FlightGear.app"
|
|
|
|
contents=bundle + "/Contents"
|
|
|
|
macosDir=contents + "/MacOS"
|
2012-08-08 13:43:45 +00:00
|
|
|
$frameworksDir=contents +"/Frameworks"
|
2011-01-17 23:42:49 +00:00
|
|
|
resourcesDir=contents+"/Resources"
|
|
|
|
osgPluginsDir=contents+"/PlugIns/osgPlugins-#{osgVersion}"
|
|
|
|
|
2012-08-28 12:47:37 +00:00
|
|
|
# for writing copyright year to Info.plist
|
|
|
|
t = Time.new
|
|
|
|
fgCurrentYear = t.year
|
2011-01-17 23:42:49 +00:00
|
|
|
|
2011-01-18 14:24:31 +00:00
|
|
|
fgVersion = File.read("#{srcDir}/version").strip
|
|
|
|
volName="\"FlightGear #{fgVersion}\""
|
|
|
|
|
2012-06-26 09:22:46 +00:00
|
|
|
dmgPath = Dir.pwd + "/output/fg_mac_#{fgVersion}.dmg"
|
2011-01-17 23:42:49 +00:00
|
|
|
|
|
|
|
puts "Creating directory structure"
|
|
|
|
`mkdir -p #{macosDir}`
|
2012-08-08 13:43:45 +00:00
|
|
|
`mkdir -p #{$frameworksDir}`
|
2011-01-17 23:42:49 +00:00
|
|
|
`mkdir -p #{resourcesDir}`
|
|
|
|
`mkdir -p #{osgPluginsDir}`
|
|
|
|
|
|
|
|
puts "Copying binaries"
|
2012-09-17 22:02:55 +00:00
|
|
|
bins = ['fgfs', 'fgjs', 'fgcom', 'fgviewer']
|
2011-01-17 23:42:49 +00:00
|
|
|
bins.each do |b|
|
2012-08-08 13:43:45 +00:00
|
|
|
if !File.exist?("#{$prefixDir}/bin/#{b}")
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
outPath = "#{macosDir}/#{b}"
|
|
|
|
`cp #{$prefixDir}/bin/#{b} #{outPath}`
|
|
|
|
fix_install_names(outPath)
|
|
|
|
fix_svn_install_names(outPath)
|
2011-01-17 23:42:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
puts "copying libraries"
|
|
|
|
$osgLibs.each do |l|
|
|
|
|
libFile = "lib#{l}.#{$osgSoVersion}.dylib"
|
2012-08-08 13:43:45 +00:00
|
|
|
`cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
|
|
|
|
fix_install_names("#{$frameworksDir}/#{libFile}")
|
2011-01-17 23:42:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# and not forgetting OpenThreads
|
|
|
|
libFile = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
|
2012-08-08 13:43:45 +00:00
|
|
|
`cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
|
2011-01-17 23:42:49 +00:00
|
|
|
|
|
|
|
$osgPlugins.each do |p|
|
|
|
|
pluginFile = "osgdb_#{p}.so"
|
2012-08-08 13:43:45 +00:00
|
|
|
`cp #{$prefixDir}/lib/osgPlugins-#{osgVersion}/#{pluginFile} #{osgPluginsDir}`
|
|
|
|
fix_install_names("#{osgPluginsDir}/#{pluginFile}")
|
2011-01-17 23:42:49 +00:00
|
|
|
end
|
|
|
|
|
2012-08-12 16:03:10 +00:00
|
|
|
copy_svn_libs()
|
2012-08-08 13:43:45 +00:00
|
|
|
|
2011-01-17 23:42:49 +00:00
|
|
|
# Macflightgear launcher
|
2011-01-18 14:24:31 +00:00
|
|
|
puts "Copying Macflightgear launcher files"
|
2011-01-18 19:28:03 +00:00
|
|
|
|
2012-07-31 18:02:26 +00:00
|
|
|
Dir.chdir "maclauncher/FlightGearOSX" do
|
2011-01-18 19:28:03 +00:00
|
|
|
`cp FlightGear #{macosDir}`
|
2013-01-31 09:26:45 +00:00
|
|
|
`rsync -a *.rb *.lproj *.sh *.tiff *.html #{resourcesDir}`
|
2011-01-18 19:28:03 +00:00
|
|
|
end
|
2012-08-08 15:27:04 +00:00
|
|
|
|
|
|
|
if File.exist?("#{$prefixDir}/bin/fgcom-data")
|
|
|
|
puts "Copying FGCom data files"
|
|
|
|
`ditto #{$prefixDir}/bin/fgcom-data #{resourcesDir}/fgcom-data`
|
|
|
|
end
|
|
|
|
|
2011-01-17 23:42:49 +00:00
|
|
|
# Info.plist
|
2011-01-18 14:24:31 +00:00
|
|
|
template = File.read("Info.plist.in")
|
2011-01-17 23:42:49 +00: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 09:34:00 +00:00
|
|
|
|
2013-01-30 15:46:15 +00:00
|
|
|
# move documentation to a public place
|
|
|
|
`mv fgdata/Docs/FGShortRef.pdf #{dmgDir}`
|
|
|
|
`mv fgdata/Docs/getstart.pdf #{dmgDir}`
|
|
|
|
|
2012-08-02 09:34:00 +00:00
|
|
|
puts "Copying base package files into the image"
|
|
|
|
`rsync -a fgdata/ #{resourcesDir}/data`
|
2011-01-17 23:42:49 +00:00
|
|
|
|
2012-08-14 09:46:00 +00:00
|
|
|
# code sign all executables in MacOS dir. Do this last since reource
|
|
|
|
# changes will invalidate the signature!
|
|
|
|
Dir.foreach(macosDir) do |b|
|
|
|
|
if b == '.' or b == '..' then
|
|
|
|
next
|
|
|
|
end
|
|
|
|
code_sign("#{macosDir}/#{b}")
|
|
|
|
end
|
|
|
|
|
2011-01-17 23:42:49 +00:00
|
|
|
puts "Creating DMG"
|
|
|
|
|
|
|
|
createArgs = "-format UDBZ -imagekey bzip2-level=9 -quiet -volname #{volName}"
|
|
|
|
|
|
|
|
`rm #{dmgPath}`
|
|
|
|
`hdiutil create -srcfolder #{dmgDir} #{createArgs} #{dmgPath}`
|