Permalink
Browse files

normalize whitespace

  • Loading branch information...
erikogan committed Dec 4, 2010
1 parent 2555115 commit 04724281b4eaf63489b6d062c8527b4b80acc3bf
@@ -16,17 +16,17 @@ srpm=`ls -1t $stage/SRPMS/*rpm | head -1`
for ver in {epel-5,fedora-{13,14}}
do
- echo --------- $ver
- xdir=$stage/`echo $ver | tr '-' '/'`/x86_64
- idir=`echo $xdir | sed -e 's/x86_64/i386/'`
- mock -r passenger-$ver-x86_64 $srpm
- mkdir -p $xdir $idir
- cp /var/lib/mock/passenger-$ver-x86_64/result/*noarch.rpm $xdir
- cp /var/lib/mock/passenger-$ver-x86_64/result/*noarch.rpm $idir
- cd $xdir/..
- short=`ls -1t x86_64/*rpm | head -1 | perl -pe 's{.*/(.*)-[^-]+-[^-]+(.noarch.rpm)}{\1\2}'`
- ln -s x86_64/*rpm $short
- cd -
+ echo --------- $ver
+ xdir=$stage/`echo $ver | tr '-' '/'`/x86_64
+ idir=`echo $xdir | sed -e 's/x86_64/i386/'`
+ mock -r passenger-$ver-x86_64 $srpm
+ mkdir -p $xdir $idir
+ cp /var/lib/mock/passenger-$ver-x86_64/result/*noarch.rpm $xdir
+ cp /var/lib/mock/passenger-$ver-x86_64/result/*noarch.rpm $idir
+ cd $xdir/..
+ short=`ls -1t x86_64/*rpm | head -1 | perl -pe 's{.*/(.*)-[^-]+-[^-]+(.noarch.rpm)}{\1\2}'`
+ ln -s x86_64/*rpm $short
+ cd -
done
mv $stage/epel $stage/rhel
View
@@ -24,15 +24,15 @@
@verbosity = 0
-@can_build = {
- 'i386' => %w{i586 i686},
- 'i686' => %w{i586 i686},
- 'ppc' => %w{},
- 'ppc64' => %w{ppc},
- 's390x' => %w{},
- 'sparc' => %w{},
- 'sparc64' => %w{sparc},
- 'x86_64' => %w{i386 i586 i686},
+@can_build = {
+ 'i386' => %w{i586 i686},
+ 'i686' => %w{i586 i686},
+ 'ppc' => %w{},
+ 'ppc64' => %w{ppc},
+ 's390x' => %w{},
+ 'sparc' => %w{},
+ 'sparc64' => %w{sparc},
+ 'x86_64' => %w{i386 i586 i686},
}
#@can_build.keys.each {|k| @can_build[k].push k}
@@ -44,130 +44,130 @@
configs = Dir["#{mock_etc_dir}/{#{CFGLIMIT.join ','}}*"].map {|f| f.gsub(%r{.*/([^.]*).cfg}, '\1')}
def limit_configs(configs, limits)
- tree = configs.inject({}) do |m,c|
- (distro,version,arch) = c.split /-/
- next m unless @can_build.include?(arch)
- [
- # Rather than construct this list programatically, just spell it out
- '',
- distro,
- "#{distro}-#{version}",
- "#{distro}-#{version}-#{arch}",
- "#{distro}--#{arch}",
- "--#{arch}",
- # doubtful these will be used, but for completeness
- "-#{version}",
- "-#{version}-#{arch}",
- ].each do |pattern|
- unless m[pattern]
- m[pattern] = []
- end
- m[pattern].push c
- end
- m
- end
- tree.default = []
- # Special case for no arguments
- limits = [nil] if limits.empty?
- # By splitting and rejoining we normalize the distro--, etc. cases.
- return limits.map do |l|
- parts = l.to_s.split(/-/).map {|v| v == '*' ? nil : v}
- if parts[2] && !@can_build.include?(parts[2])
- 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
+ tree = configs.inject({}) do |m,c|
+ (distro,version,arch) = c.split /-/
+ next m unless @can_build.include?(arch)
+ [
+ # Rather than construct this list programatically, just spell it out
+ '',
+ distro,
+ "#{distro}-#{version}",
+ "#{distro}-#{version}-#{arch}",
+ "#{distro}--#{arch}",
+ "--#{arch}",
+ # doubtful these will be used, but for completeness
+ "-#{version}",
+ "-#{version}-#{arch}",
+ ].each do |pattern|
+ unless m[pattern]
+ m[pattern] = []
+ end
+ m[pattern].push c
+ end
+ m
+ end
+ tree.default = []
+ # Special case for no arguments
+ limits = [nil] if limits.empty?
+ # By splitting and rejoining we normalize the distro--, etc. cases.
+ return limits.map do |l|
+ parts = l.to_s.split(/-/).map {|v| v == '*' ? nil : v}
+ if parts[2] && !@can_build.include?(parts[2])
+ 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
def noisy_system(*args)
- puts args.join ' ' if @verbosity > 0
- system(*args)
+ puts args.join ' ' if @verbosity > 0
+ system(*args)
end
############################################################################
options = {}
OptionParser.new do |opts|
- opts.banner = "Usage: #{$0} [options] [distro-version-arch] [distro-version] [distro--arch] [*--arch]"
-
- opts.on("-v", "--[no-]verbose", "Run verbosely. Add more -v's to increase @verbosity") do |v|
- @verbosity += v ? 1 : -1
- end
-
- opts.on('-s', '--single', 'Only build a single distro-rev-arch set (for this machine)') do |v|
- options[:single] = true
- end
-
- # Do these with options, because the order matters
- opts.on('-b', '--mock-base-dir DIR', "Mock's base directory. Default: #{mock_base_dir}") do |v|
- #mock_repo_dir = v
- 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|
- #mock_repo_dir = v
- options[:mock_repo_dir] = v
- end
-
- opts.on("-c", "--mock-config-dir DIR", "Directory for mock configuration. Default: #{mock_etc_dir}") do |v|
- if File.directory?(v)
- mock_etc_dir=v
- else
- abort "No such directory: #{v}"
- end
- end
-
- opts.on('-d', '--stage-dir DIR', "Staging directory. Default: #{stage_dir}") do |v|
- stage_dir = v
- 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_tail("-h", "--help", "Show this message") do
- puts opts
- exit
- end
+ opts.banner = "Usage: #{$0} [options] [distro-version-arch] [distro-version] [distro--arch] [*--arch]"
+
+ opts.on("-v", "--[no-]verbose", "Run verbosely. Add more -v's to increase @verbosity") do |v|
+ @verbosity += v ? 1 : -1
+ end
+
+ opts.on('-s', '--single', 'Only build a single distro-rev-arch set (for this machine)') do |v|
+ options[:single] = true
+ end
+
+ # Do these with options, because the order matters
+ opts.on('-b', '--mock-base-dir DIR', "Mock's base directory. Default: #{mock_base_dir}") do |v|
+ #mock_repo_dir = v
+ 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|
+ #mock_repo_dir = v
+ options[:mock_repo_dir] = v
+ end
+
+ opts.on("-c", "--mock-config-dir DIR", "Directory for mock configuration. Default: #{mock_etc_dir}") do |v|
+ if File.directory?(v)
+ mock_etc_dir=v
+ else
+ abort "No such directory: #{v}"
+ end
+ end
+
+ opts.on('-d', '--stage-dir DIR', "Staging directory. Default: #{stage_dir}") do |v|
+ stage_dir = v
+ 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_tail("-h", "--help", "Show this message") do
+ puts opts
+ exit
+ end
end.parse!
if options.key?(:mock_base_dir) || options.key?(:mock_repo_dir)
- if options.key?(:mock_base_dir)
- mock_base_dir = options[:mock_base_dir]
- mock_repo_dir = "#{mock_base_dir}/passenger-build-repo"
- end
- if options.key?(:mock_repo_dir)
- mock_repo_dir = options[:mock_repo_dir]
- unless mock_repo_dir[0] == '/'[0]
- mock_repo_dir = "#{mock_base_dir}/#{mock_repo_dir}"
- end
- end
+ if options.key?(:mock_base_dir)
+ mock_base_dir = options[:mock_base_dir]
+ mock_repo_dir = "#{mock_base_dir}/passenger-build-repo"
+ end
+ if options.key?(:mock_repo_dir)
+ mock_repo_dir = options[:mock_repo_dir]
+ unless mock_repo_dir[0] == '/'[0]
+ mock_repo_dir = "#{mock_base_dir}/#{mock_repo_dir}"
+ end
+ end
end
limit = ARGV
if options.key?(:single)
- # This can probably be simplified
- limit = [`rpm --queryformat '%{name}\t%{version}' -qf /etc/redhat-release`.sub(/(\w+)-release\t(\d+)/,'\1-\2').sub(/^(rhel|centos|sl)-/,'epel-') + "-#{`rpm -E '%{_host_cpu}'`.strip}"]
+ # This can probably be simplified
+ limit = [`rpm --queryformat '%{name}\t%{version}' -qf /etc/redhat-release`.sub(/(\w+)-release\t(\d+)/,'\1-\2').sub(/^(rhel|centos|sl)-/,'epel-') + "-#{`rpm -E '%{_host_cpu}'`.strip}"]
end
configs = limit_configs(configs, limit)
if configs.empty?
- abort "Can't find a set of configs for '#{ARGV[0]}' (hint try 'fedora' or 'fedora-14' or even 'fedora-14-x86_64')"
+ abort "Can't find a set of configs for '#{ARGV[0]}' (hint try 'fedora' or 'fedora-14' or even 'fedora-14-x86_64')"
end
-puts "BUILD:\n " + configs.join("\n ") if @verbosity >= 2
+puts "BUILD:\n " + configs.join("\n ") if @verbosity >= 2
# Too much of what follows expects this. Revisit it later.
Dir.chdir(File.join(File.dirname(__FILE__), '..'))
@@ -180,14 +180,14 @@ def noisy_system(*args)
# Check the ages of the configs for validity
mtime = File.mtime("#{bindir}/mocksetup.sh")
if configs.any? {|c| mtime > File.mtime("#{mock_etc_dir}/passenger-#{c}.cfg") rescue true }
- unless noisy_system("#{bindir}/mocksetup.sh", mock_repo_dir, mock_etc_dir)
- abort <<EndErr
+ unless noisy_system("#{bindir}/mocksetup.sh", mock_repo_dir, mock_etc_dir)
+ abort <<EndErr
Unable to run "#{bindir}/mocksetup.sh #{mock_repo_dir}". It is likely that you
need to run this command as root the first time, but if you have already done
that, it could also be that the current user (or this shell) is not in the
'mock' group.
EndErr
- end
+ end
end
srcdir=`rpm -E '%{_sourcedir}'`.chomp
@@ -198,19 +198,19 @@ def noisy_system(*args)
specdir="/tmp/#{`whoami`.strip}-specfile-#{Process.pid}"
FileUtils.rm_rf(specdir, :verbose => @verbosity > 0)
begin
- FileUtils.mkdir_p(specdir, :verbose => @verbosity > 0)
- FileUtils.cp('passenger.spec', specdir, :verbose => @verbosity > 0)
- # + must be escaped, but * doesn't? And people wonder why I hate sed.
- abort "Can't edit specfile" unless noisy_system('sed', '-i',
- '-e', "s/^\\(\\([[:space:]]*\\)%define[[:space:]]\\+passenger_version[[:space:]]\\)\\+[0-9.]\\+.*/\\2# From Passenger Source\\n\\1#{PhusionPassenger::VERSION_STRING}/",
- '-e', "s/^\\(\\([[:space:]]*\\)%define[[:space:]]\\+nginx_version[[:space:]]\\)\\+[0-9.]\\+.*/\\2# From Passenger Source\\n\\1#{PhusionPassenger::PREFERRED_NGINX_VERSION}/",
- "#{specdir}/passenger.spec")
- # No dist for SRPM
- unless noisy_system(rpmbuild, *((@verbosity > 0 ? [] : %w{--quiet}) + ['--define', 'dist %nil', '-bs', "#{specdir}/passenger.spec"]))
- abort "No SRPM was built. See above for the error"
- end
+ FileUtils.mkdir_p(specdir, :verbose => @verbosity > 0)
+ FileUtils.cp('passenger.spec', specdir, :verbose => @verbosity > 0)
+ # + must be escaped, but * doesn't? And people wonder why I hate sed.
+ abort "Can't edit specfile" unless noisy_system('sed', '-i',
+ '-e', "s/^\\(\\([[:space:]]*\\)%define[[:space:]]\\+passenger_version[[:space:]]\\)\\+[0-9.]\\+.*/\\2# From Passenger Source\\n\\1#{PhusionPassenger::VERSION_STRING}/",
+ '-e', "s/^\\(\\([[:space:]]*\\)%define[[:space:]]\\+nginx_version[[:space:]]\\)\\+[0-9.]\\+.*/\\2# From Passenger Source\\n\\1#{PhusionPassenger::PREFERRED_NGINX_VERSION}/",
+ "#{specdir}/passenger.spec")
+ # No dist for SRPM
+ unless noisy_system(rpmbuild, *((@verbosity > 0 ? [] : %w{--quiet}) + ['--define', 'dist %nil', '-bs', "#{specdir}/passenger.spec"]))
+ abort "No SRPM was built. See above for the error"
+ end
ensure
- FileUtils.rm_rf(specdir, :verbose => @verbosity > 0)
+ FileUtils.rm_rf(specdir, :verbose => @verbosity > 0)
end
# I really wish there was a way to query rpmbuild for this via the spec file,
@@ -225,36 +225,35 @@ def noisy_system(*args)
mockvolume = @verbosity >= 2 ? %w{-v} : @verbosity < 0 ? %w{-q} : []
configs.each do |cfg|
- puts "---------------------- Building #{cfg}" if @verbosity >= 0
- pcfg = 'passenger-' + cfg
-
- idir = './pkg'
-
- unless options.key?(:single)
- idir = File.join stage_dir, cfg.split(/-/)
- end
-
- # Move *mockvolume to the end, since it causes Ruby to cry in the middle
- # Alt sol'n: *(foo + ['bar'] )
- if noisy_system('mock', '-r', pcfg, "#{stage_dir}/SRPMS/#{srpm}", *mockvolume)
- else
- abort "Mock failed. See above for details"
- end
- FileUtils.mkdir_p(idir, :verbose => @verbosity > 0)
- FileUtils.cp(Dir["#{mock_base_dir}/#{pcfg}/result/*.rpm"],
- idir, :verbose => @verbosity > 0)
- if options.key?(:extra_packages)
- FileUtils.cp(Dir["#{options[:extra_packages]}/*.rpm"], idir, :verbose => @verbosity > 0)
- end
- FileUtils.rm_f(Dir["#{idir}/*.src.rpm"], :verbose => @verbosity > 1) unless options.key?(:single)
+ puts "---------------------- Building #{cfg}" if @verbosity >= 0
+ pcfg = 'passenger-' + cfg
+
+ idir = './pkg'
+
+ unless options.key?(:single)
+ idir = File.join stage_dir, cfg.split(/-/)
+ end
+
+ # Move *mockvolume to the end, since it causes Ruby to cry in the middle
+ # Alt sol'n: *(foo + ['bar'] )
+ unless noisy_system('mock', '-r', pcfg, "#{stage_dir}/SRPMS/#{srpm}", *mockvolume)
+ abort "Mock failed. See above for details"
+ end
+ FileUtils.mkdir_p(idir, :verbose => @verbosity > 0)
+ FileUtils.cp(Dir["#{mock_base_dir}/#{pcfg}/result/*.rpm"],
+ idir, :verbose => @verbosity > 0)
+ if options.key?(:extra_packages)
+ FileUtils.cp(Dir["#{options[:extra_packages]}/*.rpm"], idir, :verbose => @verbosity > 0)
+ end
+ FileUtils.rm_f(Dir["#{idir}/*.src.rpm"], :verbose => @verbosity > 1) unless options.key?(:single)
end
unless options.key?(:single)
- if File.directory?("#{stage_dir}/epel")
- FileUtils.mv "#{stage_dir}/epel", "#{stage_dir}/rhel", :verbose => @verbosity > 0
- end
+ if File.directory?("#{stage_dir}/epel")
+ FileUtils.mv "#{stage_dir}/epel", "#{stage_dir}/rhel", :verbose => @verbosity > 0
+ end
end
unless `rpm -E '%{?_signature}'`.strip == ''
- noisy_system('rpm', '--addsign', *Dir["#{options.key?(:single) ? stage_dir : 'pkg'}/**/*.rpm"])
+ noisy_system('rpm', '--addsign', *Dir["#{options.key?(:single) ? stage_dir : 'pkg'}/**/*.rpm"])
end
Oops, something went wrong.

0 comments on commit 0472428

Please sign in to comment.