mirror of
https://github.com/mudler/luet.git
synced 2025-09-24 12:37:53 +00:00
cmd/install: Now use _gentoo.ParsePackageStr and support pkgs without version
This commit is contained in:
committed by
Ettore Di Giacinto
parent
16453bd09f
commit
8b66127016
@@ -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
|
||||
|
Reference in New Issue
Block a user