Created
September 12, 2013 23:30
-
-
Save aidansteele/6545186 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cfpropertylist' | |
raise "#{$0}: Usage: #{$0} SourceSkin.bundle Customisations.bundle TargetSkin.bundle" unless ARGV.count == 3 | |
source, custom, target = ARGV | |
CONFIG_NAME = "configuration.plist" | |
def plist_from_path(path) | |
CFPropertyList.native_types(CFPropertyList::List.new(:file => path).value) if File.exists?(path) | |
end | |
# do it | |
`cp -R #{source} #{target}` unless source == target | |
`rsync -av --exclude=**/#{CONFIG_NAME} #{custom}/ #{target}` | |
Dir["#{custom}/**/#{CONFIG_NAME}"].each do |changes_path| | |
rel_path = changes_path[custom.length..-1] | |
config_path = File.join(source, rel_path) | |
config = plist_from_path config_path | |
changes = plist_from_path changes_path | |
config.merge! changes | |
File.open(File.join(target, rel_path), "w") {|f| f.write(config.to_plist) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment