Skip to content

Commit

Permalink
feat: add 🆕 ipsw download pcc command
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Oct 26, 2024
1 parent 3402770 commit e3ba6fa
Show file tree
Hide file tree
Showing 5 changed files with 6,171 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ www/docs/static/releases*.json
*.bndb
*.lock
internal/commands/ida/dscu/data/dscu.py
internal/download/data/proto
venv/

# Unicorn EMU
Expand Down
93 changes: 93 additions & 0 deletions cmd/ipsw/cmd/download/download_pcc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright © 2024 blacktop
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package download

import (
"fmt"

"github.com/apex/log"
"github.com/blacktop/ipsw/internal/download"
"github.com/fatih/color"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func init() {
DownloadCmd.AddCommand(pccCmd)

pccCmd.Flags().StringP("output", "o", "", "Output directory to save files to")
viper.BindPFlag("download.pcc.output", pccCmd.Flags().Lookup("output"))

pccCmd.SetHelpFunc(func(c *cobra.Command, s []string) {
DownloadCmd.PersistentFlags().MarkHidden("white-list")
DownloadCmd.PersistentFlags().MarkHidden("black-list")
DownloadCmd.PersistentFlags().MarkHidden("device")
DownloadCmd.PersistentFlags().MarkHidden("model")
DownloadCmd.PersistentFlags().MarkHidden("version")
DownloadCmd.PersistentFlags().MarkHidden("build")
DownloadCmd.PersistentFlags().MarkHidden("confirm")
DownloadCmd.PersistentFlags().MarkHidden("remove-commas")
c.Parent().HelpFunc()(c, s)
})

pccCmd.MarkFlagDirname("output")
}

// pccCmd represents the pcc command
var pccCmd = &cobra.Command{
Use: "pcc",
Aliases: []string{"p", "vre"},
Short: "🚧 Download PCC VM files",
SilenceUsage: false,
SilenceErrors: true,
RunE: func(cmd *cobra.Command, args []string) error {

if viper.GetBool("verbose") {
log.SetLevel(log.DebugLevel)
}
color.NoColor = viper.GetBool("no-color")

viper.BindPFlag("download.proxy", cmd.Flags().Lookup("proxy"))
viper.BindPFlag("download.insecure", cmd.Flags().Lookup("insecure"))
viper.BindPFlag("download.skip-all", cmd.Flags().Lookup("skip-all"))
viper.BindPFlag("download.resume-all", cmd.Flags().Lookup("resume-all"))
viper.BindPFlag("download.restart-all", cmd.Flags().Lookup("restart-all"))

// settings
// proxy := viper.GetString("download.proxy")
// insecure := viper.GetBool("download.insecure")
// skipAll := viper.GetBool("download.skip-all")
// resumeAll := viper.GetBool("download.resume-all")
// restartAll := viper.GetBool("download.restart-all")

releases, err := download.GetPCCReleases("")
if err != nil {
return err
}

for _, release := range releases {
fmt.Println(release)
}

return nil
},
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ require (
golang.org/x/sync v0.8.0
golang.org/x/sys v0.26.0
golang.org/x/term v0.25.0
google.golang.org/protobuf v1.35.1
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/postgres v1.5.9
gorm.io/gorm v1.25.12
Expand Down Expand Up @@ -186,7 +187,6 @@ require (
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gotest.tools/v3 v3.5.1 // indirect
Expand Down
Loading

0 comments on commit e3ba6fa

Please sign in to comment.