소스 검색

fix(bundler): support macOS 10.13.6+ on notarization, closes #4549 (#4593)

Lucas Fernandes Nogueira 3 년 전
부모
커밋
f7c59ecfc8
2개의 변경된 파일20개의 추가작업 그리고 11개의 파일을 삭제
  1. 1 1
      .changes/fix-notarization-stdout-parse.md
  2. 19 10
      tooling/bundler/src/bundle/macos/sign.rs

+ 1 - 1
.changes/fix-notarization-stdout-parse.md

@@ -2,4 +2,4 @@
 "tauri-bundler": patch
 ---
 
-Ensure the notarization `RequestUUID` and `Status` parser works even if the altool output does not have a newline after it.
+Ensure the notarization `RequestUUID` and `Status` parser works on macOS 10.13.6+.

+ 19 - 10
tooling/bundler/src/bundle/macos/sign.rs

@@ -275,10 +275,13 @@ pub fn notarize(
     .output_ok()
     .context("failed to upload app to Apple's notarization servers.")?;
 
-  let mut stdout = std::str::from_utf8(&output.stdout)?.to_string();
-  stdout.push('\n');
+  // combine both stdout and stderr to support macOS below 10.15
+  let mut notarize_response = std::str::from_utf8(&output.stdout)?.to_string();
+  notarize_response.push('\n');
+  notarize_response.push_str(std::str::from_utf8(&output.stderr)?);
+  notarize_response.push('\n');
   if let Some(uuid) = Regex::new(r"\nRequestUUID = (.+?)\n")?
-    .captures_iter(&stdout)
+    .captures_iter(&notarize_response)
     .next()
   {
     info!("notarization started; waiting for Apple response...");
@@ -288,7 +291,11 @@ pub fn notarize(
     staple_app(app_bundle_path.clone())?;
   } else {
     return Err(
-      anyhow::anyhow!("failed to parse RequestUUID from upload output. {}", stdout).into(),
+      anyhow::anyhow!(
+        "failed to parse RequestUUID from upload output. {}",
+        notarize_response
+      )
+      .into(),
     );
   }
 
@@ -326,10 +333,13 @@ fn get_notarization_status(
     .output_ok();
 
   if let Ok(output) = result {
-    let mut stdout = std::str::from_utf8(&output.stdout)?.to_string();
-    stdout.push('\n');
+    // combine both stdout and stderr to support macOS below 10.15
+    let mut notarize_status = std::str::from_utf8(&output.stdout)?.to_string();
+    notarize_status.push('\n');
+    notarize_status.push_str(std::str::from_utf8(&output.stderr)?);
+    notarize_status.push('\n');
     if let Some(status) = Regex::new(r"\n *Status: (.+?)\n")?
-      .captures_iter(&stdout)
+      .captures_iter(&notarize_status)
       .next()
     {
       let status = status[1].to_string();
@@ -339,7 +349,7 @@ fn get_notarization_status(
         Err(
           anyhow::anyhow!(format!(
             "Apple failed to notarize your app. {}",
-            std::str::from_utf8(&output.stdout)?
+            notarize_status
           ))
           .into(),
         )
@@ -347,8 +357,7 @@ fn get_notarization_status(
         Err(
           anyhow::anyhow!(format!(
             "Unknown notarize status {}. {}",
-            status,
-            std::str::from_utf8(&output.stdout)?
+            status, notarize_status
           ))
           .into(),
         )