Dear Lazyweb: Gem Platforms

As you may or may not have heard, RubyGems will be merged into Ruby 1.9 sometime in October. Before this can happen RubyGems needs to automatically install dependencies based on platforms. Fortunately I've got the automatic install part written. Unfortunately I don't know if I've got figuring out the platforms right. This is where you come in.

Dear Lazyweb,

Here's my proposal for how we recognize platforms. From
Config::CONFIG, take the target_os and run it through a case
statement to figure out OS and OS version (if any). Combine the
target_cpu, OS and OS version. This value is your platform.

(There will be a rubygems-platforms.gem much like sources.gem that can
be updated as necessary.)

Using the tattle data (http://tattle.rubygarden.org), the following code recognizes 26 unique platforms:

def match(cpu, os)
   cpu = case cpu
         when /i\d86/ then 'x86'
         else cpu
         end

   os = case os
        when /cygwin/ then [ 'cygwin', nil ]
        when /darwin(\d+)?/ then [ 'darwin', $1 ]
        when /freebsd(\d+)/ then [ 'freebsd', $1 ]
        when /^java([\d.]*)/ then [ 'java', $1 ]
        when /linux/ then [ 'linux', $1 ]
        when /mingw32/ then [ 'mingw32', nil ]
        when /mswin32/ then [ 'mswin32', nil ]
        when /openbsd(\d+.\d+)/ then [ 'openbsd', $1 ]
        when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
        else [ 'unknown', nil ]
        end

   [cpu, os].flatten.compact.join("-")
end

require 'rbconfig'

target_cpu = Config::CONFIG['target_cpu']
target_os = Config::CONFIG['target_os']

puts "Your target_cpu is: #{target_cpu.inspect}"
puts "Your target_os is: #{target_os.inspect}"
puts "Your platform is: #{match(target_cpu, target_os).inspect}"

Lazyweb, I have two major questions for you:

Did I get something wrong? Am I using autoconf's target_os correctly? Is Solaris 2.8 really incompatible with Solaris 2.9? What is a 64-bit Windows' target_os value?

Do I have all the platforms people run Ruby and RubyGems on? If the answer to this one is no, do this: <kbd>gem install tattle; tattle</

···

. (Yes, AIX users, I'm talking to you.)

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars

"java" is actually not used in either CPU or OS strings in the config hash
currently (this is reflected in the tattle data). JRuby uses "java" either
in the 'arch' or 'target' strings:

irb(main):002:0> Config::CONFIG.select {|k,v| v =~ /java/}
=> [["archdir",
"/Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/java"],
["arch", "i386-java1.5"], ["build", "java1.5"], ["sitearchdir",
"/Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/java"],
["target", "java1.5"]]
irb(main):003:0> RUBY_PLATFORM
=> "java"

Can you work 'arch' into the logic somehow? Or suggest an alternative way
to ensure that JRuby/java platform is possible for gems?

/Nick

···

On 8/20/07, Eric Hodel <drbrain@segment7.net> wrote:

As you may or may not have heard, RubyGems will be merged into Ruby
1.9 sometime in October. Before this can happen RubyGems needs to
automatically install dependencies based on platforms. Fortunately
I've got the automatic install part written. Unfortunately I don't
know if I've got figuring out the platforms right. This is where you
come in.

Dear Lazyweb,

Here's my proposal for how we recognize platforms. From
Config::CONFIG, take the target_os and run it through a case
statement to figure out OS and OS version (if any). Combine the
target_cpu, OS and OS version. This value is your platform.

(There will be a rubygems-platforms.gem much like sources.gem that can
be updated as necessary.)

Using the tattle data (http://tattle.rubygarden.org), the following
code recognizes 26 unique platforms:

def match(cpu, os)
   cpu = case cpu
         when /i\d86/ then 'x86'
         else cpu
         end

   os = case os
        when /cygwin/ then [ 'cygwin', nil ]
        when /darwin(\d+)?/ then [ 'darwin', $1 ]
        when /freebsd(\d+)/ then [ 'freebsd', $1 ]
        when /^java([\d.]*)/ then [ 'java', $1 ]
        when /linux/ then [ 'linux', $1 ]
        when /mingw32/ then [ 'mingw32', nil ]
        when /mswin32/ then [ 'mswin32', nil ]
        when /openbsd(\d+.\d+)/ then [ 'openbsd', $1 ]
        when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
        else [ 'unknown', nil ]
        end

   [cpu, os].flatten.compact.join("-")
end

you will be a hero if this happens: honestly!

a @ http://drawohara.com/

···

On Aug 20, 2007, at 9:10 PM, Eric Hodel wrote:

As you may or may not have heard, RubyGems will be merged into Ruby 1.9 sometime in October. Before this can happen RubyGems needs to automatically install dependencies based on platforms. Fortunately I've got the automatic install part written.

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

As you may or may not have heard, RubyGems will be merged into Ruby
1.9 sometime in October. Before this can happen RubyGems needs to
automatically install dependencies based on platforms. Fortunately
I've got the automatic install part written. Unfortunately I don't
know if I've got figuring out the platforms right. This is where you > come in.

Dear Lazyweb,

Here's my proposal for how we recognize platforms. From
Config::CONFIG, take the target_os and run it through a case
statement to figure out OS and OS version (if any). Combine the
target_cpu, OS and OS version. This value is your platform.

<snip>

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
>. (Yes, AIX users, I'm talking to you.)

I wasn't able to use tattle (because I couldn't get rubygems to
install, because I couldn't get zlib to build), but here's all the
rbconfig info I have:

djberge@td191> uname -a
HP-UX td191 B.11.31 U 9000/800 3397116299 unlimited-user license

ALLOCA =>
AR => ar
ARCHFILE =>
ARCH_FLAG =>
AS => as
ASFLAGS =>
CC => cc -Ae -s
CCDLFLAGS => +Z
CFLAGS => -g
COMMON_HEADERS =>
COMMON_LIBS =>
COMMON_MACROS =>
CP => cp
CPP => cc -Ae -s -E
CPPFLAGS =>
CPPOUTFILE => -o conftest.i
DESTDIR =>
DLDFLAGS => -E
DLDLIBS => -lc
DLEXT => sl
DLEXT2 =>
DLLWRAP =>
ECHO_C => \c
ECHO_N =>
ECHO_T =>
EGREP => grep -E
ENABLE_SHARED => no
EXEEXT =>
EXPORT_PREFIX =>
EXTOUT => .ext
EXTSTATIC =>
GNU_LD => no
INSTALL => /opt/imake/bin/install -c
INSTALL_DATA => /opt/imake/bin/install -c -m 644
INSTALL_PROGRAM => /opt/imake/bin/install -c
INSTALL_SCRIPT => /opt/imake/bin/install -c
LDFLAGS => -L.
LDSHARED => ld -b
LIBEXT => a
LIBPATHENV => SHLIB_PATH
LIBPATHFLAG => -L%s
LIBRUBY => libruby-static.a
LIBRUBYARG => -lruby-static
LIBRUBYARG_SHARED =>
LIBRUBYARG_STATIC => -lruby-static
LIBRUBY_A => libruby-static.a
LIBRUBY_ALIASES => libruby.so
LIBRUBY_DLDFLAGS => -E
LIBRUBY_LDSHARED => ld -b
LIBRUBY_SO => libruby.so.1.8.6
LIBS => -ldld -lcrypt -lm
LINK_SO =>
LN_S => ln -s
MAINLIBS =>
MAJOR => 1
MAKEDIRS => mkdir -p
MAKEFILES => Makefile
MANTYPE => man
MINIRUBY => ./miniruby
MINOR => 8
NM =>
NROFF => /usr/bin/nroff
OBJDUMP =>
OBJEXT => o
OUTFLAG => -o
PACKAGE_BUGREPORT =>
PACKAGE_NAME =>
PACKAGE_STRING =>
PACKAGE_TARNAME =>
PACKAGE_VERSION =>
PATH_SEPARATOR => :
PREP => miniruby
RANLIB => ranlib
RDOCTARGET =>
RM => rm -f
RPATHFLAG =>
RUBYW_INSTALL_NAME =>
RUBY_INSTALL_NAME => ruby
RUBY_SO_NAME => ruby
RUNRUBY => ./miniruby $(srcdir)/runruby.rb --extout=.ext --
SET_MAKE =>
SHELL => /bin/sh
SOLIBS =>
STATIC =>
STRIP => strip
TEENY => 6
TRY_LINK =>
WINDRES =>
XCFLAGS => -DRUBY_EXPORT -DYYMAXDEPTH=300
XLDFLAGS => -Wl,-E
YACC => yacc -Nl40000 -Nm40000
arch => hppa2.0w-hpux11.31
archdir => /house/djberge/lib/ruby/1.8/hppa2.0w-hpux11.31
bindir => /house/djberge/bin
build => hppa2.0w-hp-hpux11.31
build_alias =>
build_cpu => hppa2.0w
build_os => hpux11.31
build_vendor => hp
configure_args => '--prefix=/house/djberge' 'CC=cc -Ae -s'
datadir => /house/djberge/share
exec_prefix => /house/djberge
host => hppa2.0w-hp-hpux11.31
host_alias =>
host_cpu => hppa2.0w
host_os => hpux11.31
host_vendor => hp
includedir => /house/djberge/include
infodir => /house/djberge/info
libdir => /house/djberge/lib
libexecdir => /house/djberge/libexec
localstatedir => /house/djberge/var
mandir => /house/djberge/man
oldincludedir => /usr/include
prefix => /house/djberge
ruby_install_name => ruby
ruby_version => 1.8
rubylibdir => /house/djberge/lib/ruby/1.8
rubyw_install_name =>
sbindir => /house/djberge/sbin
setup => Setup
sharedstatedir => /house/djberge/com
sitearch => hppa2.0w-hpux11.31
sitearchdir => /house/djberge/lib/ruby/site_ruby/1.8/hppa2.0w-
hpux11.31
sitedir => /house/djberge/lib/ruby/site_ruby
sitelibdir => /house/djberge/lib/ruby/site_ruby/1.8
sysconfdir => /house/djberge/etc
target => hppa2.0w-hp-hpux11.31
target_alias =>
target_cpu => hppa2.0w
target_os => hpux11.31
target_vendor => hp
topdir => /house/djberge/lib/ruby/1.8/hppa2.0w-hpux11.31

Regards,

Dan

···

On Aug 20, 9:10 pm, Eric Hodel <drbr...@segment7.net> wrote:

Hi Eric

···

On Tue, 2007-08-21 at 12:10 +0900, Eric Hodel wrote:

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
>. (Yes, AIX users, I'm talking to you.)

NetBSD and DragonFly seem to be missing. Unfortunately I don't have any
machines running those to run tattle on (I suspect the arch strings
would be "netbsd" and "dragonfly" though). Maybe someone can confirm.

Andre

Hi

I'm not sure if there were any AIX-aware gems ;-), but

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
>. (Yes, AIX users, I'm talking to you.)

done.

···

--
Yutaka KANEMOTO

Can you hack in developer/user dependencies while you're in there? :wink:

--Jeremy

···

On 8/20/07, Eric Hodel <drbrain@segment7.net> wrote:

As you may or may not have heard, RubyGems will be merged into Ruby
1.9 sometime in October. Before this can happen RubyGems needs to
automatically install dependencies based on platforms. Fortunately
I've got the automatic install part written. Unfortunately I don't
know if I've got figuring out the platforms right. This is where you
come in.

Dear Lazyweb,

Here's my proposal for how we recognize platforms. From
Config::CONFIG, take the target_os and run it through a case
statement to figure out OS and OS version (if any). Combine the
target_cpu, OS and OS version. This value is your platform.

(There will be a rubygems-platforms.gem much like sources.gem that can
be updated as necessary.)

Using the tattle data (http://tattle.rubygarden.org), the following
code recognizes 26 unique platforms:

def match(cpu, os)
   cpu = case cpu
         when /i\d86/ then 'x86'
         else cpu
         end

   os = case os
        when /cygwin/ then [ 'cygwin', nil ]
        when /darwin(\d+)?/ then [ 'darwin', $1 ]
        when /freebsd(\d+)/ then [ 'freebsd', $1 ]
        when /^java([\d.]*)/ then [ 'java', $1 ]
        when /linux/ then [ 'linux', $1 ]
        when /mingw32/ then [ 'mingw32', nil ]
        when /mswin32/ then [ 'mswin32', nil ]
        when /openbsd(\d+.\d+)/ then [ 'openbsd', $1 ]
        when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
        else [ 'unknown', nil ]
        end

   [cpu, os].flatten.compact.join("-")
end

require 'rbconfig'

target_cpu = Config::CONFIG['target_cpu']
target_os = Config::CONFIG['target_os']

puts "Your target_cpu is: #{target_cpu.inspect}"
puts "Your target_os is: #{target_os.inspect}"
puts "Your platform is: #{match(target_cpu, target_os).inspect}"

Lazyweb, I have two major questions for you:

Did I get something wrong? Am I using autoconf's target_os
correctly? Is Solaris 2.8 really incompatible with Solaris 2.9?
What is a 64-bit Windows' target_os value?

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
>. (Yes, AIX users, I'm talking to you.)

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars

--
http://www.jeremymcanally.com/

My free Ruby e-book:
http://www.humblelittlerubybook.com/book/

My blogs:

http://www.rubyinpractice.com/

How's this? It now uses Config::CONFIG['arch']:

def match(arch)
   cpu, os = arch.split '-', 2
   cpu, os = nil, cpu if os.nil? # java

   cpu = case cpu
         when /i\d86/ then 'x86'
         else cpu
         end

   os = case os
        when /cygwin/ then [ 'cygwin', nil ]
        when /darwin(\d+)?/ then [ 'darwin', $1 ]
        when /freebsd(\d+)/ then [ 'freebsd', $1 ]
        when /^java$/ then [ 'java', nil ]
        when /^java([\d.]*)/ then [ 'java', $1 ]
        when /linux/ then [ 'linux', $1 ]
        when /mingw32/ then [ 'mingw32', nil ]
        when /mswin32/ then [ 'mswin32', nil ]
        when /openbsd(\d+\.\d+)/ then [ 'openbsd', $1 ]
        when /solaris(\d+\.\d+)/ then [ 'solaris', $1 ]
        else [ 'unknown', nil ]
        end

   [cpu, os].flatten.compact.join("-")
end

require 'rbconfig'

arch = Config::CONFIG['arch']
cpu, os = arch.split '-', 2

puts "Your cpu is: #{cpu.inspect}"
puts "Your os is: #{os.inspect}"
puts "Your platform is: #{match(arch).inspect}"

raise "need a tattle arch dump yaml file!" if ARGV.empty?

puts "loading archs..."

require 'yaml'
archs = YAML.load(ARGF.read)['arch'].keys

def recognize(*archs)
   unmatched = {}
   seen = {}

   archs.each do |arch|
     platform = match arch

     seen[platform] = true
     unmatched[arch] = true if platform =~ /-unknown$/
   end

   return unmatched.keys, seen.keys
end

unmatched, unique = recognize(*archs)

puts "found #{unique.length} unique platforms"
puts
puts unique.sort.join("\n")

unless unmatched.empty? then
   puts
   puts "unmatched"
   puts
   puts unmatched.join("\n")
end

···

On Aug 20, 2007, at 22:11, Nick Sieger wrote:

"java" is actually not used in either CPU or OS strings in the config hash
currently (this is reflected in the tattle data). JRuby uses "java" either
in the 'arch' or 'target' strings:

irb(main):002:0> Config::CONFIG.select {|k,v| v =~ /java/}
=> [["archdir",
"/Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/java"],
["arch", "i386-java1.5"], ["build", "java1.5"], ["sitearchdir",
"/Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/1.8/java"],
["target", "java1.5"]]
irb(main):003:0> RUBY_PLATFORM
=> "java"

Can you work 'arch' into the logic somehow? Or suggest an alternative way
to ensure that JRuby/java platform is possible for gems?

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars

Beautiful, awesome, thanks!

···

On Aug 21, 2007, at 12:14, Daniel Berger wrote:

On Aug 20, 9:10 pm, Eric Hodel <drbr...@segment7.net> wrote:

As you may or may not have heard, RubyGems will be merged into Ruby
1.9 sometime in October. Before this can happen RubyGems needs to
automatically install dependencies based on platforms. Fortunately
I've got the automatic install part written. Unfortunately I don't
know if I've got figuring out the platforms right. This is where you > come in.

Dear Lazyweb,

Here's my proposal for how we recognize platforms. From
Config::CONFIG, take the target_os and run it through a case
statement to figure out OS and OS version (if any). Combine the
target_cpu, OS and OS version. This value is your platform.

<snip>

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
>. (Yes, AIX users, I'm talking to you.)

I wasn't able to use tattle (because I couldn't get rubygems to
install, because I couldn't get zlib to build), but here's all the
rbconfig info I have:

[...]
arch => hppa2.0w-hpux11.31
[...]

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars

There's no such feature request in the tracker, so nobody actually wants them.

···

On Aug 22, 2007, at 07:57, Jeremy McAnally wrote:

Can you hack in developer/user dependencies while you're in there? :wink:

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars

I'm not sure if there were any AIX-aware gems ;-), but

There aren't any platform-aware gems for much more than win32. I still want to get the best coverage possible.

Do I have all the platforms people run Ruby and RubyGems on? If the
answer to this one is no, do this: <kbd>gem install tattle; tattle</
>. (Yes, AIX users, I'm talking to you.)

done.

Thanks much!

···

On Aug 22, 2007, at 07:48, Yutaka Kanemoto wrote:

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars

Sent one for NetBSD. It's "netbsdelf" actually.

Andre

···

On Wed, 2007-08-22 at 09:40 +0900, Andre Nathan wrote:

NetBSD and DragonFly seem to be missing. Unfortunately I don't have any
machines running those to run tattle on (I suspect the arch strings
would be "netbsd" and "dragonfly" though). Maybe someone can confirm.

Looks good, thanks.

/Nick

···

On 8/20/07, Eric Hodel <drbrain@segment7.net> wrote:

On Aug 20, 2007, at 22:11, Nick Sieger wrote:

> "java" is actually not used in either CPU or OS strings in the
> config hash
> currently (this is reflected in the tattle data). JRuby uses
> "java" either
> in the 'arch' or 'target' strings:
>
> irb(main):002:0> Config::CONFIG.select {|k,v| v =~ /java/}
> => [["archdir",
> "/Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/
> 1.8/java"],
> ["arch", "i386-java1.5"], ["build", "java1.5"], ["sitearchdir",
> "/Users/nicksieger/Projects/jruby/trunk/jruby/lib/ruby/site_ruby/
> 1.8/java"],
> ["target", "java1.5"]]
> irb(main):003:0> RUBY_PLATFORM
> => "java"
>
> Can you work 'arch' into the logic somehow? Or suggest an
> alternative way
> to ensure that JRuby/java platform is possible for gems?

How's this? It now uses Config::CONFIG['arch']:

Thanks!

···

On Aug 23, 2007, at 06:54, Andre Nathan wrote:

On Wed, 2007-08-22 at 09:40 +0900, Andre Nathan wrote:

NetBSD and DragonFly seem to be missing. Unfortunately I don't have any
machines running those to run tattle on (I suspect the arch strings
would be "netbsd" and "dragonfly" though). Maybe someone can confirm.

Sent one for NetBSD. It's "netbsdelf" actually.

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars