mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-16 12:08:04 +00:00
Parse dependency architecture even without version
This commit closes: #145 The dependency format "pkg:arch" (e.g. "python3:any") was not well parsed if not any version is given. This commit splits the dependency name and architecture in all cases.
This commit is contained in:
committed by
Andrey Smirnov
parent
7ae5a12f4a
commit
a656241d5e
@@ -37,3 +37,4 @@ List of contributors, in chronological order:
|
|||||||
* William Manley (https://github.com/wmanley)
|
* William Manley (https://github.com/wmanley)
|
||||||
* Shengjing Zhu (https://github.com/zhsj)
|
* Shengjing Zhu (https://github.com/zhsj)
|
||||||
* Nabil Bendafi (https://github.com/nabilbendafi)
|
* Nabil Bendafi (https://github.com/nabilbendafi)
|
||||||
|
* Raphael Medaer (https://github.com/rmedaer)
|
||||||
|
|||||||
+13
-7
@@ -236,6 +236,17 @@ func ParseDependencyVariants(variants string) (l []Dependency, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParseDependencyArch parses the dependency name in format "pkg:any" into name and architecture
|
||||||
|
func ParseDependencyArch(d *Dependency) {
|
||||||
|
if strings.ContainsRune(d.Pkg, ':') {
|
||||||
|
parts := strings.SplitN(d.Pkg, ":", 2)
|
||||||
|
d.Pkg, d.Architecture = parts[0], parts[1]
|
||||||
|
if d.Architecture == "any" {
|
||||||
|
d.Architecture = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ParseDependency parses dependency in format "pkg (>= 1.35) [arch]" into parts
|
// ParseDependency parses dependency in format "pkg (>= 1.35) [arch]" into parts
|
||||||
func ParseDependency(dep string) (d Dependency, err error) {
|
func ParseDependency(dep string) (d Dependency, err error) {
|
||||||
if strings.HasSuffix(dep, "}") {
|
if strings.HasSuffix(dep, "}") {
|
||||||
@@ -252,6 +263,7 @@ func ParseDependency(dep string) (d Dependency, err error) {
|
|||||||
if !strings.HasSuffix(dep, ")") {
|
if !strings.HasSuffix(dep, ")") {
|
||||||
d.Pkg = strings.TrimSpace(dep)
|
d.Pkg = strings.TrimSpace(dep)
|
||||||
d.Relation = VersionDontCare
|
d.Relation = VersionDontCare
|
||||||
|
ParseDependencyArch(&d)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,13 +274,7 @@ func ParseDependency(dep string) (d Dependency, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
d.Pkg = strings.TrimSpace(dep[0:i])
|
d.Pkg = strings.TrimSpace(dep[0:i])
|
||||||
if strings.ContainsRune(d.Pkg, ':') {
|
ParseDependencyArch(&d)
|
||||||
parts := strings.SplitN(d.Pkg, ":", 2)
|
|
||||||
d.Pkg, d.Architecture = parts[0], parts[1]
|
|
||||||
if d.Architecture == "any" {
|
|
||||||
d.Architecture = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rel := ""
|
rel := ""
|
||||||
if dep[i+1] == '>' || dep[i+1] == '<' || dep[i+1] == '=' {
|
if dep[i+1] == '>' || dep[i+1] == '<' || dep[i+1] == '=' {
|
||||||
|
|||||||
Reference in New Issue
Block a user