yay/actions.go

71 lines
1.3 KiB
Go
Raw Normal View History

2017-04-29 19:12:12 +02:00
package main
2016-09-13 03:06:24 +02:00
import (
"fmt"
"os"
2016-10-17 00:02:48 +02:00
aur "github.com/jguer/yay/aur"
2017-05-06 19:32:33 +02:00
"github.com/jguer/yay/config"
2016-12-01 01:36:58 +01:00
pac "github.com/jguer/yay/pacman"
2016-09-13 03:06:24 +02:00
)
2016-11-29 02:53:17 +01:00
// Install handles package installs
func install(pkgs []string, flags []string) error {
2016-12-01 01:36:58 +01:00
aurs, repos, _ := pac.PackageSlices(pkgs)
2017-05-07 03:43:49 +02:00
err := config.PassToPacman("-S", repos, flags)
2016-12-02 19:03:31 +01:00
if err != nil {
fmt.Println("Error installing repo packages.")
}
2016-12-01 01:36:58 +01:00
err = aur.Install(aurs, flags)
2016-11-29 02:53:17 +01:00
return err
2016-11-29 02:53:17 +01:00
}
// Upgrade handles updating the cache and installing updates.
func upgrade(flags []string) error {
2017-05-07 03:43:49 +02:00
errp := config.PassToPacman("-Syu", nil, flags)
erra := aur.Upgrade(flags)
if errp != nil {
return errp
}
return erra
}
2016-12-17 03:29:52 +01:00
// CleanDependencies removels all dangling dependencies in system
func cleanDependencies(pkgs []string) error {
2016-12-17 03:29:52 +01:00
hanging, err := pac.HangingPackages()
if err != nil {
return err
}
if len(hanging) != 0 {
2017-05-06 19:32:33 +02:00
if !config.ContinueTask("Confirm Removal?", "nN") {
2016-12-17 03:29:52 +01:00
return nil
}
err = pac.CleanRemove(hanging)
}
return err
}
2017-02-15 02:50:26 +01: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 02:50:26 +01: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
}