Skip to content

Commit

Permalink
Implement a system to recognize whether an install came from an offic…
Browse files Browse the repository at this point in the history
…ial release package
  • Loading branch information
FooBarWidget committed Aug 8, 2013
1 parent 2397990 commit c1d2433
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 3 deletions.
7 changes: 7 additions & 0 deletions bin/passenger-config
Expand Up @@ -41,6 +41,7 @@ def help
puts " --nginx-libs Show Nginx runtime library flags."
puts " --compiled Check whether runtime libraries are compiled."
puts " --natively-packaged Check whether Phusion Passenger is natively packged."
puts " --installed-from-release-package Check whether this installation came from an official release package."
puts " --detect-apache2 Autodetect Apache installations."
puts " --ruby-command Print the correct command for invoking the Ruby interpreter."
puts " --rubyext-compat-id Print the Ruby extension binary compatibility ID."
Expand Down Expand Up @@ -85,6 +86,12 @@ when "--natively-packaged"
else
exit 1
end
when "--installed-from-release-package"
if PhusionPassenger.installed_from_release_package?
exit 0
else
exit 1
end
when "--detect-apache2"
require 'phusion_passenger/platform_info/apache_detector'
detector = PhusionPassenger::PlatformInfo::ApacheDetector.new(STDOUT)
Expand Down
24 changes: 22 additions & 2 deletions build/packaging.rb
Expand Up @@ -49,8 +49,12 @@ def recursive_copy_files(files, destination_dir, preprocess = false, variables =

task :clobber => 'package:clean'

task 'package:set_official' do
ENV['OFFICIAL_RELEASE'] = '1'
end

desc "Build, sign & upload gem & tarball"
task 'package:release' => ['package:gem', 'package:tarball', 'package:sign'] do
task 'package:release' => ['package:set_official', 'package:gem', 'package:tarball', 'package:sign'] do
require 'phusion_passenger'
require 'yaml'
require 'uri'
Expand Down Expand Up @@ -119,7 +123,20 @@ def recursive_copy_files(files, destination_dir, preprocess = false, variables =

task 'package:gem' => Packaging::PREGENERATED_FILES do
require 'phusion_passenger'
sh "gem build #{PhusionPassenger::PACKAGE_NAME}.gemspec --sign --key 0x0A212A8C"
if ENV['OFFICIAL_RELEASE']
release_file = "#{PhusionPassenger.resources_dir}/release.txt"
File.unlink(release_file) rescue nil
end
begin
if release_file
File.open(release_file, "w").close
end
sh "gem build #{PhusionPassenger::PACKAGE_NAME}.gemspec --sign --key 0x0A212A8C"
ensure
if release_file
File.unlink(release_file) rescue nil
end
end
sh "mkdir -p pkg"
sh "mv #{PhusionPassenger::PACKAGE_NAME}-#{PhusionPassenger::VERSION_STRING}.gem pkg/"
end
Expand All @@ -132,6 +149,9 @@ def recursive_copy_files(files, destination_dir, preprocess = false, variables =
sh "rm -rf pkg/#{basename}"
sh "mkdir -p pkg/#{basename}"
recursive_copy_files(ORIG_TARBALL_FILES.call, "pkg/#{basename}")
if ENV['OFFICIAL_RELEASE']
File.open("pkg/#{basename}/resources/release.txt", "w").close
end
sh "cd pkg && tar -c #{basename} | gzip --best > #{basename}.tar.gz"
sh "rm -rf pkg/#{basename}"
end
Expand Down
1 change: 1 addition & 0 deletions debian.template/ruby-passenger.install
Expand Up @@ -5,6 +5,7 @@ usr/share/passenger/standalone_default_root/
usr/share/passenger/ruby_extension_source/
usr/share/passenger/*.types
usr/share/passenger/*.crt
usr/share/passenger/*.txt
usr/lib/ruby/
debian/locations.ini usr/lib/ruby/vendor_ruby/phusion_passenger/
usr/sbin/
Expand Down
1 change: 1 addition & 0 deletions debian.template/rules.template
Expand Up @@ -26,6 +26,7 @@ override_dh_auto_install:
cp -a pkg/fakeroot1.9.1/* debian/tmp/
# Do not package Passenger Standalone.
rm -rf debian/tmp/usr/bin/passenger
touch debian/tmp/usr/share/passenger/release.txt

override_dh_auto_clean:
/usr/bin/rake clean CLEAN_DOCS=false
Expand Down
4 changes: 4 additions & 0 deletions helper-scripts/download_binaries/extconf.rb
Expand Up @@ -42,6 +42,10 @@
puts "Binary downloading is only available when originally packaged. Stopping."
exit 0
end
if PhusionPassenger.installed_from_release_package?
puts "This Phusion Passenger is not installed from an official release package. Stopping."
exit 0
end

# Create download directory and do some preparation
require 'phusion_passenger/platform_info'
Expand Down
8 changes: 8 additions & 0 deletions lib/phusion_passenger.rb
Expand Up @@ -129,6 +129,14 @@ def self.natively_packaged?
return @natively_packaged
end

# Whether the current Phusion Passenger installation is installed
# from a release package, e.g. an official gem or official tarball.
# Retruns false if e.g. the gem was built by the user, or if this
# install is from a git repository.
def self.installed_from_release_package?
File.exist?("#{resources_dir}/release.txt")
end

# When originally packaged, returns the source root.
# When natively packaged, returns the location of the location configuration file.
def self.source_root
Expand Down
2 changes: 1 addition & 1 deletion passenger.gemspec
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.description = "A modern web server and application server for Ruby, Python and Node.js, " +
"optimized for performance, low memory usage and ease of use."

if ENV['WITH_DOWNLOADER']
if ENV['OFFICIAL_RELEASE']
s.extensions = ["helper-scripts/download_binaries/extconf.rb"]
end
end
4 changes: 4 additions & 0 deletions test/integration_tests/native_packaging_spec.rb
Expand Up @@ -122,6 +122,10 @@ def which(command)
system("passenger-config --natively-packaged").should be_true
end

it "recognizes the install as coming from an official package" do
system("passenger-config --installed-from-release-package").should be_true
end

it "shows the directory to the runtime library headers" do
capture_output("passenger-config --includedir").should == INCLUDEDIR
end
Expand Down

0 comments on commit c1d2433

Please sign in to comment.