diff --git a/pkg/build/lock.go b/pkg/build/lock.go index c3f76a20..ca364bee 100644 --- a/pkg/build/lock.go +++ b/pkg/build/lock.go @@ -134,9 +134,10 @@ func unify(originals []string, inputs []resolved) (map[string][]string, map[stri // special characters that delimit the package name from the cosntraint // so lop off the package name and stick the rest of the constraint into // the versions map. - if idx := strings.IndexAny(orig, "=<>~"); idx >= 0 { + if idx := strings.IndexAny(orig, "@=<>~"); idx >= 0 { name = orig[:idx] } + originalPackages.packages.Insert(name) originalPackages.versions[name] = strings.TrimPrefix(orig, name) } @@ -235,7 +236,12 @@ func unify(originals []string, inputs []resolved) (map[string][]string, map[stri // Append all of the resolved and unified packages with an exact match // based on the resolved version we found. for _, pkg := range sets.List(acc.packages) { - pl = append(pl, fmt.Sprintf("%s=%s", pkg, acc.versions[pkg])) + pkgName := fmt.Sprintf("%s=%s", pkg, acc.versions[pkg]) + // Add back the version if that is stripped before + if originalPackages.versions[pkg] != "" { + pkgName = pkgName + originalPackages.versions[pkg] + } + pl = append(pl, pkgName) } // Sort the package list explicitly with the `=` included. // This is because (foo, foo-bar) sorts differently than (foo=1, foo-bar=1) @@ -249,7 +255,12 @@ func unify(originals []string, inputs []resolved) (map[string][]string, map[stri for _, input := range inputs { pl := make([]string, 0, len(input.packages)) for _, pkg := range sets.List(input.packages) { - pl = append(pl, fmt.Sprintf("%s=%s", pkg, input.versions[pkg])) + pkgName := fmt.Sprintf("%s=%s", pkg, input.versions[pkg]) + // Add back the version if that is stripped before + if originalPackages.versions[pkg] != "" { + pkgName = pkgName + originalPackages.versions[pkg] + } + pl = append(pl, pkgName) } // Sort the package list explicitly with the `=` included. // This is because (foo, foo-bar) sorts differently than (foo=1, foo-bar=1)