summaryrefslogtreecommitdiff
path: root/lib/download.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/download.rb')
-rw-r--r--lib/download.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/download.rb b/lib/download.rb
index 5777e64..6d1b7fb 100644
--- a/lib/download.rb
+++ b/lib/download.rb
@@ -7,6 +7,26 @@
require_relative '../config/config'
require_relative 'package'
require 'net/http'
+require 'pathname'
+
+module SlackBuilder
+ extend Rake::FileUtilsExt
+
+ def self.clone(repo, package, tag_prefix = 'v')
+ repository = Pathname.new('pkg') + package.name_version
+
+ if repository.directory?
+ sh 'git', '-C', repository.to_path, 'remote', 'update', '--prune'
+ else
+ sh 'git', 'clone', repo, repository.to_path
+ end
+
+ sh 'git', '-C', repository.to_path, 'checkout', "#{tag_prefix}#{package.version}"
+ sh 'git', '-C', repository.to_path, 'submodule', 'update', '--init', '--recursive'
+
+ repository
+ end
+end
def write_download(target, response)
checksum = Digest::MD5.new