From: Kirk Haines Date: 2006-04-05T23:42:24+09:00 Subject: Re: setup.rb problems and possible fix On Tuesday 04 April 2006 9:23 pm, Trans wrote: > Very interesting. Thanks for making me aware of this. I'm curious about > a couple of things though. I wonder about this script involved. Eg. > > Package.setup("1.0") { > ... > } > > Is that neccessary for every project? If so, is there a minimal > default? I found the available docs/examples of this a bit confusing. > Do the commands confom to a standard repo structure? For example: The Package.setup() call is what handles the actual installation tasks. The '1.0' that is passed in tells it which packaging specification to use (and right now, 1.0 is the only one that is defined). The aoki() method looks like it was intended to work with a standard setup.rb directory structure: Package.setup('1.0') { aoki } Yes, the docs are very, very minimalistic. A little work here and there, though, and package.rb could be very, very nice. Here's the current setup script for the upcoming IOWA release: ----- basedir = File.dirname(__FILE__) $:.push(basedir) require 'external/package' Dir.chdir(basedir) Package.setup("1.0") { name "IOWA" lib ["iowa.rb","iowa_webrick.rb","iowa_mongrel.rb"] lib *Dir["iowa/**/*.rb"] lib "mod_iowa.rb" => "apache/mod_iowa.rb" begin require 'tmail' rescue LoadError # No tmail; install ours. translate(:lib, 'external/tmail/' => '') lib *Dir["external/tmail/**/*.rb"] lib 'external/tmail/tmail/parser.y' end bin "iowa_fcgi_handler.rb" unit_test Dir["test/TC*.rb"] } ----- One thing I like about package.rb is that while it will work to install packages laid out according to the setup.rb convention, it is simple and flexible enough to work with other data structures. This allows me to structure my source in a way that makes sense for me and for the project, and still easily create an installation script that does what I want. > # all .rb files under foo/ are installed under foo/ in the specified > libdir > lib *Dir["foo/**/*.rb"] > > Does that mean my repo dir /lib/foo will map to distro /lib/foo? Or > does it mean repo /foo maps to distro /lib/foo? That means that in your package, there is a foo/ directory. Everything in it that ends in .rb will be installed into the Ruby sitelib/foo/ Thanks, Kirk Haines