[Pkg-ruby-extras-maintainers] r685 - in tools: . gemsd

Daigo Moriwaki daigo-guest at costa.debian.org
Sun Jul 16 10:24:14 UTC 2006


Author: daigo-guest
Date: 2006-07-16 10:23:56 +0000 (Sun, 16 Jul 2006)
New Revision: 685

Added:
   tools/gemsd/
   tools/gemsd/README
   tools/gemsd/convert_gems.rb
   tools/gemsd/dh_rubygems.rb
   tools/gemsd/download_gems.rb
   tools/gemsd/utils.rb
Log:
Initial files for converting gems to debs

Added: tools/gemsd/README
===================================================================
--- tools/gemsd/README	2006-07-16 07:08:09 UTC (rev 684)
+++ tools/gemsd/README	2006-07-16 10:23:56 UTC (rev 685)
@@ -0,0 +1,10 @@
+
+1. cron: download_gems.rb
+2. cron: convert_gems.rb
+   for debuging, $ nice convert_gems.rb |tee convert_gems.log
+3. manual: upload files from ~/archive/experimental to people.debian.org
+   $ rsync -auvvzH -e ssh ~/archive/experimental people.debian.org:public_html/deb/
+   deb     http://people.debian.org/~daigo/deb experimental/
+   deb-src http://people.debian.org/~daigo/deb experimental/
+
+

Added: tools/gemsd/convert_gems.rb
===================================================================
--- tools/gemsd/convert_gems.rb	2006-07-16 07:08:09 UTC (rev 684)
+++ tools/gemsd/convert_gems.rb	2006-07-16 10:23:56 UTC (rev 685)
@@ -0,0 +1,88 @@
+#!/usr/bin/ruby
+# Copyright (C) 2006 Daigo Moriwaki <daigo at debian.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+$:.unshift( File.dirname(__FILE__).untaint )
+require 'utils'
+
+#Signal.trap(:INT) {exit 1}
+
+###
+# Executes the dput command, which is supposed to subsequently run
+# mini-dinstall, so that the deb packages generated can be downloaded in a
+# apt-line by users. Configurations (dput.cf and mini-dinstall.conf) are
+# required. 
+#
+def dput
+  files = File.join(DIR_SUCCESS, "*.changes")
+  unless system "nice dput -f local #{files}"
+    exit $?
+  end
+end
+
+###
+# Makes a deb package (*.deb) from a gem_file (*.gem). dh_rubygems.rb does
+# almost tasks.  If the package is successfully built it goes to DIR_SUCCESS,
+# otherwise DIR_FAIL.
+#
+def make_deb(gem)
+  safe_mkdir(DIR_TMP_BUILD)
+  saved_pwd = Dir.pwd
+  Dir.chdir(DIR_TMP_BUILD)
+  begin
+    puts "Making deb #{gem}..."
+    if system("nice #{DH_RUBYGEMS} #{gem}")
+      puts "  success."
+      FileUtils.mv(Dir.glob(File.join(DIR_TMP_BUILD, "rubygems-*")), 
+                   DIR_SUCCESS,
+                   :force => true)
+    else
+      puts "  fail."
+      #FileUtils.mv(Dir.glob(File.join(DIR_TMP_BUILD, "rubygems-*")), DIR_FAIL, :force => true)
+      faildir = File.join(DIR_FAIL, File.basename(gem))
+      safe_mkdir(faildir)
+      FileUtils.cp_r(DIR_TMP_BUILD, faildir)
+    end
+  ensure
+    FileUtils.rm_rf(DIR_TMP_BUILD)
+    Dir.chdir(saved_pwd)
+  end
+end
+
+###
+# Tests if a gem_file exists in the directory. If so (returns true), you don't
+# have to go futher, othereise returns false
+#
+def build_skip?(gem_file)
+  deb = gempath2debpath(gem_file)
+  return File.exists?(File.join(DIR_SUCCESS, deb))
+end
+
+
+##
+# Main 
+#
+if __FILE__ == $0
+  gems = Dir.glob(File.join(DIR_DOWNLOAD, "*.gem"))
+  gems.each do |gem_file|
+    if build_skip?(gem_file)
+      puts "Skipped #{gem_file}."
+    else
+      make_deb(gem_file)
+    end
+  end
+  dput
+end


Property changes on: tools/gemsd/convert_gems.rb
___________________________________________________________________
Name: svn:executable
   + *

Added: tools/gemsd/dh_rubygems.rb
===================================================================
--- tools/gemsd/dh_rubygems.rb	2006-07-16 07:08:09 UTC (rev 684)
+++ tools/gemsd/dh_rubygems.rb	2006-07-16 10:23:56 UTC (rev 685)
@@ -0,0 +1,451 @@
+#!/usr/bin/ruby
+# File Name: dh_rubygems.rb
+# Version: 0
+# Author: akira yamada <akira at debian.org>
+# Copyright (C) 2006 Daigo Moriwaki <daigo at debian.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+#
+# Usage:
+#   $ dh_rubygems.rb <gemfile>
+#   $ cd rubygems-<gemname>-<gemversion>
+#   (edit debia/* files)
+#   $ debuild [options]
+#     (ex. debuild --no-tgz-check -us -uc)
+#
+# NOTE: 
+# Template for debian/rules, debian/postinst and debian/prerm is modified
+# version of Debian's dh-make package (version 0.37).
+
+require 'rubygems'
+require 'rubygems/format'
+require 'time'
+require 'fileutils'
+require 'rbconfig'
+
+gem_file = ARGV.shift || Dir.glob('*.gem').first
+begin
+  spec = Gem::Format.from_file_by_path(gem_file).spec
+rescue Exception
+  $stderr.puts "#{File.basename($0)}: #{$!.message}"
+  exit(1)
+end
+
+deb_name_prefix = 'rubygems-'
+deb_version_suffix = '-1' # '-0+0' + (ENV['USER'] || ENV['LOGNAME'] || '') + '.1'
+
+# Debian package name should not contain '_'.
+specname = spec.name.downcase.gsub("_", "-")
+deb_name = deb_name_prefix + specname.downcase
+deb_depends = ['rubygems'] + 
+  spec.dependencies.collect {|dep| deb_name_prefix + dep.to_s.downcase}
+deb_builddeps = 
+  ['debhelper (>> 5)', 'dh-make', 'ruby1.8', 'ruby1.8-dev', 'rubygems (>= 0.9.0-2)'] # + deb_depends
+
+deb_summary = spec.summary
+deb_description = spec.description
+if deb_description.nil? || deb_description.empty?
+  if /\A(.*?)\.\s+(.*)/ =~ spec.summary
+    deb_summary = $1      # the first sentence
+    deb_description = $2  # the rest
+  end
+end
+deb_description ||= ""
+if spec.homepage
+  deb_description += "\nHomepage: #{spec.homepage}"
+end
+deb_description += "\nThis package was automatically generated."
+deb_summary = deb_summary.sub(/\.\s*\z/, '')#.downcase
+deb_description = 
+  deb_description.scan(/.{0,60}\b[.,\s]*/).join("\n").gsub(/^$/, '.').gsub(/^/, ' ')
+
+deb_changelog = spec.files.select {|x| %r!\Achange(?:s|log)[^/]*!i =~ x}
+deb_documents = spec.files.select {|x| %r!\A(?:readme|todo)[^/]*!i =~ x}
+
+replace = {}
+replace['name'] = deb_name
+replace['version'] = spec.version.to_s + deb_version_suffix
+replace['section'] = 'interpreters'
+replace['priority'] = 'optional'
+replace['distribution'] = 'experimental'
+replace['urgency'] = 'low'
+replace['arch'] = spec.extensions.empty? ? 'all' : 'any'
+replace['summary'] = deb_summary
+replace['description'] = deb_description
+replace['build-depends'] = deb_builddeps.join(', ')
+#replace['build-depends-tag'] = spec.extensions.empty? ? 'Build-Depends-Indep' : 'Build-Depends'
+replace['build-depends-tag'] = 'Build-Depends'
+if deb_depends.empty?
+  replace['depends'] = ''
+else
+  replace['depends'] = ', ' + deb_depends.join(', ')
+end
+
+# here is spec.name, not specname because the name of gems is not changed.
+gem_name = spec.name + '-' + spec.version.to_s
+gem_builddir = File.join('debian', deb_name, Gem.dir, 'gems', gem_name)
+replace['changelog'] = 
+  deb_changelog.collect {|x| File.join(gem_builddir, x)}.join(' ')
+replace['documents'] = 
+  deb_documents.collect {|x| File.join(gem_builddir, x)}.join(' ')
+
+replace['ruby-name'] = 
+  File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
+replace['ruby-version'] = 
+  Config::CONFIG['MAJOR'] + '.' + Config::CONFIG['MINOR']
+
+replace['test-files'] = spec.test_files.join(' ')
+#if spec.require_paths.include?('.')
+replace['require-paths'] = gem_name
+#else
+#  replace['require-paths'] = speq.require_paths.collect do |x|
+#    File.join('gems', gem_name, x.to_s)
+#  end.join(' ')
+#end
+
+replace['gem-file'] = gem_file
+replace['gem-name'] = gem_name
+replace['gemspec-file'] = File.join('debian', deb_name, Gem.dir, 'specifications', gem_name + '.gemspec')
+
+template = {}
+name = nil
+DATA.each_line do |line|
+  if /^\[\[\[([^\]]+)\]\]\]$/ =~ line
+    name = $1
+  else
+    template[name] ||= ''
+    template[name] << line
+  end
+end
+template.each_pair do |name, text|
+  replace.each_pair do |keyword, value|
+    text.gsub!(/\#\{#{Regexp.quote(keyword)}\}/, value)
+  end
+end
+
+debdir = deb_name + '-' + spec.version.to_s
+tmp_tmpldir = File.expand_path('tmp-tmpldir')
+begin
+  FileUtils.rm_rf(tmp_tmpldir)
+  Dir.mkdir(tmp_tmpldir)
+
+  File.open(File.join(tmp_tmpldir, 'control'), 'w') {|o| o.print template['debian/control']}
+  File.open(File.join(tmp_tmpldir, 'changelog'), 'w') {|o| o.print template['debian/changelog']}
+  File.open(File.join(tmp_tmpldir, 'rules'), 'w') {|o| o.print template['debian/rules']}
+  #daigo File.open(File.join(tmp_tmpldir, 'postinst'), 'w') {|o| o.print template['debian/postinst']}
+  #daigo File.open(File.join(tmp_tmpldir, 'prerm'), 'w') {|o| o.print template['debian/prerm']}
+
+  Dir.mkdir(debdir)
+  FileUtils.cp(gem_file, debdir)
+  save_pwd = Dir.pwd
+  Dir.chdir(debdir)
+  begin
+    command = "dh_make --createorig --single --packagename #{deb_name} --templates #{tmp_tmpldir}"
+    IO.popen(command, "w+") do |io|
+      io.puts "\n"
+      while l = io.gets do
+        puts l
+      end
+    end
+    unless system("tar czf ../#{debdir}.orig.tar.gz ../#{debdir}.orig")
+      exit $?
+    end
+      
+    FileUtils.rm_rf "../#{debdir}.orig"
+    #system(command)
+    #system('dh_make', '--createorig', '--single', 
+	#'--packagename', deb_name, '--templates', tmp_tmpldir)
+    FileUtils.rm_rf Dir.glob("debian/*.{ex,EX}")
+
+    system("debuild --no-tgz-check -us -uc")
+    status = $?.to_i
+    unless status == 0
+      exit status
+    end
+  ensure
+    Dir.chdir(save_pwd)
+  end
+
+  #daigo File.open(File.join(debdir, 'debian', 'buildgem.rb'), 'w') {|o| o.print template['debian/buildgem.rb']}
+
+ensure
+  FileUtils.rm_rf(tmp_tmpldir)
+end
+
+__END__
+[[[debian/control]]]
+Source: #{name}
+Section: #{section}
+Priority: #{priority}
+Maintainer: #USERNAME# <#EMAIL#>
+#{build-depends-tag}: #{build-depends}
+Standards-Version: #POLICY#
+
+Package: #{name}
+Architecture: #{arch}
+Depends: ${shlibs:Depends}, ${misc:Depends}#{depends}
+Description: #{summary}
+#{description}
+[[[debian/changelog]]]
+#{name} (#{version}) #{distribution}; urgency=#{urgency}
+
+  * Initial Package.
+    This package was automatically generated from #{gem_name}.
+
+ -- #USERNAME# <#EMAIL#>  #DATE#
+
+[[[debian/rules]]]
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+RUBY = #{ruby-name}
+
+
+#DPKG_ARCH#
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O2
+endif
+
+#CONFIGURE#
+
+build: build-stamp
+
+build-stamp: #CONFIGURE_STAMP# #CONFIG_STATUS#
+	dh_testdir
+
+	# Add here commands to compile the package.
+	#docbook-to-man debian/#PACKAGE#.sgml > #PACKAGE#.1
+
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp #CONFIGURE_STAMP#
+
+	# Add here commands to clean up after the build process.
+	-#CLEAN#
+	-rm -rf cache doc gems specifications
+
+	dh_clean #PRESERVE#
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k #PRESERVE#
+	dh_installdirs
+
+	# Add here commands to install the package into debian/#PACKAGE#.
+	##INSTALL#
+	gem install --build-root debian/#PACKAGE# #{gem-file}
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs #{changelog}
+	dh_installdocs #{documents}
+	dh_installexamples
+#	dh_install
+#	dh_installmenu
+#	dh_installdebconf	
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installmime
+#	dh_installinit
+#	dh_installcron
+#	dh_installinfo
+	dh_installman
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+#	dh_perl
+#	dh_python
+	dh_makeshlibs
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install #PHONY_CONFIGURE#
+[[[debian/buildgem.rb]]]
+# This file was originally written by akira yamada.
+# As a special exception, when this file is copied by dh_rubygems.rb into a
+# dh-make output file, you may use that output file without restriction.
+
+require 'fileutils'
+require 'rubygems'
+
+def setup_tmp_gemhome(realpath, tmppath)
+  tmppath = File.expand_path(tmppath)
+  save_cwd = Dir.pwd
+  begin
+    Dir.foreach(realpath) do |name|
+      next if /^\./ =~ name
+      path = File.join(realpath, name)
+
+      type = nil
+      begin
+	Dir.chdir(path)
+	type = :dir
+      rescue Errno::ENOTDIR
+	type = :file
+      end
+
+      Dir.chdir(tmppath)
+      if type == :file
+	File.symlink(path, name)
+      else
+	Dir.mkdir(name)
+	Dir.chdir(name)
+	Dir.foreach(path) do |x|
+	  next if /^\./ =~ x
+	  File.symlink(File.join(path, x), x)
+	end
+      end
+    end
+
+  ensure
+    Dir.chdir(save_cwd)
+  end
+end
+
+def build_gem(path, tmp_gemhome)
+  save_gemhome = ENV['GEM_HOME']
+  begin
+    ENV['GEM_HOME'] = File.expand_path(tmp_gemhome)
+    system('gem', 'install', '-i', 
+      File.expand_path(File.dirname(tmp_gemhome)), path)
+  ensure
+    ENV['GEM_HOME'] = save_gemhome if save_gemhome
+  end
+end
+
+gemhome = Gem.default_dir
+tmp_gemhome = 'tmp-gemhome'
+begin
+  Dir.mkdir(tmp_gemhome)
+  setup_tmp_gemhome(gemhome, tmp_gemhome)
+  build_gem(ARGV.shift, tmp_gemhome)
+ensure
+  FileUtils.rm_rf(tmp_gemhome)
+end
+[[[debian/dirs]]]
+usr/lib/ruby
+usr/share/rubygems
+[[[debian/postinst]]]
+#! /bin/sh
+# postinst script for #PACKAGE#
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+
+case "$1" in
+    configure)
+	ln -s /usr/share/rubygems/#{ruby-version}/gems/#{gem-file} \
+	    /var/cache/rubygems/#{ruby-version}/#{gem-file}
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+[[[debian/prerm]]]
+#! /bin/sh
+# prerm script for #PACKAGE#
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|upgrade|deconfigure)
+#       install-info --quiet --remove /usr/info/#PACKAGE#.info.gz
+	rm -f /var/cache/rubygems/#{ruby-version}/#{gem-file}
+        ;;
+    failed-upgrade)
+        ;;
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+


Property changes on: tools/gemsd/dh_rubygems.rb
___________________________________________________________________
Name: svn:executable
   + *

Added: tools/gemsd/download_gems.rb
===================================================================
--- tools/gemsd/download_gems.rb	2006-07-16 07:08:09 UTC (rev 684)
+++ tools/gemsd/download_gems.rb	2006-07-16 10:23:56 UTC (rev 685)
@@ -0,0 +1,50 @@
+#!/usr/bin/ruby
+# Copyright (C) 2006 Daigo Moriwaki <daigo at debian.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+require 'rubygems'
+require 'rubygems/remote_installer'
+require 'fileutils'
+require "utils"
+
+FileUtils.rm_rf(DIR_DOWNLOAD); safe_mkdir(DIR_DOWNLOAD)
+
+def download_gems(source)
+  rsf = Gem::RemoteSourceFetcher.new(source, nil)
+  puts "Downloading the index for #{source}..."
+  source_index = rsf.source_index
+
+  gems = []
+  source_index.each {|fullname, speck| gems << fullname}
+
+  gems.map do |name|
+    puts "Downloading #{name}..."
+    data = rsf.fetch_path("/gems/#{name}.gem")
+    File.open(File.join(DIR_DOWNLOAD, "#{name}.gem"), "w+") {|f| f.write data}
+  end
+end
+
+
+ri = Gem::RemoteInstaller.new({})
+ri.sources.each do |source|
+  download_gems(source)
+end
+
+
+exit 0
+
+#remote_gemspecs = Gem::RemoteInstaller.new({}).search(//)
+#remote_gemspecs = remote_gemspecs.flatten


Property changes on: tools/gemsd/download_gems.rb
___________________________________________________________________
Name: svn:executable
   + *

Added: tools/gemsd/utils.rb
===================================================================
--- tools/gemsd/utils.rb	2006-07-16 07:08:09 UTC (rev 684)
+++ tools/gemsd/utils.rb	2006-07-16 10:23:56 UTC (rev 685)
@@ -0,0 +1,53 @@
+# Copyright (C) 2006 Daigo Moriwaki <daigo at debian.org>
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+require 'fileutils'
+require 'rubygems'
+require 'rubygems/format'
+
+def safe_mkdir(dir)
+  FileUtils.mkdir_p(dir) unless File.exists?(dir)
+end
+
+###
+# Constants
+#
+
+ROOT          = File.join(ENV["HOME"], "gems"); safe_mkdir(ROOT)
+DIR_DOWNLOAD  = File.join(ROOT, "download"); safe_mkdir(DIR_DOWNLOAD) 
+DIR_TMP_BUILD = File.join(ROOT, "build")
+DIR_SUCCESS   = File.join(ROOT, "success"); safe_mkdir(DIR_SUCCESS)
+DIR_FAIL      = File.join(ROOT, "fail");    safe_mkdir(DIR_FAIL)
+
+DIR_PROGRAM   = File.expand_path(File.dirname(__FILE__))
+DH_RUBYGEMS   = File.join(DIR_PROGRAM, "dh_rubygems.rb")
+
+###
+# Reads a gem file and returns a deb package name with the version.
+# ex. meta_project-0.4.12.gem -> rubygems-meta-project-0.4.12
+#
+def gempath2debpath(gem_file)
+  begin
+    spec = Gem::Format.from_file_by_path(gem_file).spec
+  rescue Exception
+    $stderr.puts "#{File.basename($0)}: #{$!.message}"
+    exit(1)
+  end
+
+  deb_name_prefix = 'rubygems-'
+  specname = spec.name.downcase.gsub("_", "-")
+  deb_name = deb_name_prefix + specname.downcase
+  deb_name + "-" + spec.version.to_s
+end




More information about the pkg-ruby-extras-maintainers mailing list