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

8253149: Building an installer from invalid app image fails on Window… #271

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -27,6 +27,7 @@
import java.io.IOException;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Files;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -182,13 +183,17 @@ private List<String> getListOfNeededPackages(
}

final List<String> neededLibPackages;
if (withFindNeededPackages) {
if (withFindNeededPackages && Files.exists(thePackage.sourceRoot())) {
LibProvidersLookup lookup = new LibProvidersLookup();
initLibProvidersLookup(params, lookup);

neededLibPackages = lookup.execute(thePackage.sourceRoot());
} else {
neededLibPackages = Collections.emptyList();
if (!Files.exists(thePackage.sourceRoot())) {
Log.info(I18N.getString("warning.foreign-app-image"));

}
}

// Merge all package lists together.
Expand Down
Expand Up @@ -61,6 +61,8 @@ message.ldd-not-available=ldd command not found. Package dependencies will not b
message.deb-ldd-not-available.advice=Install "libc-bin" DEB package to get ldd.
message.rpm-ldd-not-available.advice=Install "glibc-common" RPM package to get ldd.

warning.foreign-app-image=Warning: app-image dir not generated by jpackage.

error.unexpected-package-property=Expected value of "{0}" property is [{1}]. Actual value in output package is [{2}]. Looks like custom "{3}" file from resource directory contained hard coded value of "{0}" property
error.unexpected-package-property.advice=Use [{0}] pattern string instead of hard coded value [{1}] of {2} property in custom "{3}" file
error.unexpected-default-package-property.advice=Don't explicitly set value of {0} property in custom "{1}" file
Expand Up @@ -40,6 +40,8 @@ resource.menu-shortcut-descriptor=\u30E1\u30CB\u30E5\u30FC\u30FB\u30B7\u30E7\u30
resource.menu-icon=\u30E1\u30CB\u30E5\u30FC\u30FB\u30A2\u30A4\u30B3\u30F3
resource.rpm-spec-file=RPM\u4ED5\u69D8\u30D5\u30A1\u30A4\u30EB

warning.foreign-app-image=Warning: app-image dir not generated by jpackage.

error.tool-not-found.advice=\u5FC5\u8981\u306A\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3057\u3066\u304F\u3060\u3055\u3044
error.tool-old-version.advice=\u5FC5\u8981\u306A\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3057\u3066\u304F\u3060\u3055\u3044

Expand Down
Expand Up @@ -40,6 +40,8 @@ resource.menu-shortcut-descriptor=\u83DC\u5355\u5FEB\u6377\u65B9\u5F0F\u63CF\u8F
resource.menu-icon=\u83DC\u5355\u56FE\u6807
resource.rpm-spec-file=RPM \u89C4\u8303\u6587\u4EF6

warning.foreign-app-image=Warning: app-image dir not generated by jpackage.

error.tool-not-found.advice=\u8BF7\u5B89\u88C5\u6240\u9700\u7684\u7A0B\u5E8F\u5305
error.tool-old-version.advice=\u8BF7\u5B89\u88C5\u6240\u9700\u7684\u7A0B\u5E8F\u5305

Expand Down
Expand Up @@ -27,6 +27,8 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.NoSuchFileException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -214,8 +216,15 @@ static List<String> getLauncherNames(Path appImageDir,
launchers.addAll(appImageInfo.getAddLauncherNames());
return launchers;
}
} catch (NoSuchFileException nsfe) {
// non jpackage generated app-image (no app/.jpackage.xml)
Log.info(MessageFormat.format(I18N.getString(
"warning.foreign-app-image"), appImageDir));
} catch (IOException ioe) {
Log.verbose(ioe);
Log.info(MessageFormat.format(I18N.getString(
"warning.invalid-app-image"), appImageDir));

}

launchers.add(APP_NAME.fetchFrom(params));
Expand Down
Expand Up @@ -74,6 +74,8 @@ error.jlink.failed=jlink failed with: {0}
error.blocked.option=jlink option [{0}] is not permitted in --jlink-options

warning.no.jdk.modules.found=Warning: No JDK Modules found
warning.foreign-app-image=Warning: app-image dir ({0}) not generated by jpackage.
warning.invalid-app-image=Warning: cannot parse .jpackage.xml in app-image dir ({0})

MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a package
MSG_BundlerConfigException=Bundler {0} skipped because of a configuration problem: {1} \n\
Expand Down
Expand Up @@ -74,6 +74,8 @@ error.jlink.failed=jlink\u304C\u6B21\u3067\u5931\u6557\u3057\u307E\u3057\u305F:
error.blocked.option=jlink\u30AA\u30D7\u30B7\u30E7\u30F3[{0}]\u306F--jlink-options\u3067\u306F\u8A31\u53EF\u3055\u308C\u307E\u305B\u3093

warning.no.jdk.modules.found=\u8B66\u544A: JDK\u30E2\u30B8\u30E5\u30FC\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093
warning.foreign-app-image=Warning: app-image dir ({0}) not generated by jpackage.
warning.invalid-app-image=Warning: cannot parse .jpackage.xml in app-image dir ({0})

MSG_BundlerFailed=\u30A8\u30E9\u30FC: \u30D0\u30F3\u30C9\u30E9"{1}" ({0})\u304C\u30D1\u30C3\u30B1\u30FC\u30B8\u306E\u751F\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F
MSG_BundlerConfigException=\u69CB\u6210\u306E\u554F\u984C\u306E\u305F\u3081\u3001\u30D0\u30F3\u30C9\u30E9{0}\u304C\u30B9\u30AD\u30C3\u30D7\u3055\u308C\u307E\u3057\u305F: {1} \n\u6B21\u306E\u4FEE\u6B63\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044: {2}
Expand Down
Expand Up @@ -74,6 +74,8 @@ error.jlink.failed=jlink \u5931\u8D25\uFF0C\u51FA\u73B0 {0}
error.blocked.option=\u4E0D\u5141\u8BB8\u5728 --jlink-options \u4E2D\u4F7F\u7528 jlink \u9009\u9879 [{0}]

warning.no.jdk.modules.found=\u8B66\u544A: \u672A\u627E\u5230 JDK \u6A21\u5757
warning.foreign-app-image=Warning: app-image dir ({0}) not generated by jpackage.
warning.invalid-app-image=Warning: cannot parse .jpackage.xml in app-image dir ({0})

MSG_BundlerFailed=\u9519\u8BEF\uFF1A\u6253\u5305\u7A0B\u5E8F "{1}" ({0}) \u65E0\u6CD5\u751F\u6210\u7A0B\u5E8F\u5305
MSG_BundlerConfigException=\u7531\u4E8E\u914D\u7F6E\u95EE\u9898, \u8DF3\u8FC7\u4E86\u6253\u5305\u7A0B\u5E8F{0}: {1} \n\u4FEE\u590D\u5EFA\u8BAE: {2}
Expand Down
Expand Up @@ -406,7 +406,9 @@ private Map<String, String> prepareMainProjectFile(
data.put("JpAppDescription", DESCRIPTION.fetchFrom(params));
data.put("JpAppVendor", VENDOR.fetchFrom(params));
data.put("JpAppVersion", PRODUCT_VERSION.fetchFrom(params));
data.put("JpIcon", installerIcon.toString());
if (Files.exists(installerIcon)) {
data.put("JpIcon", installerIcon.toString());
}

final Path configDir = CONFIG_ROOT.fetchFrom(params);

Expand Down
16 changes: 10 additions & 6 deletions test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LinuxHelper.java
Expand Up @@ -233,7 +233,9 @@ static long getInstalledPackageSizeKB(JPackageCommand cmd) {
"Installed-Size"));

case LINUX_RPM:
return Long.parseLong(getRpmBundleProperty(packageFile, "Size")) >> 10;
String size = getRpmBundleProperty(packageFile, "Size");
return (Long.parseLong(size) + 1023L) >> 10; // in KB rounded up

}

return 0;
Expand All @@ -254,10 +256,10 @@ static String getRpmBundleProperty(Path bundle, String fieldName) {

static void verifyPackageBundleEssential(JPackageCommand cmd) {
String packageName = LinuxHelper.getPackageName(cmd);
TKit.assertNotEquals(0L, LinuxHelper.getInstalledPackageSizeKB(
cmd), String.format(
"Check installed size of [%s] package in KB is not zero",
packageName));
Long packageSize = LinuxHelper.getInstalledPackageSizeKB(cmd);
TKit.trace("InstalledPackageSize: " + packageSize);
TKit.assertNotEquals(0L, packageSize, String.format(
"Check installed size of [%s] package in not zero", packageName));

final boolean checkPrerequisites;
if (cmd.isRuntime()) {
Expand All @@ -270,7 +272,9 @@ static void verifyPackageBundleEssential(JPackageCommand cmd) {
checkPrerequisites = expectedCriticalRuntimePaths.equals(
actualCriticalRuntimePaths);
} else {
checkPrerequisites = true;
// AppImagePackageTest.testEmpty() will have no dependencies,
// but will have more then 0 and less than 1K content size.
checkPrerequisites = packageSize > 1;
}

List<String> prerequisites = LinuxHelper.getPrerequisitePackages(cmd);
Expand Down
30 changes: 30 additions & 0 deletions test/jdk/tools/jpackage/share/AppImagePackageTest.java
Expand Up @@ -22,9 +22,14 @@
*/

import java.nio.file.Path;
import java.nio.file.Files;
import java.io.IOException;
import java.util.List;
import jdk.jpackage.test.TKit;
import jdk.jpackage.test.JPackageCommand;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.PackageType;
import jdk.jpackage.test.RunnablePackageTest.Action;
import jdk.jpackage.test.Annotations.Test;

/**
Expand Down Expand Up @@ -61,4 +66,29 @@ public static void test() {
cmd.removeArgumentWithValue("--input");
}).addBundleDesktopIntegrationVerifier(false).run();
}

@Test
public static void testEmpty() throws IOException {
final String name = "EmptyAppImagePackageTest";
final String imageName = name + (TKit.isOSX() ? ".app" : "");
Path appImageDir = TKit.createTempDirectory(null).resolve(imageName);

Files.createDirectories(appImageDir.resolve("bin"));
Path libDir = Files.createDirectories(appImageDir.resolve("lib"));
TKit.createTextFile(libDir.resolve("README"),
List.of("This is some arbitrary text for the README file\n"));

new PackageTest()
.addInitializer(cmd -> {
cmd.addArguments("--app-image", appImageDir);
cmd.removeArgumentWithValue("--input");

// on mac, with --app-image and without --mac-package-identifier,
// will try to infer it from the image, so foreign image needs it.
if (TKit.isOSX()) {
cmd.addArguments("--mac-package-identifier", name);
}
}).run(new Action[] { Action.CREATE, Action.UNPACK });
// default: {CREATE, UNPACK, VERIFY}, but we can't verify foreign image
}
}