Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Workaround for buggy apt-cache search output.

  • Loading branch information...
commit 2b6228a72ecb3650d6ae3e2135191ef46a27c534 1 parent 75c8512
@pwnall authored
View
2  CHANGELOG
@@ -1,3 +1,5 @@
+v0.6.102. Workaround for buggy apt-cache search output.
+
v0.6.101. Install MRI 1.9.2+ instead of 1.8.7+ when available.
v0.6.100. Nginx configuration for Rails 3.1 asset pipeline.
View
4 README
@@ -26,10 +26,10 @@ application.
Life with +rails_pwnerer+:
1) Install a bootstrap version of ruby and rubygems (yes the order is correct):
-sudo apt-get -y install rubygems ruby
+sudo apt-get -y install ruby1.9.1
2) Install +rails_pwnerer+:
-sudo gem install rails_pwnerer
+sudo gem install rails_pwnerer make
(if it says gem not found, retry a couple of times)
3) Get your server production-ready:
View
5 ext/rpwn_setup_notice/extconf.rb
@@ -32,9 +32,10 @@ def openup(path)
openup base_path
# We really shouldn't be abusing rubygems' root. Then again, the Debian
-# maintaines shouldn't be abusing the patience of Ruby developers.
+# maintainers shouldn't be abusing the patience of Ruby developers.
-# Now trick rubygems and echoe into believeing that a gem got installed is good.
+# 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|
View
0  lib/rails_pwnerer/app/assets.rb 100644 → 100755
File mode changed
View
2  lib/rails_pwnerer/base/dirs.rb
@@ -32,7 +32,7 @@ def current_user
# executes a block in a temporary directory
def with_temp_dir(options = {})
base_dir = if options[:root]
- File.exists?('/tmp') ? '/tmp' : '/'
+ File.exists?('/tmp') ? '/tmp/' : '/'
else
'./'
end
View
23 lib/rails_pwnerer/base/packages.rb
@@ -200,9 +200,19 @@ def best_package_matching(patterns)
# Returns a hash where the keys are matching package names, and the values
# are version numbers.
def search_packages(pattern)
- Hash[*(RailsPwnerer::Base.all_packages.select { |key, value|
+ packages = RailsPwnerer::Base.all_packages
+ Hash[packages.select { |key, value|
pattern.kind_of?(Regexp) ? (pattern =~ key) : key.index(pattern)
- }.flatten)]
+ }.map { |key, value|
+ # apt-cache search sometimes leaves version numbers out
+ # Update the cache with version numbers.
+ if value.nil?
+ info = RailsPwnerer::Base.package_info_hash(
+ Kernel.`("apt-cache show #{key}"))
+ packages[key] = value = info['Version']
+ end
+ [key, value]
+ }]
end
# A hash of all the packages in the system, associated with their versions.
@@ -217,14 +227,17 @@ def self.all_packages
def self.all_packages_without_caching
output = Kernel.` "apt-cache search --full ."
versions = output.split("\n\n").map(&:strip).reject(&:empty?).map { |info|
- info_hash = Hash[*(info.split(/\n(?=\w)/).
- map { |s| s.split(': ', 2) }.
- select { |kvp| kvp.length == 2 }.flatten)]
+ info_hash = package_info_hash info
[info_hash['Package'], info_hash['Version']]
}
Hash[*(versions.flatten)]
end
+ def self.package_info_hash(output)
+ Hash[output.split(/\n(?=\w)/m).map { |s| s.split(': ', 2) }.
+ select { |kvp| kvp.length == 2 }]
+ end
+
# Upgrades a package to the latest version.
def upgrade_package(package_name, options = {})
return install_package(package_name, options) if options[:source]
View
4 test/base_package_test.rb
@@ -15,7 +15,7 @@ def test_search_packages_with_string
def test_search_packages_with_regexp
packages = @base.search_packages /ruby.*\-dev/
assert_operator packages, :has_key?, 'ruby1.8-dev'
- assert_operator packages, :has_key?, 'ruby1.9-dev'
+ assert_operator packages, :has_key?, 'ruby1.9.1-dev'
end
def test_best_package_matching
@@ -53,7 +53,7 @@ def test_with_package_source
"Found package that no test system should have (#{package})"
source = 'http://ppa.launchpad.net/mactel-support/ppa/ubuntu'
- repos = ['lucid', 'main']
+ repos = ['oneiric', 'main']
@base.with_package_source(source, repos) do
assert !(@base.search_packages(package).empty?),
"with_new_package_source didn't integrate the new source"
Please sign in to comment.
Something went wrong with that request. Please try again.