mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 23:48:01 -05:00
Clean up rubocop configuration pt.1 (#11566)
This commit is contained in:
committed by
GitHub
parent
2799fade10
commit
0c86288d24
@@ -3,7 +3,7 @@
|
|||||||
# These pre-commit hooks mirror the Github CI, so running them locally will catch errors earlier.
|
# These pre-commit hooks mirror the Github CI, so running them locally will catch errors earlier.
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/rubocop/rubocop
|
- repo: https://github.com/rubocop/rubocop
|
||||||
rev: v1.64.1
|
rev: v1.74.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: rubocop
|
- id: rubocop
|
||||||
- repo: https://github.com/syntaqx/git-hooks
|
- repo: https://github.com/syntaqx/git-hooks
|
||||||
@@ -17,6 +17,6 @@ repos:
|
|||||||
- id: markdownlint
|
- id: markdownlint
|
||||||
args: [-s.mdl_style.rb]
|
args: [-s.mdl_style.rb]
|
||||||
- repo: https://github.com/adrienverge/yamllint
|
- repo: https://github.com/adrienverge/yamllint
|
||||||
rev: v1.35.1
|
rev: v1.36.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamllint
|
- id: yamllint
|
||||||
|
|||||||
54
.rubocop.yml
54
.rubocop.yml
@@ -22,9 +22,7 @@ Lint/OrAssignmentToConstant:
|
|||||||
- 'lib/const.rb'
|
- 'lib/const.rb'
|
||||||
- 'lib/fixup.rb'
|
- 'lib/fixup.rb'
|
||||||
|
|
||||||
Lint/SuppressedException:
|
# TODO
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Layout/HashAlignment:
|
Layout/HashAlignment:
|
||||||
EnforcedHashRocketStyle:
|
EnforcedHashRocketStyle:
|
||||||
- separator
|
- separator
|
||||||
@@ -35,83 +33,89 @@ Layout/HashAlignment:
|
|||||||
|
|
||||||
# End temporarily disabled cops
|
# End temporarily disabled cops
|
||||||
|
|
||||||
|
# These cops have either been disabled permanently or have a non-default configuration option.
|
||||||
|
# If you permanently disable another cop, please add a comment explaining why.
|
||||||
|
# If you set a non-default configuration for a cop, please add a comment explaining why.
|
||||||
|
|
||||||
|
# An empty line after a guard clause can improve readability, but mandating it reduces compactness.
|
||||||
Layout/EmptyLineAfterGuardClause:
|
Layout/EmptyLineAfterGuardClause:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# TODO
|
||||||
Layout/FirstHashElementIndentation:
|
Layout/FirstHashElementIndentation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
# EnforcedStyle: consistent
|
# EnforcedStyle: consistent
|
||||||
|
|
||||||
|
# A maximum line length tends to impede development more than it helps readability.
|
||||||
Layout/LineLength:
|
Layout/LineLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# Having an explicit return can often improve readability.
|
||||||
Style/RedundantReturn:
|
Style/RedundantReturn:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# A comment at the top of every file is not worth the minor benefits of frozen strings.
|
||||||
|
# Besides, Ruby is in the process of freezing strings by default anyway.
|
||||||
Style/FrozenStringLiteralComment:
|
Style/FrozenStringLiteralComment:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# Explicitly freezing every constant is too verbose, and provides minor benefits regardless.
|
||||||
Style/MutableConstant:
|
Style/MutableConstant:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# Mandating top-level documentation comments and the like will more often than not lead to meaningless documentation.
|
||||||
|
# Let people choose what does and does not need to be documented.
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# While using a guard clause reduces indentation and lines of code, it is not always the most logical flow.
|
||||||
|
# Let people choose which is best depending on the scenario.
|
||||||
Style/GuardClause:
|
Style/GuardClause:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/DocumentDynamicEvalDefinition:
|
# TODO
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# https://github.com/rubocop/rubocop/issues/12132
|
|
||||||
Style/OptionalBooleanParameter:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/ClassVars:
|
Style/ClassVars:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# TODO
|
||||||
Style/GlobalVars:
|
Style/GlobalVars:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# TODO
|
||||||
Style/FormatStringToken:
|
Style/FormatStringToken:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# TODO
|
||||||
Style/MultilineBlockChain:
|
Style/MultilineBlockChain:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# The only numeric literals in the codebase long enough to trip this are kilobyte sizes, for which a thousands separator does not improve readability.
|
||||||
Style/NumericLiterals:
|
Style/NumericLiterals:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/RedundantCapitalW:
|
# TODO
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/RedundantLineContinuation:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Style/RedundantStringEscape:
|
Style/RedundantStringEscape:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
# Enabling Metrics results in offenses that essentially mandate the arbitrary splitting of logic into additional files and methods.
|
||||||
|
# Even the rubocop codebase itself often inline disables these offfenses, so lets save the time and disable them all here.
|
||||||
Metrics:
|
Metrics:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Naming/AccessorMethodName:
|
# We disable this for packages because we don't want to incorrectly convert things like Xz_java into XzJava.
|
||||||
Enabled: false
|
# Many package names include - or _ and we don't want to lose that information by mistakenly converting into CamelCase.
|
||||||
|
|
||||||
Naming/BlockParameterName:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
Naming/ClassAndModuleCamelCase:
|
Naming/ClassAndModuleCamelCase:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'packages/*'
|
- 'packages/*'
|
||||||
|
|
||||||
|
# We allow all caps variables to mirror our constants, so things like @ARCH_LDFLAGS are allowed.
|
||||||
Naming/VariableName:
|
Naming/VariableName:
|
||||||
EnforcedStyle: snake_case
|
EnforcedStyle: snake_case
|
||||||
# Allow variable names which are in all caps (with optional numbers and underscores)
|
# Allow variable names which are in all caps (with optional numbers and underscores)
|
||||||
AllowedPatterns:
|
AllowedPatterns:
|
||||||
- '^@?[A-Z0-9_]+$'
|
- '^@?[A-Z0-9_]+$'
|
||||||
|
|
||||||
Naming/VariableNumber:
|
# If there is meaningful information to convey about the contents of a heredoc, a comment is the best way to do it.
|
||||||
Enabled: false
|
# Forcing unique names for all heredoc delimiters does not improve documentation in the vast majority of cases.
|
||||||
|
|
||||||
Naming/HeredocDelimiterNaming:
|
Naming/HeredocDelimiterNaming:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|||||||
16
bin/crew
16
bin/crew
@@ -139,7 +139,7 @@ at_exit do
|
|||||||
ExitMessage.print
|
ExitMessage.print
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_current_package(extra = false)
|
def print_current_package(extra: false)
|
||||||
status = if PackageUtils.installed?(@pkg.name)
|
status = if PackageUtils.installed?(@pkg.name)
|
||||||
:installed
|
:installed
|
||||||
elsif !PackageUtils.compatible?(@pkg)
|
elsif !PackageUtils.compatible?(@pkg)
|
||||||
@@ -167,7 +167,7 @@ def print_current_package(extra = false)
|
|||||||
puts ''
|
puts ''
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_package(pkg_path)
|
def check_load_package(pkg_path)
|
||||||
begin
|
begin
|
||||||
@pkg = Package.load_package(pkg_path)
|
@pkg = Package.load_package(pkg_path)
|
||||||
rescue SyntaxError => e
|
rescue SyntaxError => e
|
||||||
@@ -179,7 +179,7 @@ end
|
|||||||
|
|
||||||
def search(pkg_name, pkg_path: File.join(CREW_PACKAGES_PATH, "#{pkg_name}.rb"), silent: false)
|
def search(pkg_name, pkg_path: File.join(CREW_PACKAGES_PATH, "#{pkg_name}.rb"), silent: false)
|
||||||
begin
|
begin
|
||||||
return set_package(pkg_path) if File.file?(pkg_path)
|
return check_load_package(pkg_path) if File.file?(pkg_path)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
puts "Error with #{pkg_name}.rb: #{e}".lightred unless e.to_s.include?('uninitialized constant')
|
puts "Error with #{pkg_name}.rb: #{e}".lightred unless e.to_s.include?('uninitialized constant')
|
||||||
end
|
end
|
||||||
@@ -486,7 +486,7 @@ def download
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Download file if not cached.
|
# Download file if not cached.
|
||||||
downloader url, sha256sum, filename, CREW_VERBOSE
|
downloader url, sha256sum, filename, verbose: CREW_VERBOSE
|
||||||
|
|
||||||
puts "#{@pkg.name.capitalize} archive downloaded.".lightgreen
|
puts "#{@pkg.name.capitalize} archive downloaded.".lightgreen
|
||||||
# Stow file in cache if requested, if file is not from cache,
|
# Stow file in cache if requested, if file is not from cache,
|
||||||
@@ -513,7 +513,7 @@ def download
|
|||||||
else
|
else
|
||||||
unless git # We don't want to download a git repository as a file.
|
unless git # We don't want to download a git repository as a file.
|
||||||
FileUtils.mkdir_p @extract_dir
|
FileUtils.mkdir_p @extract_dir
|
||||||
downloader url, sha256sum, filename, CREW_VERBOSE
|
downloader url, sha256sum, filename, verbose: CREW_VERBOSE
|
||||||
|
|
||||||
puts "#{filename}: File downloaded.".lightgreen
|
puts "#{filename}: File downloaded.".lightgreen
|
||||||
|
|
||||||
@@ -1625,7 +1625,7 @@ def build_command(args)
|
|||||||
next unless Command.check(name, @opt_force)
|
next unless Command.check(name, @opt_force)
|
||||||
|
|
||||||
search @pkg_name
|
search @pkg_name
|
||||||
print_current_package CREW_VERBOSE
|
print_current_package extra: CREW_VERBOSE
|
||||||
next unless @pkg_name
|
next unless @pkg_name
|
||||||
|
|
||||||
# Process preflight block to see if package should be built
|
# Process preflight block to see if package should be built
|
||||||
@@ -1680,7 +1680,7 @@ def download_command(args)
|
|||||||
@pkg_name = name
|
@pkg_name = name
|
||||||
search @pkg_name
|
search @pkg_name
|
||||||
@pkg.build_from_source = true if @opt_source
|
@pkg.build_from_source = true if @opt_source
|
||||||
print_current_package CREW_VERBOSE
|
print_current_package extra: CREW_VERBOSE
|
||||||
if ARGV.intersect?(%w[download]) && @pkg.is_fake?
|
if ARGV.intersect?(%w[download]) && @pkg.is_fake?
|
||||||
fake_pkg_deplist = @pkg.get_deps_list(return_attr: true).flat_map(&:keys).uniq
|
fake_pkg_deplist = @pkg.get_deps_list(return_attr: true).flat_map(&:keys).uniq
|
||||||
until fake_pkg_deplist.blank?
|
until fake_pkg_deplist.blank?
|
||||||
@@ -1731,7 +1731,7 @@ def install_command(args)
|
|||||||
end
|
end
|
||||||
next unless Command.check(name, @opt_force)
|
next unless Command.check(name, @opt_force)
|
||||||
search @pkg_name
|
search @pkg_name
|
||||||
print_current_package true
|
print_current_package extra: true
|
||||||
@pkg.build_from_source = true if @opt_source || @opt_recursive || CREW_BUILD_FROM_SOURCE
|
@pkg.build_from_source = true if @opt_source || @opt_recursive || CREW_BUILD_FROM_SOURCE
|
||||||
next unless @pkg_name
|
next unless @pkg_name
|
||||||
|
|
||||||
|
|||||||
14
lib/const.rb
14
lib/const.rb
@@ -3,7 +3,7 @@
|
|||||||
require 'etc'
|
require 'etc'
|
||||||
|
|
||||||
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
|
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
|
||||||
CREW_VERSION ||= '1.57.8' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
|
CREW_VERSION ||= '1.57.9' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
|
||||||
|
|
||||||
# Kernel architecture.
|
# Kernel architecture.
|
||||||
KERN_ARCH ||= Etc.uname[:machine]
|
KERN_ARCH ||= Etc.uname[:machine]
|
||||||
@@ -61,7 +61,7 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Use sane minimal defaults if in container and no override specified.
|
# Use sane minimal defaults if in container and no override specified.
|
||||||
CREW_KERNEL_VERSION ||= \
|
CREW_KERNEL_VERSION ||=
|
||||||
if CREW_IN_CONTAINER && ENV.fetch('CREW_KERNEL_VERSION', nil).nil?
|
if CREW_IN_CONTAINER && ENV.fetch('CREW_KERNEL_VERSION', nil).nil?
|
||||||
ARCH.eql?('i686') ? '3.8' : '5.10'
|
ARCH.eql?('i686') ? '3.8' : '5.10'
|
||||||
else
|
else
|
||||||
@@ -106,7 +106,7 @@ CREW_FORCE ||= ARGV.intersect?(%w[-f --force]) unless defined?(CREW_FORCE)
|
|||||||
CREW_VERBOSE ||= ARGV.intersect?(%w[-v --verbose]) unless defined?(CREW_VERBOSE)
|
CREW_VERBOSE ||= ARGV.intersect?(%w[-v --verbose]) unless defined?(CREW_VERBOSE)
|
||||||
|
|
||||||
# Set CREW_NPROC from environment variable, `distcc -j`, or `nproc`.
|
# Set CREW_NPROC from environment variable, `distcc -j`, or `nproc`.
|
||||||
CREW_NPROC ||= \
|
CREW_NPROC ||=
|
||||||
if File.file?("#{CREW_PREFIX}/bin/distcc")
|
if File.file?("#{CREW_PREFIX}/bin/distcc")
|
||||||
ENV.fetch('CREW_NPROC', `distcc -j`.chomp)
|
ENV.fetch('CREW_NPROC', `distcc -j`.chomp)
|
||||||
else
|
else
|
||||||
@@ -139,7 +139,7 @@ CREW_BRANCH ||= ENV.fetch('CREW_BRANCH', 'master') unless defined?(CREW_BRANCH)
|
|||||||
USER ||= Etc.getlogin unless defined?(USER)
|
USER ||= Etc.getlogin unless defined?(USER)
|
||||||
|
|
||||||
unless defined?(CHROMEOS_RELEASE)
|
unless defined?(CHROMEOS_RELEASE)
|
||||||
CHROMEOS_RELEASE = \
|
CHROMEOS_RELEASE =
|
||||||
if File.exist?('/etc/lsb-release')
|
if File.exist?('/etc/lsb-release')
|
||||||
File.read('/etc/lsb-release')[/CHROMEOS_RELEASE_CHROME_MILESTONE||=(.+)/, 1]
|
File.read('/etc/lsb-release')[/CHROMEOS_RELEASE_CHROME_MILESTONE||=(.+)/, 1]
|
||||||
else
|
else
|
||||||
@@ -168,7 +168,7 @@ CREW_DOWNLOADER_RETRY ||= ENV.fetch('CREW_DOWNLOADER_RETRY', 3).to_i unless defi
|
|||||||
CREW_HIDE_PROGBAR = ENV.fetch('CREW_HIDE_PROGBAR', false) unless defined?(CREW_HIDE_PROGBAR)
|
CREW_HIDE_PROGBAR = ENV.fetch('CREW_HIDE_PROGBAR', false) unless defined?(CREW_HIDE_PROGBAR)
|
||||||
|
|
||||||
# set certificate file location for lib/downloader.rb
|
# set certificate file location for lib/downloader.rb
|
||||||
SSL_CERT_FILE ||= \
|
SSL_CERT_FILE ||=
|
||||||
if ENV['SSL_CERT_FILE'] && File.exist?(ENV['SSL_CERT_FILE'])
|
if ENV['SSL_CERT_FILE'] && File.exist?(ENV['SSL_CERT_FILE'])
|
||||||
ENV['SSL_CERT_FILE']
|
ENV['SSL_CERT_FILE']
|
||||||
elsif File.exist?("#{CREW_PREFIX}/etc/ssl/certs/ca-certificates.crt")
|
elsif File.exist?("#{CREW_PREFIX}/etc/ssl/certs/ca-certificates.crt")
|
||||||
@@ -177,7 +177,7 @@ SSL_CERT_FILE ||= \
|
|||||||
'/etc/ssl/certs/ca-certificates.crt'
|
'/etc/ssl/certs/ca-certificates.crt'
|
||||||
end
|
end
|
||||||
|
|
||||||
SSL_CERT_DIR ||= \
|
SSL_CERT_DIR ||=
|
||||||
if ENV['SSL_CERT_DIR'] && Dir.exist?(ENV['SSL_CERT_DIR'])
|
if ENV['SSL_CERT_DIR'] && Dir.exist?(ENV['SSL_CERT_DIR'])
|
||||||
ENV['SSL_CERT_DIR']
|
ENV['SSL_CERT_DIR']
|
||||||
elsif Dir.exist?("#{CREW_PREFIX}/etc/ssl/certs")
|
elsif Dir.exist?("#{CREW_PREFIX}/etc/ssl/certs")
|
||||||
@@ -211,7 +211,7 @@ CREW_COMMON_FNO_LTO_FLAGS ||= "#{CREW_CORE_FLAGS} -fno-lto"
|
|||||||
CREW_LDFLAGS ||= "-flto=auto #{CREW_LINKER_FLAGS}"
|
CREW_LDFLAGS ||= "-flto=auto #{CREW_LINKER_FLAGS}"
|
||||||
CREW_FNO_LTO_LDFLAGS ||= '-fno-lto'
|
CREW_FNO_LTO_LDFLAGS ||= '-fno-lto'
|
||||||
|
|
||||||
CREW_ENV_OPTIONS_HASH ||= \
|
CREW_ENV_OPTIONS_HASH ||=
|
||||||
if CREW_DISABLE_ENV_OPTIONS
|
if CREW_DISABLE_ENV_OPTIONS
|
||||||
{ 'CREW_DISABLE_ENV_OPTIONS' => '1' }
|
{ 'CREW_DISABLE_ENV_OPTIONS' => '1' }
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class ConvenienceFunctions
|
|||||||
|
|
||||||
def self.unset_default_browser(browser_name, browser_binary)
|
def self.unset_default_browser(browser_name, browser_binary)
|
||||||
Dir.chdir("#{CREW_PREFIX}/bin") do
|
Dir.chdir("#{CREW_PREFIX}/bin") do
|
||||||
if File.exist?('x-www-browser') && File.symlink?('x-www-browser') && \
|
if File.exist?('x-www-browser') && File.symlink?('x-www-browser') &&
|
||||||
File.realpath('x-www-browser') == "#{CREW_PREFIX}/share/#{browser_name.downcase}/#{browser_binary}"
|
File.realpath('x-www-browser') == "#{CREW_PREFIX}/share/#{browser_name.downcase}/#{browser_binary}"
|
||||||
FileUtils.rm "#{CREW_PREFIX}/bin/x-www-browser"
|
FileUtils.rm "#{CREW_PREFIX}/bin/x-www-browser"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ module DebUtils
|
|||||||
end
|
end
|
||||||
|
|
||||||
# read file meta
|
# read file meta
|
||||||
name, _modtime, _uid, _gid, mode, size, end_char = \
|
name, _modtime, _uid, _gid, mode, size, end_char =
|
||||||
line.scan(/(.{16})(.{12})(.{6})(.{6})(.{8})(.{10})(.{1})/).flatten.map(&:strip)
|
line.scan(/(.{16})(.{12})(.{6})(.{6})(.{8})(.{10})(.{1})/).flatten.map(&:strip)
|
||||||
|
|
||||||
# remove slash suffix from filename (if any)
|
# remove slash suffix from filename (if any)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ rescue RuntimeError => e
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def downloader(url, sha256sum, filename = File.basename(url), verbose = false)
|
def downloader(url, sha256sum, filename = File.basename(url), verbose: false)
|
||||||
# downloader: wrapper for all Chromebrew downloaders (`net/http`,`curl`...)
|
# downloader: wrapper for all Chromebrew downloaders (`net/http`,`curl`...)
|
||||||
# Usage: downloader <url>, <sha256sum>, <filename::optional>, <verbose::optional>
|
# Usage: downloader <url>, <sha256sum>, <filename::optional>, <verbose::optional>
|
||||||
#
|
#
|
||||||
@@ -39,13 +39,13 @@ def downloader(url, sha256sum, filename = File.basename(url), verbose = false)
|
|||||||
if CREW_USE_CURL || !ENV['CREW_DOWNLOADER'].to_s.empty?
|
if CREW_USE_CURL || !ENV['CREW_DOWNLOADER'].to_s.empty?
|
||||||
# force using external downloader if either CREW_USE_CURL or ENV['CREW_DOWNLOADER'] is set
|
# force using external downloader if either CREW_USE_CURL or ENV['CREW_DOWNLOADER'] is set
|
||||||
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
|
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
|
||||||
external_downloader(uri, filename, verbose)
|
external_downloader(uri, filename, verbose: verbose)
|
||||||
else
|
else
|
||||||
case uri.scheme
|
case uri.scheme
|
||||||
when 'http', 'https'
|
when 'http', 'https'
|
||||||
# use net/http if the url protocol is http(s)://
|
# use net/http if the url protocol is http(s)://
|
||||||
puts "http_downloader(#{uri}, #{filename}, #{verbose})" if verbose
|
puts "http_downloader(#{uri}, #{filename}, #{verbose})" if verbose
|
||||||
http_downloader(uri, filename, verbose)
|
http_downloader(uri, filename, verbose: verbose)
|
||||||
when 'file'
|
when 'file'
|
||||||
# use FileUtils to copy if it is a local file (the url protocol is file://)
|
# use FileUtils to copy if it is a local file (the url protocol is file://)
|
||||||
if File.exist?(uri.path)
|
if File.exist?(uri.path)
|
||||||
@@ -56,7 +56,7 @@ def downloader(url, sha256sum, filename = File.basename(url), verbose = false)
|
|||||||
else
|
else
|
||||||
# use external downloader (curl by default) if the url protocol is not http(s):// or file://
|
# use external downloader (curl by default) if the url protocol is not http(s):// or file://
|
||||||
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
|
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
|
||||||
external_downloader(uri, filename, verbose)
|
external_downloader(uri, filename, verbose: verbose)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -88,10 +88,10 @@ rescue StandardError => e
|
|||||||
|
|
||||||
# fallback to curl if error occurred
|
# fallback to curl if error occurred
|
||||||
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
|
puts "external_downloader(#{uri}, #{filename}, #{verbose})" if verbose
|
||||||
external_downloader(uri, filename, verbose)
|
external_downloader(uri, filename, verbose: verbose)
|
||||||
end
|
end
|
||||||
|
|
||||||
def http_downloader(uri, filename = File.basename(url), verbose = false)
|
def http_downloader(uri, filename = File.basename(url), verbose: false)
|
||||||
# http_downloader: Downloader based on net/http library
|
# http_downloader: Downloader based on net/http library
|
||||||
ssl_error_retry = 0
|
ssl_error_retry = 0
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ def http_downloader(uri, filename = File.basename(url), verbose = false)
|
|||||||
redirect_uri.scheme ||= uri.scheme
|
redirect_uri.scheme ||= uri.scheme
|
||||||
redirect_uri.host ||= uri.host
|
redirect_uri.host ||= uri.host
|
||||||
|
|
||||||
return send(__method__, redirect_uri, filename, verbose)
|
return send(__method__, redirect_uri, filename, verbose: verbose)
|
||||||
else
|
else
|
||||||
abort "Download of #{uri} failed with error #{response.code}: #{response.msg}".lightred
|
abort "Download of #{uri} failed with error #{response.code}: #{response.msg}".lightred
|
||||||
end
|
end
|
||||||
@@ -167,7 +167,7 @@ rescue OpenSSL::SSL::SSLError
|
|||||||
ssl_error_retry <= 3 ? retry : raise
|
ssl_error_retry <= 3 ? retry : raise
|
||||||
end
|
end
|
||||||
|
|
||||||
def external_downloader(uri, filename = File.basename(url), verbose = false)
|
def external_downloader(uri, filename = File.basename(url), verbose: false)
|
||||||
# external_downloader: wrapper for external downloaders in CREW_DOWNLOADER (curl by default)
|
# external_downloader: wrapper for external downloaders in CREW_DOWNLOADER (curl by default)
|
||||||
|
|
||||||
# default curl cmdline, CREW_DOWNLOADER should be in this format also
|
# default curl cmdline, CREW_DOWNLOADER should be in this format also
|
||||||
|
|||||||
@@ -143,9 +143,9 @@ class Package
|
|||||||
deps = pkg_obj.dependencies
|
deps = pkg_obj.dependencies
|
||||||
|
|
||||||
# Append buildessential to deps if building from source is needed/specified.
|
# Append buildessential to deps if building from source is needed/specified.
|
||||||
if ((include_build_deps == true) || ((include_build_deps == 'auto') && is_source)) && \
|
if ((include_build_deps == true) || ((include_build_deps == 'auto') && is_source)) &&
|
||||||
!pkg_obj.no_compile_needed? && \
|
!pkg_obj.no_compile_needed? &&
|
||||||
!exclude_buildessential && \
|
!exclude_buildessential &&
|
||||||
!@checked_list.keys.include?('buildessential')
|
!@checked_list.keys.include?('buildessential')
|
||||||
|
|
||||||
deps = { 'buildessential' => [[:build]] }.merge(deps)
|
deps = { 'buildessential' => [[:build]] }.merge(deps)
|
||||||
@@ -155,8 +155,8 @@ class Package
|
|||||||
expanded_deps = deps.uniq.map do |dep, (dep_tags, ver_check)|
|
expanded_deps = deps.uniq.map do |dep, (dep_tags, ver_check)|
|
||||||
# Check build dependencies only if building from source is needed/specified.
|
# Check build dependencies only if building from source is needed/specified.
|
||||||
# Do not recursively find :build based build dependencies.
|
# Do not recursively find :build based build dependencies.
|
||||||
next unless (include_build_deps == true && @crew_current_package == pkg_obj.name) || \
|
next unless (include_build_deps == true && @crew_current_package == pkg_obj.name) ||
|
||||||
((include_build_deps == 'auto') && is_source && @crew_current_package == pkg_obj.name) || \
|
((include_build_deps == 'auto') && is_source && @crew_current_package == pkg_obj.name) ||
|
||||||
!dep_tags.include?(:build)
|
!dep_tags.include?(:build)
|
||||||
|
|
||||||
# Overwrite tags if parent dependency is a build dependency.
|
# Overwrite tags if parent dependency is a build dependency.
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ class Selector
|
|||||||
# discard any input in the input buffer
|
# discard any input in the input buffer
|
||||||
$stdin.read_nonblock(1024)
|
$stdin.read_nonblock(1024)
|
||||||
rescue IO::WaitReadable
|
rescue IO::WaitReadable
|
||||||
|
# We wait here for reading as per https://docs.ruby-lang.org/en/master/IO.html#method-c-select
|
||||||
ensure
|
ensure
|
||||||
Thread.current[:input] = $stdin.getc
|
Thread.current[:input] = $stdin.getc
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class Firefox < Package
|
|||||||
|
|
||||||
def self.preremove
|
def self.preremove
|
||||||
Dir.chdir("#{CREW_PREFIX}/bin") do
|
Dir.chdir("#{CREW_PREFIX}/bin") do
|
||||||
if File.exist?('x-www-browser') && File.symlink?('x-www-browser') && \
|
if File.exist?('x-www-browser') && File.symlink?('x-www-browser') &&
|
||||||
File.realpath('x-www-browser') == "#{CREW_PREFIX}/bin/firefox"
|
File.realpath('x-www-browser') == "#{CREW_PREFIX}/bin/firefox"
|
||||||
FileUtils.rm "#{CREW_PREFIX}/bin/x-www-browser"
|
FileUtils.rm "#{CREW_PREFIX}/bin/x-www-browser"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ class Foremost < Package
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.install
|
def self.install
|
||||||
FileUtils.mkdir_p ["#{CREW_DEST_PREFIX}/bin", \
|
FileUtils.mkdir_p ["#{CREW_DEST_PREFIX}/bin",
|
||||||
"#{CREW_DEST_PREFIX}/man/man1", \
|
"#{CREW_DEST_PREFIX}/man/man1",
|
||||||
"#{CREW_DEST_PREFIX}/etc"]
|
"#{CREW_DEST_PREFIX}/etc"]
|
||||||
FileUtils.cp_r 'foremost', "#{CREW_DEST_PREFIX}/bin/"
|
FileUtils.cp_r 'foremost', "#{CREW_DEST_PREFIX}/bin/"
|
||||||
FileUtils.cp_r 'foremost.8.gz', "#{CREW_DEST_PREFIX}/man/man1/foremost.1.gz"
|
FileUtils.cp_r 'foremost.8.gz', "#{CREW_DEST_PREFIX}/man/man1/foremost.1.gz"
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ class Nss < Package
|
|||||||
depends_on 'zlib' # R
|
depends_on 'zlib' # R
|
||||||
|
|
||||||
def self.build
|
def self.build
|
||||||
@build_64 = ARCH == 'x86_64' ? '1' : '0'
|
@build64 = ARCH == 'x86_64' ? '1' : '0'
|
||||||
@arch_cflags = ''
|
@arch_cflags = ''
|
||||||
@arch_ldflags = @arch_cflags
|
@arch_ldflags = @arch_cflags
|
||||||
|
|
||||||
Dir.chdir 'nss' do
|
Dir.chdir 'nss' do
|
||||||
system "env opt_build=1 build_64=#{@build_64} \
|
system "env opt_build=1 build_64=#{@build64} \
|
||||||
NSS_ENABLE_WERROR=0 NS_USE_GCC=1 USEABSPATH=NO \
|
NSS_ENABLE_WERROR=0 NS_USE_GCC=1 USEABSPATH=NO \
|
||||||
NSS_GYP_PREFIX=#{CREW_PREFIX} CFLAGS='-pipe #{@arch_cflags}' \
|
NSS_GYP_PREFIX=#{CREW_PREFIX} CFLAGS='-pipe #{@arch_cflags}' \
|
||||||
CXXFLAGS='-pipe #{@arch_cflags}' LDFLAGS='#{@arch_ldflags}' \
|
CXXFLAGS='-pipe #{@arch_cflags}' LDFLAGS='#{@arch_ldflags}' \
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ class Qemacs < Package
|
|||||||
def self.build
|
def self.build
|
||||||
system "sed -i 's,css.h,libqhtml/css.h,' html2png.c"
|
system "sed -i 's,css.h,libqhtml/css.h,' html2png.c"
|
||||||
system "sed -i 's/$(prefix)/$(DESTDIR)$(prefix)/g' Makefile"
|
system "sed -i 's/$(prefix)/$(DESTDIR)$(prefix)/g' Makefile"
|
||||||
system './configure', \
|
system './configure',
|
||||||
"--prefix=#{CREW_PREFIX}", \
|
"--prefix=#{CREW_PREFIX}",
|
||||||
'--disable-x11', \
|
'--disable-x11',
|
||||||
'--disable-xv', \
|
'--disable-xv',
|
||||||
'--disable-xrender', \
|
'--disable-xrender',
|
||||||
'--disable-html', \
|
'--disable-html',
|
||||||
'--disable-png'
|
'--disable-png'
|
||||||
system 'make'
|
system 'make'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ class Vifm < Package
|
|||||||
})
|
})
|
||||||
|
|
||||||
def self.build
|
def self.build
|
||||||
system './configure', \
|
system './configure',
|
||||||
"--prefix=#{CREW_PREFIX}", \
|
"--prefix=#{CREW_PREFIX}",
|
||||||
'--without-gtk', \
|
'--without-gtk',
|
||||||
'--without-X11', \
|
'--without-X11',
|
||||||
# "--with-curses=#{CREW_PREFIX}/include/ncursesw" \
|
# "--with-curses=#{CREW_PREFIX}/include/ncursesw" \
|
||||||
# "--with-curses-name=ncursesw" \
|
# "--with-curses-name=ncursesw" \
|
||||||
"CPPFLAGS=-I#{CREW_PREFIX}/include/ncursesw"
|
"CPPFLAGS=-I#{CREW_PREFIX}/include/ncursesw"
|
||||||
|
|||||||
@@ -99,9 +99,7 @@ def main(pkg)
|
|||||||
end.flatten.compact.uniq
|
end.flatten.compact.uniq
|
||||||
|
|
||||||
# Figure out which Chromebrew packages provide the relevant deps.
|
# Figure out which Chromebrew packages provide the relevant deps.
|
||||||
pkgdeps = pkgdepsfiles.map do |file|
|
pkgdeps = pkgdepsfiles.map { |file| whatprovidesfxn(file, pkg) }.sort.reject { |i| i.include?(pkg) }.map { |i| i.split("\n") }.flatten.uniq
|
||||||
whatprovidesfxn(file, pkg)
|
|
||||||
end.sort.reject { |i| i.include?(pkg) }.map { |i| i.split("\n") }.flatten.uniq
|
|
||||||
|
|
||||||
# Massage the glibc entries in the dependency list.
|
# Massage the glibc entries in the dependency list.
|
||||||
pkgdeps = pkgdeps.map { |i| i.gsub(/glibc_build.*/, 'glibc') }.uniq
|
pkgdeps = pkgdeps.map { |i| i.gsub(/glibc_build.*/, 'glibc') }.uniq
|
||||||
|
|||||||
Reference in New Issue
Block a user