Skip to content
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

3.2: Packs libraries alongside executable in function.zip #35721

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ private void handleAdditionalProperties(List<String> command) {
+ CONTAINER_BUILD_VOLUME_PATH + "/" + MOVED_TRUST_STORE_NAME);
} catch (IOException e) {
throw new UncheckedIOException("Unable to copy trustStore file '" + configuredTrustStorePath
+ "' to volume root directory '" + outputDir.toAbsolutePath().toString() + "'", e);
+ "' to volume root directory '" + outputDir.toAbsolutePath() + "'", e);
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -21,8 +23,10 @@
import io.quarkus.deployment.pkg.builditem.JarBuildItem;
import io.quarkus.deployment.pkg.builditem.LegacyJarRequiredBuildItem;
import io.quarkus.deployment.pkg.builditem.NativeImageBuildItem;
import io.quarkus.deployment.pkg.builditem.NativeImageRunnerBuildItem;
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
import io.quarkus.deployment.pkg.builditem.UpxCompressedBuildItem;
import io.quarkus.deployment.pkg.steps.GraalVM;
import io.quarkus.deployment.pkg.steps.NativeBuild;

/**
Expand Down Expand Up @@ -106,7 +110,8 @@ public void jvmZip(OutputTargetBuildItem target,
public void nativeZip(OutputTargetBuildItem target,
Optional<UpxCompressedBuildItem> upxCompressed, // used to ensure that we work with the compressed native binary if compression was enabled
BuildProducer<ArtifactResultBuildItem> artifactResultProducer,
NativeImageBuildItem nativeImage) throws Exception {
NativeImageBuildItem nativeImage,
NativeImageRunnerBuildItem nativeImageRunner) throws Exception {
Path zipDir = findNativeZipDir(target.getOutputDirectory());

Path zipPath = target.getOutputDirectory().resolve("function.zip");
Expand Down Expand Up @@ -137,8 +142,26 @@ public void nativeZip(OutputTargetBuildItem target,
}
}
addZipEntry(zip, nativeImage.getPath(), executableName, 0755);

final GraalVM.Version graalVMVersion = nativeImageRunner.getBuildRunner().getGraalVMVersion();
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0) {
// See https://github.com/oracle/graal/issues/4921
try (DirectoryStream<Path> sharedLibs = Files.newDirectoryStream(nativeImage.getPath().getParent(),
"*.{so,dll}")) {
rsvoboda marked this conversation as resolved.
Show resolved Hide resolved
sharedLibs.forEach(src -> {
try {
// In this use case, we can force all libs to be non-executable.
addZipEntry(zip, src, src.getFileName().toString(), 0644);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
} catch (IOException e) {
log.errorf("Could not list files in directory %s. Continuing. Error: %s", nativeImage.getPath().getParent(),
e);
}
}
}
;
}

private void copyZipEntry(ZipArchiveOutputStream zip, InputStream zinput, ZipArchiveEntry from) throws Exception {
Expand Down
Loading