Skip to content
Permalink
Browse files
8264055: backout JDK-8248904 in order to resubmit with additional att…
…ribution.

Reviewed-by: kcr, asemenyuk
  • Loading branch information
Andy Herrick committed Mar 23, 2021
1 parent 2425462 commit 15bcf6d9f5b34dd679918814593a4b29b64473c2
Showing with 105 additions and 269 deletions.
  1. +1 −1 src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxAppImageBuilder.java
  2. BIN src/jdk.jpackage/linux/classes/jdk/jpackage/internal/resources/{JavaApp.png → java32.png}
  3. +6 −16 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java
  4. +45 −84 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java
  5. +8 −7 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java
  6. +1 −1 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java
  7. +26 −69 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java
  8. +2 −2 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/Info-lite.plist.template
  9. +3 −4 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties
  10. +2 −2 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_ja.properties
  11. +2 −2 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_zh_CN.properties
  12. BIN src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/{JavaApp.icns → java.icns}
  13. +0 −11 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/product-def.plist
  14. +0 −18 src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/sandbox.plist
  15. +0 −8 src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
  16. +0 −3 src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java
  17. +3 −11 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources.properties
  18. +1 −13 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_ja.properties
  19. +1 −13 src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/HelpResources_zh_CN.properties
  20. +1 −1 src/jdk.jpackage/windows/classes/jdk/jpackage/internal/WindowsAppImageBuilder.java
  21. BIN src/jdk.jpackage/windows/classes/jdk/jpackage/internal/resources/{JavaApp.ico → java48.ico}
  22. +3 −3 test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherIconVerifier.java
@@ -54,7 +54,7 @@
},
(s, p) -> Path.of(s));

final static String DEFAULT_ICON = "JavaApp.png";
final static String DEFAULT_ICON = "java32.png";

LinuxAppImageBuilder(Path imageOutDir) {
super(imageOutDir);
@@ -31,7 +31,6 @@
import java.util.Optional;
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEYCHAIN;
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEY_USER;
import static jdk.jpackage.internal.MacAppImageBuilder.APP_STORE;
import static jdk.jpackage.internal.StandardBundlerParam.MAIN_CLASS;
import static jdk.jpackage.internal.StandardBundlerParam.VERBOSE;
import static jdk.jpackage.internal.StandardBundlerParam.VERSION;
@@ -42,7 +41,7 @@ public MacAppBundler() {
setParamsValidator(MacAppBundler::doValidate);
}

private static final String TEMPLATE_BUNDLE_ICON = "JavaApp.icns";
private static final String TEMPLATE_BUNDLE_ICON = "java.icns";

public static final BundlerParamInfo<String> MAC_CF_BUNDLE_NAME =
new StandardBundlerParam<>(
@@ -63,20 +62,11 @@ public MacAppBundler() {
"mac.signing-key-developer-id-app",
String.class,
params -> {
String user = SIGNING_KEY_USER.fetchFrom(params);
String keychain = SIGNING_KEYCHAIN.fetchFrom(params);
String result = null;
if (APP_STORE.fetchFrom(params)) {
result = MacBaseInstallerBundler.findKey(
"3rd Party Mac Developer Application: ",
user, keychain);
}
// if either not signing for app store or couldn't find
if (result == null) {
result = MacBaseInstallerBundler.findKey(
"Developer ID Application: ", user, keychain);
}

String result = MacBaseInstallerBundler.findKey(
"Developer ID Application: ",
SIGNING_KEY_USER.fetchFrom(params),
SIGNING_KEYCHAIN.fetchFrom(params),
VERBOSE.fetchFrom(params));
if (result != null) {
MacCertificate certificate = new MacCertificate(result);

@@ -72,7 +72,7 @@
private static final ResourceBundle I18N = ResourceBundle.getBundle(
"jdk.jpackage.internal.resources.MacResources");

private static final String TEMPLATE_BUNDLE_ICON = "JavaApp.icns";
private static final String TEMPLATE_BUNDLE_ICON = "java.icns";
private static final String OS_TYPE_CODE = "APPL";
private static final String TEMPLATE_INFO_PLIST_LITE =
"Info-lite.plist.template";
@@ -102,13 +102,6 @@
params -> null,
(s, p) -> s);

public static final BundlerParamInfo<String> APP_CATEGORY =
new StandardBundlerParam<>(
Arguments.CLIOptions.MAC_CATEGORY.getId(),
String.class,
params -> "utilities",
(s, p) -> s);

public static final BundlerParamInfo<String> MAC_CF_BUNDLE_IDENTIFIER =
new StandardBundlerParam<>(
Arguments.CLIOptions.MAC_BUNDLE_IDENTIFIER.getId(),
@@ -153,38 +146,6 @@
null : Boolean.valueOf(s)
);

public static final StandardBundlerParam<Boolean> APP_STORE =
new StandardBundlerParam<>(
Arguments.CLIOptions.MAC_APP_STORE.getId(),
Boolean.class,
params -> false,
// valueOf(null) is false, we actually do want null in some cases
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
null : Boolean.valueOf(s)
);

public static final BundlerParamInfo<Path> ENTITLEMENTS =
new StandardBundlerParam<>(
Arguments.CLIOptions.MAC_ENTITLEMENTS.getId(),
Path.class,
params -> {
try {
Path path = CONFIG_ROOT.fetchFrom(params).resolve(
getLauncherName(params) + ".entitlements");
String defPath = (APP_STORE.fetchFrom(params) ?
"sandbox.plist" : "entitlements.plist");
createResource(defPath, params)
.setCategory(I18N.getString("resource.entitlements"))
.saveToFile(path);
return path;
} catch (IOException ioe) {
Log.verbose(ioe);
}
return null;
},
(s, p) -> Path.of(s)
);

private static final StandardBundlerParam<String> FA_MAC_CFBUNDLETYPEROLE =
new StandardBundlerParam<>(
Arguments.MAC_CFBUNDLETYPEROLE,
@@ -375,14 +336,27 @@ private void sign(Map<String, ? super Object> params) throws IOException {
String signingIdentity =
DEVELOPER_ID_APP_SIGNING_KEY.fetchFrom(params);
if (signingIdentity != null) {
prepareEntitlements(params);
signAppBundle(params, root, signingIdentity,
BUNDLE_ID_SIGNING_PREFIX.fetchFrom(params),
ENTITLEMENTS.fetchFrom(params));
getConfig_Entitlements(params));
}
restoreKeychainList(params);
}
}

static Path getConfig_Entitlements(Map<String, ? super Object> params) {
return CONFIG_ROOT.fetchFrom(params).resolve(
getLauncherName(params) + ".entitlements");
}

static void prepareEntitlements(Map<String, ? super Object> params)
throws IOException {
createResource("entitlements.plist", params)
.setCategory(I18N.getString("resource.entitlements"))
.saveToFile(getConfig_Entitlements(params));
}

private static String getLauncherName(Map<String, ? super Object> params) {
return APP_NAME.fetchFrom(params);
}
@@ -417,17 +391,8 @@ private void writeRuntimeInfoPlist(Path file,
String name = StandardBundlerParam.isRuntimeInstaller(params) ?
getBundleName(params): "Java Runtime Image";
data.put("CF_BUNDLE_NAME", name);
String ver = VERSION.fetchFrom(params);
String sver = ver;
int index = ver.indexOf(".");
if (index > 0 && ((index + 1) < ver.length())) {
index = ver.indexOf(".", index + 1);
if (index > 0 ) {
sver = ver.substring(0, index);
}
}
data.put("CF_BUNDLE_VERSION", ver);
data.put("CF_BUNDLE_SHORT_VERSION_STRING", sver);
data.put("CF_BUNDLE_VERSION", VERSION.fetchFrom(params));
data.put("CF_BUNDLE_SHORT_VERSION_STRING", VERSION.fetchFrom(params));

createResource(TEMPLATE_RUNTIME_INFO_PLIST, params)
.setPublicName("Runtime-Info.plist")
@@ -478,8 +443,6 @@ private void writeInfoPlist(Path file, Map<String, ? super Object> params)
data.put("DEPLOY_LAUNCHER_NAME", getLauncherName(params));
data.put("DEPLOY_BUNDLE_SHORT_VERSION", VERSION.fetchFrom(params));
data.put("DEPLOY_BUNDLE_CFBUNDLE_VERSION", VERSION.fetchFrom(params));
data.put("DEPLOY_APP_CATEGORY", "public.app-category." +
APP_CATEGORY.fetchFrom(params));

StringBuilder bundleDocumentTypes = new StringBuilder();
StringBuilder exportedTypes = new StringBuilder();
@@ -680,8 +643,9 @@ static void signAppBundle(
}
}).filter(p -> Files.isRegularFile(p) &&
(Files.isExecutable(p) || p.toString().endsWith(".dylib"))
&& !(p.toString().contains("dylib.dSYM/Contents"))
&& !(p.toString().endsWith(appExecutable))
&& !(p.toString().endsWith(appExecutable)
|| p.toString().contains("/Contents/runtime")
|| p.toString().contains("/Contents/Frameworks"))
).forEach(p -> {
// noinspection ThrowableResultOfMethodCallIgnored
if (toThrow.get() != null) return;
@@ -690,30 +654,12 @@ static void signAppBundle(
if (Files.isSymbolicLink(p)) {
Log.verbose(MessageFormat.format(I18N.getString(
"message.ignoring.symlink"), p.toString()));
} else if (isFileSigned(p)) {
// executable or lib already signed
Log.verbose(MessageFormat.format(I18N.getString(
"message.already.signed"), p.toString()));
} else {
List<String> args;
// runtime and Framework files will be signed below
// but they need to be unsigned first here
if ((p.toString().contains("/Contents/runtime")) ||
(p.toString().contains("/Contents/Frameworks"))) {

args = new ArrayList<>();
args.addAll(Arrays.asList("/usr/bin/codesign",
"--remove-signature", p.toString()));
try {
Set<PosixFilePermission> oldPermissions =
Files.getPosixFilePermissions(p);
p.toFile().setWritable(true, true);
ProcessBuilder pb = new ProcessBuilder(args);
IOUtils.exec(pb);
Files.setPosixFilePermissions(p,oldPermissions);
} catch (IOException ioe) {
Log.verbose(ioe);
toThrow.set(ioe);
return;
}
}
args = new ArrayList<>();
List<String> args = new ArrayList<>();
args.addAll(Arrays.asList("/usr/bin/codesign",
"--timestamp",
"--options", "runtime",
@@ -724,19 +670,25 @@ static void signAppBundle(
args.add("--keychain");
args.add(keyChain);
}

if (Files.isExecutable(p)) {
if (entitlements != null) {
args.add("--entitlements");
args.add(entitlements.toString());
}
}

args.add(p.toString());

try {
Set<PosixFilePermission> oldPermissions =
Files.getPosixFilePermissions(p);
p.toFile().setWritable(true, true);

ProcessBuilder pb = new ProcessBuilder(args);

IOUtils.exec(pb);

Files.setPosixFilePermissions(p, oldPermissions);
} catch (IOException ioe) {
toThrow.set(ioe);
@@ -769,10 +721,6 @@ static void signAppBundle(
args.add("--keychain");
args.add(keyChain);
}
if (entitlements != null) {
args.add("--entitlements");
args.add(entitlements.toString());
}
args.add(path.toString());
ProcessBuilder pb = new ProcessBuilder(args);

@@ -810,7 +758,6 @@ static void signAppBundle(
"--options", "runtime",
"--force",
"-s", signingIdentity,
"--prefix", identifierPrefix,
"-vvvv"));

if (keyChain != null && !keyChain.isEmpty()) {
@@ -831,6 +778,20 @@ static void signAppBundle(
IOUtils.exec(pb);
}

private static boolean isFileSigned(Path file) {
ProcessBuilder pb =
new ProcessBuilder("/usr/bin/codesign",
"--verify", file.toString());

try {
IOUtils.exec(pb);
} catch (IOException ex) {
return false;
}

return true;
}

private static String extractBundleIdentifier(Map<String, Object> params) {
if (PREDEFINED_APP_IMAGE.fetchFrom(params) == null) {
return null;
@@ -152,13 +152,14 @@ public String getBundleType() {
return "INSTALLER";
}

public static String findKey(String keyPrefix, String teamName, String keychainName) {

boolean useAsIs = teamName.startsWith(keyPrefix)
|| teamName.startsWith("Developer ID")
|| teamName.startsWith("3rd Party Mac");

String key = (useAsIs) ? teamName : (keyPrefix + teamName);
public static String findKey(String keyPrefix, String teamName, String keychainName,
boolean verbose) {
String key = (teamName.startsWith(keyPrefix)
|| teamName.startsWith("3rd Party Mac Developer"))
? teamName : (keyPrefix + teamName);
if (Platform.getPlatform() != Platform.MAC) {
return null;
}

try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos)) {
@@ -58,7 +58,7 @@
static final String BACKGROUND_IMAGE_FOLDER =".background";
static final String BACKGROUND_IMAGE = "background.tiff";
static final String DEFAULT_DMG_SETUP_SCRIPT = "DMGsetup.scpt";
static final String TEMPLATE_BUNDLE_ICON = "JavaApp.icns";
static final String TEMPLATE_BUNDLE_ICON = "java.icns";

static final String DEFAULT_LICENSE_PLIST="lic_template.plist";

1 comment on commit 15bcf6d

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 15bcf6d Mar 23, 2021

Please sign in to comment.