8238692: MacOS runtime Installer issue

Reviewed-by: kizune, asemenyuk, almatvee
This commit is contained in:
Andy Herrick 2020-03-03 18:10:15 -05:00
parent ef4053ee41
commit 128f083359
3 changed files with 33 additions and 2 deletions

View File

@ -111,7 +111,15 @@ public class MacAppImageBuilder extends AbstractAppImageBuilder {
return identifier;
}
return IDENTIFIER.fetchFrom(params);
identifier = IDENTIFIER.fetchFrom(params);
if (identifier != null) {
return identifier;
}
// the IDENTIFIER (above) will default to derive from
// the main-class, in case there is no main-class
// (such as runtime installer) revert to the name.
// any of these could be invalid, so check later.
return APP_NAME.fetchFrom(params);
},
(s, p) -> s);

View File

@ -510,6 +510,20 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
return "pkg";
}
private static boolean isValidBundleIdentifier(String id) {
for (int i = 0; i < id.length(); i++) {
char a = id.charAt(i);
// We check for ASCII codes first which we accept. If check fails,
// check if it is acceptable extended ASCII or unicode character.
if ((a >= 'A' && a <= 'Z') || (a >= 'a' && a <= 'z')
|| (a >= '0' && a <= '9') || (a == '-' || a == '.')) {
continue;
}
return false;
}
return true;
}
@Override
public boolean validate(Map<String, ? super Object> params)
throws ConfigException {
@ -520,12 +534,19 @@ public class MacPkgBundler extends MacBaseInstallerBundler {
// we are not interested in return code, only possible exception
validateAppImageAndBundeler(params);
if (MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params) == null) {
String identifier = MAC_CF_BUNDLE_IDENTIFIER.fetchFrom(params);
if (identifier == null) {
throw new ConfigException(
I18N.getString("message.app-image-requires-identifier"),
I18N.getString(
"message.app-image-requires-identifier.advice"));
}
if (!isValidBundleIdentifier(identifier)) {
throw new ConfigException(
MessageFormat.format(I18N.getString(
"message.invalid-identifier"), identifier),
I18N.getString("message.invalid-identifier.advice"));
}
// reject explicitly set sign to true and no valid signature key
if (Optional.ofNullable(MacAppImageBuilder.

View File

@ -76,6 +76,8 @@ message.app-image-requires-app-name=When using an external app image you must sp
message.app-image-requires-app-name.advice=Set the app name via the -name CLI flag, the fx:application/@name ANT attribute, or via the 'appName' bundler argument.
message.app-image-requires-identifier=Unable to extract identifier from app image.
message.app-image-requires-identifier.advice=Use "--verbose" for extended error message or specify it via "--mac-package-identifier".
message.invalid-identifier=invalid mac bundle identifier [{0}].
message.invalid-identifier.advice=specify identifier with "--mac-package-identifier".
message.building-dmg=Building DMG package for {0}.
message.running-script=Running shell script on application image [{0}].
message.preparing-dmg-setup=Preparing dmg setup: {0}.