Abstract:
To update Firefox addon-sdk, using git repository (https://github.com/mozilla/addon-sdk) is good idea. However, addon-sdk's version and Firefox's version must be corresponding or the cfx command will not work well. So I have written update_addonsdk.rb, which reads git tag
and determine the latest release.
Firefoxのaddon-sdkを更新する簡単な方法はgitリポジトリを使うことですが、sdkのバージョンをFirefox自体のバージョンと合致させなければうまく動きません。
masterはFirefoxのalpha(nightly)版でしか動かないそうです。
そこで次のようなアルゴリズムでaddon-sdkの更新を試みました。
-
git checkout master
で一旦masterに戻す -
git pull
で更新する -
git tag
でタグ一覧を取得、数字とドットのみの行を取り出しソート、最大のものを取り出す -
git checkout VER
で当該バージョンに移行する
update_addonsdk.rb
# !/usr/bin/env ruby
devnull=['mswin','mingw'].any?(&RUBY_PLATFORM.method(:include?)) ? 'NUL' : '/dev/null'
com='git checkout master 2>'+devnull
puts '[*] '+com
IO.popen(com,'r'){|f|f.read}
com='git pull'
puts '[*] '+com
IO.popen(com,'r'){|f|f.read}
com='git tag'
puts '[*] '+com
ver='master'
IO.popen(com,'r'){|f|
a=f.readlines.map(&:chomp).select{|e|
e=~/^[\d\.]+$/
}.map{|e|
e.split('.').map(&:to_i)
}.max
ver=a.join('.')
}
puts '[+] selected '+ver
com='git checkout '+ver+' 2>'+devnull
puts '[*] '+com
IO.popen(com,'r'){|f|f.read}