summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-08-25 10:30:24 +0200
committerEugen Wissner <belka@caraus.de>2023-08-25 10:30:24 +0200
commit2126488066713719e26a1049adb080e68ec124f1 (patch)
treec3bdae9dd7a71f4e06666bf125e834f120453794 /lib
parent6983304b9d11e78ebf5fd21c835dd04c776102f5 (diff)
downloadslackbuilder-2126488066713719e26a1049adb080e68ec124f1.tar.gz
Implement clone command in the binary
Diffstat (limited to 'lib')
-rw-r--r--lib/download.rb55
1 files changed, 1 insertions, 54 deletions
diff --git a/lib/download.rb b/lib/download.rb
index f230837..ef255f6 100644
--- a/lib/download.rb
+++ b/lib/download.rb
@@ -15,20 +15,7 @@ module SlackBuilder
extend Rake::FileUtilsExt
def self.clone(repo, tarball, tag_prefix = 'v')
- name_version = File.basename tarball, '.tar.xz'
- remote_path = tarball[tarball.index('/')..]
-
- if remote_file_exists?(remote_path)
- uri = URI hosted_sources(remote_path)
-
- return download(uri, "slackbuilds/#{tarball}").hexdigest
- end
-
- clone_and_archive repo, name_version, tarball, tag_prefix
-
- sh(*upload_command(tarball, remote_path))
-
- Digest::MD5.hexdigest File.read("slackbuilds/#{tarball}")
+ `./bin/slackbuilder clone #{repo} #{tarball} #{tag_prefix}`
end
def self.download(uri, target)
@@ -56,46 +43,6 @@ module SlackBuilder
checksum.hexdigest
end
- private_class_method def self.redirect_download(location, target)
- puts 'redirecting...'
- new_location = URI location
-
- download new_location, target
- end
-
- private_class_method def self.write_chunk(response, checksum, progressbar, io)
- response.read_body do |chunk|
- progressbar.progress += chunk.length
- io << chunk
- checksum << chunk
- end
- end
-
- private_class_method def self.write_download(target, response)
- checksum = Digest::MD5.new
- progressbar = ProgressBar.create title: target, total: response.header.content_length
-
- File.open target, 'w' do |io|
- write_chunk response, checksum, progressbar, io
- end
- progressbar.finish
-
- checksum
- end
-
- private_class_method def self.start_download(uri, target, http)
- request = Net::HTTP::Get.new uri
-
- http.request request do |response|
- case response
- when Net::HTTPRedirection
- return redirect_download response['location'], target
- else
- return write_download target, response
- end
- end
- end
-
private_class_method def self.upload_command(local_path, remote_path)
['scp', "slackbuilds/#{local_path}", CONFIG[:remote_path] + remote_path]
end