mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-06 05:30:57 +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
+13
-7
@@ -236,6 +236,17 @@ func ParseDependencyVariants(variants string) (l []Dependency, err error) {
|
||||
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
|
||||
func ParseDependency(dep string) (d Dependency, err error) {
|
||||
if strings.HasSuffix(dep, "}") {
|
||||
@@ -252,6 +263,7 @@ func ParseDependency(dep string) (d Dependency, err error) {
|
||||
if !strings.HasSuffix(dep, ")") {
|
||||
d.Pkg = strings.TrimSpace(dep)
|
||||
d.Relation = VersionDontCare
|
||||
ParseDependencyArch(&d)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -262,13 +274,7 @@ func ParseDependency(dep string) (d Dependency, err error) {
|
||||
}
|
||||
|
||||
d.Pkg = strings.TrimSpace(dep[0:i])
|
||||
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 = ""
|
||||
}
|
||||
}
|
||||
ParseDependencyArch(&d)
|
||||
|
||||
rel := ""
|
||||
if dep[i+1] == '>' || dep[i+1] == '<' || dep[i+1] == '=' {
|
||||
|
||||
Reference in New Issue
Block a user