diff --git a/cmd/install.go b/cmd/install.go index 34c33fd0..175df726 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -15,9 +15,9 @@ package cmd import ( + "fmt" "os" "path/filepath" - "regexp" installer "github.com/mudler/luet/pkg/installer" @@ -25,6 +25,7 @@ import ( . "github.com/mudler/luet/pkg/logger" pkg "github.com/mudler/luet/pkg/package" + _gentoo "github.com/Sabayon/pkgs-checker/pkg/gentoo" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -47,17 +48,23 @@ var installCmd = &cobra.Command{ var toInstall []pkg.Package for _, a := range args { - decodepackage, err := regexp.Compile(`^([<>]?\~?=?)((([^\/]+)\/)?(?U)(\S+))(-(\d+(\.\d+)*[a-z]?(_(alpha|beta|pre|rc|p)\d*)*(-r\d+)?))?$`) + gp, err := _gentoo.ParsePackageStr(a) if err != nil { - Fatal("Error: " + err.Error()) + Fatal("Invalid package string ", a, ": ", err.Error()) } - packageInfo := decodepackage.FindAllStringSubmatch(a, -1) - category := packageInfo[0][4] - name := packageInfo[0][5] - version := packageInfo[0][1] + packageInfo[0][7] - toInstall = append(toInstall, &pkg.DefaultPackage{Name: name, Category: category, Version: version}) + if gp.Version == "" { + gp.Version = "0" + gp.Condition = _gentoo.PkgCondGreaterEqual + } + pack := &pkg.DefaultPackage{ + Name: gp.Name, + Version: fmt.Sprintf("%s%s%s", gp.Condition.String(), gp.Version, gp.VersionSuffix), + Category: gp.Category, + Uri: make([]string, 0), + } + toInstall = append(toInstall, pack) } // This shouldn't be necessary, but we need to unmarshal the repositories to a concrete struct, thus we need to port them back to the Repositories type