Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Complete (and fix) the yum repository build

build/rpm.rb:
  * Use the :package target to build the tarball rather than building it by hand
  * Add the ability to override the --stage-dir & --extra_packages arguments to the build command
  * Copy the shtml files, GPG key, and example .htaccess file into the repository
  * Default verbosity to 1 everywhere, not just in called scripts
rpm/release/build.rb:
  * Remove the sorting of targets, now that the root cause of the problem is identified
  * Add building of passenger-release packages & copying/symlinking them to the correct locations for a yum-repo
  * Fix RPM signing: Use the right macro and only sign packages that are not already signed by your key
  • Loading branch information...
commit b877b6d88b6c17586b9117a4eacc879f0659fab9 1 parent dd10460
Erik Ogan erikogan authored
39 build/rpm.rb
View
@@ -31,17 +31,8 @@ def noisy_system(*args)
system(*args)
end
- def create_tarball(verbosity = 0)
- working_dir = "/tmp/#{`whoami`.strip}-passenger-rpm-#{Process.pid}"
- sub_dir = "passenger-#{PhusionPassenger::VERSION_STRING}"
- FileUtils.rm_rf(working_dir, :verbose => verbosity > 0)
- begin
- FileUtils.mkdir_p("#{working_dir}/#{sub_dir}", :verbose => verbosity > 0)
- noisy_system(*(%w{rsync -ra --exclude=.git --exclude=rpm/pkg --exclude=rpm/yum-repo --exclude=*.o --exclude=*.so} + (@verbosity > 2 ? %w{-v} : []) + (@verbosity > 3 ? %w{--progress} : []) + ['.', "#{working_dir}/#{sub_dir}/."] ))
- noisy_system('tar', "cz#{verbosity >= 2 ? 'v' : ''}", "-C", working_dir, '-f', "#{sources_dir}/#{sub_dir}.tar.gz", sub_dir)
- ensure
- FileUtils.rm_rf("#{working_dir}", :verbose => verbosity > 0)
- end
+ def copy_tarball(verbosity = 0)
+ FileUtils.cp(File.join('pkg', "passenger-#{PhusionPassenger::VERSION_STRING}.tar.gz"), sources_dir, :verbose => verbosity > 0)
end
def test_setup(*args)
@@ -55,6 +46,8 @@ def fetch(dir)
end
end
+ ENV['BUILD_VERBOSITY'] = @verbosity.to_s
+
result = noisy_system('./rpm/release/mocksetup-first.sh', *args)
if !result
# exit status 4 means that the user needs to relogin.
@@ -68,22 +61,24 @@ def fetch(dir)
end
desc "Package the current release into a set of RPMs"
- task 'rpm' => :rpm_verbosity do
+ task 'rpm' => [:package, :rpm_verbosity] do
test_setup
- create_tarball(@verbosity)
- # Add a single -v for some feedback
- noisy_system(*(%w{./rpm/release/build.rb --single --stage-dir=pkg --extra-packages=release/mock-repo} + @build_verbosity))
+ copy_tarball(@verbosity)
+ noisy_system(*(%w{./rpm/release/build.rb --single} + ["--stage-dir=#{ENV['stage_dir'] || 'pkg'}", "--extra-packages=#{ENV['extra_packages'] || 'release/mock-repo'}"] + @build_verbosity))
end
desc "Build a Yum repository for the current release"
- task 'yum' => :rpm_verbosity do
+ task 'yum' => [:package, :rpm_verbosity] do
test_setup(*%w{-p createrepo -p rubygem-gem2rpm})
- create_tarball(@verbosity)
- # Add a single -v for some feedback
- noisy_system(*(%w{./rpm/release/build.rb --stage-dir=yum-repo --extra-packages=release/mock-repo} + @build_verbosity))
- Dir["yum-repo/{fedora,rhel}/*/{i386,x86_64}"].each do |dir|
+ copy_tarball(@verbosity)
+ noisy_system(*(%w{./rpm/release/build.rb --include-release} + ["--stage-dir=#{ENV['stage_dir'] || 'yum-repo'}", "--extra-packages=#{ENV['extra_packages'] || 'release/mock-repo'}"] + @build_verbosity))
+ repo=File.expand_path("#{ENV['stage_dir'] || 'yum-repo'}", 'rpm')
+ Dir["#{repo}/{fedora,rhel}/*/{i386,x86_64}"].each do |dir|
noisy_system('createrepo', dir)
end
+ FileUtils.cp(Dir["rpm/doc/*.shtml"], repo, :verbose => @verbosity > 0)
+ FileUtils.cp('rpm/doc/example_yum_repository_htaccess', "#{repo}/.htaccess.example", :verbose => @verbosity > 0)
+ FileUtils.cp('rpm/release/RPM-GPG-KEY-stealthymonkeys'. "#{repo}/RPM-GPG-KEY-stealthymonkeys.asc")
end
task 'rpm_verbosity' do
@@ -91,8 +86,8 @@ def fetch(dir)
@verbosity = 1
@build_verbosity = %w{-v}
else
- @verbosity = ENV['verbosity'].to_i
- @build_verbosity = %w{-v} * (ENV['verbosity'].nil? ? 1 : @verbosity)
+ @verbosity = ENV['verbosity'] ? ENV['verbosity'].to_i : 1
+ @build_verbosity = %w{-v} * @verbosity
end
end
end
5 rpm/doc/example_yum_repository_htaccess
View
@@ -0,0 +1,5 @@
+Options +Includes
+IndexOptions +FancyIndexing +IgnoreCase +SuppressDescription +NameWidth=* +SuppressHTMLPreamble
+HeaderName /header.shtml
+ReadmeName /footer.shtml
+IndexIgnore header.shtml footer.shtml
84 rpm/release/build.rb
View
@@ -76,21 +76,11 @@ def limit_configs(configs, limits)
abort "ERROR: Cannot build '#{parts[2]}' packages on '#{rpmarch}'"
end
tree[parts.join '-']
- # All of a sudden the i386 mock builds are failing IFF they're run after an
- # x86_64 build. I don't understand how separate processes in separate
- # (chroot'ed!) environments can pollute each other, and I find it rather
- # troubling. But for now the workaround is to sort by arch & do i386 first.
- end.flatten.sort do |a,b|
- ap = a.split(/-/)
- ap.unshift(ap.pop)
- bp = b.split(/-/)
- bp.unshift(bp.pop)
- ap <=> bp
- end
+ end.flatten
end
def noisy_system(*args)
- puts args.join ' ' if @verbosity > 0
+ puts(args.join(' ')) if @verbosity > 0
system(*args)
end
@@ -114,7 +104,7 @@ def noisy_system(*args)
options[:mock_base_dir] = v
end
- opts.on('-r', '--mock-repo-dir DIR', "Directory for special mock yum repository. Default: #{mock_repo_dir}") do |v|
+ opts.on('-m', '--mock-repo-dir DIR', "Directory for special mock yum repository. Default: #{mock_repo_dir}") do |v|
#mock_repo_dir = v
options[:mock_repo_dir] = v
end
@@ -132,10 +122,13 @@ def noisy_system(*args)
end
opts.on('-e', '--extra-packages DIR', "Directory for extra packages to install.") do |v|
- #mock_repo_dir = v
options[:extra_packages] = v
end
+ opts.on('-r', '--include-release', "Also build passenger-release packages") do
+ options[:release] = true
+ end
+
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
@@ -192,7 +185,7 @@ def noisy_system(*args)
srcdir=`rpm -E '%{_sourcedir}'`.chomp
-FileUtils.ln_sf(Dir["#{Dir.getwd}/{config/,patches/,release/GPG}*"], srcdir, :verbose => @verbosity > 0)
+FileUtils.ln_sf(Dir["#{Dir.getwd}/{config/,patches/,release/RPM-GPG}*"], srcdir, :verbose => @verbosity > 0)
# Force the default versions in the spec file to be the ones in the source so a given SRPM doesn't need a --define to set versions.
specdir="/tmp/#{`whoami`.strip}-specfile-#{Process.pid}"
@@ -213,17 +206,32 @@ def noisy_system(*args)
FileUtils.rm_rf(specdir, :verbose => @verbosity > 0)
end
-# I really wish there was a way to query rpmbuild for this via the spec file,
-# but rpmbuild --eval doesn't seem to work
srpm="rubygem-passenger-#{PhusionPassenger::VERSION_STRING}-#{`grep '%define passenger_release' passenger.spec | awk '{print $3}'`.strip}.src.rpm".sub(/%\{[^}]+\}/, '')
FileUtils.mkdir_p(stage_dir + '/SRPMS', :verbose => @verbosity > 0)
-FileUtils.cp("#{rpmtopdir}/SRPMS/#{srpm}", "#{stage_dir}/SRPMS",
-:verbose => @verbosity > 0)
+FileUtils.cp("#{rpmtopdir}/SRPMS/#{srpm}", "#{stage_dir}/SRPMS", :verbose => @verbosity > 0)
+
+if options[:release]
+ # It's not EXACTLY equivalent, is it? (REALLY doesn't want to symlink to a different name)
+ # FileUtils.ln_sf(Dir["#{Dir.getwd}/release/mirrors"], "#{srcdir}/mirrors-passenger", :verbose => @verbosity > 0)
+ FileUtils.ln_sf(Dir["#{Dir.getwd}/release/mirrors"], srcdir, :verbose => @verbosity > 0)
+ FileUtils.rm_f( "#{srcdir}/mirrors-passenger", :verbose => @verbosity > 0)
+ FileUtils.mv("#{srcdir}/mirrors", "#{srcdir}/mirrors-passenger", :force => true, :verbose => @verbosity > 0)
+ unless noisy_system(rpmbuild, *((@verbosity > 0 ? [] : %w{--quiet}) + ['--define', 'dist %nil', '-bs', "passenger-release.spec"]))
+ abort "No passenger-release SRPM was built. See above for the error"
+ end
+ rel_version = `grep '^Version:' passenger-release.spec | awk '{print $2}'`.to_i
+ rel_release = `grep '^Release:' passenger-release.spec | awk '{print $2}'`.to_i
+ @rel_srpm = "passenger-release-#{rel_version}-#{rel_release}.src.rpm"
+ FileUtils.cp("#{rpmtopdir}/SRPMS/passenger-release-#{rel_version}-#{rel_release}.src.rpm",
+ "#{stage_dir}/SRPMS", :verbose => @verbosity > 0)
+end
mockvolume = @verbosity >= 2 ? %w{-v} : @verbosity < 0 ? %w{-q} : []
+@release_cache = {}
+
configs.each do |cfg|
puts "---------------------- Building #{cfg}" if @verbosity >= 0
pcfg = 'passenger-' + cfg
@@ -245,6 +253,23 @@ def noisy_system(*args)
if options.key?(:extra_packages)
FileUtils.cp(Dir["#{options[:extra_packages]}/*.rpm"], idir, :verbose => @verbosity > 0)
end
+
+ if options[:release]
+ cache_key = cfg.split(/-/).first(2).join('-')
+ # There is little sense in rebuilding a noarch package over & over
+ if @release_cache[cache_key]
+ FileUtils.cp(@release_cache[cache_key], idir, :verbose => @verbosity > 0)
+ else
+ unless noisy_system('mock', '-r', pcfg, "#{stage_dir}/SRPMS/#{@rel_srpm}", *mockvolume)
+ abort "Release Mock failed. See above for details"
+ end
+
+ FileUtils.cp(Dir["#{mock_base_dir}/#{pcfg}/result/*.rpm"],
+ idir, :verbose => @verbosity > 0)
+ @release_cache[cache_key] = Dir["#{idir}/passenger-release*noarch.rpm"].last
+ end
+ end
+
FileUtils.rm_f(Dir["#{idir}/*.src.rpm"], :verbose => @verbosity > 1)
end
@@ -254,6 +279,23 @@ def noisy_system(*args)
end
end
-unless `rpm -E '%{?_signature}'`.strip == ''
- noisy_system('rpm', '--addsign', *Dir["#{options.key?(:single) ? stage_dir : 'pkg'}/**/*.rpm"])
+if options[:release]
+ Dir["#{stage_dir}/*/*"].each do |distro_version|
+ next unless File.directory?(distro_version)
+ arch = Dir["#{distro_version}/{#{@can_build.sort.join ','}}"].last
+ pkg = Dir["#{arch}/passenger-release*rpm"].last
+ pkg = pkg.split(/#{File::SEPARATOR}/).last(2)
+ FileUtils.ln_sf(File.join(pkg), "#{distro_version}/passenger-release.noarch.rpm", :verbose => @verbosity > 0)
+ end
+end
+
+unless `rpm -E '%{?_gpg_name}'`.strip == ''
+ signor=`rpm -E '%{_gpg_name}'`.strip
+ key=`gpg --list-key #{signor} | grep '^pub' | awk '{print $2}' | cut -d/ -f2`
+ # Don't re-sign packages already signed by your key
+ files=Dir["#{options.key?(:single) ? 'pkg' : stage_dir}/**/*.rpm"].select do |rpm|
+ !File.symlink?(rpm) && (`rpm --checksig #{rpm}` !~ /#{key}/)
+ end
+
+ noisy_system('rpm', '--addsign', *files)
end
Please sign in to comment.
Something went wrong with that request. Please try again.