slackbuilder/Rakefile

183 lines
6.4 KiB
Ruby
Raw Normal View History

2020-12-09 18:28:42 +01:00
# 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 'digest/md5'
require 'net/http'
2022-12-23 17:47:14 +01:00
require 'open3'
2021-01-02 07:39:32 +01:00
require_relative 'config/config'
2020-12-09 18:28:42 +01:00
require_relative 'lib/package'
require_relative 'lib/download'
2023-06-28 23:47:21 +02:00
require_relative 'lib/up2date'
2020-12-09 18:28:42 +01:00
2022-10-30 18:08:12 +01:00
task :dmd, [:version] do |_, arguments|
raise 'Version is not specified.' unless arguments.key? :version
2023-07-06 21:59:25 +02:00
dub_version = '1.33.0'
dscanner_version = '0.15.2'
dcd_version = '0.15.2'
2020-12-09 18:28:42 +01:00
2022-11-20 12:44:28 +01:00
SlackBuilder::DmdTools.update_dmd arguments[:version]
SlackBuilder::DmdTools.update_tools arguments[:version], dub_version, dscanner_version, dcd_version
2020-12-09 18:28:42 +01:00
end
task :hhvm, [:version] do |_, arguments|
2022-10-30 18:08:12 +01:00
raise 'Version is not specified.' unless arguments.key? :version
2021-05-04 07:47:24 +02:00
2022-10-30 18:08:12 +01:00
checksum = {}
2023-03-18 13:15:12 +01:00
checksum[:hhvm] = SlackBuilder.clone 'https://github.com/facebook/hhvm.git',
2022-10-30 18:08:12 +01:00
"development/hhvm/hhvm-#{arguments[:version]}.tar.xz", 'HHVM-'
2021-05-04 07:47:24 +02:00
package = Package.new 'development/hhvm',
2022-10-30 18:08:12 +01:00
version: arguments[:version],
2021-05-04 07:47:24 +02:00
homepage: 'https://hhvm.com/',
requires: %w[tbb glog libdwarf libmemcached dobule-conversion]
write_info package,
downloads: [
2023-03-18 13:15:12 +01:00
Download.new(SlackBuilder.hosted_sources("/hhvm/hhvm-#{package.version}.tar.xz"), checksum[:hhvm], is64: true)
2021-05-04 07:47:24 +02:00
]
2022-10-30 18:08:12 +01:00
update_slackbuild_version 'development/hhvm', package.version
2021-05-04 07:47:24 +02:00
end
2021-10-12 07:42:35 +02:00
2023-03-18 13:15:12 +01:00
task 'php', [:version] do |_, arguments|
2022-10-30 18:08:12 +01:00
raise 'Version is not specified.' unless arguments.key? :version
2023-03-18 13:15:12 +01:00
package = Package.new 'development/php82',
2022-10-30 18:08:12 +01:00
version: arguments[:version],
2023-03-18 13:15:12 +01:00
homepage: 'https://www.php.net/',
requires: ['postgresql']
2021-10-12 07:42:35 +02:00
2023-03-18 13:15:12 +01:00
uri = "https://www.php.net/distributions/php-#{arguments[:version]}.tar.xz"
tarball = "slackbuilds/development/php82/php-#{arguments[:version]}.tar.xz"
checksum = SlackBuilder.download URI(uri), tarball
write_info package, downloads: [Download.new(uri, checksum)]
update_slackbuild_version 'development/php82', arguments[:version]
2021-10-12 07:42:35 +02:00
2023-03-18 13:15:12 +01:00
commit 'development/php82', arguments[:version]
2021-10-12 07:42:35 +02:00
end
2022-12-23 17:47:14 +01:00
task :webex do
tarball = 'slackbuilds/network/webex/Webex.deb'
uri = 'https://binaries.webex.com/WebexDesktop-Ubuntu-Official-Package/Webex.deb'
2023-01-04 10:51:08 +01:00
checksum = SlackBuilder.download URI(uri), tarball
2022-12-23 17:47:14 +01:00
last_stdout, = Open3.pipeline_r ['ar', 'p', tarball, 'control.tar.gz'], ['tar', 'zxO', './control']
version = last_stdout.read.lines
.find { |line| line.start_with? 'Version: ' }
.split.last
package = Package.new 'network/webex',
version: version,
homepage: 'https://www.webex.com'
write_info package,
downloads: [Download.new(uri, checksum, is64: true)]
update_slackbuild_version 'network/webex', package.version
commit 'network/webex', package.version
end
2023-01-04 10:51:08 +01:00
task 'rdiff-backup', [:version] do |_, arguments|
raise 'Version is not specified.' unless arguments.key? :version
package = Package.new 'system/rdiff-backup',
version: arguments[:version],
homepage: 'https://rdiff-backup.net/',
requires: ['librsync']
uri = "https://github.com/rdiff-backup/rdiff-backup/releases/download/v#{arguments[:version]}/rdiff-backup-#{arguments[:version]}.tar.gz"
tarball = "system/rdiff-backup/rdiff-backup-#{arguments[:version]}.tar.gz"
2023-03-18 13:15:12 +01:00
checksum = SlackBuilder.download_and_deploy URI(uri), tarball
2023-01-04 10:51:08 +01:00
download = "https://download.dlackware.com/hosted-sources/rdiff-backup/rdiff-backup-#{arguments[:version]}.tar.gz"
write_info package, downloads: [Download.new(download, checksum)]
update_slackbuild_version 'system/rdiff-backup', arguments[:version]
commit 'system/rdiff-backup', arguments[:version]
end
2023-06-28 23:47:21 +02:00
2023-07-06 21:59:25 +02:00
module SlackBuilder
class Updater
include Rake::FileUtilsExt
def update(version)
raise NotImplementedError
end
end
class UniversalCtags < Updater
def update(version)
package = create_package version
uri = "https://github.com/universal-ctags/ctags/archive/#{version}/ctags-#{version}.tar.gz"
tarball = "slackbuilds/development/universal-ctags/ctags-#{version}.tar.gz"
checksum = SlackBuilder.download URI(uri), tarball
download = "https://download.dlackware.com/hosted-sources/universal-ctags/ctags-#{version}.tar.gz"
write_info package, downloads: [Download.new(download, checksum.hexdigest)]
update_slackbuild_version 'development/universal-ctags', version
sh 'scp', tarball, "#{CONFIG[:remote_path]}/universal-ctags"
commit 'development/universal-ctags', version
end
private
def create_package(version)
Package.new 'development/universal-ctags',
version: version,
homepage: 'https://ctags.io/',
requires: ['%README%']
end
end
2023-07-13 18:03:02 +02:00
class Composer < Updater
def update(version)
package = Package.new 'development/composer',
version: version,
homepage: 'https://getcomposer.org/'
uri = "https://getcomposer.org/download/#{version}/composer.phar"
checksum = SlackBuilder.download URI(uri), 'slackbuilds/development/composer/composer.phar'
write_info package, downloads: [Download.new(uri, checksum.hexdigest)]
update_slackbuild_version 'development/composer', version
commit 'development/composer', version
end
end
2023-07-06 21:59:25 +02:00
end
2023-06-28 23:47:21 +02:00
php_transform = proc do |version|
version.delete_prefix 'php-' if version.match?(/^php-8\.2\.[[:digit:]+]$/)
end
2023-07-13 18:03:02 +02:00
rdiff_backup_transform = proc do |version|
version.delete_prefix 'v' if version.match?(/^v\d+\.\d+\.\d+/)
end
2023-06-28 23:47:21 +02:00
AUTO_UPDATABLE = {
2023-07-06 21:59:25 +02:00
'universal-ctags' => [SlackBuilder::GitHub.new('universal-ctags', 'ctags'), SlackBuilder::UniversalCtags.new],
2023-07-13 18:03:02 +02:00
'composer' => [SlackBuilder::Packagist.new('composer', 'composer'), SlackBuilder::Composer.new],
2023-07-06 21:59:25 +02:00
'php82' => [SlackBuilder::GitHub.new('php', 'php-src', php_transform)],
2023-07-13 18:03:02 +02:00
'rdiff-backup' => [SlackBuilder::GitHub.new('rdiff-backup', 'rdiff-backup', rdiff_backup_transform)],
2023-07-06 21:59:25 +02:00
'librsync' => [SlackBuilder::GitHub.new('librsync', 'librsync')],
'jitsi-meet-desktop' => [SlackBuilder::GitHub.new('jitsi', 'jitsi-meet-electron')],
'dmd' => [SlackBuilder::LatestText.new('https://downloads.dlang.org/releases/LATEST')]
2023-06-28 23:47:21 +02:00
}.freeze
task :up2date do
AUTO_UPDATABLE.each do |key, value|
2023-07-06 21:59:25 +02:00
repository, updater = value
latest_version = SlackBuilder.check_for_latest key, repository
next if latest_version.nil? || updater.nil?
puts "Would like to update #{key} to #{latest_version} (y/N)? "
updater.update latest_version if $stdin.gets.chomp.downcase.start_with? 'y'
2023-06-28 23:47:21 +02:00
end
end