slackbuilder/lib/download.rb

58 lines
1.6 KiB
Ruby
Raw Normal View History

2020-12-09 18:28:42 +01:00
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
# frozen_string_literal: true
2021-01-02 07:39:32 +01:00
require_relative '../config/config'
2020-12-09 18:28:42 +01:00
require_relative 'package'
require 'net/http'
2022-06-17 22:49:30 +02:00
require 'pathname'
2022-12-04 15:03:14 +01:00
require 'progressbar'
require 'term/ansicolor'
2022-06-17 22:49:30 +02:00
module SlackBuilder
extend Rake::FileUtilsExt
2023-03-18 13:15:12 +01:00
def self.clone(repo, tarball, tag_prefix = 'v')
2023-08-25 10:30:24 +02:00
`./bin/slackbuilder clone #{repo} #{tarball} #{tag_prefix}`
2022-06-17 22:49:30 +02:00
end
2020-12-09 18:28:42 +01:00
2023-01-04 10:51:08 +01:00
def self.download(uri, target)
2023-08-21 13:38:20 +02:00
`./bin/slackbuilder download #{uri} #{target}`.strip
2020-12-09 18:28:42 +01:00
end
def self.hosted_sources(absolute_url)
2023-03-18 13:15:12 +01:00
CONFIG[:download_url] + absolute_url
end
def self.remote_file_exists?(url)
`./bin/slackbuilder exists #{url}`.strip == 'True'
2023-03-18 13:15:12 +01:00
end
def self.download_and_deploy(uri, tarball)
2023-08-28 21:05:47 +02:00
`./bin/slackbuilder deploy #{uri} #{tarball}`.strip
2023-03-18 13:15:12 +01:00
end
private_class_method def self.upload_command(local_path, remote_path)
['scp', "slackbuilds/#{local_path}", CONFIG[:remote_path] + remote_path]
2020-12-09 18:28:42 +01:00
end
2023-03-18 13:15:12 +01:00
private_class_method def self.clone_and_archive(repo, name_version, tarball, tag_prefix = 'v')
sh './bin/slackbuilder', 'archive', repo, name_version, tarball, tag_prefix
2020-12-09 18:28:42 +01:00
end
end
2021-05-04 07:47:24 +02:00
def write_info(package, downloads:)
2022-06-14 06:52:24 +02:00
File.write "slackbuilds/#{package.path}/#{package.name}.info",
info_template(package, downloads)
2020-12-09 18:28:42 +01:00
end
def update_slackbuild_version(package_path, version)
2023-08-15 10:33:19 +02:00
sh './bin/slackbuilder', 'slackbuild', package_path, version
2020-12-09 18:28:42 +01:00
end
def commit(package_path, version)
2023-08-15 10:33:19 +02:00
sh './bin/slackbuilder', 'commit', package_path, version
2020-12-09 18:28:42 +01:00
end