Fixed circular dependency problems

This commit is contained in:
EnumDev 2024-10-08 19:59:29 +03:00
parent 4793424f3d
commit c8939614b1
2 changed files with 15 additions and 5 deletions

View File

@ -224,7 +224,7 @@ func resolveCommand() {
}]()
for _, pkg := range clone.Keys() {
value, _ := clone.Get(pkg)
resolved, unresolved := value.pkgInfo.ResolveAll(&[]string{}, &[]string{}, value.pkgInfo.Type == "source", !noOptional, !reinstall, rootDir)
resolved, unresolved := value.pkgInfo.ResolveAll(&[]string{}, &[]string{}, value.pkgInfo.Type == "source", !noOptional, !reinstall, verbose, rootDir)
unresolvedDepends = append(unresolvedDepends, unresolved...)
for _, depend := range resolved {
if _, ok := pkgsToInstall.Get(depend); !ok && depend != value.pkgInfo.Name {
@ -411,7 +411,7 @@ func resolveCommand() {
clone := toUpdate.Copy()
for _, key := range clone.Keys() {
pkg, _ := clone.Get(key)
r, u := pkg.entry.Info.ResolveAll(&[]string{}, &[]string{}, pkg.entry.Info.Type == "source", !noOptional, true, rootDir)
r, u := pkg.entry.Info.ResolveAll(&[]string{}, &[]string{}, pkg.entry.Info.Type == "source", !noOptional, true, verbose, rootDir)
unresolved = append(unresolved, u...)
for _, depend := range r {
if _, ok := toUpdate.Get(depend); !ok {

View File

@ -1284,11 +1284,21 @@ func (pkgInfo *PackageInfo) CheckConflicts(rootDir string) []string {
return ret
}
func (pkgInfo *PackageInfo) ResolveAll(resolved, unresolved *[]string, checkMake, checkOptional, ignoreInstalled bool, rootDir string) ([]string, []string) {
func (pkgInfo *PackageInfo) ResolveAll(resolved, unresolved *[]string, checkMake, checkOptional, ignoreInstalled, verbose bool, rootDir string) ([]string, []string) {
*unresolved = append(*unresolved, pkgInfo.Name)
for _, depend := range pkgInfo.GetAllDependencies(checkMake, checkOptional) {
depend = strings.TrimSpace(depend)
depend = strings.ToLower(depend)
if !slices.Contains(*resolved, depend) {
if slices.Contains(*unresolved, depend) || (ignoreInstalled && IsPackageInstalled(depend, rootDir)) {
if slices.Contains(*unresolved, depend) {
if verbose {
fmt.Printf("Circular dependency was detected (%s -> %s). Installing %s first\n", pkgInfo.Name, depend, depend)
}
if !slices.Contains(*resolved, depend) {
*resolved = append(*resolved, depend)
}
continue
} else if ignoreInstalled && IsPackageInstalled(depend, rootDir) {
continue
}
entry, _, err := GetRepositoryEntry(depend)
@ -1298,7 +1308,7 @@ func (pkgInfo *PackageInfo) ResolveAll(resolved, unresolved *[]string, checkMake
}
continue
}
entry.Info.ResolveAll(resolved, unresolved, checkMake, checkOptional, ignoreInstalled, rootDir)
entry.Info.ResolveAll(resolved, unresolved, checkMake, checkOptional, ignoreInstalled, verbose, rootDir)
}
}
if !slices.Contains(*resolved, pkgInfo.Name) {