Browse files

Remove support for Ruby 1.8 and hacks for old distributions.

  • Loading branch information...
1 parent 942473b commit 4ba7ad9e3e029dcf69d03a0f709615e2a11d24ea @pwnall committed Dec 31, 2013
Showing with 78 additions and 127 deletions.
  1. +2 −0 CHANGELOG
  2. +0 −1 Manifest
  3. +9 −9 README
  4. +5 −9 Rakefile
  5. +0 −43 ext/rpwn_setup_notice/extconf.rb
  6. +44 −44 lib/rails_pwnerer/scaffolds/packages.rb
  7. +18 −21 lib/rails_pwnerer/scaffolds/rubygems.rb
View
2 CHANGELOG
@@ -1,3 +1,5 @@
+v0.7.7. Remove support for Ruby 1.8 and hacks for old distributions.
+
v0.7.6. nginx configuration fix for redirections on non-standard ports.
v0.7.5. One more nginx configuration adjustment.
View
1 Manifest
@@ -6,7 +6,6 @@ Rakefile
bin/rpwn
bin/rpwnctl
bin/rpwndev
-ext/rpwn_setup_notice/extconf.rb
lib/rails_pwnerer.rb
lib/rails_pwnerer/app/assets.rb
lib/rails_pwnerer/app/cluster_config.rb
View
18 README
@@ -6,7 +6,7 @@ much rather having ruby do that for me.
Right now, +rails_pwnerer+ assumes a fresh Ubuntu 8.04 installation. You're
welcome to test/update for other systems, and I'll be happy to merge patches,
-or add you to the RubyForge project.
+or add you to the RubyForge project.
Life without +rails_pwnerer+:
@@ -16,7 +16,7 @@ ready for production. You'll be frustrated in the process, but feel
accomplished at the end. Assuming you don't do something wrong.
Read a couple more 20-page guides, and learn to push newer versions
-of your application. You'll become lazy, and take shortcuts, like having
+of your application. You'll become lazy, and take shortcuts, like having
production passwords in the repository, or insecure file permissions, or
you'll forget to delete cached javascripts and stylesheets from public/.
I won't even mention backups. Or scripts to recover your frontends
@@ -26,7 +26,7 @@ application.
Life with +rails_pwnerer+:
1) Install a bootstrap version of ruby and rubygems:
-sudo apt-get -y install ruby1.9.1 make
+sudo apt-get -y install ruby
2) Install +rails_pwnerer+:
sudo gem install rails_pwnerer
@@ -54,7 +54,7 @@ sudo rpwn install you@your.repository.host/path/to/your_application.git
or
sudo rpwn install p4://you:yourpass@host:port/path/to/your/application
-
+
5) Maintain your application
* Push the updates in the SVN repository:
@@ -76,7 +76,7 @@ rpwn console your_application
rpwn db_console your_application
* Configure DynDns for your application server
-sudo rpwn scaffold ddns full_host_name ddns_user ddns_password
+sudo rpwn scaffold ddns full_host_name ddns_user ddns_password
* Change the database password
sudp rpwn rekey your_application
@@ -151,7 +151,7 @@ SSL servers with +rails_pwnerer+:
1) Generate a server key:
openssl req -new -newkey rsa:2048 -keyout config/rails_pwnerer/instance.pem -out instance.csr -nodes
-2) Be sure to set the CN (Common Name) to your server's DNS address. Send the
+2) Be sure to set the CN (Common Name) to your server's DNS address. Send the
CSR file to your CA: cat instance.csr
3) Copy the certificate into the +rails_pwnerer+ configuration directory:
@@ -183,14 +183,14 @@ The following prefixes are searched for in script/rails_pwnerer:
The first script matching the pattern is executed. This means you can
have an "install.rb", so you can use your favorite language extension.
You cannot have both an "install.rb" and an "install.sh" executing at
-the same time.
+the same time.
If the script ends in _su or _su.extension (e.g. _su.ruby), it will be
run as the super-user (root). Otherwise it will be run as the
application's user. For instance, post_reset_su.rb wil be run as the
-super-user, whereas post_reset.sh will not.
+super-user, whereas post_reset.sh will not.
Writing your lifecycle scripts in Ruby? You can use the +rails_pwnerer+
gem to commonly-used chunks of functionality . RailsPwnage::Util
(including RailsPwnage::Base) is likely to be useful.
-
+
View
14 Rakefile
@@ -3,23 +3,19 @@ require 'echoe'
Echoe.new('rails_pwnerer') do |p|
p.project = 'rails-pwnage' # rubyforge project
-
+
p.author = 'Victor Costan'
p.email = 'victor@costan.us'
p.summary = 'Rails deployment hack.'
- p.url = 'http://www.costan.us/rails_pwnage'
- p.dependencies = []
+ p.url = 'http://github.com/pwnall/rails_pwnage'
+ p.licenses = ['MIT']
p.development_dependencies = ['echoe', 'fakefs', 'flexmock']
p.runtime_dependencies = ['zerg_support']
- p.extension_pattern = ['ext/**/extconf.rb']
- p.eval = proc do |p|
- p.default_executable = 'bin/rpwn'
- end
-
+
p.need_tar_gz = !Gem.win_platform?
p.need_zip = !Gem.win_platform?
p.rdoc_pattern =
- /^(lib|bin|tasks|ext)|^BUILD|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
+ /^(lib|bin|tasks|ext)|^BUILD|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
end
if $0 == __FILE__
View
43 ext/rpwn_setup_notice/extconf.rb
@@ -1,43 +0,0 @@
-# Invoked when the gem is installed. Hack to get a post-install hook.
-
-require 'rubygems'
-
-
-# Cheat to get the gem binaries installed in the user's path even on Debians.
-['rpwn', 'rpwnctl', 'rpwndev'].each do |file|
- bin_path = "/usr/bin/#{file}"
- unless File.exists? bin_path
- source_path = File.expand_path "../../../bin/#{file}", __FILE__
- Kernel.system "ln -s #{source_path} #{bin_path}"
- end
-
- File.chmod((File.stat(binpath).mode | 0755), binpath) rescue nil
-end
-
-# Make the gem readable and runnable by anyone.
-#
-# This is a work-around for systems with messed up permission masks.
-def openup(path)
- if File.file?(path)
- File.chmod((File.stat(path).mode | 0755), path) rescue nil
- return
- end
-
- Dir.foreach(path) do |entry|
- next if ['.', '..'].include? entry
- openup File.join(path, entry)
- end
-end
-base_path = File.expand_path "../../..", __FILE__
-openup base_path
-
-# We really shouldn't be abusing rubygems' root. Then again, the Debian
-# maintainers shouldn't be abusing the patience of Ruby developers.
-
-# Now trick rubygems and echoe into believing that a gem got installed and
-# everything is good.
-ext_binary = 'rpwn_setup_notice' + (Gem.win_platform? ? '.dll' : '.so')
-File.open(ext_binary, 'w') { |f| }
-File.open('Makefile', 'w') do |f|
- f.write "# target_prefix = #{ext_binary}\nall:\n\ninstall:\n\n"
-end
View
88 lib/rails_pwnerer/scaffolds/packages.rb
@@ -2,133 +2,133 @@
class RailsPwnerer::Scaffolds::Packages
include RailsPwnerer::Base
-
+
# Packages needed to manage the server remotely and install applications.
def install_management
# Needed to play with the configuration database.
package 'debconf'
package 'debconf-utils'
-
+
# Keys for Debian packages.
package 'debian-archive-keyring'
-
+
# Fetch files via HTTP.
package 'curl'
package 'wget'
-
+
package 'dpkg-dev' # Builds packages from source.
package 'openssh-server' # SSH into the box.
# For gems with native extensions.
package 'build-essential'
package 'g++'
-
+
# Pull code from version control.
- package 'subversion'
+ package 'subversion'
package 'git-core'
package 'avahi-daemon' # mDNS, a.k.a. Bonjour
package 'ddclient' # dynamic DNS
end
-
+
# Packages needed by popular gems.
def install_tools
# For eventmachine.
package 'libssl-dev'
-
+
# For rmagick (image processing).
package 'libmagickwand-dev', /^libmagick\d*-dev$/
-
+
# For HTML/XML parsers (nokogiri, hpricot).
package 'libxml2-dev'
package 'libxslt1-dev'
-
+
# For HTTP fetchers (curb).
package 'libcurl-dev', 'libcurl-openssl-dev', /^libcurl\d*-dev$/,
/^libcurl\d*-openssl-dev$/
-
+
# needed for solr and other java-based services
package /^openjdk-\d+-jdk/
-
+
# useful to be able to work with compressed data
package 'zlib-dev', /^zlib[0-9a-z]*-dev$/
package 'bzip2'
package 'gzip'
package 'tar'
package 'zip'
end
-
+
# Packages for all the database servers we could need.
def install_databases
package 'sqlite3'
package 'libsqlite3-dev'
-
+
package 'mysql-client'
package 'mysql-server'
package 'libmysql-dev', 'libmysqlclient-dev', /^libmysqlclient\d*-dev$/
-
+
package 'postgresql-client'
package 'libpq-dev'
-
+
# TODO: NoSQL stores.
- end
-
+ end
+
# The ruby environment (ruby, irb, rubygems).
def install_ruby
- install_ruby_19 || install_ruby_18
+ # remove the bootstrap version of ruby to install the best available one.
+ remove_packages %w(ruby)
+ install_ruby_20 || install_ruby_19
end
-
- # MRI19 (1.9.2 or above).
- def install_ruby_19(retry_with_repos = true)
- package = best_package_matching(['ruby1.9.1'])
- if !package or package[:version] < '1.9.2'
+
+ # MRI 2.0.
+ def install_ruby_20(retry_with_repos = true)
+ package = best_package_matching(['ruby2.0'])
+ if !package
return false unless retry_with_repos
-
+
# This distribution has an old ruby. Work around it.
deb_source = 'http://debian.mirrors.tds.net/debian/'
deb_repos = %w(testing main non-free contrib)
- return_value = nil
+ return_value = nil
with_package_source deb_source, deb_repos do
- return_value = install_ruby_19 false
+ return_value = install_ruby_20 false
end
return return_value
end
-
- package 'ruby1.9.1-full'
+ package 'ruby2.0', 'ruby2.0-dev'
true
end
-
- # MRI18 (1.8.7 or above).
- def install_ruby_18
- package = best_package_matching(['ruby1.8-full'])
- if !package or package[:version] < '1.8.7'
+
+ # MRI19 (1.9.2 or above).
+ def install_ruby_19(retry_with_repos = true)
+ package = best_package_matching(['ruby1.9.1'])
+ if !package or package[:version] < '1.9.2'
+ return false unless retry_with_repos
+
# This distribution has an old ruby. Work around it.
deb_source = 'http://debian.mirrors.tds.net/debian/'
deb_repos = %w(testing main non-free contrib)
- return_value = nil
+ return_value = nil
with_package_source deb_source, deb_repos do
- return_value = install_ruby
+ return_value = install_ruby_19 false
end
return return_value
end
-
- package 'ruby1.8-full', 'ruby-full'
- # Ecosystem command-line tools.
- package 'rubygems', 'rubygems1.8'
+ package 'ruby1.9.1', 'ruby1.9.1-dev'
+ true
end
-
+
# Package for front-end servers.
def install_frontends
package 'nginx'
- package 'varnish'
end
-
+
# Implementation of the super-simple package DSL.
def package(*patterns)
install_package_matching patterns
end
-
+
# Runner.
def run
update_package_metadata
View
39 lib/rails_pwnerer/scaffolds/rubygems.rb
@@ -3,14 +3,14 @@
class RailsPwnerer::Scaffolds::RubyGems
include RailsPwnerer::Base
-
+
# retrieves the URI for a Google "I'm Feeling Lucky" search
def google_lucky_uri(query)
uri = URI.parse "http://www.google.com/search?q=#{URI.escape query}&btnI=Lucky"
response = Net::HTTP.start(uri.host, uri.port) { |http| http.get "#{uri.path}?#{uri.query}" }
response.header['location']
end
-
+
# retrieves the download URI for a RubyForge project
def rubyforge_download_uri(project, gem_name = project, extension = ".gem")
frs_uri = URI.parse google_lucky_uri("#{project} download page")
@@ -20,10 +20,10 @@ def rubyforge_download_uri(project, gem_name = project, extension = ".gem")
latest_link = frs_links.sort_by { |n| n.match(/#{gem_name}-(.*)\.#{extension}/)[1] }.last
return frs_uri.merge(latest_link)
end
-
+
# installs Rubygems on the system
def install_rubygems
- with_temp_dir(:root => true) do
+ with_temp_dir(:root => true) do
tgz_uri = rubyforge_download_uri('rubygems', 'rubygems', 'tgz')
file_name = File.basename tgz_uri.path
loop do
@@ -36,55 +36,52 @@ def install_rubygems
File.open(file_name, 'wb') { |f| f.write response.body }
break
end
-
- system "tar -xzf #{file_name}"
+
+ system "tar -xzf #{file_name}"
File.unlink file_name
Dir.chdir(Dir.glob('*').first) do
system "ruby setup.rb"
end
- end
+ end
end
-
+
# sets up good defaults for Rubygems
def configure_rubygems
File.open('/etc/gemrc', 'w') do |f|
f.write "gem: --no-force --no-rdoc --no-ri --no-user-install --wrappers\n"
end
end
-
+
def run
# get the old path set by pre-go
old_gems = @@old_gems
-
- # remove the (retarded) Debian gems package and install from source
+
+ # remove the Debian gems package and install from source
remove_packages %w(rubygems)
install_rubygems
-
+
# configure rubygems so it doesn't waste time
configure_rubygems
- # patch Ubuntu's broken rubygems installation
- Kernel.system "cp /usr/bin/gem1.8 /usr/bin/gem"
-
# remove the gems that are trailing behind
new_gems = File.dirname(File.dirname(path_to_gem('sources', '/lib/sources.rb')))
return if new_gems == old_gems # don't wipe the new dir by mistake
- FileUtils.rm_r old_gems
+ FileUtils.rm_r old_gems
end
-
+
def preflight
# save old lib path, in case we need to wipe it
# we need to do this because setting up packages might wipe Ubuntu's gems
- @@old_gems = File.dirname(File.dirname(path_to_gem('sources', '/lib/sources.rb')))
+ @@old_gems = File.dirname(File.dirname(path_to_gem('sources', '/lib/sources.rb')))
end
-
+
# called before packages get installed
def self.pre_go
self.new.preflight
end
-
+
# standalone runner
def self.go
self.new.run
- end
+ end
end

0 comments on commit 4ba7ad9

Please sign in to comment.