Skip to content

Generate and sign macOS Distribution packages from Go

License

Notifications You must be signed in to change notification settings

kai5263499/go-macos-pkg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pkg.go.dev

About

go-macos-pkg was built out of a desire to generate and sign macOS pkgs on non-macOS OSs.

Caveats

  • Right now most of the heavy lifting is done by calling the xar utility, as there aren't currently (2021) Go libraries that write xar archives. The good news is xar is available on other OSs, unlike productsign/productbuild
  • Right now only payload-free (e.g. just runs postinstall) packages can be generated as that's all I currently need. It shouldn't be too hard for someone to add payload capabilities, though.

Usage

script := []byte("#!/bin/bash\necho 'hello, world!'\n")

pkg, err := macospkg.GeneratePkg("com.github.korylprince.go-macos-pkg", "1.0.0", script)
if err != nil {
    log.Fatalln("could not generate pkg:", err)
}

// use Apple Developer ID Installer cert and key to sign
signed, err := macospkg.SignPkg(pkg, cert, key)
if err != nil {
    log.Fatalln("could not sign pkg:", err)
}

if err = os.WriteFile("signed.pkg", signed, 0644); err != nil {
    log.Fatalln("could not write signed pkg:", err)
}

About

Generate and sign macOS Distribution packages from Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%