Skip to content

Commit

Permalink
Update gpu.go
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Aug 5, 2024
1 parent 2091dcc commit 3775927
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions cmd/ipsw/cmd/fw/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (
"path/filepath"

"github.com/apex/log"
"github.com/blacktop/ipsw/internal/commands/extract"
fwcmd "github.com/blacktop/ipsw/internal/commands/fw"
"github.com/blacktop/ipsw/internal/magic"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand All @@ -52,8 +54,27 @@ var gpuCmd = &cobra.Command{
log.SetLevel(log.DebugLevel)
}

if _, err := fwcmd.SplitGpuFW(filepath.Clean(args[0]), viper.GetString("fw.gpu.output")); err != nil {
return fmt.Errorf("failed to split GPU firmware: %v", err)
if isZip, err := magic.IsZip(filepath.Clean(args[0])); err != nil {
return fmt.Errorf("failed to determine if file is a zip: %v", err)
} else if isZip {
out, err := extract.Search(&extract.Config{
IPSW: filepath.Clean(args[0]),
Pattern: "armfw_.*.im4p$",
Output: viper.GetString("fw.gpu.output"),
})
if err != nil {
return err
}
for _, f := range out {
folder := filepath.Join(filepath.Dir(f), "extracted")
if _, err := fwcmd.SplitGpuFW(f, folder); err != nil {
return fmt.Errorf("failed to split GPU firmware: %v", err)
}
}
} else {
if _, err := fwcmd.SplitGpuFW(filepath.Clean(args[0]), viper.GetString("fw.gpu.output")); err != nil {
return fmt.Errorf("failed to split GPU firmware: %v", err)
}
}

return nil
Expand Down

0 comments on commit 3775927

Please sign in to comment.