ext/packaging/tasks/rpm_repos.rake in puppet-2.7.22 vs ext/packaging/tasks/rpm_repos.rake in puppet-2.7.23
- old
+ new
@@ -11,47 +11,48 @@
#
namespace :pl do
namespace :jenkins do
desc "Create yum repositories of built RPM packages for this SHA on the distribution server"
task :rpm_repos => "pl:fetch" do
- # Formulate our command string, which will just find directories with rpms
- # and create and update repositories.
- #
- artifact_directory = File.join(@build.jenkins_repo_path, @build.project, @build.ref)
+ begin
+ # Formulate our command string, which will just find directories with rpms
+ # and create and update repositories.
+ #
+ artifact_directory = File.join(@build.jenkins_repo_path, @build.project, @build.ref)
- ##
- # Test that the artifacts directory exists on the distribution server.
- # This will give us some more helpful output.
- #
- cmd = 'echo "Checking for build artifacts. Will exit if not found." ; '
- cmd << "[ -d #{artifact_directory}/artifacts ] || exit 0 ; "
+ ##
+ # Test that the artifacts directory exists on the distribution server.
+ # This will give us some more helpful output.
+ #
+ cmd = 'echo "Checking for build artifacts. Will exit if not found." ; '
+ cmd << "[ -d #{artifact_directory}/artifacts ] || exit 1 ; "
- ##
- # Enter the directory containing the build artifacts and create repos.
- #
- cmd << "pushd #{artifact_directory} ; "
- cmd << 'echo "Checking for running repo creation. Will wait if detected." ; '
- cmd << "while [ -f .lock ] ; do sleep 1 ; echo -n '.' ; done ; "
- cmd << 'echo "Setting lock" ; '
- cmd << "touch .lock ; "
- cmd << "rsync -avxl artifacts/ repos/ ; pushd repos ; "
- cmd << "createrepo=$(which createrepo) ; "
- cmd << 'for repodir in $(find ./ -name "*.rpm" | xargs -I {} dirname {}) ; do '
- cmd << "pushd $repodir && $createrepo -d --update . && popd ; "
- cmd << "done ; popd "
+ ##
+ # Enter the directory containing the build artifacts and create repos.
+ #
+ cmd << "pushd #{artifact_directory} ; "
+ cmd << 'echo "Checking for running repo creation. Will wait if detected." ; '
+ cmd << "while [ -f .lock ] ; do sleep 1 ; echo -n '.' ; done ; "
+ cmd << 'echo "Setting lock" ; '
+ cmd << "touch .lock ; "
+ cmd << "rsync -avxl artifacts/ repos/ ; pushd repos ; "
+ cmd << "createrepo=$(which createrepo) ; "
+ cmd << 'for repodir in $(find ./ -name "*.rpm" | xargs -I {} dirname {}) ; do '
+ cmd << "pushd $repodir && $createrepo -d --update . && popd ; "
+ cmd << "done ; popd "
- remote_ssh_cmd(@build.distribution_server, cmd)
+ remote_ssh_cmd(@build.distribution_server, cmd)
+ # Now that we've created our repositories, we can create the configs for
+ # them
+ Rake::Task["pl:jenkins:generate_rpm_repo_configs"].execute
- # Always remove the lock file, even if we've failed
- remote_ssh_cmd(@build.distribution_server, "rm -f #{artifact_directory}/.lock")
-
- # Now that we've created our repositories, we can create the configs for
- # them
- Rake::Task["pl:jenkins:generate_rpm_repo_configs"].execute
-
- # And once they're created, we can ship them
- Rake::Task["pl:jenkins:ship_repo_configs"].execute
+ # And once they're created, we can ship them
+ Rake::Task["pl:jenkins:ship_repo_configs"].execute
+ ensure
+ # Always remove the lock file, even if we've failed
+ remote_ssh_cmd(@build.distribution_server, "rm -f #{artifact_directory}/.lock")
+ end
end
# Generate yum configuration files that point to the repositories created
# on the distribution server with packages created from the current source
# repo commit. There is one for each dist/version that is packaged (e.g.
@@ -63,14 +64,11 @@
task :generate_rpm_repo_configs => "pl:fetch" do
# We have a hard requirement on wget because of all the download magicks
# we have to do
#
- unless wget = find_tool("wget")
- warn "Could not find `wget` tool. This is needed for composing the yum repo configurations. Install `wget` and try again."
- exit 0
- end
+ wget = find_tool("wget") or fail "Could not find `wget` tool. This is needed for composing the yum repo configurations. Install `wget` and try again."
# This is the standard path to all build artifacts on the distribution
# server for this commit
#
base_url = "http://#{@build.builds_server}/#{@build.project}/#{@build.ref}/repos/"
@@ -92,14 +90,11 @@
unless %x{#{wget} --spider -r -l 1 --no-parent #{url} 2>&1}.split.uniq.reject{ |x| x =~ /\?|index/ }.select{|x| x =~ /http:.*\.rpm$/}.empty?
yum_repos << url
end
end
- if yum_repos.empty?
- puts "No rpm repos were found to generate configs from. Exiting.."
- exit 0
- end
+ yum_repos.empty? and fail "No rpm repos were found to generate configs from!"
mkdir_p File.join("pkg","repo_configs","rpm")
# Parse the rpm configs file to generate repository configs. Each line in
# the rpm_configs file corresponds with a repo directory on the
@@ -107,11 +102,10 @@
#
yum_repos.each do |url|
# We ship a base 'srpm' that gets turned into a repo, but we want to
# ignore this one because its an extra
next if url == "#{base_url}srpm/"
- elements = url.split('/')
dist,version,subdir,arch = url.split('/')[-4..-1]
# Create an array of lines that will become our yum config
#
@@ -129,21 +123,16 @@
puts "Wrote yum configuration files for #{@build.project} at #{@build.ref} to pkg/repo_configs/rpm"
end
desc "Retrieve rpm yum repository configs from distribution server"
task :rpm_repo_configs => "pl:fetch" do
- if wget = find_tool("wget")
- mkdir_p "pkg/repo_configs"
- config_url = "#{@build.builds_server}/#{@build.project}/#{@build.ref}/repo_configs/rpm/"
- begin
- sh "#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{config_url}"
- rescue
- warn "Couldn't retrieve rpm yum repo configs. See preceding http response for more info."
- exit 1
- end
- else
- warn "Could not find `wget` tool! wget is required to download the repository configs."
- exit 1
+ wget = find_tool("wget") or fail "Could not find `wget` tool! wget is required to download the repository configs."
+ mkdir_p "pkg/repo_configs"
+ config_url = "#{@build.builds_server}/#{@build.project}/#{@build.ref}/repo_configs/rpm/"
+ begin
+ sh "#{wget} -r -np -nH --cut-dirs 3 -P pkg/repo_configs --reject 'index*' #{config_url}"
+ rescue
+ fail "Couldn't retrieve rpm yum repo configs. See preceding http response for more info."
end
end
end
end