lib/packaging/rpm/repo.rb in packaging-0.114.0 vs lib/packaging/rpm/repo.rb in packaging-0.115.0
- old
+ new
@@ -38,11 +38,29 @@
remote_repos_path
)
end
end
+ ##
+ ## Let a wrapper script handle lock setting and pathing for the createrepo command
+ ##
def repo_creation_command(repo_directory, artifact_paths = nil)
+ artifact_paths_argument = if artifact_paths
+ artifact_paths.join(' ')
+ else
+ ''
+ end
+ "/usr/local/bin/packaging-createrepo-wrapper #{repo_directory} #{artifact_paths_argument}"
+ end
+
+
+ ##
+ ## Deprecated
+ ## This was a slightly tortous way of going about this. Instead, see above.
+ ## Instead of constructing loop, let a wrapper script handle the details.
+ ##
+ def deprecated_repo_creation_command(repo_directory, artifact_paths = nil)
cmd = "[ -d #{repo_directory} ] || exit 1 ; "
cmd << "pushd #{repo_directory} > /dev/null && "
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" && '
@@ -129,18 +147,23 @@
Pkg::Util::Gpg.sign_file(file)
end
end
def retrieve_repo_configs(target = "repo_configs")
- wget = Pkg::Util::Tool.check_tool("wget")
+ wget = Pkg::Util::Tool.check_tool('wget')
FileUtils.mkdir_p("pkg/#{target}")
config_url = "#{base_url}/#{target}/rpm/"
+
+ config_fetch_command = <<~CONFIG_FETCH_COMMAND.gsub(%r{\n}, ' ')
+ #{wget} --recursive --no-parent --no-host-directories --cut-dirs=3
+ "--directory-prefix=pkg/#{target} --reject='index' #{config_url}"
+ CONFIG_FETCH_COMMAND
+
begin
- stdout, = Pkg::Util::Execution.capture3("#{wget} -r -np -nH --cut-dirs 3 -P pkg/#{target} --reject 'index*' #{config_url}")
- stdout
+ Pkg::Util::Execution.capture3(config_fetch_command)[0]
rescue StandardError => e
- fail "Couldn't retrieve rpm yum repo configs.\n#{e}"
+ fail "\"#{config_fetch_command} failed.\n#{e}"
end
end
# Generate yum configuration files that point to the repositories created
# on the distribution server with packages created from the current source
@@ -150,30 +173,24 @@
# clients to install these packages.
#
def generate_repo_configs(source = "repos", target = "repo_configs", signed = false)
# We have a hard requirement on wget because of all the download magicks
# we have to do
- #
wget = Pkg::Util::Tool.check_tool("wget")
# This is the standard path to all build artifacts on the distribution
# server for this commit
- #
repo_base = "#{base_url}/#{source}/"
- # First check if the artifacts directory exists
- #
-
# We have to do two checks here - first that there are directories with
# repodata folders in them, and second that those same directories also
# contain rpms
- #
stdout, = Pkg::Util::Execution.capture3("#{wget} --spider -r -l 5 --no-parent #{repo_base} 2>&1")
- stdout = stdout.split.uniq.reject { |x| x =~ /\?|index/ }.select { |x| x =~ /http:.*repodata\/$/ }
+ stdout = stdout.split.uniq.reject { |x| x =~ /\?|index/ }
+ .select { |x| x =~ /http:.*repodata\/$/ }
# RPMs will always exist at the same directory level as the repodata
# folder, which means if we go up a level we should find rpms
- #
yum_repos = []
stdout.map { |x| x.chomp('repodata/') }.each do |url|
output, = Pkg::Util::Execution.capture3("#{wget} --spider -r -l 1 --no-parent #{url} 2>&1")
unless output.split.uniq.reject { |x| x =~ /\?|index/ }.select { |x| x =~ /http:.*\.rpm$/ }.empty?
yum_repos << url