yay/actions.go

71 lines
1.3 KiB
Go
Raw Normal View History

2017-04-29 17:12:12 +00:00
package main
2016-09-13 01:06:24 +00:00
import (
"fmt"
"os"
2016-10-16 22:02:48 +00:00
aur "github.com/jguer/yay/aur"
2016-12-01 00:36:58 +00:00
pac "github.com/jguer/yay/pacman"
2017-01-05 16:13:52 +00:00
"github.com/jguer/yay/util"
2016-09-13 01:06:24 +00:00
)
2016-11-29 01:53:17 +00:00
// Install handles package installs
func install(pkgs []string, flags []string) error {
2016-12-01 00:36:58 +00:00
aurs, repos, _ := pac.PackageSlices(pkgs)
2016-12-02 18:03:31 +00:00
err := pac.Install(repos, flags)
if err != nil {
fmt.Println("Error installing repo packages.")
}
2016-12-01 00:36:58 +00:00
err = aur.Install(aurs, flags)
2016-11-29 01:53:17 +00:00
return err
2016-11-29 01:53:17 +00:00
}
// Upgrade handles updating the cache and installing updates.
func upgrade(flags []string) error {
2016-12-01 00:36:58 +00:00
errp := pac.UpdatePackages(flags)
erra := aur.Upgrade(flags)
if errp != nil {
return errp
}
return erra
}
2016-12-17 02:29:52 +00:00
// CleanDependencies removels all dangling dependencies in system
func cleanDependencies(pkgs []string) error {
2016-12-17 02:29:52 +00:00
hanging, err := pac.HangingPackages()
if err != nil {
return err
}
if len(hanging) != 0 {
2017-01-05 16:13:52 +00:00
if !util.ContinueTask("Confirm Removal?", "nN") {
2016-12-17 02:29:52 +00:00
return nil
}
err = pac.CleanRemove(hanging)
}
return err
}
2017-02-15 01:50:26 +00:00
// GetPkgbuild gets the pkgbuild of the package 'pkg' trying the ABS first and then the AUR trying the ABS first and then the AUR.
func getPkgbuild(pkg string) (err error) {
2017-02-15 01:50:26 +00:00
wd, err := os.Getwd()
if err != nil {
return
}
wd = wd + "/"
err = pac.GetPkgbuild(pkg, wd)
if err == nil {
return
}
err = aur.GetPkgbuild(pkg, wd)
return
}