Forum: Ruby setup.rb problems and possible fix

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Trans (Guest)
on 2006-04-03 00:36
(Received via mailing list)
As I reported earlier there seems to be some issues with setup.rb.
After investingating deeper it appears that there may be some very odd
bugs lurking within. There's is a lot of good code in their, but I'm
starting to think it may need a fresh rewrite. Of course, it doesn't
help that Minero whas not responded to my emails, and appearnetly does
not frequent this list.

The issue I'm currently facing is that setup.rb does not seem to be
handling --prefix correctly. While most things get the prefix, the lib/
directory does not. Looking at the code one sees these relavent pieces.

  def install_dir_lib(rel)
    install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644
  end

  def install_files(list, dest, mode)
    mkdir_p dest, @config.install_prefix
    list.each do |fname|
      install fname, dest, mode, @config.install_prefix
    end
  end

  def mkdir_p(dirname, prefix = nil)
    dirname = prefix + File.expand_path(dirname) if prefix
    $stderr.puts "mkdir -p #{dirname}" if verbose?
    return if no_harm?

    # Does not check '/', it's too abnormal.
    dirs = File.expand_path(dirname).split(%r<(?=/)>)
    if /\A[a-z]:\z/i =~ dirs[0]
      disk = dirs.shift
      dirs[0] = disk + dirs[0]
    end
    dirs.each_index do |idx|
      path = dirs[0..idx].join('')
      Dir.mkdir path unless File.dir?(path)
    end
  end

Looking at this code one would expect that @config.install_prefix would
hold the value of the --prefix command line option. But oddly it does
not --I'm almost inclined to think that this is unintended in itself.
But assuming that's not how it's supposed to be, then obviously
config('rbdir') must contain the prefix. But it doesn't. The other
similiar config dirs do, config('bindir'), config('datadir'), etc. But
not 'rbdir', which leads me to think that it should actually be
'libdir'.

T.

P.S. Although I've now subscribed to the RubyGems mailing list and
posted my simple solution to the datadir problem, no one has responded
whatsoever.
Trans (Guest)
on 2006-04-03 05:39
(Received via mailing list)
Sigh, 'libdir' isn't right either.

Is setup.rb just not being supported any longer?

T.
Erik H. (Guest)
on 2006-04-04 18:21
(Received via mailing list)
On 2006-04-02 13:29:04 -0700, "Trans" <removed_email_address@domain.invalid> 
said:

> As I reported earlier there seems to be some issues with setup.rb.
> After investingating deeper it appears that there may be some very odd
> bugs lurking within. There's is a lot of good code in their, but I'm
> starting to think it may need a fresh rewrite. Of course, it doesn't
> help that Minero whas not responded to my emails, and appearnetly does
> not frequent this list.

I have had similar troubles. Testing was added in a recent version (a
few months ago, IIRC) and was broken. I sent him a patch and recieved
no response.

If anyone knows a sure-fire way to get ahold of him so I know he at
least had the opportunity to consider my patch (which I'm using in my
own projects without trouble), I'd love to know, please privately
contact me.

It sounds like this will end up becoming a (for lack of a better term)
"qmail patching nightmare" unless we get some consensus on what tool to
use or how to provide patches for it. On another note, having tools
like this in the standard distribution (like MakeMaker is for perl)
would really eliminate a lot of the problems.
Trans (Guest)
on 2006-04-04 23:44
(Received via mailing list)
> On another note, having tools like this in the standard distribution
> (like MakeMaker is for perl) would really eliminate a lot of the problems.

I agree. In fact, it never occured to me before, but why isn't setup.rb
a part of the Ruby distibution?

Well, I'm not sure what I'm going to do about it yet. I may re-write
it. The code looks more like C than Ruby and I find it difficult to
work on (I still haven't figured out where the prefix is worked-in
exactly). Have any interested in such a project?

T.
Kirk H. (Guest)
on 2006-04-05 00:03
(Received via mailing list)
On Tuesday 04 April 2006 1:43 pm, Trans wrote:

> Well, I'm not sure what I'm going to do about it yet. I may re-write
> it. The code looks more like C than Ruby and I find it difficult to
> work on (I still haven't figured out where the prefix is worked-in
> exactly). Have any interested in such a project?

Wait.  Before you rewrite it, take a look at the work that was done on
package.rb by Mauricio F. and Chris Neukirchen.  They haven't
worked
on it since late last year, but even as is, it is a very capable system.
I
only have one released package, at the moment, that uses it, but I have
several more in various states of progress towards new releases, and
they all
use it.  It works well, is flexible, and is terribly simple to use.  And
it
can be used in a way that is compatible with existing setup.rb uses.

The URL that I have for it is:

http://chneukirchen.org/repos/package


Kirk H.
Trans (Guest)
on 2006-04-05 07:26
(Received via mailing list)
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:

  # 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?

T.
Jeff C. (Guest)
on 2006-04-05 08:03
Coming from the Windows world, this thread really interests me.
Installing software on Windows has traditionally been a challenge; in
recent years Microsoft started including an installation engine (Windows
Installer) in the OS.  Then .NET promised "xcopy deployment" but that
wasn't quite true either (except in the simplest of cases).

1. I've seen usage of setup.rb and just assumed it came with my
one-click-installer distribution.  Until I read this thread I didn't
think twice about it, but what exactly is/was the mission of setup.rb?

2. If we're just talking about copying files, etc. I wonder if using
Rake would be better than an entirely new system.  Would it be possible
to just use Rake tasks as a way to install files?

3. What happens in a Ruby setup other than copying files into the right
folders?

4. Is there a desire/need for OS-specific setup options?  For example,
on Windows, "good" installers place an entry in the Control Panel's
Add/Remove list, and also probably install some shortcut icons in the
start menu, etc.  And maybe there are similar needs on *nix and Mac?

Please pardon any stupid-sounding newbie questions here... any light
that could be shed would be much appreciated :-)

Thanks
Jeff
www.softiesonrails.com
Kirk H. (Guest)
on 2006-04-05 18:43
(Received via mailing list)
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 H.
This topic is locked and can not be replied to.