Replace hhvm updater

This commit is contained in:
2021-05-04 07:47:24 +02:00
parent f0975ea4a1
commit 6e15f2340d
5 changed files with 82 additions and 93 deletions

View File

@ -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

View File

@ -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