Created
July 10, 2010 19:16
-
-
Save stepheneb/470947 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
| # | |
| # file get-mdns.rb | |
| # | |
| # Create a local git repository in mdns-responder-git of | |
| # Apple's mDNSResponder open source implementation of zeroconf | |
| # | |
| # See: http://opensource.apple.com/source/mDNSResponder/ | |
| # | |
| # Each mDNSResponder archive located here: | |
| # http://www.opensource.apple.com/tarballs/mDNSResponder/ | |
| # is expanded and committed. | |
| # | |
| require 'rubygems' | |
| require 'open-uri' | |
| require 'hpricot' | |
| require 'fileutils' | |
| def version(tgz_name) | |
| tgz_name[/mDNSResponder-(.+)\.tar\.gz/, 1] | |
| end | |
| LOG=true | |
| def do_cmd(cmd) | |
| puts "*** cmd: #{cmd}" if LOG | |
| system(cmd) | |
| end | |
| d = Hpricot(open("http://www.opensource.apple.com/tarballs/mDNSResponder/")) | |
| r = d.search("//a").select { |a| a[:href][/^mDNSResponder.*/] }. | |
| collect { |a| a[:href] }.uniq. | |
| sort { |a,b| version(a).to_f <=> version(b).to_f } | |
| FileUtils.rm_rf('mdns-responder-tgz-files') | |
| FileUtils.mkdir_p('mdns-responder-tgz-files') | |
| Dir.chdir('mdns-responder-tgz-files') do | |
| r.each do |tgz_file| | |
| source = "http://www.opensource.apple.com/tarballs/mDNSResponder/#{tgz_file}" | |
| destination = "mdns-responder-tgz-files/#{tgz_file}" | |
| do_cmd("curl #{source} -o \"#{tgz_file}\"") | |
| end | |
| end | |
| FileUtils.rm_rf('mdns-responder-git') | |
| FileUtils.mkdir_p('mdns-responder-git') | |
| Dir.chdir('mdns-responder-git') do | |
| do_cmd("git init") | |
| r.each do |tgz_file| | |
| do_cmd("rm -rf *") | |
| do_cmd("tar --strip-components 1 -xzf ../mdns-responder-tgz-files/#{tgz_file}") | |
| do_cmd("git add *") | |
| do_cmd("git commit -am '#{tgz_file}'") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment