Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8238692: MacOS runtime Installer issue
Browse files Browse the repository at this point in the history
Reviewed-by: kizune, asemenyuk, almatvee
  • Loading branch information
Andy Herrick committed Mar 3, 2020
1 parent ef4053e commit 128f083
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,20 @@ public String getID() {
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 {
Expand All @@ -520,12 +534,19 @@ public boolean validate(Map<String, ? super Object> params)
// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down

0 comments on commit 128f083

Please sign in to comment.