I know we already mentioned this before on the list but I couldn''t find it in the archives. Is there a way to differentiate the versions for ruby/mswin32 so that I could run a command like: # sudo gem install mongrel --source=http://mongrel.rubyforge.org/releases/ --include-dependencies --version 1.0 and have it not prompt me like this: Select which gem to install for your platform (i686-linux) 1. mongrel 1.0 (ruby) 2. mongrel 1.0 (mswin32) 3. Cancel installation my feeble attempts at scripting this and trying to automatically pipe or echo 1 into the installation are failing. Anyone know how to do this automatically, or could we somehow add a number or letter to the version? -- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com
Charles Brian Quinn wrote:> I know we already mentioned this before on the list but I couldn''t > find it in the archives. Is there a way to differentiate the versions > for ruby/mswin32 so that I could run a command like: > > # sudo gem install mongrel > --source=http://mongrel.rubyforge.org/releases/ --include-dependencies > --version 1.0 > > and have it not prompt me like this: > > Select which gem to install for your platform (i686-linux) > 1. mongrel 1.0 (ruby) > 2. mongrel 1.0 (mswin32) > 3. Cancel installation > > my feeble attempts at scripting this and trying to automatically pipe > or echo 1 into the installation are failing. > > Anyone know how to do this automatically, or could we somehow add a > number or letter to the version? > >I believe this thread has what you are looking for: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/226938 Regards, Steven
On 12/21/06, Charles Brian Quinn <me at seebq.com> wrote:> I know we already mentioned this before on the list but I couldn''t > find it in the archives. Is there a way to differentiate the versions > for ruby/mswin32 so that I could run a command like: > > # sudo gem install mongrel > --source=http://mongrel.rubyforge.org/releases/ --include-dependencies > --version 1.0 > > and have it not prompt me like this: > > Select which gem to install for your platform (i686-linux) > 1. mongrel 1.0 (ruby) > 2. mongrel 1.0 (mswin32) > 3. Cancel installation > > my feeble attempts at scripting this and trying to automatically pipe > or echo 1 into the installation are failing. > > Anyone know how to do this automatically, or could we somehow add a > number or letter to the version? >That''s a rubygem limitation. You could manually download the gem: wget http://mongrel.rubyforge.org/releases/gems/mongrel-1.0.gem or http://mongrel.rubyforge.org/releases/gems/mongrel-1.0-mswin32.gem and do: gem install path/to/gem-name.gem maybe you could ask the rubygem guys or fill a bug report on their tracker: http://rubyforge.org/tracker/?group_id=126 -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi
Thanks Steven, This is using Jamis'' net/ssh library and using: sudo cmd do |channel, stream, data| data.each_line do | line | to regex match lines and type in input. this could work, but i was hoping for bash or something simpler.... Guess that means it''s time to move my all of my shell scripts over to ruby (except for the one that installs ruby) ;-) Thanks! On 12/21/06, Steven Hansen <runner at berkeley.edu> wrote:> Charles Brian Quinn wrote: > > I know we already mentioned this before on the list but I couldn''t > > find it in the archives. Is there a way to differentiate the versions > > for ruby/mswin32 so that I could run a command like: > > > > # sudo gem install mongrel > > --source=http://mongrel.rubyforge.org/releases/ --include-dependencies > > --version 1.0 > > > > and have it not prompt me like this: > > > > Select which gem to install for your platform (i686-linux) > > 1. mongrel 1.0 (ruby) > > 2. mongrel 1.0 (mswin32) > > 3. Cancel installation > > > > my feeble attempts at scripting this and trying to automatically pipe > > or echo 1 into the installation are failing. > > > > Anyone know how to do this automatically, or could we somehow add a > > number or letter to the version? > > > > > > I believe this thread has what you are looking for: > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/226938 > > Regards, > Steven > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com
On Dec 21, 2006, at 11:13 AM, Charles Brian Quinn wrote:> Thanks Steven, > > This is using Jamis'' net/ssh library and using: > > sudo cmd do |channel, stream, data| > data.each_line do | line | > > to regex match lines and type in input. this could work, but i was > hoping for bash or something simpler.... > > Guess that means it''s time to move my all of my shell scripts over to > ruby (except for the one that installs ruby) ;-) > > Thanks!Charles- You and me both. I didn''t want to spend the time writing bash scripts for this when I need to do it on tons of machines anyway. So the script he linked to is actually a capistrano plugin. Take the file and put it somewhere in your load path and then require it from a capistrano recipe file and then you can use it like this: require ''cap_gem'' task :install_gems, :roles => :app do gem.select ''mongrel'' , ''http://mongrel.rubyforge.org/releases'' gem.install ''mongrel'', ''http://mongrel.rubyforge.org/releases'' , ''1.0'' end select will select the most recent versions for the current platform and install it. install will install a specific version but won''t auto select from a menu. So is there are two or more versions of a gem then you want to use select. Here is the more current version of the plugin for cap. This one supports the --source option. require ''rubygems'' require ''capistrano'' # Installs within Capistrano as the plugin _gem_. # Prefix all calls to the library with <tt>gem.</tt> # Manages installing gems and versioned gems. module Gem # Default install command # # * doesn''t install documentation # * installs all required dependencies automatically. # GEM_INSTALL="gem install -y --no-rdoc" # Upgrade the *gem* system to the latest version. Runs via *sudo* def update_system sudo "gem update --system" end # Updates all the installed gems to the latest version. Runs via *sudo*. # Don''t use this command if any of the gems require a version selection. def upgrade sudo "gem update --no-rdoc" end # Removes old versions of gems from installation area. def cleanup sudo "gem cleanup" end # Installs the gems detailed in +packages+, selecting version +version+ if # specified. # # +packages+ can be a single string or an array of strings. # def install(packages, source=nil, version=nil) sudo "#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # {source ? ''--source=''+source : nil } #{packages.to_a.join('' '')}" end def uninstall(package) sudo "gem uninstall #{package}" do |channel, stream, data| data.each_line do |line| if line =~ /\[Yn\]/ channel.send_data "Y\n" end end end end # Auto selects a gem from a list and installs it. # # *gem* has no mechanism on the command line of disambiguating builds for # different platforms, and instead asks the user. This method has the necessary # conversation to select the +version+ relevant to +platform+ (or the one nearest # the top of the list if you don''t specify +version+). def select(package, source=nil, version=nil, platform=''ruby'') selections={} cmd="#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # {package} #{source ? ''--source=''+source : nil }" sudo cmd do |channel, stream, data| data.each_line do | line | case line when /\s(\d+).*\(#{platform}\)/ if selections[channel[:host]].nil? selections[channel[:host]]=$1.dup+"\n" logger.info "Selecting #$&", "#{stream} :: #{channel[:host]}" end when /\s\d+\./ # Discard other selections from data stream when /^>/ channel.send_data selections[channel[:host]] logger.debug line, "#{stream} :: #{channel[:host]}" else logger.info line, "#{stream} :: #{channel[:host]}" end end end end end Capistrano.plugin :gem, Gem Cheers- -- Ezra Zygmuntowicz-- Lead Rails Evangelist -- ez at engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)
On Thu Dec 21, 2006 at 01:38:39PM -0500, Charles Brian Quinn wrote:> I know we already mentioned this before on the list but I couldn''t > find it in the archives. Is there a way to differentiate the versions > for ruby/mswin32 so that I could run a command like: > > # sudo gem install mongrel > --source=http://mongrel.rubyforge.org/releases/ --include-dependencies > --version 1.0 > > and have it not prompt me like this: > > Select which gem to install for your platform (i686-linux) > 1. mongrel 1.0 (ruby) > 2. mongrel 1.0 (mswin32) > 3. Cancel installation > > my feeble attempts at scripting this and trying to automatically pipe > or echo 1 into the installation are failing. > > Anyone know how to do this automaticallysubmit a patch to the rubygems package: m ~ # irb irb(main):001:0> include Config => Object irb(main):002:0> CONFIG["arch"] => "x86_64-linux" irb(main):003:0> this should be enough for it to answer its own questions from now on... in the meantime, pay close attention when running ''gem install mongrel''. the ruby version of FastThread is 2), while the ruby version of mongrel is 1) .. by ruby version, do we meen UNIX version? thats a bit confusing. since presumably both versions have C code that is compiled to the platform (ie the ''ruby'' choice isnt really pure-ruby)
On Thu, 21 Dec 2006 14:13:12 -0500 "Charles Brian Quinn" <me at seebq.com> wrote:> Thanks Steven, > > This is using Jamis'' net/ssh library and using: > > sudo cmd do |channel, stream, data| > data.each_line do | line | > > to regex match lines and type in input. this could work, but i was > hoping for bash or something simpler.... > > Guess that means it''s time to move my all of my shell scripts over to > ruby (except for the one that installs ruby) ;-)You know you can make your own gem source right? I think that''d be a hell of a lot better for provisioning a bunch of machines than pulling the stuff of the internet. Take a look in the Rakefile for mongrel at the gem_source target. All you do is grab all the .gem files your systems need, then run the gem indexing tool and rsync them up to your own web server. After that, you just setup all your scripts to always grab from there instead of the internet. Should speed things up and you can even do different sources for win32 vs. unix gems. -- Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu http://www.zedshaw.com/ http://www.awprofessional.com/title/0321483502 -- The Mongrel Book http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
On 12/21/06, carmen <_ at whats-your.name> wrote:> On Thu Dec 21, 2006 at 01:38:39PM -0500, Charles Brian Quinn wrote: > > I know we already mentioned this before on the list but I couldn''t > > find it in the archives. Is there a way to differentiate the versions > > for ruby/mswin32 so that I could run a command like: > > > > # sudo gem install mongrel > > --source=http://mongrel.rubyforge.org/releases/ --include-dependencies > > --version 1.0 > > > > and have it not prompt me like this: > > > > Select which gem to install for your platform (i686-linux) > > 1. mongrel 1.0 (ruby) > > 2. mongrel 1.0 (mswin32) > > 3. Cancel installation > > > > my feeble attempts at scripting this and trying to automatically pipe > > or echo 1 into the installation are failing. > > > > Anyone know how to do this automatically > > > submit a patch to the rubygems package: > > m ~ # irb > irb(main):001:0> include Config > => Object > irb(main):002:0> CONFIG["arch"] > => "x86_64-linux" > irb(main):003:0> > > this should be enough for it to answer its own questions from now on... > > in the meantime, pay close attention when running ''gem install mongrel''. the ruby version of FastThread is 2), while the ruby version of mongrel is 1) .. > > by ruby version, do we meen UNIX version? thats a bit confusing. since presumably both versions have C code that is compiled to the platform (ie the ''ruby'' choice isnt really pure-ruby)That is a problem, nor Zed or me could package precompiled versions of the gem to each platform supported by ruby. Also, each linux distro links against different version of glibc and with different shared libraries, which could turn things bad with a few segfaults due ABI incompatibilities. The "ruby" term used by rubygems could be interpreted as the simplest / plain gem that will work on any platform, if you could provide the conditions required for each particular case (like a compiler or another gem). In the case of mswin32, its also wrong, but is the only way to close the gap between users, and allow ppl without compilers or extensive C development knowledge use packages. I guess that couldn''t and, from my POV, will not be fixed, at least on the gems I package or maintain. -- Luis Lavena Multimedia systems - Leaders are made, they are not born. They are made by hard effort, which is the price which all of us must pay to achieve any goal that is worthwhile. Vince Lombardi
Ezra, I found this cap plugin you posted to be extremely useful, ccing Capistrano list, where I know you''ve posted about it too. I have a patch, adding the options as a params hash for readability. My cursory googling..err..searching could not reveal where this capistrano "Gem" plugin resides. main difference is this method: def install(packages, source=nil, version=nil) is now: def install(packages, options={}) so you can do: gem.select ''mysql'', :version => ''2.7'', :platform => ''ruby'', :extra_params => ''-- --with-mysql-config'' or: gem.select ''mongrel'', :version => ''0.3.13.4'' Here''s the diff, (email formatting is horrible), or point me to an svn for latest to build a patch $ diff cap_gem_plugin.rb cap_gem_plugin_cbq.rb 39,41c36,40 < def install(packages, source=nil, version=nil) < sudo "#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # < {source ? ''--source=''+source : nil } #{packages.to_a.join('' '')}" ---> # def install(packages, source=nil, version=nil) > def install(packages, options={}) > sudo "#{GEM_INSTALL} #{options[:version] ? ''-v ''+options[:version].to_s : nil} " + > "#{options[:source] ? ''--source=''+options[:source] : nil } " + > "#{packages.to_a.join('' '')}"63c59,60 < def select(package, source=nil, version=nil, platform=''ruby'') ---> # def select(package, source=nil, version=nil, platform=''ruby'') > def select(package, options={})65,66c62,65 < cmd="#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # < {package} #{source ? ''--source=''+source : nil }" ---> cmd="#{GEM_INSTALL} #{options[:version] ? ''-v ''+options[:version].to_s : nil} " + > "#{package} " + > "#{options[:source] ? ''--source=''+options[:source] : nil } " + > "#{options[:extra_params] ? options[:extra_params] : nil}"70c69 < when /\s(\d+).*\(#{platform}\)/ ---> when /\s(\d+).*\(#{options[:platform]}\)/Thanks! -- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com 678.389.9462 Ruby on Rails Bootcamp at the Big Nerd Ranch Intensive Ruby on Rails Training: http://www.bignerdranch.com/classes/ruby.shtml On 12/21/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:> On Dec 21, 2006, at 11:13 AM, Charles Brian Quinn wrote: > > Thanks Steven, > > > > This is using Jamis'' net/ssh library and using: > > > > sudo cmd do |channel, stream, data| > > data.each_line do | line | > > > > to regex match lines and type in input. this could work, but i was > > hoping for bash or something simpler.... > > > > Guess that means it''s time to move my all of my shell scripts over to > > ruby (except for the one that installs ruby) ;-) > > > > Thanks! > > > Charles- > > You and me both. I didn''t want to spend the time writing bash > scripts for this when I need to do it on tons of machines anyway. So > the script he linked to is actually a capistrano plugin. Take the > file and put it somewhere in your load path and then require it from > a capistrano recipe file and then you can use it like this: > > > require ''cap_gem'' > > task :install_gems, :roles => :app do > gem.select ''mongrel'' , ''http://mongrel.rubyforge.org/releases'' > gem.install ''mongrel'', ''http://mongrel.rubyforge.org/releases'' , > ''1.0'' > end > > select will select the most recent versions for the current platform > and install it. install will install a specific version but won''t > auto select from a menu. So is there are two or more versions of a > gem then you want to use select. > > Here is the more current version of the plugin for cap. This one > supports the --source option. > > require ''rubygems'' > require ''capistrano'' > # Installs within Capistrano as the plugin _gem_. > # Prefix all calls to the library with <tt>gem.</tt> > # Manages installing gems and versioned gems. > module Gem > > # Default install command > # > # * doesn''t install documentation > # * installs all required dependencies automatically. > # > GEM_INSTALL="gem install -y --no-rdoc" > > # Upgrade the *gem* system to the latest version. Runs via *sudo* > def update_system > sudo "gem update --system" > end > > # Updates all the installed gems to the latest version. Runs via > *sudo*. > # Don''t use this command if any of the gems require a version > selection. > def upgrade > sudo "gem update --no-rdoc" > end > > # Removes old versions of gems from installation area. > def cleanup > sudo "gem cleanup" > end > > # Installs the gems detailed in +packages+, selecting version > +version+ if > # specified. > # > # +packages+ can be a single string or an array of strings. > # > def install(packages, source=nil, version=nil) > sudo "#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # > {source ? ''--source=''+source : nil } #{packages.to_a.join('' '')}" > end > > def uninstall(package) > sudo "gem uninstall #{package}" do |channel, stream, data| > data.each_line do |line| > if line =~ /\[Yn\]/ > channel.send_data "Y\n" > end > end > end > end > > # Auto selects a gem from a list and installs it. > # > # *gem* has no mechanism on the command line of disambiguating > builds for > # different platforms, and instead asks the user. This method has > the necessary > # conversation to select the +version+ relevant to +platform+ (or > the one nearest > # the top of the list if you don''t specify +version+). > def select(package, source=nil, version=nil, platform=''ruby'') > selections={} > cmd="#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # > {package} #{source ? ''--source=''+source : nil }" > sudo cmd do |channel, stream, data| > data.each_line do | line | > case line > when /\s(\d+).*\(#{platform}\)/ > if selections[channel[:host]].nil? > selections[channel[:host]]=$1.dup+"\n" > logger.info "Selecting #$&", "#{stream} :: #{channel[:host]}" > end > when /\s\d+\./ > # Discard other selections from data stream > when /^>/ > channel.send_data selections[channel[:host]] > logger.debug line, "#{stream} :: #{channel[:host]}" > else > logger.info line, "#{stream} :: #{channel[:host]}" > end > end > end > end > > end > > Capistrano.plugin :gem, Gem > > > Cheers- > -- Ezra Zygmuntowicz-- Lead Rails Evangelist > -- ez at engineyard.com > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273) > > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >
Hey Charles- Cool I''m glad you like it. It definitely needed a cleanup of the params and your patch looks really nice. Unfortunately email ate the formatting and I can''t use it :/ Can you send me a copy of the entire file in its new state? You can send it to me directly if you like. I really need to package this thing up with a few other goodies I have and release it. Thanks- -Ezra On Jan 9, 2007, at 3:00 PM, Charles Brian Quinn wrote:> Ezra, I found this cap plugin you posted to be extremely useful, ccing > Capistrano list, where I know you''ve posted about it too. I have a > patch, adding the options as a params hash for readability. My > cursory googling..err..searching could not reveal where this > capistrano "Gem" plugin resides. > > main difference is this method: > > def install(packages, source=nil, version=nil) > > is now: > > def install(packages, options={}) > > so you can do: > > gem.select ''mysql'', :version => ''2.7'', :platform => ''ruby'', > :extra_params => ''-- --with-mysql-config'' > > or: > > gem.select ''mongrel'', :version => ''0.3.13.4'' > > Here''s the diff, (email formatting is horrible), or point me to an svn > for latest to build a patch > > $ diff cap_gem_plugin.rb cap_gem_plugin_cbq.rb > 39,41c36,40 > < def install(packages, source=nil, version=nil) > < sudo "#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # > < {source ? ''--source=''+source : nil } #{packages.to_a.join('' '')}" > --- >> # def install(packages, source=nil, version=nil) >> def install(packages, options={}) >> sudo "#{GEM_INSTALL} #{options[:version] ? ''-v ''+options >> [:version].to_s : nil} " + >> "#{options[:source] ? ''--source=''+options[:source] : >> nil } " + >> "#{packages.to_a.join('' '')}" > 63c59,60 > < def select(package, source=nil, version=nil, platform=''ruby'') > --- >> # def select(package, source=nil, version=nil, platform=''ruby'') >> def select(package, options={}) > 65,66c62,65 > < cmd="#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # > < {package} #{source ? ''--source=''+source : nil }" > --- >> cmd="#{GEM_INSTALL} #{options[:version] ? ''-v ''+options >> [:version].to_s : nil} " + >> "#{package} " + >> "#{options[:source] ? ''--source=''+options[:source] : nil } >> " + >> "#{options[:extra_params] ? options[:extra_params] : nil}" > 70c69 > < when /\s(\d+).*\(#{platform}\)/ > --- >> when /\s(\d+).*\(#{options[:platform]}\)/ > > > Thanks! > -- > Charles Brian Quinn > self-promotion: www.seebq.com > highgroove studios: www.highgroove.com > slingshot hosting: www.slingshothosting.com > 678.389.9462 > > Ruby on Rails Bootcamp at the Big Nerd Ranch > Intensive Ruby on Rails Training: > http://www.bignerdranch.com/classes/ruby.shtml > > On 12/21/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote: >> On Dec 21, 2006, at 11:13 AM, Charles Brian Quinn wrote: >>> Thanks Steven, >>> >>> This is using Jamis'' net/ssh library and using: >>> >>> sudo cmd do |channel, stream, data| >>> data.each_line do | line | >>> >>> to regex match lines and type in input. this could work, but i was >>> hoping for bash or something simpler.... >>> >>> Guess that means it''s time to move my all of my shell scripts >>> over to >>> ruby (except for the one that installs ruby) ;-) >>> >>> Thanks! >> >> >> Charles- >> >> You and me both. I didn''t want to spend the time writing bash >> scripts for this when I need to do it on tons of machines anyway. So >> the script he linked to is actually a capistrano plugin. Take the >> file and put it somewhere in your load path and then require it from >> a capistrano recipe file and then you can use it like this: >> >> >> require ''cap_gem'' >> >> task :install_gems, :roles => :app do >> gem.select ''mongrel'' , ''http://mongrel.rubyforge.org/releases'' >> gem.install ''mongrel'', ''http://mongrel.rubyforge.org/releases'' , >> ''1.0'' >> end >> >> select will select the most recent versions for the current platform >> and install it. install will install a specific version but won''t >> auto select from a menu. So is there are two or more versions of a >> gem then you want to use select. >> >> Here is the more current version of the plugin for cap. This one >> supports the --source option. >> >> require ''rubygems'' >> require ''capistrano'' >> # Installs within Capistrano as the plugin _gem_. >> # Prefix all calls to the library with <tt>gem.</tt> >> # Manages installing gems and versioned gems. >> module Gem >> >> # Default install command >> # >> # * doesn''t install documentation >> # * installs all required dependencies automatically. >> # >> GEM_INSTALL="gem install -y --no-rdoc" >> >> # Upgrade the *gem* system to the latest version. Runs via *sudo* >> def update_system >> sudo "gem update --system" >> end >> >> # Updates all the installed gems to the latest version. Runs via >> *sudo*. >> # Don''t use this command if any of the gems require a version >> selection. >> def upgrade >> sudo "gem update --no-rdoc" >> end >> >> # Removes old versions of gems from installation area. >> def cleanup >> sudo "gem cleanup" >> end >> >> # Installs the gems detailed in +packages+, selecting version >> +version+ if >> # specified. >> # >> # +packages+ can be a single string or an array of strings. >> # >> def install(packages, source=nil, version=nil) >> sudo "#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # >> {source ? ''--source=''+source : nil } #{packages.to_a.join('' '')}" >> end >> >> def uninstall(package) >> sudo "gem uninstall #{package}" do |channel, stream, data| >> data.each_line do |line| >> if line =~ /\[Yn\]/ >> channel.send_data "Y\n" >> end >> end >> end >> end >> >> # Auto selects a gem from a list and installs it. >> # >> # *gem* has no mechanism on the command line of disambiguating >> builds for >> # different platforms, and instead asks the user. This method has >> the necessary >> # conversation to select the +version+ relevant to +platform+ (or >> the one nearest >> # the top of the list if you don''t specify +version+). >> def select(package, source=nil, version=nil, platform=''ruby'') >> selections={} >> cmd="#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # >> {package} #{source ? ''--source=''+source : nil }" >> sudo cmd do |channel, stream, data| >> data.each_line do | line | >> case line >> when /\s(\d+).*\(#{platform}\)/ >> if selections[channel[:host]].nil? >> selections[channel[:host]]=$1.dup+"\n" >> logger.info "Selecting #$&", "#{stream} :: #{channel >> [:host]}" >> end >> when /\s\d+\./ >> # Discard other selections from data stream >> when /^>/ >> channel.send_data selections[channel[:host]] >> logger.debug line, "#{stream} :: #{channel[:host]}" >> else >> logger.info line, "#{stream} :: #{channel[:host]}" >> end >> end >> end >> end >> >> end >> >> Capistrano.plugin :gem, Gem >> >> >> Cheers- >> -- Ezra Zygmuntowicz-- Lead Rails Evangelist >> -- ez at engineyard.com >> -- Engine Yard, Serious Rails Hosting >> -- (866) 518-YARD (9273) >> >> >> _______________________________________________ >> Mongrel-users mailing list >> Mongrel-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mongrel-users >> > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez at engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)
Charles Brian Quinn
2007-Jan-12 06:32 UTC
[Mongrel] [Capistrano] Re: versioning of win32 versus ruby gems
Here ya go Ezra, good stuff. documented it a tad and provided an example with the new options hash. -- Charles Brian Quinn self-promotion: www.seebq.com highgroove studios: www.highgroove.com slingshot hosting: www.slingshothosting.com 678.389.9462 Ruby on Rails Bootcamp at the Big Nerd Ranch Intensive Ruby on Rails Training: http://www.bignerdranch.com/classes/ruby.shtml On 1/9/07, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:> > Hey Charles- > > Cool I''m glad you like it. It definitely needed a cleanup of the > params and your patch looks really nice. Unfortunately email ate the > formatting and I can''t use it :/ Can you send me a copy of the entire > file in its new state? You can send it to me directly if you like. I > really need to package this thing up with a few other goodies I have > and release it. > > Thanks- > -Ezra > > > > On Jan 9, 2007, at 3:00 PM, Charles Brian Quinn wrote: > > > Ezra, I found this cap plugin you posted to be extremely useful, ccing > > Capistrano list, where I know you''ve posted about it too. I have a > > patch, adding the options as a params hash for readability. My > > cursory googling..err..searching could not reveal where this > > capistrano "Gem" plugin resides. > > > > main difference is this method: > > > > def install(packages, source=nil, version=nil) > > > > is now: > > > > def install(packages, options={}) > > > > so you can do: > > > > gem.select ''mysql'', :version => ''2.7'', :platform => ''ruby'', > > :extra_params => ''-- --with-mysql-config'' > > > > or: > > > > gem.select ''mongrel'', :version => ''0.3.13.4'' > > > > Here''s the diff, (email formatting is horrible), or point me to an svn > > for latest to build a patch > > > > $ diff cap_gem_plugin.rb cap_gem_plugin_cbq.rb > > 39,41c36,40 > > < def install(packages, source=nil, version=nil) > > < sudo "#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # > > < {source ? ''--source=''+source : nil } #{packages.to_a.join('' '')}" > > --- > >> # def install(packages, source=nil, version=nil) > >> def install(packages, options={}) > >> sudo "#{GEM_INSTALL} #{options[:version] ? ''-v ''+options > >> [:version].to_s : nil} " + > >> "#{options[:source] ? ''--source=''+options[:source] : > >> nil } " + > >> "#{packages.to_a.join('' '')}" > > 63c59,60 > > < def select(package, source=nil, version=nil, platform=''ruby'') > > --- > >> # def select(package, source=nil, version=nil, platform=''ruby'') > >> def select(package, options={}) > > 65,66c62,65 > > < cmd="#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # > > < {package} #{source ? ''--source=''+source : nil }" > > --- > >> cmd="#{GEM_INSTALL} #{options[:version] ? ''-v ''+options > >> [:version].to_s : nil} " + > >> "#{package} " + > >> "#{options[:source] ? ''--source=''+options[:source] : nil } > >> " + > >> "#{options[:extra_params] ? options[:extra_params] : nil}" > > 70c69 > > < when /\s(\d+).*\(#{platform}\)/ > > --- > >> when /\s(\d+).*\(#{options[:platform]}\)/ > > > > > > Thanks! > > -- > > Charles Brian Quinn > > self-promotion: www.seebq.com > > highgroove studios: www.highgroove.com > > slingshot hosting: www.slingshothosting.com > > 678.389.9462 > > > > Ruby on Rails Bootcamp at the Big Nerd Ranch > > Intensive Ruby on Rails Training: > > http://www.bignerdranch.com/classes/ruby.shtml > > > > On 12/21/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote: > >> On Dec 21, 2006, at 11:13 AM, Charles Brian Quinn wrote: > >>> Thanks Steven, > >>> > >>> This is using Jamis'' net/ssh library and using: > >>> > >>> sudo cmd do |channel, stream, data| > >>> data.each_line do | line | > >>> > >>> to regex match lines and type in input. this could work, but i was > >>> hoping for bash or something simpler.... > >>> > >>> Guess that means it''s time to move my all of my shell scripts > >>> over to > >>> ruby (except for the one that installs ruby) ;-) > >>> > >>> Thanks! > >> > >> > >> Charles- > >> > >> You and me both. I didn''t want to spend the time writing bash > >> scripts for this when I need to do it on tons of machines anyway. So > >> the script he linked to is actually a capistrano plugin. Take the > >> file and put it somewhere in your load path and then require it from > >> a capistrano recipe file and then you can use it like this: > >> > >> > >> require ''cap_gem'' > >> > >> task :install_gems, :roles => :app do > >> gem.select ''mongrel'' , ''http://mongrel.rubyforge.org/releases'' > >> gem.install ''mongrel'', ''http://mongrel.rubyforge.org/releases'' , > >> ''1.0'' > >> end > >> > >> select will select the most recent versions for the current platform > >> and install it. install will install a specific version but won''t > >> auto select from a menu. So is there are two or more versions of a > >> gem then you want to use select. > >> > >> Here is the more current version of the plugin for cap. This one > >> supports the --source option. > >> > >> require ''rubygems'' > >> require ''capistrano'' > >> # Installs within Capistrano as the plugin _gem_. > >> # Prefix all calls to the library with <tt>gem.</tt> > >> # Manages installing gems and versioned gems. > >> module Gem > >> > >> # Default install command > >> # > >> # * doesn''t install documentation > >> # * installs all required dependencies automatically. > >> # > >> GEM_INSTALL="gem install -y --no-rdoc" > >> > >> # Upgrade the *gem* system to the latest version. Runs via *sudo* > >> def update_system > >> sudo "gem update --system" > >> end > >> > >> # Updates all the installed gems to the latest version. Runs via > >> *sudo*. > >> # Don''t use this command if any of the gems require a version > >> selection. > >> def upgrade > >> sudo "gem update --no-rdoc" > >> end > >> > >> # Removes old versions of gems from installation area. > >> def cleanup > >> sudo "gem cleanup" > >> end > >> > >> # Installs the gems detailed in +packages+, selecting version > >> +version+ if > >> # specified. > >> # > >> # +packages+ can be a single string or an array of strings. > >> # > >> def install(packages, source=nil, version=nil) > >> sudo "#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # > >> {source ? ''--source=''+source : nil } #{packages.to_a.join('' '')}" > >> end > >> > >> def uninstall(package) > >> sudo "gem uninstall #{package}" do |channel, stream, data| > >> data.each_line do |line| > >> if line =~ /\[Yn\]/ > >> channel.send_data "Y\n" > >> end > >> end > >> end > >> end > >> > >> # Auto selects a gem from a list and installs it. > >> # > >> # *gem* has no mechanism on the command line of disambiguating > >> builds for > >> # different platforms, and instead asks the user. This method has > >> the necessary > >> # conversation to select the +version+ relevant to +platform+ (or > >> the one nearest > >> # the top of the list if you don''t specify +version+). > >> def select(package, source=nil, version=nil, platform=''ruby'') > >> selections={} > >> cmd="#{GEM_INSTALL} #{version ? ''-v ''+version.to_s : nil} # > >> {package} #{source ? ''--source=''+source : nil }" > >> sudo cmd do |channel, stream, data| > >> data.each_line do | line | > >> case line > >> when /\s(\d+).*\(#{platform}\)/ > >> if selections[channel[:host]].nil? > >> selections[channel[:host]]=$1.dup+"\n" > >> logger.info "Selecting #$&", "#{stream} :: #{channel > >> [:host]}" > >> end > >> when /\s\d+\./ > >> # Discard other selections from data stream > >> when /^>/ > >> channel.send_data selections[channel[:host]] > >> logger.debug line, "#{stream} :: #{channel[:host]}" > >> else > >> logger.info line, "#{stream} :: #{channel[:host]}" > >> end > >> end > >> end > >> end > >> > >> end > >> > >> Capistrano.plugin :gem, Gem > >> > >> > >> Cheers- > >> -- Ezra Zygmuntowicz-- Lead Rails Evangelist > >> -- ez at engineyard.com > >> -- Engine Yard, Serious Rails Hosting > >> -- (866) 518-YARD (9273) > >> > >> > >> _______________________________________________ > >> Mongrel-users mailing list > >> Mongrel-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/mongrel-users > >> > > _______________________________________________ > > Mongrel-users mailing list > > Mongrel-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/mongrel-users > > > > -- Ezra Zygmuntowicz > -- Lead Rails Evangelist > -- ez at engineyard.com > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273) > > > > --~--~---------~--~----~------------~-------~--~----~ > To unsubscribe from this group, send email to capistrano-unsubscribe at googlegroups.com > For more options, visit this group at http://groups.google.com/group/capistrano > -~----------~----~----~----~------~----~------~--~--- > >-------------- next part -------------- A non-text attachment was scrubbed... Name: cap_gem_plugin_cbq.rb Type: text/x-ruby-script Size: 3302 bytes Desc: not available Url : http://rubyforge.org/pipermail/mongrel-users/attachments/20070112/3b82ccae/attachment.bin