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
|
|
|
|
|
2023-03-22 10:58:37 +01:00
|
|
|
def self.hosted_sources(absolute_url)
|
2023-03-18 13:15:12 +01:00
|
|
|
CONFIG[:download_url] + absolute_url
|
|
|
|
end
|
|
|
|
|
2023-03-22 10:58:37 +01:00
|
|
|
def self.remote_file_exists?(url)
|
2023-08-17 22:07:09 +02:00
|
|
|
`./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
|
|
|
|
end
|