mirror of
https://github.com/mudler/luet.git
synced 2025-09-14 06:13:01 +00:00
Accept specific versions in cli input and avoid gentoo parser by default
This is a breaking change as changes the way packages can be given as arguments to luet. From this change, the following applies: - If a package string contains @, the right part is parsed as version (e.g. foo/bar@1.1) - If a package contains "/" and no "@", cat/name is applied (e.g. foo/bar) - If a package doesn't contain either, is implied its just a name without category - If a package contains "=" at the beginning, the gentoo parsing default is being used ( e.g. =foo/bar-1.1 ) Fixes #154
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
_gentoo "github.com/Sabayon/pkgs-checker/pkg/gentoo"
|
||||
pkg "github.com/mudler/luet/pkg/package"
|
||||
@@ -41,7 +42,41 @@ func CreateRegexArray(rgx []string) ([]*regexp.Regexp, error) {
|
||||
return ans, nil
|
||||
}
|
||||
|
||||
func packageData(p string) (string, string) {
|
||||
cat := ""
|
||||
name := ""
|
||||
if strings.Contains(p, "/") {
|
||||
packagedata := strings.Split(p, "/")
|
||||
cat = packagedata[0]
|
||||
name = packagedata[1]
|
||||
} else {
|
||||
name = p
|
||||
}
|
||||
return cat, name
|
||||
}
|
||||
func ParsePackageStr(p string) (*pkg.DefaultPackage, error) {
|
||||
|
||||
if !strings.HasPrefix(p, "=") {
|
||||
ver := ">=0"
|
||||
cat := ""
|
||||
name := ""
|
||||
|
||||
if strings.Contains(p, "@") {
|
||||
packageinfo := strings.Split(p, "@")
|
||||
ver = packageinfo[1]
|
||||
cat, name = packageData(packageinfo[0])
|
||||
} else {
|
||||
cat, name = packageData(p)
|
||||
}
|
||||
|
||||
return &pkg.DefaultPackage{
|
||||
Name: name,
|
||||
Category: cat,
|
||||
Version: ver,
|
||||
Uri: make([]string, 0),
|
||||
}, nil
|
||||
}
|
||||
|
||||
gp, err := _gentoo.ParsePackageStr(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@@ -62,7 +62,7 @@ EOF
|
||||
}
|
||||
|
||||
testInstall() {
|
||||
luet install -y --config $tmpdir/luet.yaml test/c-1.0
|
||||
luet install -y --config $tmpdir/luet.yaml test/c@1.0
|
||||
#luet install -y --config $tmpdir/luet.yaml test/c-1.0 > /dev/null
|
||||
installst=$?
|
||||
assertEquals 'install test successfully' "$installst" "0"
|
||||
@@ -77,7 +77,7 @@ testReInstall() {
|
||||
}
|
||||
|
||||
testUnInstall() {
|
||||
luet uninstall -y --config $tmpdir/luet.yaml test/c-1.0
|
||||
luet uninstall -y --config $tmpdir/luet.yaml =test/c-1.0
|
||||
installst=$?
|
||||
assertEquals 'uninstall test successfully' "$installst" "0"
|
||||
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
|
||||
|
Reference in New Issue
Block a user