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
|
|
|
|
2017-02-05 05:15:44 +01: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
|
2017-05-02 17:46:14 +02:00
|
|
|
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
|
|
|
|
2017-05-02 17:46:14 +02:00
|
|
|
err = aur.Install(aurs, flags)
|
2016-11-29 02:53:17 +01:00
|
|
|
|
2017-05-02 17:46:14 +02:00
|
|
|
return err
|
2016-11-29 02:53:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Upgrade handles updating the cache and installing updates.
|
2017-05-02 17:46:14 +02:00
|
|
|
func upgrade(flags []string) error {
|
2017-05-07 03:43:49 +02:00
|
|
|
errp := config.PassToPacman("-Syu", nil, flags)
|
2016-12-10 00:33:21 +01:00
|
|
|
erra := aur.Upgrade(flags)
|
2016-10-02 18:23:55 +02:00
|
|
|
|
|
|
|
if errp != nil {
|
|
|
|
return errp
|
|
|
|
}
|
|
|
|
|
|
|
|
return erra
|
|
|
|
}
|
|
|
|
|
2016-12-17 03:29:52 +01:00
|
|
|
// CleanDependencies removels all dangling dependencies in system
|
2017-05-02 17:46:14 +02:00
|
|
|
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.
|
2017-05-02 17:46:14 +02:00
|
|
|
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
|
|
|
|
}
|