Files
chromebrew/packages/jdk18.rb
Maximilian Downey Twiss 33901368d7 Enable more rubocop cops (#9980)
* Remove self.check in python3.rb as tests were not actuallly being run

* Enable Lint/ImplicitStringConcatenation cop

* Enable Layout/CommentIndentation cop

* Remove unnecessary configuration of Layout/IndentationStyle to EnforcedStyle: spaces, as this is already the default

* Enable Layout/LeadingCommentSpace cop

* Enable Layout/SpaceInsideBlockBraces cop

* Enable Layout/SpaceInsideParens cop

* Enable Layout/TrailingEmptyLines cop

* Enable Lint/LiteralAsCondition cop

* Document the current issue stopping us from enabling Style/OptionalBooleanParameter

* Stop downloading our rubocop config when installing ruby_rubocop
2024-06-17 16:19:11 -04:00

73 lines
2.4 KiB
Ruby

require 'package'
require 'uri'
class Jdk18 < Package
description 'The Oracle JDK is a development environment for building applications, applets, and components using the Java programming language.'
homepage 'https://www.oracle.com/java'
version '18.0.2.1'
license 'Oracle-BCLA-JavaSE'
compatibility 'x86_64'
source_url File.join('file://', HOME, 'Downloads', "jdk-#{version}_linux-x64_bin.tar.gz")
source_sha256 'cd905013facbb5c2b5354165cc372e327259de4991c28f31c7d4231dbf638934'
no_compile_needed
no_patchelf
def self.preflight
jdk_exec = File.join(CREW_PREFIX, 'bin', 'java')
if File.exist?(jdk_exec)
jdk_ver_str = `#{jdk_exec} -version 2>&1`
jdk_ver = jdk_ver_str[/version "(.+?)"/, 1]
jdk_major_ver = jdk_ver.match?(/^1.8/) ? '8' : jdk_ver.partition('.')[0]
is_openjdk = jdk_ver_str.include?('openjdk')
pkg_branding = is_openjdk ? 'OpenJDK' : 'Oracle JDK'
pkg_prefix = is_openjdk ? 'openjdk' : 'jdk'
abort <<~EOT.yellow unless jdk_major_ver == name.delete_prefix('jdk') && !is_openjdk
#{pkg_branding} #{jdk_ver} installed.
Run "crew remove #{pkg_prefix}#{jdk_major_ver}; crew install #{name}" to install this version of JDK
EOT
end
return if File.exist?(URI(source_url).path)
abort <<~EOT.orange
Oracle now requires an account to download the JDK.
You must login at https://login.oracle.com/mysso/signon.jsp and then visit:
https://www.oracle.com/java/technologies/javase/jdk18-archive-downloads.html
Download "jdk-#{version}_linux-x64_bin.tar.gz" (Linux x64 Compressed Archive) to Chrome OS download folder to continue.
EOT
end
def self.install
jdk_dir = File.join(CREW_DEST_PREFIX, 'share', name)
FileUtils.mkdir_p [jdk_dir, File.join(CREW_DEST_PREFIX, 'bin'), CREW_DEST_MAN_PREFIX]
FileUtils.rm_f 'lib/src.zip'
FileUtils.cp_r Dir['*'], jdk_dir
Dir[File.join(jdk_dir, 'bin', '*')].each do |path|
filename = File.basename(path)
symlink = File.join(CREW_DEST_PREFIX, 'bin', filename)
FileUtils.ln_s path.sub(CREW_DEST_PREFIX, CREW_PREFIX), symlink
end
FileUtils.rm Dir[File.join(jdk_dir, 'man/man1/k{init,list}.1')] # conflicts with krb5 package
FileUtils.mv Dir[File.join(jdk_dir, 'man', '*')], CREW_DEST_MAN_PREFIX
end
def self.postinstall
# remove jdk archive after installed
FileUtils.rm_f URI(source_url).path
end
end