-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Do not fail UPX if compression level is not given #39069
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
|
@@ -15,7 +16,6 @@ | |
import org.jboss.logging.Logger; | ||
|
||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.pkg.NativeConfig; | ||
import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem; | ||
import io.quarkus.deployment.pkg.builditem.NativeImageBuildItem; | ||
|
@@ -34,7 +34,6 @@ public class UpxCompressionBuildStep { | |
*/ | ||
private static final String PATH = "PATH"; | ||
|
||
@BuildStep(onlyIf = NativeBuild.class) | ||
public void compress(NativeConfig nativeConfig, NativeImageRunnerBuildItem nativeImageRunner, | ||
NativeImageBuildItem image, | ||
BuildProducer<UpxCompressedBuildItem> upxCompressedProducer, | ||
|
@@ -70,11 +69,13 @@ public void compress(NativeConfig nativeConfig, NativeImageRunnerBuildItem nativ | |
} | ||
|
||
private boolean runUpxFromHost(File upx, File executable, NativeConfig nativeConfig) { | ||
String level = getCompressionLevel(nativeConfig.compression().level().getAsInt()); | ||
List<String> extraArgs = nativeConfig.compression().additionalArgs().orElse(Collections.emptyList()); | ||
List<String> args = Stream.concat( | ||
Stream.concat(Stream.of(upx.getAbsolutePath(), level), extraArgs.stream()), | ||
List<String> args = Stream.of( | ||
Stream.of(upx.getAbsolutePath()), | ||
nativeConfig.compression().level().stream().mapToObj(this::getCompressionLevel), | ||
extraArgs.stream(), | ||
Stream.of(executable.getAbsolutePath())) | ||
.flatMap(Function.identity()) | ||
.collect(Collectors.toList()); | ||
log.infof("Executing %s", String.join(" ", args)); | ||
final ProcessBuilder processBuilder = new ProcessBuilder(args) | ||
|
@@ -104,7 +105,6 @@ private boolean runUpxFromHost(File upx, File executable, NativeConfig nativeCon | |
|
||
private boolean runUpxInContainer(NativeImageBuildItem nativeImage, NativeConfig nativeConfig, | ||
String effectiveBuilderImage) { | ||
String level = getCompressionLevel(nativeConfig.compression().level().getAsInt()); | ||
List<String> extraArgs = nativeConfig.compression().additionalArgs().orElse(Collections.emptyList()); | ||
|
||
List<String> commandLine = new ArrayList<>(); | ||
|
@@ -140,7 +140,9 @@ private boolean runUpxInContainer(NativeImageBuildItem nativeImage, NativeConfig | |
volumeOutputPath + ":" + NativeImageBuildStep.CONTAINER_BUILD_VOLUME_PATH + ":z"); | ||
|
||
commandLine.add(effectiveBuilderImage); | ||
commandLine.add(level); | ||
if (nativeConfig.compression().level().isPresent()) { | ||
commandLine.add(getCompressionLevel(nativeConfig.compression().level().getAsInt())); | ||
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. I didn't know you could run without a compression level. 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. According to the docs, "The default compression level is -8 for files smaller than 512 KiB, and -7 otherwise". Since the property is an |
||
} | ||
commandLine.addAll(extraArgs); | ||
|
||
commandLine.add(nativeImage.getPath().toFile().getName()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmlloyd I assume this was removed by accident?
Asking because of #39699
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, #39702 brings it back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I believe this must have been an error.