clean.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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() error {
  19. hanging, err := hangingPackages()
  20. if err != nil {
  21. return err
  22. }
  23. if len(hanging) != 0 {
  24. if !continueTask("Confirm Removal?", "nN") {
  25. return nil
  26. }
  27. err = cleanRemove(hanging)
  28. }
  29. return err
  30. }
  31. // CleanRemove sends a full removal command to pacman with the pkgName slice
  32. func cleanRemove(pkgNames []string) (err error) {
  33. if len(pkgNames) == 0 {
  34. return nil
  35. }
  36. oldvalue := config.NoConfirm
  37. config.NoConfirm = true
  38. arguments := makeArguments()
  39. arguments.addArg("R")
  40. arguments.addTarget(pkgNames...)
  41. err = passToPacman(arguments)
  42. config.NoConfirm = oldvalue
  43. return err
  44. }