4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Updating Firefox's addon-sdk easily

Posted at

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の更新を試みました。

  1. git checkout masterで一旦masterに戻す
  2. git pullで更新する
  3. git tagでタグ一覧を取得、数字とドットのみの行を取り出しソート、最大のものを取り出す
  4. 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}
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?