-
Notifications
You must be signed in to change notification settings - Fork 328
Extract conscrypt native libs from Snowflake and Google_Api #13211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -506,6 +506,99 @@ object StdBits { | |
) | ||
} | ||
|
||
/** Extract native libraries from `org.conscrypt:conscrypt-openjdk-uber:2.5.2` jar, which is | ||
* a transitive dependency of | ||
* `com.google.analytics:google-analytics-admin:0.66.0` and of | ||
* `net.snowflake:snowflake-jdbc-thin:3.15.0`. | ||
* | ||
* Currently, it is included in both `Standard.Google_Api` and `Standard.Snowflake` libraries. | ||
* | ||
* Names of the native libraries in jar: | ||
* - `META-INF/native/conscrypt_openjdk_jni-windows-x86.dll` | ||
* - `META-INF/native/conscrypt_openjdk_jni-windows-x86_64.dll` | ||
* - `META-INF/native/libconscrypt_openjdk_jni-linux-x86_64.so` | ||
* - `META-INF/native/libconscrypt_openjdk_jni-osx-x86_64.dylib` | ||
* | ||
* The jar is signed, so we also have to remove `META-INF/SIGNING.SF`. | ||
*/ | ||
def extractNativeLibsFromConscrypt( | ||
polyglotRootDir: File, | ||
nativeLibsDir: File, | ||
updateReport: UpdateReport, | ||
logger: ManagedLogger, | ||
moduleName: String, | ||
scalaBinaryVersion: String, | ||
cacheStoreFactory: CacheStoreFactory, | ||
previousRun: Option[AnalysisOfExtractedNativeLibs] | ||
): AnalysisOfExtractedNativeLibs = { | ||
if (previousRun.exists(!_.isOutdated)) { | ||
return previousRun.get | ||
} | ||
val osName = plainOsName().replace("macos", "osx") | ||
val validOsExt = osExt() | ||
val validArch = arch().replace("-", "_") | ||
val prefix = "META-INF/native" | ||
val entriesToRemove = Seq( | ||
"META-INF/SIGNINGC.SF", | ||
"META-INF/SIGNINGC.RSA" | ||
) | ||
val conscryptVersion = "2.5.2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be provided as a parameter of a function. We don't want to have multiple versions of conscrypt floating around. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I agree on this one. As mentioned in the docs for this method, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. In that case it is still broken. If we upgrade the dependency that brings conscrypt and the former bumps its version, it will only show up when running your test suite (I guess?). Ideally the inference of the version would be automatic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is no "test suite". This is done during
Yes, ideally it should. Ideally, sbt should be properly documented and it should expose API for fetching dependencies. But it does not. |
||
|
||
def renameFunc(entryName: String): Option[String] = { | ||
val strippedEntryName = entryName.substring(prefix.length + 1) | ||
val pattern = "^(.+)-(\\w+)-([\\w_]+)(\\.\\w+)$".r | ||
strippedEntryName match { | ||
case pattern(libname, entryOs, entryArch, entryExt) => | ||
if ( | ||
!entryOs.equals(osName) || | ||
!entryArch.equals(validArch) || | ||
!entryExt.equals(validOsExt) | ||
) { | ||
None | ||
} else { | ||
val outputArch = validArch.replace("x86_64", "amd64") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the name of the directory that will be put inside the |
||
Some(s"$outputArch/$osName/$libname$entryExt") | ||
} | ||
case _ => | ||
throw new RuntimeException( | ||
s"Unexpected entry name format: $strippedEntryName" | ||
) | ||
} | ||
} | ||
|
||
val conscryptJar = JPMSUtils | ||
.filterModulesFromUpdate( | ||
updateReport, | ||
Seq("org.conscrypt" % "conscrypt-openjdk-uber" % conscryptVersion), | ||
logger, | ||
moduleName, | ||
scalaBinaryVersion, | ||
shouldContainAll = true | ||
) | ||
.head | ||
val outputJar = | ||
(polyglotRootDir / s"conscrypt-openjdk-uber-$conscryptVersion.jar").toPath | ||
val extractedLibs = JARUtils.extractFilesFromJar( | ||
conscryptJar.toPath, | ||
Some(prefix), | ||
Some(outputJar), | ||
nativeLibsDir.toPath, | ||
renameFunc, | ||
logger, | ||
cacheStoreFactory, | ||
previousRun.flatMap(_.forJar(conscryptJar)) | ||
) | ||
JARUtils.removeEntriesFromJar( | ||
outputJar, | ||
entryName => entriesToRemove.contains(entryName) | ||
) | ||
AnalysisOfExtractedNativeLibs( | ||
conscryptJar, | ||
extractedLibs.getOrElse(Nil), | ||
Some(outputJar.toFile) | ||
) | ||
} | ||
|
||
def ensureDirExistsAndIsClean( | ||
path: Path, | ||
logger: sbt.util.Logger, | ||
|
Uh oh!
There was an error while loading. Please reload this page.