Xu Xiaodong avatar Xu Xiaodong committed 7f86c08

add create_gem_ebuild.rb

Comments (0)

Files changed (2)

 Some useful scripts for Gentoo Linux.
 
 + create\_ebuild.pl: create ebuild for Perl module
++ create\_gem\_ebuild.rb: create ebuild for Rubygems
 + not\_dep\_pkg.pl: check orphan packages
 + reinstall\_driver.pl: reinstall drivers
 + update\_kernel.pl: update Gentoo kernel

create_gem_ebuild.rb

+#!/usr/bin/env ruby
+#
+# name:      create_gem_ebuild.rb, create ebuild for rubygems
+# author:    Xu Xiaodong <xxdlhy@gmail.com>
+# license:   GPL
+# created:   2011 May 07
+# modified:  2011 May 07
+#
+
+require 'uri'
+require 'yajl/http_stream'
+
+class Ebuild
+  def initialize(name)
+    @name = name
+  end
+
+  def create
+    url = URI.parse("http://rubygems.org/api/v1/gems/#{@name}.json")
+    Yajl::HttpStream.get(url) do |metainfo|
+      desc = metainfo['info']
+      ver  = metainfo['version']
+      home = metainfo['homepage_uri']
+
+      Dir.chdir('/usr/local/portage/dev-ruby')
+      Dir.mkdir(@name)
+      Dir.chdir(@name)
+
+      lines = []
+      lines << %Q{# Copyright 1999-2011 Gentoo Foundation}
+      lines << %Q{# Distributed under the terms of the GNU General Public License v2}
+      lines << %Q{}
+      lines << %Q{EAPI=3}
+      lines << %Q{USE_RUBY="ruby19"}
+      lines << %Q{}
+      lines << %Q{RUBY_FAKEGEM_BINWRAP=""}
+      lines << %Q{}
+      lines << %Q{RUBY_FAKEGEM_TASK_DOC=""}
+      lines << %Q{RUBY_FAKEGEM_TASK_TEST=""}
+      lines << %Q{}
+      lines << %Q{inherit ruby-fakegem}
+      lines << %Q{}
+      lines << %Q{DESCRIPTION="#{desc}"}
+      lines << %Q{HOMEPAGE="#{home}"}
+      lines << %Q{}
+      lines << %Q{LICENSE="MIT"}
+      lines << %Q{SLOT="3.0"}
+      lines << %Q{KEYWORDS="~amd64 ~x86"}
+      lines << %Q{}
+      lines << %Q{IUSE=""}
+      lines.join("\n")
+
+      f = File.open("#{@name}-#{ver}.ebuild", 'w')
+      f.puts lines
+      f.close
+
+      system('ebuild', "#{@name}-#{ver}.ebuild", 'manifest')
+    end
+  end
+end
+
+if __FILE__ == $0
+  if ARGV.empty?
+    puts 'Usage: create_gem_ebuild.rb <gem>'
+  else
+    ARGV.each do |gem|
+      eb = Ebuild.new(gem)
+      eb.create
+    end
+  end
+end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.