[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: make_gem.rb

From: Kouhei Sutou <kou_at_cozmixng.org>
Date: 2007-04-08 03:56:22 CEST

Hi DJ,

> I've been tweaking make_dist.py to use make_gem.rb, but a couple of

Great!

> First, can make_gem.rb be tweaked to put the output file in a
> directory specified on the commandline?
>
> And second, can it be tweaked to only pull in the files and subdirs it
> needs from the dist tree? Currently it seems to be pulling in
> everything from the specified directory (which was meant to be just
> the ruby zip tree, I think Kou said), but it'd be easier for me to
> specify the already-built full dist directory and have make_gem.rb be
> smart enough to just include the subdirs it needs.

What about the attached patch?

You can use like the following:
  % ruby make_gem.rb --output-dir=DIST_DIR DIR/README.txt DIR/ruby DIR/licenses DIR/share

Thanks,

--
kou

Index: build/win32/make_gem.rb
===================================================================
--- build/win32/make_gem.rb (revision 24496)
+++ build/win32/make_gem.rb (working copy)
@@ -1,29 +1,56 @@
-# -*- ruby -*-
+#!/usr/bin/env ruby
 
-def usage
- puts "#{$0} target_directory"
+require 'optparse'
+require 'ostruct'
+require 'tmpdir'
+require 'fileutils'
+
+options = OpenStruct.new
+options.output_dir = File.expand_path(Dir.pwd)
+
+opts = OptionParser.new do |opts|
+ opts.banner += " DIRECTORIES"
+ opts.on("-oDIRECTORY", "--output-dir=DIRECTORY",
+ "Output generated gem to DIRECTORY",
+ "[#{options.output_dir}]") do |dir|
+ options.output_dir = File.expand_path(dir)
+ end
+
+ opts.separator ""
+
+ opts.on("-h", "--help", "Show this message") do
+ puts opts
+ exit
+ end
 end
 
-if ARGV.size < 1
- usage
+target_dirs = opts.parse!(ARGV)
+if target_dirs.empty?
+ puts opts
   exit 1
 end
 
-target_dir = ARGV.shift
-
-if target_dir == "--help"
- usage
- exit
+target_dirs.each do |dir|
+ next unless File.basename(dir) == "ruby"
+ base_dir = File.expand_path(dir)
+ $LOAD_PATH.unshift(File.join(base_dir, "ext"))
+ $LOAD_PATH.unshift(File.join(base_dir, "lib"))
 end
 
-base_dir = File.expand_path(File.join(target_dir, "ruby"))
-$LOAD_PATH.unshift(File.join(base_dir, "ext"))
-$LOAD_PATH.unshift(File.join(base_dir, "lib"))
-
 require 'svn/core'
 
-gem_file = nil
-Dir.chdir(target_dir) do
+
+archive_dir = File.join(Dir.tmpdir, "svn-ruby-gem-#{Process.pid}")
+FileUtils.mkdir(archive_dir)
+at_exit {FileUtils.rm_rf(archive_dir)}
+
+target_dirs.each do |dir|
+ FileUtils.cp_r(dir, archive_dir)
+end
+
+
+generated_gem_file = nil
+Dir.chdir(archive_dir) do
   require 'rubygems'
   Gem.manage_gems
 
@@ -42,6 +69,8 @@
     s.required_ruby_version = '>= 1.8.2'
   end
 
- gem_file = File.expand_path(Gem::Builder.new(spec).build)
+ generated_gem_file = File.expand_path(Gem::Builder.new(spec).build)
 end
-FileUtils.mv(gem_file, File.basename(gem_file))
+
+gem_file = File.join(options.output_dir, File.basename(generated_gem_file))
+FileUtils.mv(generated_gem_file, gem_file)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Apr 8 03:56:41 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.