From 9770cc8829d6fdacd1ae02e1f78fcf270e5a5503 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 4 Nov 2023 14:13:59 +0100 Subject: Remove gem and rake support files --- .rubocop.yml | 41 ------------ Gemfile | 15 ----- Gemfile.lock | 48 -------------- Rakefile | 109 -------------------------------- app/Main.hs | 8 --- app/SlackBuilder/CommandLine.hs | 13 ---- config/config.rb.example | 7 --- lib/SlackBuilder/Download.hs | 17 ----- lib/download.rb | 40 ------------ lib/package.rb | 24 ------- private/hhvm.rb | 135 ++++++++++++++++++++++++++++++++++++++++ 11 files changed, 135 insertions(+), 322 deletions(-) delete mode 100644 .rubocop.yml delete mode 100644 Gemfile delete mode 100644 Gemfile.lock delete mode 100644 Rakefile delete mode 100644 config/config.rb.example delete mode 100644 lib/download.rb delete mode 100644 lib/package.rb create mode 100644 private/hhvm.rb diff --git a/.rubocop.yml b/.rubocop.yml deleted file mode 100644 index 02cb8ff..0000000 --- a/.rubocop.yml +++ /dev/null @@ -1,41 +0,0 @@ -AllCops: - Exclude: - - 'vendor/**/*' - - '.git/**/*' - - 'slackbuilds/**/*' - - 'bin/bundle' - - 'bin/cap*' - - 'bin/rake' - - 'bin/rspec' - - 'bin/rubocop' - - 'bin/setup' - - 'bin/spring' - - 'bin/update' - - 'pkg/**/*' - - TargetRubyVersion: '3.0' - NewCops: enable - SuggestExtensions: false - -Style/Documentation: - Enabled: false - -# False-Positive: non-string-variable + 'some string' -Style/StringConcatenation: - Enabled: false - -Layout/MultilineMethodCallIndentation: - EnforcedStyle: indented - -Layout/MultilineOperationIndentation: - EnforcedStyle: indented - -Layout/ArgumentAlignment: - EnforcedStyle: with_fixed_indentation - -Layout/EndAlignment: - EnforcedStyleAlignWith: variable - -Metrics/BlockLength: - AllowedMethods: - - namespace diff --git a/Gemfile b/Gemfile deleted file mode 100644 index f760775..0000000 --- a/Gemfile +++ /dev/null @@ -1,15 +0,0 @@ -# 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 - -source 'https://rubygems.org' - -git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } - -gem 'rake', '~> 13.0' -gem 'rubocop', '~> 1.53.1', require: false - -gem 'progressbar', '~> 1.11' -gem 'term-ansicolor', '~> 1.7' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 80f2329..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,48 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - ast (2.4.2) - json (2.6.3) - language_server-protocol (3.17.0.3) - parallel (1.23.0) - parser (3.2.2.3) - ast (~> 2.4.1) - racc - progressbar (1.13.0) - racc (1.7.1) - rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.8.1) - rexml (3.2.6) - rubocop (1.53.1) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) - parser (>= 3.2.2.3) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) - parser (>= 3.2.1.0) - ruby-progressbar (1.13.0) - sync (0.5.0) - term-ansicolor (1.7.1) - tins (~> 1.0) - tins (1.32.1) - sync - unicode-display_width (2.4.2) - -PLATFORMS - ruby - -DEPENDENCIES - progressbar (~> 1.11) - rake (~> 13.0) - rubocop (~> 1.53.1) - term-ansicolor (~> 1.7) - -BUNDLED WITH - 2.2.33 diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 06b6fa4..0000000 --- a/Rakefile +++ /dev/null @@ -1,109 +0,0 @@ -# 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 'pathname' -require 'digest/md5' -require 'net/http' -require_relative 'config/config' -require_relative 'lib/package' -require_relative 'lib/download' - -namespace :hhvm do - def filter_set_hhvm_third_party_source_args(tokens) - args = tokens[0] - allowed_arguments = tokens[1..].each_slice(2) - .filter do |key, _value| - !key.end_with?('_URL') && !key.end_with?('_HASH') - end - - allowed_arguments - .flatten - .prepend(" #{args}") - .join("\n ") - end - - def split_set_hhvm_third_party_source_args(section_content) - section_content - .split("\n") - .map do |line| - hash_index = line.index '#' - line = line[...hash_index] unless hash_index.nil? - - line.strip - end - end - - def rewrite_set_hhvm_third_party_source_args(contents) - set_hhvm_start = contents.index 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS(' - return nil if set_hhvm_start.nil? - - section_contents = contents[set_hhvm_start + 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS('.length..] - set_hhvm_end = section_contents.index ')' - - lines = split_set_hhvm_third_party_source_args section_contents[...set_hhvm_end] - new_cmake_section = filter_set_hhvm_third_party_source_args lines.reject(&:blank?).join(' ').split - - contents[...set_hhvm_start] + - "SET_HHVM_THIRD_PARTY_SOURCE_ARGS(\n#{new_cmake_section}\n)\n" + - section_contents[set_hhvm_end..] - end - - desc 'Generates diffs with removed download URLs' - task :bundled_dependencies, [:version] do |_, arguments| - run_on_source arguments[:version] do |third_party| - c_make_lists = third_party + 'CMakeLists.txt' - next unless c_make_lists.exist? - - contents = c_make_lists.read - rewritten_cmake = rewrite_set_hhvm_third_party_source_args contents - next if rewritten_cmake.nil? - - puts Open3.capture2('diff', '-Nur', c_make_lists.to_path, '-', stdin_data: rewritten_cmake).first - end - end - - desc 'Generated SlackBuild code to prepare bundled dependencies' - task :bundled_code, [:version] do |_, arguments| - run_on_source arguments[:version] do |third_party| - c_make_lists = third_party + 'CMakeLists.txt' - next unless c_make_lists.exist? - - contents = c_make_lists.read - set_hhvm_start = contents.index 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS(' - next if set_hhvm_start.nil? - - set_hhvm_end = contents.index ')', set_hhvm_start - set_hhvm_start += 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS('.length - set_hhvm_end -= 1 - contents = contents[set_hhvm_start..set_hhvm_end].split[1..].map(&:strip) - - src = Pathname.new('third-party') + - third_party.basename + - "bundled_#{third_party.basename}-prefix" + 'src' - bundled = src + "bundled_#{third_party.basename}" - archive_name = contents[1][contents[1].rindex('/') + 1..-2] - - puts "mkdir -p #{bundled}" - puts "install -m 0644 -D $CWD/#{archive_name} #{src + archive_name}" - puts "tar -zxvf $CWD/#{archive_name} -C #{bundled}" - puts - end - end -end - -private - -def run_on_source(version, &block) - package = Package.new 'development/hhvm', - version: version, - homepage: 'https://hhvm.com/', - requires: %w[tbb glog libdwarf libmemcached dobule-conversion] - repository = SlackBuilder.clone 'https://github.com/facebook/hhvm.git', package, 'HHVM-' - - (repository + 'third-party').each_child do |third_party| - block.call third_party - end -end diff --git a/app/Main.hs b/app/Main.hs index 5c18a7e..535b655 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -416,14 +416,6 @@ main = do categories <- liftIO $ findCategory repository' liftIO $ print $ splitFileName . makeRelative repository' <$> categories pure Nothing - ExistsCommand urlPath -> pure . Text.pack . show - <$> remoteFileExists urlPath - DownloadCommand url target - | Just uri' <- mkURI url -> fmap (Text.pack . show) - <$> download uri' target - | otherwise -> pure Nothing CloneCommand repo tarball tagPrefix -> fmap (Text.pack . show) <$> clone repo tarball tagPrefix - DownloadAndDeployCommand uri' tarball -> fmap (Text.pack . show) - <$> downloadAndDeploy uri' tarball Up2DateCommand -> up2Date >> pure Nothing diff --git a/app/SlackBuilder/CommandLine.hs b/app/SlackBuilder/CommandLine.hs index 9b26671..7cfe747 100644 --- a/app/SlackBuilder/CommandLine.hs +++ b/app/SlackBuilder/CommandLine.hs @@ -21,10 +21,7 @@ import Options.Applicative data SlackBuilderCommand = CategoryCommand Text - | ExistsCommand Text - | DownloadCommand Text String | CloneCommand Text Text Text - | DownloadAndDeployCommand Text Text | Up2DateCommand data PackagistArguments = PackagistArguments @@ -49,23 +46,13 @@ slackBuilderParser = info slackBuilderCommand fullDesc slackBuilderCommand :: Parser SlackBuilderCommand slackBuilderCommand = subparser $ command "category" (info categoryCommand mempty) - <> command "exists" (info existsCommand mempty) - <> command "download" (info downloadCommand mempty) <> command "clone" (info cloneCommand mempty) - <> command "deploy" (info deployCommand mempty) <> command "up2date" (info up2DateCommand mempty) where categoryCommand = CategoryCommand <$> argument str (metavar "PKGNAM") - existsCommand = ExistsCommand <$> argument str (metavar "PATH") - downloadCommand = DownloadCommand - <$> argument str (metavar "URI") - <*> argument str (metavar "TARGET") cloneCommand = CloneCommand <$> argument str (metavar "REPO") <*> argument str (metavar "TARBALL") <*> argument str (metavar "TAG_PREFIX") - deployCommand = DownloadAndDeployCommand - <$> argument str (metavar "URI") - <*> argument str (metavar "TARBALL") up2DateCommand = pure Up2DateCommand diff --git a/config/config.rb.example b/config/config.rb.example deleted file mode 100644 index c23023d..0000000 --- a/config/config.rb.example +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -CONFIG = { - remote_path: 'example.com:/srv/httpd/some/path', - download_url: 'https://example.com/some/path', - repository: '../slackbuilds' -}.freeze diff --git a/lib/SlackBuilder/Download.hs b/lib/SlackBuilder/Download.hs index 4003afd..7729b0b 100644 --- a/lib/SlackBuilder/Download.hs +++ b/lib/SlackBuilder/Download.hs @@ -3,7 +3,6 @@ module SlackBuilder.Download , cloneAndArchive , commit , download - , downloadAndDeploy , hostedSources , remoteFileExists , updateSlackBuildVersion @@ -207,19 +206,3 @@ clone repo tarball tagPrefix = do in cloneAndArchive repo nameVersion tarballPath tagPrefix >> uploadCommand tarball remotePath >> liftIO (runConduitRes go) <&> Just - -downloadAndDeploy :: Text -> Text -> SlackBuilderT (Maybe (Digest MD5)) -downloadAndDeploy uri tarball = do - repository' <- SlackBuilderT $ asks repository - let tarballPath = Text.unpack tarball - remotePath = Text.pack $ joinPath $ ("/" :) $ drop 1 $ splitPath tarballPath - localPath = repository' tarballPath - remoteFileExists' <- remoteFileExists remotePath - - if remoteFileExists' - then - hostedSources remotePath >>= flip download localPath - else do - checksum <- liftIO (mkURI uri) >>= flip download localPath - uploadCommand tarball remotePath - pure checksum diff --git a/lib/download.rb b/lib/download.rb deleted file mode 100644 index 17b119b..0000000 --- a/lib/download.rb +++ /dev/null @@ -1,40 +0,0 @@ -# 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_relative '../config/config' -require_relative 'package' -require 'net/http' -require 'pathname' -require 'progressbar' -require 'term/ansicolor' - -module SlackBuilder - extend Rake::FileUtilsExt - - def self.clone(repo, tarball, tag_prefix = 'v') - `./bin/slackbuilder clone #{repo} #{tarball} #{tag_prefix}` - end - - def self.download(uri, target) - `./bin/slackbuilder download #{uri} #{target}`.strip - end - - def self.hosted_sources(absolute_url) - CONFIG[:download_url] + absolute_url - end - - def self.remote_file_exists?(url) - `./bin/slackbuilder exists #{url}`.strip == 'True' - end - - def self.download_and_deploy(uri, tarball) - `./bin/slackbuilder deploy #{uri} #{tarball}`.strip - end - - private_class_method def self.upload_command(local_path, remote_path) - ['scp', "slackbuilds/#{local_path}", CONFIG[:remote_path] + remote_path] - end -end diff --git a/lib/package.rb b/lib/package.rb deleted file mode 100644 index b5c44bb..0000000 --- a/lib/package.rb +++ /dev/null @@ -1,24 +0,0 @@ -# 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 - -class Package - attr_reader :path, :version, :homepage, :requires - - def initialize(path, version:, homepage:, requires: []) - @path = path - @version = version - @homepage = homepage - @requires = requires - end - - def name - File.basename @path - end - - def name_version - "#{name}-#{@version}" - end -end diff --git a/private/hhvm.rb b/private/hhvm.rb new file mode 100644 index 0000000..85e78b7 --- /dev/null +++ b/private/hhvm.rb @@ -0,0 +1,135 @@ +# 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 'pathname' +require 'digest/md5' +require 'net/http' +require_relative 'config/config' +require_relative 'lib/package' + +class Package + attr_reader :path, :version, :homepage, :requires + + def initialize(path, version:, homepage:, requires: []) + @path = path + @version = version + @homepage = homepage + @requires = requires + end + + def name + File.basename @path + end + + def name_version + "#{name}-#{@version}" + end +end + +module SlackBuilder + extend Rake::FileUtilsExt + + def self.clone(repo, tarball, tag_prefix = 'v') + `./bin/slackbuilder clone #{repo} #{tarball} #{tag_prefix}` + end +end + +namespace :hhvm do + def filter_set_hhvm_third_party_source_args(tokens) + args = tokens[0] + allowed_arguments = tokens[1..].each_slice(2) + .filter do |key, _value| + !key.end_with?('_URL') && !key.end_with?('_HASH') + end + + allowed_arguments + .flatten + .prepend(" #{args}") + .join("\n ") + end + + def split_set_hhvm_third_party_source_args(section_content) + section_content + .split("\n") + .map do |line| + hash_index = line.index '#' + line = line[...hash_index] unless hash_index.nil? + + line.strip + end + end + + def rewrite_set_hhvm_third_party_source_args(contents) + set_hhvm_start = contents.index 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS(' + return nil if set_hhvm_start.nil? + + section_contents = contents[set_hhvm_start + 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS('.length..] + set_hhvm_end = section_contents.index ')' + + lines = split_set_hhvm_third_party_source_args section_contents[...set_hhvm_end] + new_cmake_section = filter_set_hhvm_third_party_source_args lines.reject(&:blank?).join(' ').split + + contents[...set_hhvm_start] + + "SET_HHVM_THIRD_PARTY_SOURCE_ARGS(\n#{new_cmake_section}\n)\n" + + section_contents[set_hhvm_end..] + end + + desc 'Generates diffs with removed download URLs' + task :bundled_dependencies, [:version] do |_, arguments| + run_on_source arguments[:version] do |third_party| + c_make_lists = third_party + 'CMakeLists.txt' + next unless c_make_lists.exist? + + contents = c_make_lists.read + rewritten_cmake = rewrite_set_hhvm_third_party_source_args contents + next if rewritten_cmake.nil? + + puts Open3.capture2('diff', '-Nur', c_make_lists.to_path, '-', stdin_data: rewritten_cmake).first + end + end + + desc 'Generated SlackBuild code to prepare bundled dependencies' + task :bundled_code, [:version] do |_, arguments| + run_on_source arguments[:version] do |third_party| + c_make_lists = third_party + 'CMakeLists.txt' + next unless c_make_lists.exist? + + contents = c_make_lists.read + set_hhvm_start = contents.index 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS(' + next if set_hhvm_start.nil? + + set_hhvm_end = contents.index ')', set_hhvm_start + set_hhvm_start += 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS('.length + set_hhvm_end -= 1 + contents = contents[set_hhvm_start..set_hhvm_end].split[1..].map(&:strip) + + src = Pathname.new('third-party') + + third_party.basename + + "bundled_#{third_party.basename}-prefix" + 'src' + bundled = src + "bundled_#{third_party.basename}" + archive_name = contents[1][contents[1].rindex('/') + 1..-2] + + puts "mkdir -p #{bundled}" + puts "install -m 0644 -D $CWD/#{archive_name} #{src + archive_name}" + puts "tar -zxvf $CWD/#{archive_name} -C #{bundled}" + puts + end + end +end + +private + +def run_on_source(version, &block) + package = Package.new 'development/hhvm', + version: version, + homepage: 'https://hhvm.com/', + requires: %w[tbb glog libdwarf libmemcached dobule-conversion] + repository = SlackBuilder.clone 'https://github.com/facebook/hhvm.git', package, 'HHVM-' + + (repository + 'third-party').each_child do |third_party| + block.call third_party + end +end -- cgit v1.2.3