slackbuilder/Rakefile

119 lines
4.0 KiB
Ruby

# 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
require 'infra/rake/ruby'
require 'digest/md5'
require 'net/http'
require_relative 'config/config'
require_relative 'lib/package'
require_relative 'lib/download'
task :dmd do
version = '2.094.2'
dub_version = '1.23.0'
dscanner_version = '0.11.0'
dcd_version = '0.13.1'
tarball_name = "dmd.#{version}.linux.tar.xz"
uri = URI "http://downloads.dlang.org/releases/2.x/#{version}/#{tarball_name}"
checksum = {
dmd: download(uri, "slackbuilds/development/dmd/#{tarball_name}").hexdigest,
}
package = Package.new 'development/dmd',
version: version,
homepage: 'https://dlang.org'
write_info package,
download: [uri.to_s],
md5sum: [checksum[:dmd]]
update_slackbuild_version 'development/dmd', version
commit 'development/dmd', version
uri = URI "https://codeload.github.com/dlang/tools/tar.gz/v#{version}"
checksum[:tools] = download_and_deploy uri,
"development/d-tools/tools-#{version}.tar.gz"
uri = URI "https://codeload.github.com/dlang/dub/tar.gz/v#{dub_version}"
checksum[:dub] = download_and_deploy uri,
"development/d-tools/dub-#{dub_version}.tar.gz"
checksum[:dscanner] = clone 'https://github.com/dlang-community/D-Scanner.git',
"development/d-tools/D-Scanner-#{dscanner_version}.tar.xz"
checksum[:dcd] = clone 'https://github.com/dlang-community/DCD.git',
"development/d-tools/DCD-#{dcd_version}.tar.xz"
package = Package.new 'development/d-tools',
version: version,
homepage: 'https://dlang.org',
requires: ['dmd']
write_info package,
download: [
hosted_sources("/d-tools/dub-#{dub_version}.tar.gz"),
hosted_sources("/d-tools/tools-#{version}.tar.gz"),
hosted_sources("/d-tools/D-Scanner-#{dscanner_version}.tar.xz"),
hosted_sources("/d-tools/DCD-#{dcd_version}.tar.xz")
],
md5sum: [
checksum[:dub],
checksum[:tools],
checksum[:dscanner],
checksum[:dcd]
]
slackbuild_filename = 'slackbuilds/development/d-tools/d-tools.SlackBuild'
slackbuild_contents = File.read(slackbuild_filename)
.gsub(/^DUB_VERSION=\${DUB_VERSION:-.+/,
"DUB_VERSION=${DUB_VERSION:-#{dub_version}}")
.gsub(/^DSCANNER_VERSION=\${DSCANNER_VERSION:-.+/,
"DSCANNER_VERSION=${DSCANNER_VERSION:-#{dscanner_version}}")
.gsub(/^DCD_VERSION=\${DCD_VERSION:-.+/,
"DCD_VERSION=${DCD_VERSION:-#{dcd_version}}")
File.open(slackbuild_filename, 'w') { |file| file.puts slackbuild_contents }
update_slackbuild_version 'development/d-tools', version
commit 'development/d-tools', version
end
task :composer do
version = '2.0.8'
package = Package.new 'development/composer',
version: version,
homepage: 'https://getcomposer.org/'
uri = URI "https://getcomposer.org/download/#{version}/composer.phar"
checksum = download uri, 'slackbuilds/development/composer/composer.phar'
write_info package,
download: ["https://getcomposer.org/download/#{version}/composer.phar"],
md5sum: [checksum.hexdigest]
update_slackbuild_version 'development/composer', version
commit 'development/composer', version
end
task 'universal-ctags' do
ENV['COMMIT'] = `git ls-remote https://github.com/universal-ctags/ctags.git master`
.split
.first
ENV['HASH'] = ENV['COMMIT'][0...7]
sh 'git', 'clone', '--recurse-submodules', 'https://github.com/universal-ctags/ctags.git', "ctags-#{ENV['COMMIT']}"
rm_rf ["ctags-#{ENV['COMMIT']}/.git", "ctags-#{ENV['COMMIT']}/.gitignore"], secure: true
sh 'tar', 'Jcvf', "ctags-#{ENV['COMMIT']}.tar.xz", "ctags-#{ENV['COMMIT']}"
rm_rf "ctags-#{ENV['COMMIT']}", secure: true
checksum = Digest::MD5.file "ctags-#{ENV['COMMIT']}.tar.xz"
ENV['CHECKSUM'] = checksum.hexdigest
sh 'scp', "ctags-#{ENV['COMMIT']}.tar.xz", "#{CONFIG[:remote_path]}/universal-ctags"
sh 'bash', 'scripts/universal-ctags.sh'
end