8341939: SigningOptionsTest fails without Xcode with command line developer tools after JDK-8341443
Reviewed-by: asemenyuk
This commit is contained in:
parent
de92fe3757
commit
9a7a850e28
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package jdk.jpackage.internal;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -148,20 +147,6 @@ public class MacAppBundler extends AppImageBundler {
|
||||
|
||||
// No need to validate --mac-app-image-sign-identity, since it is
|
||||
// pass through option.
|
||||
|
||||
// Signing will not work without Xcode with command line developer tools
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder("/usr/bin/xcrun", "--help");
|
||||
Process p = pb.start();
|
||||
int code = p.waitFor();
|
||||
if (code != 0) {
|
||||
throw new ConfigException(
|
||||
I18N.getString("error.no.xcode.signing"),
|
||||
I18N.getString("error.no.xcode.signing.advice"));
|
||||
}
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
throw new ConfigException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ import static jdk.jpackage.internal.MacAppBundler.BUNDLE_ID_SIGNING_PREFIX;
|
||||
import static jdk.jpackage.internal.MacAppBundler.DEVELOPER_ID_APP_SIGNING_KEY;
|
||||
import static jdk.jpackage.internal.MacAppBundler.APP_IMAGE_SIGN_IDENTITY;
|
||||
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEYCHAIN;
|
||||
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEY_USER;
|
||||
import static jdk.jpackage.internal.MacBaseInstallerBundler.INSTALLER_SIGN_IDENTITY;
|
||||
import static jdk.jpackage.internal.OverridableResource.createResource;
|
||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
|
||||
@ -76,8 +75,6 @@ import static jdk.jpackage.internal.StandardBundlerParam.ADD_LAUNCHERS;
|
||||
import static jdk.jpackage.internal.StandardBundlerParam.SIGN_BUNDLE;
|
||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_STORE;
|
||||
import static jdk.jpackage.internal.StandardBundlerParam.APP_CONTENT;
|
||||
import static jdk.jpackage.internal.StandardBundlerParam.getPredefinedAppImage;
|
||||
import static jdk.jpackage.internal.StandardBundlerParam.hasPredefinedAppImage;
|
||||
|
||||
public class MacAppImageBuilder extends AbstractAppImageBuilder {
|
||||
|
||||
@ -754,6 +751,14 @@ public class MacAppImageBuilder extends AbstractAppImageBuilder {
|
||||
"message.codesign.failed.reason.app.content"));
|
||||
}
|
||||
|
||||
// Signing might not work without Xcode with command line
|
||||
// developer tools. Show user if Xcode is missing as possible
|
||||
// reason.
|
||||
if (!isXcodeDevToolsInstalled()) {
|
||||
Log.info(I18N.getString(
|
||||
"message.codesign.failed.reason.xcode.tools"));
|
||||
}
|
||||
|
||||
// Log "codesign" output
|
||||
Log.info(MessageFormat.format(I18N.getString(
|
||||
"error.tool.failed.with.output"), "codesign"));
|
||||
@ -764,6 +769,16 @@ public class MacAppImageBuilder extends AbstractAppImageBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isXcodeDevToolsInstalled() {
|
||||
try {
|
||||
Executor.of("/usr/bin/xcrun", "--help").executeExpectSuccess();
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void signAppBundle(
|
||||
Map<String, ? super Object> params, Path appLocation,
|
||||
String signingIdentity, String identifierPrefix, Path entitlements)
|
||||
|
@ -39,8 +39,6 @@ error.no-app-signing-key.advice=Install your app signing keys into your Mac Keyc
|
||||
error.no-pkg-signing-key=No Mac App Store Installer Signing Key
|
||||
error.no-pkg-signing-key.advice=Install your app signing keys into your Mac Keychain using XCode.
|
||||
error.certificate.expired=Error: Certificate expired {0}
|
||||
error.no.xcode.signing=Xcode with command line developer tools is required for signing
|
||||
error.no.xcode.signing.advice=Install Xcode with command line developer tools.
|
||||
error.cert.not.found=No certificate found matching [{0}] using keychain [{1}]
|
||||
error.multiple.certs.found=WARNING: Multiple certificates found matching [{0}] using keychain [{1}], using first one
|
||||
error.app-image.mac-sign.required=Error: --mac-sign option is required with predefined application image and with type [app-image]
|
||||
@ -95,5 +93,6 @@ message.signing.pkg=Warning: For signing PKG, you might need to set "Always Trus
|
||||
message.setfile.dmg=Setting custom icon on DMG file skipped because 'SetFile' utility was not found. Installing Xcode with Command Line Tools should resolve this issue.
|
||||
message.install-dir-ignored=Warning: "--install-dir" is not supported by DMG and will be default to /Applications.
|
||||
message.codesign.failed.reason.app.content="codesign" failed and additional application content was supplied via the "--app-content" parameter. Probably the additional content broke the integrity of the application bundle and caused the failure. Ensure content supplied via the "--app-content" parameter does not break the integrity of the application bundle, or add it in the post-processing step.
|
||||
message.codesign.failed.reason.xcode.tools=Possible reason for "codesign" failure is missing Xcode with command line developer tools. Install Xcode with command line developer tools to see if it resolves the problem.
|
||||
warning.unsigned.app.image=Warning: Using unsigned app-image to build signed {0}.
|
||||
warning.per.user.app.image.signed=Warning: Support for per-user configuration of the installed application will not be supported due to missing "{0}" in predefined signed application image.
|
||||
|
@ -39,8 +39,6 @@ error.no-app-signing-key.advice=Installieren Sie Ihre App-Signaturschlüssel mit
|
||||
error.no-pkg-signing-key=Kein Signaturschlüssel für Mac App Store-Installationsprogramm
|
||||
error.no-pkg-signing-key.advice=Installieren Sie Ihre App-Signaturschlüssel mit XCode in Ihrem Mac-Schlüsselbund.
|
||||
error.certificate.expired=Fehler: Zertifikat abgelaufen {0}
|
||||
error.no.xcode.signing=Für die Signatur ist Xcode mit Befehlszeilen-Entwicklertools erforderlich
|
||||
error.no.xcode.signing.advice=Installieren Sie Xcode mit Befehlszeilen-Entwicklertools.
|
||||
error.cert.not.found=Kein Zertifikat gefunden, das [{0}] mit Schlüsselbund [{1}] entspricht
|
||||
error.multiple.certs.found=WARNUNG: Mehrere Zertifikate gefunden, die [{0}] mit Schlüsselbund [{1}] entsprechen. Es wird das erste Zertifikat verwendet
|
||||
error.app-image.mac-sign.required=Fehler: Die Option "--mac-sign" ist mit einem vordefinierten Anwendungsimage und Typ [app-image] erforderlich
|
||||
@ -95,5 +93,6 @@ message.signing.pkg=Warnung: Zum Signieren von PKG müssen Sie möglicherweise m
|
||||
message.setfile.dmg=Das Festlegen des benutzerdefinierten Symbols für die DMG-Datei wurde übersprungen, weil das Utility "SetFile" nicht gefunden wurde. Durch Installieren von Xcode mit Befehlszeilentools sollte dieses Problem behoben werden.
|
||||
message.install-dir-ignored=Warnung: "--install-dir" wird von DMG nicht unterstützt. Stattdessen wird standardmäßig /Applications verwendet.
|
||||
message.codesign.failed.reason.app.content="codesign" war nicht erfolgreich, und zusätzlicher Anwendungsinhalt wurde über den Parameter "--app-content" angegeben. Wahrscheinlich hat der zusätzliche Inhalt die Integrität des Anwendungs-Bundles beeinträchtigt und den Fehler verursacht. Stellen Sie sicher, das der über den Parameter "--app-content" angegebene Inhalt nicht die Integrität des Anwendungs-Bundles beeinträchtigt, oder fügen Sie ihn im Nachverarbeitungsschritt hinzu.
|
||||
message.codesign.failed.reason.xcode.tools=Possible reason for "codesign" failure is missing Xcode with command line developer tools. Install Xcode with command line developer tools to see if it resolves the problem.
|
||||
warning.unsigned.app.image=Warnung: Nicht signiertes app-image wird zum Erstellen von signiertem {0} verwendet.
|
||||
warning.per.user.app.image.signed=Warnung: Konfiguration der installierten Anwendung pro Benutzer wird nicht unterstützt, da "{0}" im vordefinierten signierten Anwendungsimage fehlt.
|
||||
|
@ -39,8 +39,6 @@ error.no-app-signing-key.advice=XCodeを使用してアプリケーションの
|
||||
error.no-pkg-signing-key=Mac App Storeインストーラの署名キーがありません
|
||||
error.no-pkg-signing-key.advice=XCodeを使用してアプリケーションの署名キーをMacキーチェーンにインストールします。
|
||||
error.certificate.expired=エラー: 証明書は{0}に期限が切れました
|
||||
error.no.xcode.signing=署名には、Xcodeとコマンドライン・デベロッパ・ツールが必要です
|
||||
error.no.xcode.signing.advice=Xcodeとコマンドライン・デベロッパ・ツールをインストールしてください。
|
||||
error.cert.not.found=キーチェーン[{1}]を使用する[{0}]と一致する証明書が見つかりません
|
||||
error.multiple.certs.found=警告: キーチェーン[{1}]を使用する[{0}]と一致する複数の証明書が見つかりました。最初のものを使用します
|
||||
error.app-image.mac-sign.required=エラー: --mac-signオプションは、事前定義済アプリケーション・イメージおよびタイプ[app-image]で必要です
|
||||
@ -95,5 +93,6 @@ message.signing.pkg=警告: PKGへの署名の場合、「キーチェーン・
|
||||
message.setfile.dmg='SetFile'ユーティリティが見つからないため、DMGファイルでのカスタム・アイコンの設定がスキップされました。Xcodeとコマンド・ライン・ツールをインストールすると、この問題は解決されます。
|
||||
message.install-dir-ignored=警告: "--install-dir"はDMGでサポートされていません。/Applicationsにデフォルト設定されます。
|
||||
message.codesign.failed.reason.app.content="codesign"が失敗したため、追加のアプリケーション・コンテンツが、"--app-content"パラメータを介して提供されました。追加のコンテンツにより、アプリケーション・バンドルの整合性が損われ、失敗の原因になった可能性があります。"--app-content"パラメータを介して提供されたコンテンツによって、アプリケーション・バンドルの整合性が損われていないことを確認するか、処理後のステップで追加してください。
|
||||
message.codesign.failed.reason.xcode.tools=Possible reason for "codesign" failure is missing Xcode with command line developer tools. Install Xcode with command line developer tools to see if it resolves the problem.
|
||||
warning.unsigned.app.image=警告: 署名されていないapp-imageを使用して署名された{0}を作成します。
|
||||
warning.per.user.app.image.signed=警告: 事前定義済の署名付きアプリケーション・イメージに"{0}"がないため、インストール済アプリケーションのユーザーごとの構成はサポートされません。
|
||||
|
@ -39,8 +39,6 @@ error.no-app-signing-key.advice=使用 XCode 将应用程序签名密钥安装
|
||||
error.no-pkg-signing-key=无 Mac App Store 安装程序签名密钥
|
||||
error.no-pkg-signing-key.advice=使用 XCode 将应用程序签名密钥安装到 Mac 密钥链中。
|
||||
error.certificate.expired=错误: 证书已失效 {0}
|
||||
error.no.xcode.signing=需要使用带命令行开发人员工具的 Xcode 进行签名
|
||||
error.no.xcode.signing.advice=安装带命令行开发人员工具的 Xcode。
|
||||
error.cert.not.found=使用密钥链 [{1}] 找不到与 [{0}] 匹配的证书
|
||||
error.multiple.certs.found=警告:使用密钥链 [{1}] 找到多个与 [{0}] 匹配的证书,将使用第一个证书
|
||||
error.app-image.mac-sign.required=错误:预定义的应用程序映像和类型 [app image] 需要 --mac-sign 选项
|
||||
@ -95,5 +93,6 @@ message.signing.pkg=警告:要对 PKG 进行签名,可能需要使用“密
|
||||
message.setfile.dmg=由于未找到 'SetFile' 实用程序,跳过了针对 DMG 文件设置定制图标的操作。安装带命令行工具的 Xcode 应能解决此问题。
|
||||
message.install-dir-ignored=警告:"--install-dir" 不受 DMG 支持,将默认为 /Applications。
|
||||
message.codesign.failed.reason.app.content="codesign" 失败,并通过 "--app-content" 参数提供了附加应用程序内容。可能是附加内容破坏了应用程序包的完整性,导致了故障。请确保通过 "--app-content" 参数提供的内容不会破坏应用程序包的完整性,或者在后处理步骤中添加该内容。
|
||||
message.codesign.failed.reason.xcode.tools=Possible reason for "codesign" failure is missing Xcode with command line developer tools. Install Xcode with command line developer tools to see if it resolves the problem.
|
||||
warning.unsigned.app.image=警告:使用未签名的 app-image 生成已签名的 {0}。
|
||||
warning.per.user.app.image.signed=警告:由于预定义的已签名应用程序映像中缺少 "{0}",不支持对已安装应用程序的每用户配置提供支持。
|
||||
|
@ -32,6 +32,11 @@ import jdk.jpackage.test.TKit;
|
||||
* @test
|
||||
* @summary Test jpackage signing options errors
|
||||
* @library ../helpers
|
||||
* @library /test/lib
|
||||
* @library base
|
||||
* @build SigningBase
|
||||
* @build SigningCheck
|
||||
* @build jtreg.SkippedException
|
||||
* @build SigningOptionsTest
|
||||
* @modules jdk.jpackage/jdk.jpackage.internal
|
||||
* @requires (os.family == "mac")
|
||||
@ -44,6 +49,11 @@ import jdk.jpackage.test.TKit;
|
||||
* @test
|
||||
* @summary Test jpackage signing options errors
|
||||
* @library ../helpers
|
||||
* @library /test/lib
|
||||
* @library base
|
||||
* @build SigningBase
|
||||
* @build SigningCheck
|
||||
* @build jtreg.SkippedException
|
||||
* @build SigningOptionsTest
|
||||
* @modules jdk.jpackage/jdk.jpackage.internal
|
||||
* @requires (os.family == "mac")
|
||||
@ -69,27 +79,31 @@ public final class SigningOptionsTest {
|
||||
"--mac-signing-key-user-name", "test-key",
|
||||
"--mac-app-image-sign-identity", "test-identity"},
|
||||
null,
|
||||
"Mutually exclusive options"},
|
||||
"Mutually exclusive options",
|
||||
Boolean.FALSE},
|
||||
// --mac-signing-key-user-name and --mac-installer-sign-identity
|
||||
{"Hello",
|
||||
new String[]{"--mac-sign",
|
||||
"--mac-signing-key-user-name", "test-key",
|
||||
"--mac-installer-sign-identity", "test-identity"},
|
||||
null,
|
||||
"Mutually exclusive options"},
|
||||
"Mutually exclusive options",
|
||||
Boolean.FALSE},
|
||||
// --mac-installer-sign-identity and --type app-image
|
||||
{"Hello",
|
||||
new String[]{"--mac-sign",
|
||||
"--mac-installer-sign-identity", "test-identity"},
|
||||
null,
|
||||
"Option [--mac-installer-sign-identity] is not valid with type"},
|
||||
"Option [--mac-installer-sign-identity] is not valid with type",
|
||||
Boolean.FALSE},
|
||||
// --mac-installer-sign-identity and --type dmg
|
||||
{"Hello",
|
||||
new String[]{"--type", "dmg",
|
||||
"--mac-sign",
|
||||
"--mac-installer-sign-identity", "test-identity"},
|
||||
new String[]{"--type"},
|
||||
"Option [--mac-installer-sign-identity] is not valid with type"},
|
||||
"Option [--mac-installer-sign-identity] is not valid with type",
|
||||
Boolean.FALSE},
|
||||
// --app-content and --type app-image
|
||||
// JDK-8340802: "codesign" may or may not fail if additional
|
||||
// content is specified based on macOS version. For example on
|
||||
@ -104,14 +118,20 @@ public final class SigningOptionsTest {
|
||||
"--mac-app-image-sign-identity", "test-identity"},
|
||||
null,
|
||||
"\"codesign\" failed and additional application content" +
|
||||
" was supplied via the \"--app-content\" parameter."},
|
||||
" was supplied via the \"--app-content\" parameter.",
|
||||
Boolean.TRUE},
|
||||
});
|
||||
}
|
||||
|
||||
public SigningOptionsTest(String javaAppDesc, String[] jpackageArgs,
|
||||
String[] removeArgs, String expectedError) {
|
||||
String[] removeArgs, String expectedError,
|
||||
Boolean checkRequirements) {
|
||||
this.expectedError = expectedError;
|
||||
|
||||
if (checkRequirements) {
|
||||
SigningCheck.isXcodeDevToolsInstalled();
|
||||
}
|
||||
|
||||
cmd = JPackageCommand.helloAppImage(javaAppDesc)
|
||||
.saveConsoleOutput(true).dumpOutput(true);
|
||||
if (jpackageArgs != null) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
|
||||
import jdk.jpackage.test.TKit;
|
||||
import jdk.jpackage.test.Executor;
|
||||
@ -89,4 +90,12 @@ public class SigningCheck {
|
||||
.apply(result.stream());
|
||||
}
|
||||
|
||||
public static void isXcodeDevToolsInstalled() {
|
||||
int code = Executor.of("/usr/bin/xcrun", "--help")
|
||||
.executeWithoutExitCodeCheck().getExitCode();
|
||||
if (code != 0) {
|
||||
TKit.throwSkippedException("Missing Xcode with command line developer tools");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user