From a2947afc6c0b72467a6431c117199731a71dd447 Mon Sep 17 00:00:00 2001 From: Carlos de Paula Date: Mon, 26 Feb 2024 15:12:52 -0300 Subject: [PATCH] Add IBM Semeru (OpenJ9) to the index --- src/GenerateIndex.scala | 7 ++-- src/IBMSemeru.scala | 72 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/IBMSemeru.scala diff --git a/src/GenerateIndex.scala b/src/GenerateIndex.scala index 58c574f..cf8d6a8 100644 --- a/src/GenerateIndex.scala +++ b/src/GenerateIndex.scala @@ -19,14 +19,17 @@ object GenerateIndex { val adoptIndex0 = Temurin.fullIndex(GhToken.token) val zuluIndex0 = Zulu.index() val libericaIndex0 = Liberica.index() + val ibmsemeruIndex0 = IBMSemeru.fullIndex(GhToken.token) - val index = graalvmLegacyIndex0 + + val index = + graalvmLegacyIndex0 + graalvmIndex0 + oracleIndex0 + adoptIndex0 + zuluIndex0 + libericaIndex0 + - correttoIndex0 + correttoIndex0 + + ibmsemeruIndex0 val json = index.json os.write.over(dest, json) diff --git a/src/IBMSemeru.scala b/src/IBMSemeru.scala new file mode 100644 index 0000000..72f48e0 --- /dev/null +++ b/src/IBMSemeru.scala @@ -0,0 +1,72 @@ +object IBMSemeru { + + def fullIndex(ghToken: String): Index = { + val ibmsemeruJdk11Index0 = index(ghToken, "11") + val ibmsemeruJdk17Index0 = index(ghToken, "17") + val ibmsemeruJdk21Index0 = index(ghToken, "21") + ibmsemeruJdk11Index0 + ibmsemeruJdk17Index0 + ibmsemeruJdk21Index0 + } + + def index( + ghToken: String, + javaVersion: String + ): Index = { + + val ghOrg = "ibmruntimes" + val ghProj = s"semeru${javaVersion}-binaries" + val releases0 = Release.releaseIds(ghOrg, ghProj, ghToken) + .filter(!_.prerelease) + + def osOpt(input: String): Option[(String, String)] = + input match + case input if input.startsWith("linux") => Some(("linux", input.stripPrefix("linux_"))) + case input if input.startsWith("mac") => Some(("darwin", input.stripPrefix("mac_"))) + case input if input.startsWith("windows") => Some(("windows", input.stripPrefix("windows_"))) + case input if input.startsWith("aix") => Some(("aix", input.stripPrefix("aix_"))) + case _ => None + + def archOpt(input: String): Option[(String, String)] = + input match + case input if input.startsWith("x64") => Some(("amd64", input.stripPrefix("x64_"))) + case input if input.startsWith("aarch64") => Some(("arm64", input.stripPrefix("aarch64_"))) + case input if input.startsWith("ppc64le") => Some(("ppc64le", input.stripPrefix("ppc64le_"))) + case input if input.startsWith("ppc64") => Some(("ppc64", input.stripPrefix("ppc64_"))) + case input if input.startsWith("s390x") => Some(("s390x", input.stripPrefix("s390x_"))) + case _ => None + + def archiveTypeOpt(input: String): Option[(String, String)] = + input match + case input if input.endsWith(".zip") => Some(("zip", input.stripSuffix(".zip"))) + case input if input.endsWith(".tar.gz") => Some(("tgz", input.stripSuffix(".tar.gz"))) + case _ => None + + val indices = releases0 + .filter(release => release.tagName.startsWith(s"jdk-$javaVersion")) + .flatMap { release => + val version = release.tagName.stripPrefix("jdk-") + val assetNamePrefix = s"ibm-semeru-open-jdk_" + val assets = Asset.releaseAssets(ghOrg, ghProj, ghToken, release.tagName) + assets + .filter(asset => asset.name.startsWith(assetNamePrefix)) + .flatMap { asset => + val name0 = asset.name.stripPrefix(assetNamePrefix) + println(s"asset.name: ${asset.name}") + // val nameGlobal = "jdk@ibm-semeru-openj9" + val nameVersion = s"jdk@ibm-semeru-openj9-java$javaVersion" + val opt = + for { + (arch, rem) <- archOpt(name0) + (os, rem0) <- osOpt(rem) + (archiveType, ver) <- archiveTypeOpt(rem0) + } yield Seq( + // Index(os, arch, nameGlobal, version, archiveType + "+" + asset.downloadUrl), + Index(os, arch, nameVersion, version, archiveType + "+" + asset.downloadUrl) + ) + opt.toSeq.flatten + } + } + + indices.foldLeft(Index.empty)(_ + _) + } + +}