Skip to content

Commit

Permalink
Mac: Installer extraction bug fixes
Browse files Browse the repository at this point in the history
- Mark `RawImagePatch` weak
- Fix reversed condition in disk image unmounting
- Ensure source files are closed when copying
- Use 0-based indexing when determining installer OS version

Bug: None
Change-Id: I015f2b0d9c88a5ec128822d55c974e22723a1a6e
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/5291963
Reviewed-by: Mark Mentovai <[email protected]>
  • Loading branch information
speednoisemovement committed Feb 13, 2024
1 parent 6b871f4 commit 55036dd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/tools/mac/upload_system_symbols/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package main
// uint32_t verbose;
// } RawImage;
//
// extern int32_t RawImagePatch(RawImage *);
// extern int32_t RawImagePatch(RawImage *) __attribute__((weak));
import "C"

import (
Expand Down Expand Up @@ -125,7 +125,7 @@ func (e *Extractor) vlog(format string, args ...interface{}) {
func (e *Extractor) mountDMG(dmgPath string, mountpoint string) error {
cmd := exec.Command("hdiutil", "attach", dmgPath, "-mountpoint", mountpoint, "-quiet", "-nobrowse", "-readonly")
err := cmd.Run()
if err != nil {
if err == nil {
e.dmgMountPaths = append(e.dmgMountPaths, mountpoint)
}
return err
Expand Down Expand Up @@ -299,7 +299,7 @@ func (e *installAssistantExtractor) expandInstaller(installerPath string, destin
// hasCryptexes returns true if the installer containing the plist at `plistPath` is for
// macOS version 13 or higher, and accordingly stores dyld shared caches inside cryptexes.
func (e *installAssistantExtractor) hasCryptexes(plistPath string) (bool, error) {
print_cmd := "print :Assets:1:OSVersion"
print_cmd := "print :Assets:0:OSVersion"
result, err := exec.Command("PlistBuddy", "-c", print_cmd, plistPath).Output()
if err != nil {
return false, fmt.Errorf("couldn't read OS version from %s: %v", plistPath, err)
Expand Down Expand Up @@ -502,6 +502,7 @@ func copyFile(src, dst string) error {
if err != nil {
return err
}
defer reader.Close()
if _, err := io.Copy(w, reader); err != nil {
return err
}
Expand Down

0 comments on commit 55036dd

Please sign in to comment.