diff --git a/cmd/deploy.go b/cmd/deploy.go index cb49e56..e577c0f 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -242,14 +242,7 @@ var deployCmd = &cobra.Command{ block_size, _ := adbd.RunCommand("blockdev --getsize64 /dev/block/sda") block_size = strings.TrimRight(block_size, "\n") - is128 := false - if r, _ := regexp.MatchString(`^125[0-9]{9}$`, block_size); r { - is128 = true - } else if r, _ := regexp.MatchString(`^253[0-9]{9}$`, block_size); r { - is128 = false - } - - for _, cmd := range utils.GenRepartCommands(partpercent, is128) { + for _, cmd := range utils.GenRepartCommands(partpercent, block_size) { adbd.RunCommand(cmd) logger.Debug("Executed command", logger.Args("cmd", cmd)) } diff --git a/utils/utils.go b/utils/utils.go index 7242547..48950cc 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -4,14 +4,17 @@ import ( "fmt" "math" "net" + "regexp" ) -func GenRepartCommands(percent int, is128 bool) []string { - var maxsize uint8 - if is128 { +func GenRepartCommands(percent int, blocksize string) []string { + var maxsize uint16 + if r, _ := regexp.MatchString(`^125[0-9]{9}$`, blocksize); r { maxsize = 126 - } else { + } else if r, _ := regexp.MatchString(`^253[0-9]{9}$`, blocksize); r { maxsize = 254 + } else if r, _ := regexp.MatchString(`^509[0-9]{9}$`, blocksize); r { + maxsize = 509 } linux_max := maxsize - 12 size := math.Round(float64(linux_max)*float64(percent)) / 100 @@ -26,7 +29,6 @@ func GenRepartCommands(percent int, is128 bool) []string { } } - func GetFreePort() (int, error) { listener, err := net.Listen("tcp", ":0") if err != nil {