2010-11-02 09:29:12 +00:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
|
|
|
|
require 'ERB'
|
|
|
|
|
|
|
|
$osgLibs = ['osgFX', 'osgParticle', 'osg', 'osgGA', 'osgText', 'osgUtil', 'osgSim', 'osgViewer', 'osgDB']
|
2012-08-07 13:03:29 +00:00
|
|
|
$osgPlugins = ['ac', 'osg', 'freetype', 'imageio', 'rgb', 'txf', 'mdl', '3ds', 'dds']
|
2010-11-04 18:47:17 +00:00
|
|
|
|
2010-11-05 08:33:17 +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 10:40:24 +00:00
|
|
|
$codeSignIdentity = ENV['FG_CODESIGN_IDENTITY']
|
|
|
|
puts "Code signing identity is #{$codeSignIdentity}"
|
2012-08-13 10:27:04 +00:00
|
|
|
|
2010-11-05 08:33:17 +00:00
|
|
|
puts "osgVersion=#{osgVersion}, so-number=#{$osgSoVersion}"
|
2010-11-04 18:47:17 +00:00
|
|
|
|
2012-08-07 13:03:29 +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 08:47:10 +00:00
|
|
|
'svn_ra_svn', 'svn_subr', 'svn_ra_neon']
|
2012-08-07 13:03:29 +00:00
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
def fix_install_names(object)
|
|
|
|
#puts "fixing install names for #{object}"
|
|
|
|
|
|
|
|
$osgLibs.each do |l|
|
2010-11-04 18:47:17 +00:00
|
|
|
oldName = "lib#{l}.#{$osgSoVersion}.dylib"
|
2010-11-02 09:29:12 +00:00
|
|
|
newName = "@executable_path/../Frameworks/#{oldName}"
|
|
|
|
`install_name_tool -change #{oldName} #{newName} #{object}`
|
|
|
|
end
|
|
|
|
|
2010-11-05 08:33:17 +00:00
|
|
|
oldName = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
|
2010-11-02 09:29:12 +00:00
|
|
|
newName= "@executable_path/../Frameworks/#{oldName}"
|
|
|
|
`install_name_tool -change #{oldName} #{newName} #{object}`
|
|
|
|
end
|
|
|
|
|
2012-08-07 13:03:29 +00:00
|
|
|
$prefixDir=Dir.pwd + "/dist"
|
2010-11-02 09:29:12 +00:00
|
|
|
dmgDir=Dir.pwd + "/image"
|
|
|
|
srcDir=Dir.pwd + "/flightgear"
|
2010-11-14 22:58:21 +00:00
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
puts "Erasing previous image dir"
|
|
|
|
`rm -rf #{dmgDir}`
|
|
|
|
|
|
|
|
bundle=dmgDir + "/FlightGear.app"
|
|
|
|
contents=bundle + "/Contents"
|
|
|
|
macosDir=contents + "/MacOS"
|
2012-08-07 13:03:29 +00:00
|
|
|
$frameworksDir=contents +"/Frameworks"
|
2010-11-02 09:29:12 +00:00
|
|
|
resourcesDir=contents+"/Resources"
|
2010-11-03 08:32:59 +00:00
|
|
|
osgPluginsDir=contents+"/PlugIns/osgPlugins-#{osgVersion}"
|
2010-11-02 09:29:12 +00:00
|
|
|
volName="\"FlightGear Nightly Build\""
|
|
|
|
|
2012-08-22 21:31:59 +00:00
|
|
|
def fix_svn_install_names(object)
|
|
|
|
$svnLibs.each do |l|
|
|
|
|
fileName = "lib#{l}-1.0.dylib"
|
|
|
|
newName = "@executable_path/../Frameworks/#{fileName}"
|
|
|
|
`install_name_tool -change #{fileName} #{newName} #{object}`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-07 13:03:29 +00:00
|
|
|
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:31:59 +00:00
|
|
|
# `install_name_tool -id #{libFile} #{path}`
|
2012-08-07 13:03:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def code_sign(path)
|
|
|
|
puts "Signing #{path}"
|
2012-08-13 10:40:24 +00:00
|
|
|
`codesign -s "#{$codeSignIdentity}" #{path}`
|
2012-08-07 13:03:29 +00:00
|
|
|
end
|
|
|
|
|
2011-01-24 13:35:01 +00:00
|
|
|
fgVersion = File.read("#{srcDir}/version").strip
|
2010-11-14 18:14:23 +00:00
|
|
|
|
2011-01-24 13:48:01 +00:00
|
|
|
dmgPath = Dir.pwd + "/fg_mac_nightly_#{fgVersion}.dmg"
|
2010-11-14 22:58:21 +00:00
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
puts "Creating directory structure"
|
|
|
|
`mkdir -p #{macosDir}`
|
2012-08-07 13:03:29 +00:00
|
|
|
`mkdir -p #{$frameworksDir}`
|
2010-11-02 09:29:12 +00:00
|
|
|
`mkdir -p #{resourcesDir}`
|
|
|
|
`mkdir -p #{osgPluginsDir}`
|
|
|
|
|
|
|
|
puts "Copying binaries"
|
2012-08-07 13:03:29 +00:00
|
|
|
bins = ['fgfs', 'fgjs', 'fgcom']
|
2010-11-02 09:29:12 +00:00
|
|
|
bins.each do |b|
|
2012-08-07 13:03:29 +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)
|
2010-11-02 09:29:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
puts "copying libraries"
|
|
|
|
$osgLibs.each do |l|
|
2010-11-04 18:47:17 +00:00
|
|
|
libFile = "lib#{l}.#{$osgSoVersion}.dylib"
|
2012-08-07 13:03:29 +00:00
|
|
|
`cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
|
|
|
|
fix_install_names("#{$frameworksDir}/#{libFile}")
|
2010-11-02 09:29:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# and not forgetting OpenThreads
|
2010-11-05 08:33:17 +00:00
|
|
|
libFile = "libOpenThreads.#{$openThreadsSoVersion}.dylib"
|
2012-08-07 13:03:29 +00:00
|
|
|
`cp #{$prefixDir}/lib/#{libFile} #{$frameworksDir}`
|
2010-11-02 09:29:12 +00:00
|
|
|
|
|
|
|
$osgPlugins.each do |p|
|
|
|
|
pluginFile = "osgdb_#{p}.so"
|
2012-08-07 13:03:29 +00:00
|
|
|
`cp #{$prefixDir}/lib/osgPlugins-#{osgVersion}/#{pluginFile} #{osgPluginsDir}`
|
2010-11-02 09:29:12 +00:00
|
|
|
fix_install_names("#{osgPluginsDir}/#{pluginFile}")
|
|
|
|
end
|
|
|
|
|
2012-08-11 14:23:17 +00:00
|
|
|
copy_svn_libs()
|
2012-08-07 13:03:29 +00:00
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
# Info.plist
|
|
|
|
template = File.read("#{srcDir}/package/mac/nightly.plist.in")
|
|
|
|
output = ERB.new(template).result(binding)
|
|
|
|
|
|
|
|
File.open("#{contents}/Info.plist", 'w') { |f|
|
|
|
|
f.write(output)
|
|
|
|
}
|
|
|
|
|
|
|
|
`cp #{srcDir}/package/mac/nightly-readme.rtf #{dmgDir}/ReadMe.rtf`
|
|
|
|
`cp #{srcDir}/package/mac/FlightGear.icns #{resourcesDir}/FlightGear.icns`
|
|
|
|
`cp #{srcDir}/COPYING #{dmgDir}`
|
|
|
|
|
2011-01-24 13:35:01 +00:00
|
|
|
# Macflightgear launcher
|
2012-08-07 13:03:29 +00:00
|
|
|
if File.exist?("FlightGearOSX")
|
|
|
|
puts "Copying Macflightgear launcher files"
|
|
|
|
Dir.chdir "FlightGearOSX" do
|
|
|
|
`cp FlightGear #{macosDir}`
|
|
|
|
`rsync -a *.rb *.lproj *.sh *.tiff #{resourcesDir}`
|
|
|
|
end
|
2011-01-24 13:35:01 +00:00
|
|
|
end
|
|
|
|
|
2012-08-08 14:57:07 +00:00
|
|
|
if File.exist?("#{$prefixDir}/bin/fgcom-data")
|
|
|
|
puts "Copying FGCom data files"
|
|
|
|
`ditto #{$prefixDir}/bin/fgcom-data #{resourcesDir}/fgcom-data`
|
|
|
|
end
|
|
|
|
|
2012-08-14 09:01:09 +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
|
|
|
|
|
2010-11-02 09:29:12 +00:00
|
|
|
puts "Creating DMG"
|
|
|
|
|
|
|
|
createArgs = "-format UDBZ -imagekey bzip2-level=9 -quiet -volname #{volName}"
|
|
|
|
|
|
|
|
`rm #{dmgPath}`
|
|
|
|
`hdiutil create -srcfolder #{dmgDir} #{createArgs} #{dmgPath}`
|