summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2021-05-04 07:47:24 +0200
committerEugen Wissner <belka@caraus.de>2021-05-04 07:47:24 +0200
commit6e15f2340d1b455aea74dd1edfa945f22ffa18cf (patch)
treebd7892dc6a1083045ca4e44c59b8658a4ad0ee44 /lib
parentf0975ea4a15dc0be67a22fc12a4ae07d8bc33a88 (diff)
downloadslackbuilder-6e15f2340d1b455aea74dd1edfa945f22ffa18cf.tar.gz
Replace hhvm updater
Diffstat (limited to 'lib')
-rw-r--r--lib/download.rb18
-rw-r--r--lib/package.rb49
2 files changed, 52 insertions, 15 deletions
diff --git a/lib/download.rb b/lib/download.rb
index cb09c42..56cabc3 100644
--- a/lib/download.rb
+++ b/lib/download.rb
@@ -72,20 +72,20 @@ def upload_command(local_path, remote_path)
['scp', "slackbuilds/#{local_path}", CONFIG[:remote_path] + remote_path]
end
-def clone_and_archive(repo, name_version, tarball)
+def clone_and_archive(repo, name_version, tarball, tag_prefix = 'v')
_, _, version = name_version.rpartition '-'
rm_rf name_version
- sh "git clone #{repo} #{name_version}"
- sh "git -C #{name_version} checkout v#{version}"
- sh "git -C #{name_version} submodule update --init --recursive"
+ sh 'git', 'clone', repo, name_version
+ sh 'git', '-C', name_version, 'checkout', "#{tag_prefix}#{version}"
+ sh 'git', '-C', name_version, 'submodule', 'update', '--init', '--recursive'
- sh "tar Jcvf slackbuilds/#{tarball} #{name_version}"
+ sh 'tar', 'Jcvf', "slackbuilds/#{tarball}", name_version
rm_rf name_version
end
-def clone(repo, tarball)
+def clone(repo, tarball, tag_prefix = 'v')
name_version = File.basename tarball, '.tar.xz'
remote_path = tarball[tarball.index('/')..]
@@ -95,7 +95,7 @@ def clone(repo, tarball)
return download(uri, "slackbuilds/#{tarball}").hexdigest
end
- clone_and_archive repo, name_version, tarball
+ clone_and_archive repo, name_version, tarball, tag_prefix
sh(*upload_command(tarball, remote_path))
@@ -115,9 +115,9 @@ def download_and_deploy(uri, tarball)
checksum.hexdigest
end
-def write_info(package, download:, md5sum:)
+def write_info(package, downloads:)
File.open "slackbuilds/#{package.path}/#{package.name}.info", 'w' do |file|
- file.write info_template(package, download, md5sum)
+ file.write info_template(package, downloads)
end
end
diff --git a/lib/package.rb b/lib/package.rb
index cf6e629..739e18e 100644
--- a/lib/package.rb
+++ b/lib/package.rb
@@ -19,17 +19,54 @@ class Package
end
end
-def info_template(package, download, md5sum)
+class Download
+ attr_reader :download, :md5sum
+
+ def initialize(download, md5sum, is64: false)
+ @download = download
+ @md5sum = md5sum
+ @is64 = is64
+ end
+
+ def is64?
+ @is64
+ end
+end
+
+def info_template(package, downloads)
+ downloads64, downloads32 = downloads.partition(&:is64?)
+ download32, md5sum32, download64, md5sum64 = download_entries downloads64, downloads32
+
<<~INFO_FILE
PRGNAM="#{package.name}"
VERSION="#{package.version}"
HOMEPAGE="#{package.homepage}"
- DOWNLOAD="#{download * " \\\n "}"
- MD5SUM="#{md5sum * " \\\n "}"
- DOWNLOAD_x86_64=""
- MD5SUM_x86_64=""
- REQUIRES="#{package.requires.empty? ? '%README%' : package.requires * ' '}"
+ DOWNLOAD="#{download32}"
+ MD5SUM="#{md5sum32}"
+ DOWNLOAD_x86_64="#{download64}"
+ MD5SUM_x86_64="#{md5sum64}"
+ REQUIRES="#{requires_entry package.requires}"
MAINTAINER="Eugene Wissner"
EMAIL="belka@caraus.de"
INFO_FILE
end
+
+private
+
+def requires_entry(requires)
+ requires.empty? ? '%README%' : requires * ' '
+end
+
+def download_entries(downloads64, downloads32)
+ download32 =
+ if downloads32.empty? && !downloads64.empty?
+ 'UNSUPPORTED'
+ else
+ downloads32.map(&:download) * " \\\n "
+ end
+ md5sum32 = downloads32.map(&:md5sum) * " \\\n "
+ download64 = downloads64.map(&:download) * " \\\n "
+ md5sum64 = downloads64.map(&:md5sum) * " \\\n "
+
+ [download32, md5sum32, download64, md5sum64]
+end