Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
go-version: "1.26.5"
cache: true
- run: go generate github.com/majd/ipatool/...
- run: go generate ./...
- uses: golangci/golangci-lint-action@v8
with:
version: v2.9
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
with:
go-version: "1.26.5"
cache: true
- run: go generate github.com/majd/ipatool/...
- run: go test -v github.com/majd/ipatool/...
- run: go generate ./...
- run: go test -v -timeout 20m ./...
build:
name: Build
runs-on: macos-latest
Expand Down
43 changes: 41 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@ on:
- main

jobs:
cross_build_library:
name: Cross-build Windows library consumer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26.5"
cache: true
- name: Build from an independent module without dependency replacements
shell: bash
env:
GOWORK: "off"
CGO_ENABLED: "0"
run: |
consumer_dir=$(mktemp -d)
cd "$consumer_dir"
go mod init example.com/ipatool-consumer
go mod edit -require=github.com/majd/ipatool/v2@v2.0.0
go mod edit -replace="github.com/majd/ipatool/v2=$GITHUB_WORKSPACE"
cat > main.go <<'EOF'
package main
import (
"context"
"github.com/majd/ipatool/v2/pkg/appstore"
)
func main() {
_ = appstore.NewAppStore(appstore.Args{})
if err := appstore.Prepare(context.Background()); err != nil {
panic(err)
}
}
EOF
go mod tidy
GOOS=windows GOARCH=amd64 go build -o consumer-amd64.exe .
GOOS=windows GOARCH=arm64 go build -o consumer-arm64.exe .
run_tests:
name: Run tests
runs-on: ${{ matrix.runner }}
Expand All @@ -19,5 +58,5 @@ jobs:
with:
go-version: "1.26.5"
cache: true
- run: go generate github.com/majd/ipatool/...
- run: go test -v github.com/majd/ipatool/...
- run: go generate ./...
- run: go test -v -timeout 20m ./...
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
.vscode/
.idea/
**/*_mock.go
exp/
exp/
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ module github.com/majd/ipatool/v2

go 1.26.5

// go-apfs requires this package path; keep decoding pure Go for cross-platform builds.
replace github.com/blacktop/lzfse-cgo => ./internal/lzfsecompat

require (
github.com/avast/retry-go v3.0.0+incompatible
github.com/blacktop/go-apfs v1.0.28
github.com/blacktop/go-macho v1.1.282
github.com/bodgit/sevenzip v1.6.3
github.com/byteness/go-keychain v0.0.0-20191008050251-8e49817e8af4
Expand All @@ -17,6 +13,7 @@ require (
github.com/go-compressions/lzfse v0.3.0
github.com/juju/persistent-cookiejar v1.0.0
github.com/klauspost/compress v1.18.6
github.com/majd/go-apfs v1.0.29
github.com/modelcontextprotocol/go-sdk v1.8.0
github.com/onsi/ginkgo/v2 v2.5.0
github.com/onsi/gomega v1.24.0
Expand All @@ -27,6 +24,7 @@ require (
go.uber.org/mock v0.4.0
golang.org/x/sys v0.48.0
golang.org/x/term v0.46.0
golang.org/x/text v0.42.0
howett.net/plist v1.0.1
)

Expand All @@ -39,7 +37,6 @@ require (
github.com/apex/log v1.9.0 // indirect
github.com/blacktop/go-dwarf v1.0.14 // indirect
github.com/blacktop/go-plist v1.0.2 // indirect
github.com/blacktop/lzfse-cgo v1.2.0 // indirect
github.com/bodgit/plumbing v1.3.0 // indirect
github.com/bodgit/windows v1.0.1 // indirect
github.com/byteness/go-libsecret v0.0.0-20260108215642-107379d3dee0 // indirect
Expand Down Expand Up @@ -93,7 +90,6 @@ require (
golang.org/x/net v0.58.0 // indirect
golang.org/x/oauth2 v0.35.0 // indirect
golang.org/x/sync v0.23.0 // indirect
golang.org/x/text v0.42.0 // indirect
golang.org/x/time v0.15.0 // indirect
golang.org/x/tools v0.49.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHS
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
github.com/blacktop/go-apfs v1.0.28 h1:kXihmwrGdKZjUn37ULxWHG0R6IgtQKOqmtRHo6QuAa8=
github.com/blacktop/go-apfs v1.0.28/go.mod h1:i2Sfy/il/t2ADGIGPN0FAm+7CAot7TnQwgmMQXzF0xs=
github.com/blacktop/go-dwarf v1.0.14 h1:OjmzfSgg/qAKckn2tWFebcgKgJ7HOqCj7bS+CiE1lrY=
github.com/blacktop/go-dwarf v1.0.14/go.mod h1:4W2FKgSFYcZLDwnR7k+apv5i3nrau4NGl9N6VQ9DSTo=
github.com/blacktop/go-macho v1.1.282 h1:DW3HYz5zVCT6+Jlp1+hxauYvEgxqZsGMvu8/1j4+Ibg=
Expand Down Expand Up @@ -122,6 +120,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/majd/go-apfs v1.0.29 h1:UogjWvwkvNIcDRjiEQvIpOxrK5PgFo48yRern2mnrVM=
github.com/majd/go-apfs v1.0.29/go.mod h1:gA+fjwBmzHsm5ubsWtRJJUdRcu/8qhyuAJ4jFGGNYdk=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
Expand Down
5 changes: 0 additions & 5 deletions internal/lzfsecompat/go.mod

This file was deleted.

37 changes: 0 additions & 37 deletions internal/lzfsecompat/lzfse.go

This file was deleted.

7 changes: 7 additions & 0 deletions internal/sap/assets/aea.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"io"
"net/http"
"net/url"
"strings"
"sync"

"github.com/go-compressions/lzfse"
Expand Down Expand Up @@ -544,6 +545,12 @@ func (r *aeaReader) decodeSegment(cacheIndex int, segment aeaSegment) ([]byte, e
decoded = compressed
} else {
decoded, err = lzfse.Decompress(compressed)
if err != nil && strings.Contains(err.Error(), "fse: stream too short") {
padded, e := padLZFSEStreams(compressed)
if e == nil {
decoded, err = lzfse.Decompress(padded)
}
}
if err != nil {
return nil, fmt.Errorf("decompress AEA cluster %d segment %d: %w", segment.cluster, segment.index, err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/sap/assets/apfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
"strings"
"sync"

"github.com/blacktop/go-apfs"
"github.com/blacktop/go-apfs/pkg/disk"
"github.com/blacktop/go-apfs/pkg/disk/dmg"
"github.com/blacktop/go-apfs/types"
"github.com/deploymenttheory/go-macos-pkg/pkg/lzbitmap"
"github.com/go-compressions/lzfse"
"github.com/majd/go-apfs"
"github.com/majd/go-apfs/pkg/disk"
"github.com/majd/go-apfs/pkg/disk/dmg"
"github.com/majd/go-apfs/types"
)

const (
Expand Down
24 changes: 15 additions & 9 deletions internal/sap/assets/dyld.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ const (
)

type dyldCache struct {
members []*dyldCacheMember
primary *dyldCacheMember
slide5 *dyldSlideInfo5
members []*dyldCacheMember
primary *dyldCacheMember
slide5 *dyldSlideInfo5
relativeSelectorBase uint64
}

type dyldCacheMember struct {
Expand Down Expand Up @@ -89,11 +90,14 @@ func extractDyldImageFromFiles(opener dyldCacheOpener, imagePath, outputPath str
if err != nil {
return fmt.Errorf("find %s in shared cache: %w", imagePath, err)
}
imageMachO, err := cache.openImage(image)
imageMachO, err := cache.openImage(image, machotypes.LC_SYMTAB, machotypes.LC_DYSYMTAB)
if err != nil {
return fmt.Errorf("read %s from shared cache: %w", imagePath, err)
}
defer imageMachO.Close()
if err = cache.imageSymbols(image, imageMachO); err != nil {
return fmt.Errorf("read %s symbols: %w", imagePath, err)
}

var chainedFixups *fixupchains.DyldChainedFixups
if imageMachO.HasFixups() {
Expand All @@ -113,7 +117,7 @@ func extractDyldImageFromFiles(opener dyldCacheOpener, imagePath, outputPath str
return nil
}

func (c *dyldCache) openImage(image *dyldImage) (*macho.File, error) {
func (c *dyldCache) openImage(image *dyldImage, excluding ...machotypes.LoadCmd) (*macho.File, error) {
linkeditAddress, err := image.linkeditAddress()
if err != nil {
return nil, err
Expand Down Expand Up @@ -143,10 +147,12 @@ func (c *dyldCache) openImage(image *dyldImage) (*macho.File, error) {
file, err := macho.NewFile(
io.NewSectionReader(image.member.file, int64(image.offset), image.member.size-int64(image.offset)),
macho.FileConfig{
Offset: int64(image.offset),
SectionReader: sectionReader,
CacheReader: reader,
VMAddrConverter: converter,
Offset: int64(image.offset),
SectionReader: sectionReader,
CacheReader: reader,
VMAddrConverter: converter,
RelativeSelectorBase: c.relativeSelectorBase,
LoadExcluding: excluding,
},
)
if err != nil {
Expand Down
Loading
Loading