clean.go 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package main
  2. // GetPkgbuild gets the pkgbuild of the package 'pkg' trying the ABS first and then the AUR trying the ABS first and then the AUR.
  3. // RemovePackage removes package from VCS information
  4. func removeVCSPackage(pkgs []string) {
  5. updated := false
  6. for _, pkgName := range pkgs {
  7. _, ok := savedInfo[pkgName]
  8. if ok {
  9. delete(savedInfo, pkgName)
  10. updated = true
  11. }
  12. }
  13. if updated {
  14. saveVCSInfo()
  15. }
  16. }
  17. // CleanDependencies removes all dangling dependencies in system
  18. func cleanDependencies(removeOptional bool) error {
  19. hanging, err := hangingPackages(removeOptional)
  20. if err != nil {
  21. return err
  22. }
  23. if len(hanging) != 0 {
  24. err = cleanRemove(hanging)
  25. }
  26. return err
  27. }
  28. // CleanRemove sends a full removal command to pacman with the pkgName slice
  29. func cleanRemove(pkgNames []string) (err error) {
  30. if len(pkgNames) == 0 {
  31. return nil
  32. }
  33. arguments := makeArguments()
  34. arguments.addArg("R")
  35. arguments.addTarget(pkgNames...)
  36. err = passToPacman(arguments)
  37. return err
  38. }