Files
chromebrew/packages/ruby.rb
Maximilian Downey Twiss f6dc1d8d4e Derive binary_url in package.rb (#7082)
* Add binary_compression value to each package

* Remove binary_url values and arrays

* Handle packages with empty binary_sha256 arrays (either missing binaries or not compiled by us)
2024-01-25 11:03:31 -05:00

73 lines
2.7 KiB
Ruby

require 'package'
class Ruby < Package
description 'Ruby is a dynamic, open source programming language with a focus on simplicity and productivity.'
homepage 'https://www.ruby-lang.org/en/'
version '3.3.0' # Do not use @_ver here, it will break the installer.
license 'Ruby-BSD and BSD-2'
compatibility 'all'
source_url 'https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.0.tar.gz'
source_sha256 '96518814d9832bece92a85415a819d4893b307db5921ae1f0f751a9a89a56b7d'
binary_compression 'tar.zst'
binary_sha256({
aarch64: 'c26e8e64fdbb62c5a728582b957cc78ff64a7bc00bec978c3dede8b7a8a329f7',
armv7l: 'c26e8e64fdbb62c5a728582b957cc78ff64a7bc00bec978c3dede8b7a8a329f7',
i686: 'a97a17336b4d233129fb5a55c82d32b38b981d017cda70ba3cbb51012bc129ca',
x86_64: '8df1eee697c2561529e4c3c0b6c16c4d9a99922b1764a7c515473cf9b45d27ef'
})
depends_on 'zlibpkg' # R
depends_on 'glibc' # R
depends_on 'filecmd' # L (This is to enable file command use in package files.)
depends_on 'gmp' # R
depends_on 'gcc_lib' # R
depends_on 'libffi' # R
depends_on 'openssl' # R
depends_on 'libyaml' # R
depends_on 'readline' # R
depends_on 'rust' => :build
depends_on 'ca_certificates'
depends_on 'libyaml' # This is needed to install gems
# at run-time, system's gmp, openssl, readline and zlibpkg can be used
def self.build
@yjit = ARCH == 'x86_64' ? '--enable-yjit' : ''
system '[ -x configure ] || autoreconf -fiv'
system "RUBY_TRY_CFLAGS='stack_protector=no' \
RUBY_TRY_LDFLAGS='stack_protector=no' \
optflags='-flto=auto -fuse-ld=#{CREW_LINKER}' \
mold -run ./configure #{CREW_OPTIONS} \
--enable-shared \
#{@yjit} \
--disable-fortify-source"
system "MAKEFLAGS='--jobs #{CREW_NPROC}' make"
end
def self.check
# Do not run checks if rebuilding current ruby version.
# RUBY_VERSION is a built-in ruby constant.
system "MAKEFLAGS='--jobs #{CREW_NPROC}' make check || true" unless version.split('-')[0] == RUBY_VERSION
end
def self.install
system 'make', "DESTDIR=#{CREW_DEST_DIR}", 'install'
# See https://stackoverflow.com/questions/1844118/ruby-split-string-at-character-counting-from-the-right-side.
@ruby_ver = version.split(/\.([^.]*)$/).first
# Gems are stored in a ruby majorversion.minorversion.0 folder.
@gemrc = <<~GEMRCEOF
gem: --no-document
gempath: #{CREW_LIB_PREFIX}/ruby/gems/#{@ruby_ver}.0
GEMRCEOF
FileUtils.mkdir_p CREW_DEST_HOME
File.write("#{CREW_DEST_HOME}/.gemrc", @gemrc)
end
def self.postinstall
puts 'Updating ruby gems. This may take a while...'
silent = @opt_verbose ? '' : '--silent'
system "gem update #{silent} -N --system", exception: false
end
end