mirror of
https://github.com/mudler/luet.git
synced 2025-08-17 14:56:46 +00:00
Add support for build identifier on version
This commit is contained in:
parent
38296bc5d7
commit
def04724d4
@ -161,6 +161,35 @@ func ParseVersion(v string) (PkgVersionSelector, error) {
|
|||||||
ans.Condition = PkgCondNot
|
ans.Condition = PkgCondNot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if build number is present
|
||||||
|
buildIdx := strings.Index(v, "+")
|
||||||
|
buildVersion := ""
|
||||||
|
if buildIdx > 0 {
|
||||||
|
// <pre-release> ::= <dot-separated pre-release identifiers>
|
||||||
|
//
|
||||||
|
// <dot-separated pre-release identifiers> ::=
|
||||||
|
// <pre-release identifier> | <pre-release identifier> "."
|
||||||
|
// <dot-separated pre-release identifiers>
|
||||||
|
//
|
||||||
|
// <build> ::= <dot-separated build identifiers>
|
||||||
|
//
|
||||||
|
// <dot-separated build identifiers> ::= <build identifier>
|
||||||
|
// | <build identifier> "." <dot-separated build identifiers>
|
||||||
|
//
|
||||||
|
// <pre-release identifier> ::= <alphanumeric identifier>
|
||||||
|
// | <numeric identifier>
|
||||||
|
//
|
||||||
|
// <build identifier> ::= <alphanumeric identifier>
|
||||||
|
// | <digits>
|
||||||
|
//
|
||||||
|
// <alphanumeric identifier> ::= <non-digit>
|
||||||
|
// | <non-digit> <identifier characters>
|
||||||
|
// | <identifier characters> <non-digit>
|
||||||
|
// | <identifier characters> <non-digit> <identifier characters>
|
||||||
|
buildVersion = v[buildIdx:]
|
||||||
|
v = v[0:buildIdx]
|
||||||
|
}
|
||||||
|
|
||||||
regexPkg := regexp.MustCompile(
|
regexPkg := regexp.MustCompile(
|
||||||
fmt.Sprintf("(%s|%s|%s|%s|%s|%s)((%s|%s|%s|%s|%s|%s|%s)+)*$",
|
fmt.Sprintf("(%s|%s|%s|%s|%s|%s)((%s|%s|%s|%s|%s|%s|%s)+)*$",
|
||||||
// Version regex
|
// Version regex
|
||||||
@ -216,6 +245,8 @@ func ParseVersion(v string) (PkgVersionSelector, error) {
|
|||||||
ans.Condition = PkgCondEqual
|
ans.Condition = PkgCondEqual
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ans.Version += buildVersion
|
||||||
|
|
||||||
// NOTE: Now suffix complex like _alpha_rc1 are not supported.
|
// NOTE: Now suffix complex like _alpha_rc1 are not supported.
|
||||||
return ans, nil
|
return ans, nil
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,61 @@ var _ = Describe("Versions", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Context("Versions Parser11 - semver", func() {
|
||||||
|
v, err := ParseVersion("0.1.0+0")
|
||||||
|
It("ParseVersion10", func() {
|
||||||
|
var c PkgSelectorCondition = PkgCondEqual
|
||||||
|
Expect(err).Should(BeNil())
|
||||||
|
Expect(v.Version).Should(Equal("0.1.0+0"))
|
||||||
|
Expect(v.VersionSuffix).Should(Equal(""))
|
||||||
|
Expect(v.Condition).Should(Equal(c))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("Versions Parser12 - semver", func() {
|
||||||
|
v, err := ParseVersion(">=0.1.0_alpha+AB")
|
||||||
|
It("ParseVersion10", func() {
|
||||||
|
var c PkgSelectorCondition = PkgCondGreaterEqual
|
||||||
|
Expect(err).Should(BeNil())
|
||||||
|
Expect(v.Version).Should(Equal("0.1.0+AB"))
|
||||||
|
Expect(v.VersionSuffix).Should(Equal("_alpha"))
|
||||||
|
Expect(v.Condition).Should(Equal(c))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("Versions Parser13 - semver", func() {
|
||||||
|
v, err := ParseVersion(">=0.1.0_alpha+0.1.22")
|
||||||
|
It("ParseVersion10", func() {
|
||||||
|
var c PkgSelectorCondition = PkgCondGreaterEqual
|
||||||
|
Expect(err).Should(BeNil())
|
||||||
|
Expect(v.Version).Should(Equal("0.1.0+0.1.22"))
|
||||||
|
Expect(v.VersionSuffix).Should(Equal("_alpha"))
|
||||||
|
Expect(v.Condition).Should(Equal(c))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("Versions Parser14 - semver", func() {
|
||||||
|
v, err := ParseVersion(">=0.1.0_alpha+0.1.22")
|
||||||
|
It("ParseVersion10", func() {
|
||||||
|
var c PkgSelectorCondition = PkgCondGreaterEqual
|
||||||
|
Expect(err).Should(BeNil())
|
||||||
|
Expect(v.Version).Should(Equal("0.1.0+0.1.22"))
|
||||||
|
Expect(v.VersionSuffix).Should(Equal("_alpha"))
|
||||||
|
Expect(v.Condition).Should(Equal(c))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("Versions Parser15 - semver", func() {
|
||||||
|
v, err := ParseVersion("<=0.3.222.4.5+AB")
|
||||||
|
It("ParseVersion10", func() {
|
||||||
|
var c PkgSelectorCondition = PkgCondLessEqual
|
||||||
|
Expect(err).Should(BeNil())
|
||||||
|
Expect(v.Version).Should(Equal("0.3.222.4.5+AB"))
|
||||||
|
Expect(v.VersionSuffix).Should(Equal(""))
|
||||||
|
Expect(v.Condition).Should(Equal(c))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
Context("Selector1", func() {
|
Context("Selector1", func() {
|
||||||
v1, err := ParseVersion(">=0.0.20190406.4.9.172-r1")
|
v1, err := ParseVersion(">=0.0.20190406.4.9.172-r1")
|
||||||
v2, err2 := ParseVersion("1.0.111")
|
v2, err2 := ParseVersion("1.0.111")
|
||||||
@ -184,6 +239,42 @@ var _ = Describe("Versions", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Context("Selector5", func() {
|
||||||
|
v1, err := ParseVersion(">0.1.0+0.4")
|
||||||
|
v2, err2 := ParseVersion("0.1.0+0.3")
|
||||||
|
match, err3 := PackageAdmit(v1, v2)
|
||||||
|
It("Selector5", func() {
|
||||||
|
Expect(err).Should(BeNil())
|
||||||
|
Expect(err2).Should(BeNil())
|
||||||
|
Expect(err3).Should(BeNil())
|
||||||
|
Expect(match).Should(Equal(false))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("Selector6", func() {
|
||||||
|
v1, err := ParseVersion(">=0.1.0+0.4")
|
||||||
|
v2, err2 := ParseVersion("0.1.0+0.5")
|
||||||
|
match, err3 := PackageAdmit(v1, v2)
|
||||||
|
It("Selector6", func() {
|
||||||
|
Expect(err).Should(BeNil())
|
||||||
|
Expect(err2).Should(BeNil())
|
||||||
|
Expect(err3).Should(BeNil())
|
||||||
|
Expect(match).Should(Equal(true))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
PContext("Selector7", func() {
|
||||||
|
v1, err := ParseVersion(">0.1.0+0.4")
|
||||||
|
v2, err2 := ParseVersion("0.1.0+0.5")
|
||||||
|
match, err3 := PackageAdmit(v1, v2)
|
||||||
|
It("Selector7", func() {
|
||||||
|
Expect(err).Should(BeNil())
|
||||||
|
Expect(err2).Should(BeNil())
|
||||||
|
Expect(err3).Should(BeNil())
|
||||||
|
Expect(match).Should(Equal(true))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
Context("Condition Converter 1", func() {
|
Context("Condition Converter 1", func() {
|
||||||
gp, err := gentoo.ParsePackageStr("=layer/build-1.0")
|
gp, err := gentoo.ParsePackageStr("=layer/build-1.0")
|
||||||
var cond gentoo.PackageCond = gentoo.PkgCondEqual
|
var cond gentoo.PackageCond = gentoo.PkgCondEqual
|
||||||
|
Loading…
Reference in New Issue
Block a user