setup.rb problems and possible fix

T

Trans

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.
 
T

Trans

Sigh, 'libdir' isn't right either.

Is setup.rb just not being supported any longer?

T.
 
E

Erik Hollensbe

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.
 
T

Trans

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.
 
K

Kirk Haines

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 Fernandez 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 Haines
 
T

Trans

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.
 
J

Jeff Cohen

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
 
T

Trans

Hmm... I tried out this package.rb and to be honest I'm suprised it's
working for you. It was onely after I first ran it direcly from my
project's directory, where it tired to install make beleive files like
"fuutils.rb", that this is meant to be required and used in a Rakefile
or something like that. Thankfully, it didn't actually copy anything.
But I'm not sure why --it acted like it did, there was no error. So
then I tried to "fix" it with this:

Package.setup("1.0") {
bin *Dir['bin/**/*']
lib *Dir['lib/**/*']
doc *Dir['doc/**/*']
ext *Dir['ext/**/*']
data *Dir['data/**/*']
conf *Dir['conf/**/*']
}

Which seems like must be the basic minimal. Well, trying that it goes
to install files in all the wrong places. First line:

mkdir -p /usr/local/lib/site_ruby/1.8/lib/reap

Notice the extra lib/ dir right before my project's name. It did this
with every directory. Thankfully, it again did not actually install
anything --so I count my lucky stars.

At this point I'm missing the whol "easy to use" part. :-(

BTW, I see in the --help that it has a --destdir option, which is
exactly what I wish setup.rb had.
 
T

Trans

Jeff said:
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).

You've got that right. In my experience I've had to use a commerical
program like InstallShield to create a proper Windows install. Now I've
never tried it with Ruby, so I have no idea where Ruby libs ought to go
in a Windows system, but I assume it relects the unix layout, just
stored somewhere under Programs/ruby, or something like that.
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?

Hmm... well, setup.rb allows one to manually install a program/library.
You download the archive, unpack it, cd into it, and type 'ruby
setup.rb'. Done. But honestly I have no idea if setup.rb works with
Windows. I assume it does b/c it depend on ruby's own install setup
--but that's fully an assumption on my part.
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?

You could, you could even write your own stand-alone script, and many
have. But that's a limited solution. Setup.rb takes into account many
factors. It looks at your current installation to figure out where to
put things by default. It also compiles extensions. And it allows you
to set command line options to adjust those.
3. What happens in a Ruby setup other than copying files into the right
folders?

Besides compiling extensions, nothing.
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?

Which is exactly why for Windows a good installer is generally a
commercial application like Installshield. In the long run I am working
on targeting specific OSes. Windows will no doubt be a substantial
challenge.
Please pardon any stupid-sounding newbie questions here... any light
that could be shed would be much appreciated :)

Not stupid at all. It can be complicated.

T.
 
E

Erik Hollensbe

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.

I would be happy to work with you on this, or get setup.rb to a point
where it's in a managable state with multiple contributors/maintainers
so handling patches wouldn't be an issue.

I like the simplicity of setup.rb, and the discussion of package.rb
leaves me wondering whether working with that would be worth it.
 
T

Trans

Erik said:
I would be happy to work with you on this, or get setup.rb to a point
where it's in a managable state with multiple contributors/maintainers
so handling patches wouldn't be an issue.

I like the simplicity of setup.rb, and the discussion of package.rb
leaves me wondering whether working with that would be worth it.

I too was leaning toward cleaning up setup.rb at first, but after
hacking on it and looking a package.rb again I've decided Kirk Haines
has the right idea.

While package.rb still needs improvement to be a little easier to use
and to catch up to the capabilites of setup.rb, it is not far off, plus
it does things that setup.rb cannot, and importantly the code is
reasonably well written and maintainable.

I've been in contact with Christian Neukirchen, (one of) the original
author(s), and Kirk Haines who said he plans to continue with it's
developent soon. (Christian said he didn't have the time but asks we
submit patches back to him.)

So what about taking a closer look a package.rb and see if you'd like
to work with us on improving it?

Thanks,
T.
 
E

Erik Hollensbe

I too was leaning toward cleaning up setup.rb at first, but after
hacking on it and looking a package.rb again I've decided Kirk Haines
has the right idea.

While package.rb still needs improvement to be a little easier to use
and to catch up to the capabilites of setup.rb, it is not far off, plus
it does things that setup.rb cannot, and importantly the code is
reasonably well written and maintainable.

I've been in contact with Christian Neukirchen, (one of) the original
author(s), and Kirk Haines who said he plans to continue with it's
developent soon. (Christian said he didn't have the time but asks we
submit patches back to him.)

So what about taking a closer look a package.rb and see if you'd like
to work with us on improving it?


Sounds like a great idea. I'll contact you off-list when I have some
time to get geared up (this is going to be a busy week for me), if you
don't mind.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top