lib/choctop/appcast.rb in choctop-0.9.0 vs lib/choctop/appcast.rb in choctop-0.9.1
- old
+ new
@@ -4,12 +4,12 @@
end
def make_appcast
app_name = File.basename(File.expand_path('.'))
- FileUtils.mkdir_p "appcast/build"
- appcast = File.open("appcast/build/#{appcast_filename}", 'w')
+ FileUtils.mkdir_p "#{build_path}"
+ appcast = File.open("#{build_path}/#{appcast_filename}", 'w')
xml = Builder::XmlMarkup.new(:target => appcast, :indent => 2)
xml.instruct!
xml.rss('xmlns:atom' => "http://www.w3.org/2005/Atom",
@@ -25,30 +25,48 @@
xml.atom(:link, :href => "#{base_url}/#{appcast_filename}",
:rel => "self", :type => "application/rss+xml")
xml.item do
xml.title("#{name} #{version}")
- xml.tag! "sparkle:releaseNotesLink", release_notes_link
+ xml.tag! "sparkle:releaseNotesLink", "#{base_url}/#{release_notes}"
xml.pubDate Time.now.to_s(:rfc822) #(File.mtime(pkg))
xml.guid("#{name}-#{version}", :isPermaLink => "false")
xml.enclosure(:url => "#{base_url}/#{pkg_name}",
:length => "#{File.size(pkg)}",
:type => "application/dmg",
- :"sparkle:version" => version)
+ :"sparkle:version" => version,
+ :"sparkle:dsaSignature" => dsa_signature)
end
end
end
end
def make_index_redirect
- File.open("appcast/build/index.php", 'w') do |f|
+ File.open("#{build_path}/index.php", 'w') do |f|
f << %Q{<?php header("Location: #{pkg_relative_url}"); ?>}
end
end
def upload_appcast
_host = host.blank? ? "" : "#{host}:"
sh %{rsync -aCv appcast/build/ #{_host}#{remote_dir}}
end
+ # Returns a file path to the dsa_priv.pem file
+ # If private key + public key haven't been generated yet then
+ # generate them
+ def private_key
+ unless File.exists?('dsa_priv.pem')
+ puts "Creating new private and public keys for signing the DMG..."
+ `openssl dsaparam 2048 < /dev/urandom > dsaparam.pem`
+ `openssl gendsa dsaparam.pem -out dsa_priv.pem`
+ `openssl dsa -in dsa_priv.pem -pubout -out dsa_pub.pem`
+ `rm dsaparam.pem`
+ end
+ File.expand_path('dsa_priv.pem')
+ end
+
+ def dsa_signature
+ @dsa_signature ||= `openssl dgst -sha1 -binary < "#{pkg}" | openssl dgst -dss1 -sign "#{private_key}" | openssl enc -base64`
+ end
end
ChocTop.send(:include, ChocTop::Appcast)