-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1060 from SUSE/refactor_repomd_mirroring
[4/x] Refactor repomd mirroring
- Loading branch information
Showing
13 changed files
with
305 additions
and
9,419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class RMT::Mirror::License < RMT::Mirror::Base | ||
DIRECTORY_YAST = 'directory.yast'.freeze | ||
def repository_url(*args) | ||
URI.join(repository.external_url.chomp('/') + '.license/', *args).to_s | ||
end | ||
|
||
def repository_path(*args) | ||
File.join(mirroring_base_dir, repository.local_path.chomp('/') + '.license/', *args) | ||
end | ||
|
||
def licenses_available? | ||
uri = URI.join(repository_url(DIRECTORY_YAST)) | ||
uri.query = repository.auth_token if repository.auth_token | ||
|
||
request = RMT::HttpRequest.new(uri, method: :head, followlocation: true) | ||
request.on_success do | ||
return true | ||
end | ||
request.run | ||
|
||
false | ||
end | ||
|
||
def mirror_implementation | ||
return unless licenses_available? | ||
|
||
create_temp_dir(:license) | ||
directory_yast = download_cached!(DIRECTORY_YAST, to: temp(:license)) | ||
|
||
File.readlines(directory_yast.local_path) | ||
.map(&:strip).reject { |item| item == 'directory.yast' } | ||
.map { |relative_path| file_reference(relative_path, to: temp(:license)) } | ||
.each { |ref| enqueue(ref) } | ||
|
||
download_enqueued | ||
|
||
replace_directory(source: temp(:license), destination: repository_path) | ||
rescue RMT::Downloader::Exception => e | ||
raise RMT::Mirror::Exception.new(_('Error while mirroring license files: %{error}') % { error: e.message }) | ||
end | ||
|
||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
directory.yast | ||
license.de.txt | ||
license.es.txt | ||
license.fr.txt | ||
license.it.txt | ||
license.ja.txt | ||
license.ko.txt | ||
license.pt_BR.txt | ||
license.ru.txt | ||
license.txt | ||
license.zh_CN.txt | ||
license.zh_TW.txt |
Oops, something went wrong.