Split dmd and d-tools update functions
This commit is contained in:
parent
3b93e0d950
commit
e3fa7d216f
@ -37,4 +37,4 @@ Layout/EndAlignment:
|
|||||||
EnforcedStyleAlignWith: variable
|
EnforcedStyleAlignWith: variable
|
||||||
|
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Max: 55
|
Max: 37
|
||||||
|
59
Rakefile
59
Rakefile
@ -9,68 +9,17 @@ require 'net/http'
|
|||||||
require_relative 'config/config'
|
require_relative 'config/config'
|
||||||
require_relative 'lib/package'
|
require_relative 'lib/package'
|
||||||
require_relative 'lib/download'
|
require_relative 'lib/download'
|
||||||
|
require_relative 'lib/dmd_tools'
|
||||||
|
|
||||||
task :dmd, [:version] do |_, arguments|
|
task :dmd, [:version] do |_, arguments|
|
||||||
raise 'Version is not specified.' unless arguments.key? :version
|
raise 'Version is not specified.' unless arguments.key? :version
|
||||||
|
|
||||||
dub_version = '1.29.0'
|
dub_version = '1.30.0'
|
||||||
dscanner_version = '0.12.2'
|
dscanner_version = '0.12.2'
|
||||||
dcd_version = '0.13.6'
|
dcd_version = '0.13.6'
|
||||||
tarball_name = "dmd.#{arguments[:version]}.linux.tar.xz"
|
|
||||||
|
|
||||||
uri = URI "http://downloads.dlang.org/releases/2.x/#{arguments[:version]}/#{tarball_name}"
|
SlackBuilder::DmdTools.update_dmd arguments[:version]
|
||||||
checksum = {
|
SlackBuilder::DmdTools.update_tools arguments[:version], dub_version, dscanner_version, dcd_version
|
||||||
dmd: download(uri, "slackbuilds/development/dmd/#{tarball_name}").hexdigest
|
|
||||||
}
|
|
||||||
|
|
||||||
package = Package.new 'development/dmd',
|
|
||||||
version: arguments[:version],
|
|
||||||
homepage: 'https://dlang.org'
|
|
||||||
|
|
||||||
write_info package,
|
|
||||||
downloads: [Download.new(uri.to_s, checksum[:dmd])]
|
|
||||||
|
|
||||||
update_slackbuild_version 'development/dmd', package.version
|
|
||||||
commit 'development/dmd', version
|
|
||||||
|
|
||||||
uri = URI "https://codeload.github.com/dlang/tools/tar.gz/v#{package.version}"
|
|
||||||
checksum[:tools] = download_and_deploy uri,
|
|
||||||
"development/d-tools/tools-#{package.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: arguments[:version],
|
|
||||||
homepage: 'https://dlang.org',
|
|
||||||
requires: ['dmd']
|
|
||||||
|
|
||||||
write_info package,
|
|
||||||
downloads: [
|
|
||||||
Download.new(hosted_sources("/d-tools/dub-#{dub_version}.tar.gz"), checksum[:dub]),
|
|
||||||
Download.new(hosted_sources("/d-tools/tools-#{package.version}.tar.gz"), checksum[:tools]),
|
|
||||||
Download.new(hosted_sources("/d-tools/D-Scanner-#{dscanner_version}.tar.xz"), checksum[:dscanner]),
|
|
||||||
Download.new(hosted_sources("/d-tools/DCD-#{dcd_version}.tar.xz"), 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', package.version
|
|
||||||
commit 'development/d-tools', package.version
|
|
||||||
end
|
end
|
||||||
|
|
||||||
task :composer, [:version] do |_, arguments|
|
task :composer, [:version] do |_, arguments|
|
||||||
|
83
lib/dmd_tools.rb
Normal file
83
lib/dmd_tools.rb
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
# 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 'rake'
|
||||||
|
require_relative 'download'
|
||||||
|
|
||||||
|
module SlackBuilder
|
||||||
|
module DmdTools
|
||||||
|
extend Rake::FileUtilsExt
|
||||||
|
|
||||||
|
def self.update_dmd(version)
|
||||||
|
tarball_name = "dmd.#{version}.linux.tar.xz"
|
||||||
|
|
||||||
|
uri = URI "http://downloads.dlang.org/releases/2.x/#{version}/#{tarball_name}"
|
||||||
|
checksum = download(uri, "slackbuilds/development/dmd/#{tarball_name}")
|
||||||
|
|
||||||
|
package = Package.new 'development/dmd', version: version,
|
||||||
|
homepage: 'https://dlang.org'
|
||||||
|
|
||||||
|
write_info package, downloads: [Download.new(uri.to_s, checksum.hexdigest)]
|
||||||
|
|
||||||
|
update_slackbuild_version 'development/dmd', package.version
|
||||||
|
commit 'development/dmd', version
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.update_tools(version, dub_version, dscanner_version, dcd_version)
|
||||||
|
checksum = collect_checksums(version, dub_version, dscanner_version, dcd_version)
|
||||||
|
|
||||||
|
package = Package.new 'development/d-tools',
|
||||||
|
version: version,
|
||||||
|
homepage: 'https://dlang.org',
|
||||||
|
requires: ['dmd']
|
||||||
|
|
||||||
|
write_tools_info package, dub_version, dscanner_version, dcd_version, checksum
|
||||||
|
update_tools_versions dub_version, dscanner_version, dcd_version
|
||||||
|
|
||||||
|
update_slackbuild_version 'development/d-tools', package.version
|
||||||
|
commit 'development/d-tools', package.version
|
||||||
|
end
|
||||||
|
|
||||||
|
private_class_method def self.write_tools_info(package, dub_version, dscanner_version, dcd_version, checksum)
|
||||||
|
write_info package,
|
||||||
|
downloads: [
|
||||||
|
Download.new(hosted_sources("/d-tools/dub-#{dub_version}.tar.gz"), checksum[:dub]),
|
||||||
|
Download.new(hosted_sources("/d-tools/tools-#{package.version}.tar.gz"), checksum[:tools]),
|
||||||
|
Download.new(hosted_sources("/d-tools/D-Scanner-#{dscanner_version}.tar.xz"), checksum[:dscanner]),
|
||||||
|
Download.new(hosted_sources("/d-tools/DCD-#{dcd_version}.tar.xz"), checksum[:dcd])
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
private_class_method def self.collect_checksums(version, dub_version, dscanner_version, dcd_version)
|
||||||
|
checksum = {}
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
checksum
|
||||||
|
end
|
||||||
|
|
||||||
|
private_class_method def self.update_tools_versions(dub_version, dscanner_version, dcd_version)
|
||||||
|
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 }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user