2017-08-02 17:24:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-05-04 07:24:32 +00:00
|
|
|
"errors"
|
2017-08-02 17:24:03 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
2018-03-28 14:52:20 +00:00
|
|
|
"path/filepath"
|
2018-02-16 21:45:19 +00:00
|
|
|
"strconv"
|
2018-02-21 08:41:25 +00:00
|
|
|
"strings"
|
2018-08-02 15:49:30 +00:00
|
|
|
"sync"
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2020-10-01 11:38:03 +00:00
|
|
|
alpm "github.com/Jguer/go-alpm/v2"
|
2020-05-02 14:17:20 +00:00
|
|
|
gosrc "github.com/Morganamilo/go-srcinfo"
|
2020-05-04 07:24:32 +00:00
|
|
|
"github.com/leonelquinteros/gotext"
|
2020-05-02 14:17:20 +00:00
|
|
|
|
2020-06-13 17:29:50 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/completion"
|
2020-07-31 23:20:00 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/db"
|
2020-07-10 00:36:45 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/dep"
|
2020-06-13 17:29:50 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/intrange"
|
|
|
|
"github.com/Jguer/yay/v10/pkg/multierror"
|
2020-07-10 22:48:30 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/pgp"
|
2020-07-05 00:01:08 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/query"
|
2020-07-05 00:45:23 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/settings"
|
2020-06-13 17:29:50 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/stringset"
|
|
|
|
"github.com/Jguer/yay/v10/pkg/text"
|
2020-07-31 23:20:00 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/upgrade"
|
2017-08-02 17:24:03 +00:00
|
|
|
)
|
|
|
|
|
2020-07-24 21:24:53 +00:00
|
|
|
const gitEmptyTree = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
|
|
|
|
|
2021-01-24 19:31:46 +00:00
|
|
|
func asdeps(cmdArgs *settings.Arguments, pkgs []string) (err error) {
|
2019-10-10 14:55:43 +00:00
|
|
|
if len(pkgs) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
cmdArgs = cmdArgs.CopyGlobal()
|
2021-01-24 19:31:46 +00:00
|
|
|
_ = cmdArgs.AddArg("q", "D", "asdeps")
|
2020-07-08 01:22:01 +00:00
|
|
|
cmdArgs.AddTarget(pkgs...)
|
2021-01-24 19:31:46 +00:00
|
|
|
err = config.Runtime.CmdRunner.Show(passToPacman(cmdArgs))
|
2019-10-10 14:55:43 +00:00
|
|
|
if err != nil {
|
2021-01-24 19:31:46 +00:00
|
|
|
return fmt.Errorf(gotext.Get("error updating package install reason to dependency"))
|
2019-10-10 14:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-24 19:31:46 +00:00
|
|
|
func asexp(cmdArgs *settings.Arguments, pkgs []string) (err error) {
|
2019-10-10 14:55:43 +00:00
|
|
|
if len(pkgs) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
cmdArgs = cmdArgs.CopyGlobal()
|
2021-01-24 19:31:46 +00:00
|
|
|
_ = cmdArgs.AddArg("q", "D", "asexplicit")
|
2020-07-08 01:22:01 +00:00
|
|
|
cmdArgs.AddTarget(pkgs...)
|
2021-01-24 19:31:46 +00:00
|
|
|
err = config.Runtime.CmdRunner.Show(passToPacman(cmdArgs))
|
2019-10-10 14:55:43 +00:00
|
|
|
if err != nil {
|
2021-01-24 19:31:46 +00:00
|
|
|
return fmt.Errorf(gotext.Get("error updating package install reason to explicit"))
|
2019-10-10 14:55:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-01-20 22:37:10 +00:00
|
|
|
// Install handles package installs
|
2020-08-16 21:41:38 +00:00
|
|
|
func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProviders bool) (err error) {
|
2019-10-16 21:25:40 +00:00
|
|
|
var incompatible stringset.StringSet
|
2020-07-10 00:36:45 +00:00
|
|
|
var do *dep.Order
|
2018-03-21 00:26:56 +00:00
|
|
|
|
2020-07-31 23:20:00 +00:00
|
|
|
var aurUp upgrade.UpSlice
|
|
|
|
var repoUp upgrade.UpSlice
|
2018-03-29 02:42:11 +00:00
|
|
|
|
2018-08-11 04:00:46 +00:00
|
|
|
var srcinfos map[string]*gosrc.Srcinfo
|
2018-04-11 03:43:51 +00:00
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
warnings := query.NewWarnings()
|
2018-03-29 02:42:11 +00:00
|
|
|
|
2020-07-05 00:45:23 +00:00
|
|
|
if config.Runtime.Mode == settings.ModeAny || config.Runtime.Mode == settings.ModeRepo {
|
2018-06-22 13:44:38 +00:00
|
|
|
if config.CombinedUpgrade {
|
2020-07-08 01:22:01 +00:00
|
|
|
if cmdArgs.ExistsArg("y", "refresh") {
|
|
|
|
err = earlyRefresh(cmdArgs)
|
2018-06-22 13:44:38 +00:00
|
|
|
if err != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
return fmt.Errorf(gotext.Get("error refreshing databases"))
|
2018-06-22 13:44:38 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-08 01:22:01 +00:00
|
|
|
} else if cmdArgs.ExistsArg("y", "refresh") || cmdArgs.ExistsArg("u", "sysupgrade") || len(cmdArgs.Targets) > 0 {
|
2020-08-16 22:02:14 +00:00
|
|
|
err = earlyPacmanCall(cmdArgs, dbExecutor)
|
2018-06-22 13:44:38 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-07-19 18:53:17 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-22 13:44:38 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
// we may have done -Sy, our handle now has an old
|
|
|
|
// database.
|
2020-08-16 22:02:14 +00:00
|
|
|
err = dbExecutor.RefreshHandle()
|
2020-07-31 22:01:01 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-22 13:44:38 +00:00
|
|
|
|
2020-07-31 23:20:00 +00:00
|
|
|
localNames, remoteNames, err := query.GetPackageNamesBySource(dbExecutor)
|
2018-07-19 18:53:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 13:44:38 +00:00
|
|
|
}
|
|
|
|
|
2019-10-16 21:58:55 +00:00
|
|
|
remoteNamesCache := stringset.FromSlice(remoteNames)
|
|
|
|
localNamesCache := stringset.FromSlice(localNames)
|
2018-07-19 18:53:17 +00:00
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
requestTargets := cmdArgs.Copy().Targets
|
2018-06-22 13:44:38 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
// create the arguments to pass for the repo install
|
2020-07-08 01:22:01 +00:00
|
|
|
arguments := cmdArgs.Copy()
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.DelArg("asdeps", "asdep")
|
|
|
|
arguments.DelArg("asexplicit", "asexp")
|
|
|
|
arguments.Op = "S"
|
|
|
|
arguments.ClearTargets()
|
2018-02-21 08:41:25 +00:00
|
|
|
|
2020-07-05 00:45:23 +00:00
|
|
|
if config.Runtime.Mode == settings.ModeAUR {
|
|
|
|
arguments.DelArg("u", "sysupgrade")
|
2018-05-31 15:23:15 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
// if we are doing -u also request all packages needing update
|
2020-07-08 01:22:01 +00:00
|
|
|
if cmdArgs.ExistsArg("u", "sysupgrade") {
|
2021-02-05 21:47:03 +00:00
|
|
|
aurUp, repoUp, err = upList(warnings, dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"), func(upgrade.Upgrade) bool { return true })
|
2018-01-04 00:59:57 +00:00
|
|
|
if err != nil {
|
2018-02-18 23:46:25 +00:00
|
|
|
return err
|
2018-01-04 00:59:57 +00:00
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
warnings.Print()
|
2018-05-30 02:21:17 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
ignore, aurUp, errUp := upgradePkgs(aurUp, repoUp)
|
|
|
|
if errUp != nil {
|
|
|
|
return errUp
|
2018-05-30 02:21:17 +00:00
|
|
|
}
|
2018-04-04 20:51:57 +00:00
|
|
|
|
|
|
|
for _, up := range repoUp {
|
2019-10-05 17:39:31 +00:00
|
|
|
if !ignore.Get(up.Name) {
|
2018-04-04 20:51:57 +00:00
|
|
|
requestTargets = append(requestTargets, up.Name)
|
2020-07-08 01:22:01 +00:00
|
|
|
cmdArgs.AddTarget(up.Name)
|
2018-04-04 20:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for up := range aurUp {
|
2018-08-09 21:28:27 +00:00
|
|
|
requestTargets = append(requestTargets, "aur/"+up)
|
2020-07-08 01:22:01 +00:00
|
|
|
cmdArgs.AddTarget("aur/" + up)
|
2018-04-04 20:51:57 +00:00
|
|
|
}
|
|
|
|
|
2018-05-11 23:24:47 +00:00
|
|
|
if len(ignore) > 0 {
|
2020-07-26 21:40:21 +00:00
|
|
|
arguments.CreateOrAppendOption("ignore", ignore.ToSlice()...)
|
2018-05-11 23:12:33 +00:00
|
|
|
}
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
targets := stringset.FromSlice(cmdArgs.Targets)
|
2018-06-02 14:01:39 +00:00
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
dp, err := dep.GetPool(requestTargets,
|
2020-08-16 22:02:14 +00:00
|
|
|
warnings, dbExecutor, config.Runtime.Mode,
|
2020-08-18 22:17:35 +00:00
|
|
|
ignoreProviders, settings.NoConfirm, config.Provides, config.ReBuild, config.RequestSplitN)
|
2018-05-10 13:36:38 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
if !cmdArgs.ExistsDouble("d", "nodeps") {
|
2020-01-20 19:59:21 +00:00
|
|
|
err = dp.CheckMissing()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-05-10 13:36:38 +00:00
|
|
|
}
|
2018-06-11 18:48:20 +00:00
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
if len(dp.Aur) == 0 {
|
2018-07-03 12:42:13 +00:00
|
|
|
if !config.CombinedUpgrade {
|
2020-07-08 01:22:01 +00:00
|
|
|
if cmdArgs.ExistsArg("u", "sysupgrade") {
|
2020-05-04 07:24:32 +00:00
|
|
|
fmt.Println(gotext.Get(" there is nothing to do"))
|
2018-07-23 23:13:34 +00:00
|
|
|
}
|
2018-07-03 12:42:13 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
cmdArgs.Op = "S"
|
|
|
|
cmdArgs.DelArg("y", "refresh")
|
2020-07-06 00:02:12 +00:00
|
|
|
if arguments.ExistsArg("ignore") {
|
2020-07-26 21:48:33 +00:00
|
|
|
cmdArgs.CreateOrAppendOption("ignore", arguments.GetArgs("ignore")...)
|
2020-07-06 00:02:12 +00:00
|
|
|
}
|
2020-08-18 23:48:07 +00:00
|
|
|
return config.Runtime.CmdRunner.Show(passToPacman(cmdArgs))
|
2018-06-10 23:26:36 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 20:02:44 +00:00
|
|
|
if len(dp.Aur) > 0 && os.Geteuid() == 0 {
|
2020-05-04 07:24:32 +00:00
|
|
|
return fmt.Errorf(gotext.Get("refusing to install AUR packages as root, aborting"))
|
2018-06-10 23:26:36 +00:00
|
|
|
}
|
2018-05-10 13:36:38 +00:00
|
|
|
|
2020-01-20 19:59:21 +00:00
|
|
|
var conflicts stringset.MapStringSet
|
2020-07-08 01:22:01 +00:00
|
|
|
if !cmdArgs.ExistsDouble("d", "nodeps") {
|
2020-08-18 22:17:35 +00:00
|
|
|
conflicts, err = dp.CheckConflicts(config.UseAsk, settings.NoConfirm)
|
2020-01-20 19:59:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-05-10 13:36:38 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
do = dep.GetOrder(dp)
|
2019-01-15 18:41:38 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range do.Repo {
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.AddTarget(pkg.DB().Name() + "/" + pkg.Name())
|
2018-02-19 19:38:34 +00:00
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
for _, pkg := range dp.Groups {
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.AddTarget(pkg)
|
2018-03-16 01:14:34 +00:00
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
if len(do.Aur) == 0 && len(arguments.Targets) == 0 && (!cmdArgs.ExistsArg("u", "sysupgrade") || config.Runtime.Mode == settings.ModeAUR) {
|
2020-05-04 07:24:32 +00:00
|
|
|
fmt.Println(gotext.Get(" there is nothing to do"))
|
2018-02-20 01:23:16 +00:00
|
|
|
return nil
|
|
|
|
}
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
do.Print()
|
2018-06-10 23:26:36 +00:00
|
|
|
fmt.Println()
|
2018-02-16 21:45:19 +00:00
|
|
|
|
2019-06-11 13:54:24 +00:00
|
|
|
if config.CleanAfter {
|
|
|
|
defer cleanAfter(do.Aur)
|
|
|
|
}
|
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
if do.HasMake() {
|
2019-03-07 20:02:44 +00:00
|
|
|
switch config.RemoveMake {
|
|
|
|
case "yes":
|
2019-10-13 11:15:51 +00:00
|
|
|
defer func() {
|
|
|
|
err = removeMake(do)
|
|
|
|
}()
|
|
|
|
|
2019-03-07 20:02:44 +00:00
|
|
|
case "no":
|
2019-06-11 13:54:24 +00:00
|
|
|
break
|
2019-03-07 20:02:44 +00:00
|
|
|
default:
|
2020-08-18 22:17:35 +00:00
|
|
|
if text.ContinueTask(gotext.Get("Remove make dependencies after install?"), false, settings.NoConfirm) {
|
2019-10-13 11:15:51 +00:00
|
|
|
defer func() {
|
|
|
|
err = removeMake(do)
|
|
|
|
}()
|
2019-06-11 13:54:24 +00:00
|
|
|
}
|
2018-06-10 23:26:36 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-11 03:43:51 +00:00
|
|
|
|
2018-06-10 23:26:36 +00:00
|
|
|
if config.CleanMenu {
|
2019-01-15 18:41:38 +00:00
|
|
|
if anyExistInCache(do.Aur) {
|
|
|
|
askClean := pkgbuildNumberMenu(do.Aur, remoteNamesCache)
|
2020-05-02 14:17:20 +00:00
|
|
|
toClean, errClean := cleanNumberMenu(do.Aur, remoteNamesCache, askClean)
|
|
|
|
if errClean != nil {
|
|
|
|
return errClean
|
2018-08-18 19:50:20 +00:00
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-08-18 19:50:20 +00:00
|
|
|
cleanBuilds(toClean)
|
|
|
|
}
|
2018-06-10 23:26:36 +00:00
|
|
|
}
|
2018-04-11 15:47:00 +00:00
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
toSkip := pkgbuildsToSkip(do.Aur, targets)
|
|
|
|
cloned, err := downloadPkgbuilds(do.Aur, toSkip, config.BuildDir)
|
2018-06-10 23:26:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
var toDiff []dep.Base
|
|
|
|
var toEdit []dep.Base
|
2018-02-15 20:51:18 +00:00
|
|
|
|
2018-06-10 23:26:36 +00:00
|
|
|
if config.DiffMenu {
|
2019-01-15 18:41:38 +00:00
|
|
|
pkgbuildNumberMenu(do.Aur, remoteNamesCache)
|
|
|
|
toDiff, err = diffNumberMenu(do.Aur, remoteNamesCache)
|
2018-02-16 15:33:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-10 01:02:24 +00:00
|
|
|
|
2018-06-10 23:26:36 +00:00
|
|
|
if len(toDiff) > 0 {
|
2018-08-11 03:51:10 +00:00
|
|
|
err = showPkgbuildDiffs(toDiff, cloned)
|
2018-06-10 14:56:57 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-10 23:26:36 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-10 14:56:57 +00:00
|
|
|
|
2018-06-12 20:06:21 +00:00
|
|
|
if len(toDiff) > 0 {
|
2020-08-18 22:17:35 +00:00
|
|
|
oldValue := settings.NoConfirm
|
|
|
|
settings.NoConfirm = false
|
2018-06-12 20:06:21 +00:00
|
|
|
fmt.Println()
|
2020-08-18 22:17:35 +00:00
|
|
|
if !text.ContinueTask(gotext.Get("Proceed with install?"), true, settings.NoConfirm) {
|
2020-05-04 07:24:32 +00:00
|
|
|
return fmt.Errorf(gotext.Get("aborting due to user"))
|
2018-06-12 20:06:21 +00:00
|
|
|
}
|
2020-05-02 14:17:20 +00:00
|
|
|
err = updatePkgbuildSeenRef(toDiff)
|
2019-10-13 11:15:51 +00:00
|
|
|
if err != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
text.Errorln(err.Error())
|
2019-10-13 11:15:51 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 22:17:35 +00:00
|
|
|
settings.NoConfirm = oldValue
|
2018-06-12 20:06:21 +00:00
|
|
|
}
|
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
err = mergePkgbuilds(do.Aur)
|
2018-06-12 20:06:21 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
srcinfos, err = parseSrcinfoFiles(do.Aur, true)
|
2018-07-19 21:19:24 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-06-10 23:26:36 +00:00
|
|
|
if config.EditMenu {
|
2019-01-15 18:41:38 +00:00
|
|
|
pkgbuildNumberMenu(do.Aur, remoteNamesCache)
|
|
|
|
toEdit, err = editNumberMenu(do.Aur, remoteNamesCache)
|
2018-06-10 23:26:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-10 14:56:57 +00:00
|
|
|
}
|
|
|
|
|
2018-06-10 23:26:36 +00:00
|
|
|
if len(toEdit) > 0 {
|
2018-08-11 04:00:46 +00:00
|
|
|
err = editPkgbuilds(toEdit, srcinfos)
|
2018-03-09 22:11:30 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-10 14:56:57 +00:00
|
|
|
}
|
2018-06-10 23:26:36 +00:00
|
|
|
}
|
2018-06-10 14:56:57 +00:00
|
|
|
|
2018-06-12 20:06:21 +00:00
|
|
|
if len(toEdit) > 0 {
|
2020-08-18 22:17:35 +00:00
|
|
|
oldValue := settings.NoConfirm
|
|
|
|
settings.NoConfirm = false
|
2018-06-10 23:26:36 +00:00
|
|
|
fmt.Println()
|
2020-08-18 22:17:35 +00:00
|
|
|
if !text.ContinueTask(gotext.Get("Proceed with install?"), true, settings.NoConfirm) {
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("aborting due to user"))
|
2018-02-16 15:33:17 +00:00
|
|
|
}
|
2020-08-18 22:17:35 +00:00
|
|
|
settings.NoConfirm = oldValue
|
2018-06-10 23:26:36 +00:00
|
|
|
}
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2020-07-31 23:20:00 +00:00
|
|
|
incompatible, err = getIncompatible(do.Aur, srcinfos, dbExecutor)
|
2018-06-10 23:26:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-19 16:51:11 +00:00
|
|
|
|
2018-06-10 23:26:36 +00:00
|
|
|
if config.PGPFetch {
|
2020-08-18 22:17:35 +00:00
|
|
|
err = pgp.CheckPgpKeys(do.Aur, srcinfos, config.GpgBin, config.GpgFlags, settings.NoConfirm)
|
2018-01-17 21:48:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-21 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 12:42:13 +00:00
|
|
|
if !config.CombinedUpgrade {
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.DelArg("u", "sysupgrade")
|
2018-07-03 12:42:13 +00:00
|
|
|
}
|
|
|
|
|
2020-07-05 00:45:23 +00:00
|
|
|
if len(arguments.Targets) > 0 || arguments.ExistsArg("u") {
|
2020-08-18 23:48:07 +00:00
|
|
|
if errShow := config.Runtime.CmdRunner.Show(passToPacman(arguments)); errShow != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("error installing repo packages"))
|
2018-03-21 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2019-10-10 14:55:43 +00:00
|
|
|
deps := make([]string, 0)
|
|
|
|
exp := make([]string, 0)
|
2018-03-21 00:26:56 +00:00
|
|
|
|
2019-10-04 18:33:54 +00:00
|
|
|
for _, pkg := range do.Repo {
|
2019-10-05 17:39:31 +00:00
|
|
|
if !dp.Explicit.Get(pkg.Name()) && !localNamesCache.Get(pkg.Name()) && !remoteNamesCache.Get(pkg.Name()) {
|
2019-10-10 14:55:43 +00:00
|
|
|
deps = append(deps, pkg.Name())
|
2018-05-29 21:35:58 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
if cmdArgs.ExistsArg("asdeps", "asdep") && dp.Explicit.Get(pkg.Name()) {
|
2019-10-10 14:55:43 +00:00
|
|
|
deps = append(deps, pkg.Name())
|
2020-07-08 01:22:01 +00:00
|
|
|
} else if cmdArgs.ExistsArg("asexp", "asexplicit") && dp.Explicit.Get(pkg.Name()) {
|
2019-10-10 14:55:43 +00:00
|
|
|
exp = append(exp, pkg.Name())
|
2018-03-22 15:22:05 +00:00
|
|
|
}
|
2018-03-21 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
if errDeps := asdeps(cmdArgs, deps); errDeps != nil {
|
2020-05-02 14:17:20 +00:00
|
|
|
return errDeps
|
2018-03-21 00:26:56 +00:00
|
|
|
}
|
2020-07-08 01:22:01 +00:00
|
|
|
if errExp := asexp(cmdArgs, exp); errExp != nil {
|
2020-05-02 14:17:20 +00:00
|
|
|
return errExp
|
2018-05-29 21:35:58 +00:00
|
|
|
}
|
2018-03-21 00:26:56 +00:00
|
|
|
}
|
|
|
|
|
2020-08-08 16:43:37 +00:00
|
|
|
go func() {
|
|
|
|
_ = completion.Update(dbExecutor, config.AURURL, config.Runtime.CompletionPath, config.CompletionInterval, false)
|
|
|
|
}()
|
2018-07-24 13:16:12 +00:00
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
err = downloadPkgbuildsSources(do.Aur, incompatible)
|
2018-06-10 23:26:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2020-07-31 23:20:00 +00:00
|
|
|
err = buildInstallPkgbuilds(cmdArgs, dbExecutor, dp, do, srcinfos, incompatible, conflicts)
|
2018-06-10 23:26:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
|
2019-06-11 13:54:24 +00:00
|
|
|
return nil
|
|
|
|
}
|
2018-06-10 23:26:36 +00:00
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func removeMake(do *dep.Order) error {
|
2020-07-05 00:45:23 +00:00
|
|
|
removeArguments := settings.MakeArguments()
|
|
|
|
err := removeArguments.AddArg("R", "u")
|
2019-10-13 11:15:51 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-15 21:23:34 +00:00
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
for _, pkg := range do.GetMake() {
|
2020-07-05 00:45:23 +00:00
|
|
|
removeArguments.AddTarget(pkg)
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
|
2020-08-18 22:17:35 +00:00
|
|
|
oldValue := settings.NoConfirm
|
|
|
|
settings.NoConfirm = true
|
2020-08-18 23:48:07 +00:00
|
|
|
err = config.Runtime.CmdRunner.Show(passToPacman(removeArguments))
|
2020-08-18 22:17:35 +00:00
|
|
|
settings.NoConfirm = oldValue
|
2019-10-13 11:15:51 +00:00
|
|
|
|
|
|
|
return err
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 21:41:38 +00:00
|
|
|
func inRepos(dbExecutor db.Executor, pkg string) bool {
|
2020-07-10 00:36:45 +00:00
|
|
|
target := dep.ToTarget(pkg)
|
2018-07-19 18:53:17 +00:00
|
|
|
|
2019-02-04 16:56:02 +00:00
|
|
|
if target.DB == "aur" {
|
2018-07-19 18:53:17 +00:00
|
|
|
return false
|
2019-02-04 16:56:02 +00:00
|
|
|
} else if target.DB != "" {
|
2018-07-19 18:53:17 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
previousHideMenus := settings.HideMenus
|
|
|
|
settings.HideMenus = false
|
2020-07-31 23:20:00 +00:00
|
|
|
exists := dbExecutor.SyncSatisfierExists(target.DepString())
|
2020-07-10 00:36:45 +00:00
|
|
|
settings.HideMenus = previousHideMenus
|
2018-07-19 18:53:17 +00:00
|
|
|
|
2020-07-31 23:20:00 +00:00
|
|
|
return exists || len(dbExecutor.PackagesFromGroup(target.Name)) > 0
|
2018-07-19 18:53:17 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 21:41:38 +00:00
|
|
|
func earlyPacmanCall(cmdArgs *settings.Arguments, dbExecutor db.Executor) error {
|
2020-07-08 01:22:01 +00:00
|
|
|
arguments := cmdArgs.Copy()
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.Op = "S"
|
2020-07-08 01:22:01 +00:00
|
|
|
targets := cmdArgs.Targets
|
|
|
|
cmdArgs.ClearTargets()
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.ClearTargets()
|
2018-07-19 18:53:17 +00:00
|
|
|
|
2020-07-05 00:45:23 +00:00
|
|
|
if config.Runtime.Mode == settings.ModeRepo {
|
|
|
|
arguments.Targets = targets
|
2018-07-19 18:53:17 +00:00
|
|
|
} else {
|
2020-05-02 14:17:20 +00:00
|
|
|
// separate aur and repo targets
|
2018-07-19 18:53:17 +00:00
|
|
|
for _, target := range targets {
|
2020-07-31 23:20:00 +00:00
|
|
|
if inRepos(dbExecutor, target) {
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.AddTarget(target)
|
2018-07-19 18:53:17 +00:00
|
|
|
} else {
|
2020-07-08 01:22:01 +00:00
|
|
|
cmdArgs.AddTarget(target)
|
2018-07-19 18:53:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
if cmdArgs.ExistsArg("y", "refresh") || cmdArgs.ExistsArg("u", "sysupgrade") || len(arguments.Targets) > 0 {
|
2020-08-18 23:48:07 +00:00
|
|
|
if err := config.Runtime.CmdRunner.Show(passToPacman(arguments)); err != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("error installing repo packages"))
|
2018-07-19 18:53:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
func earlyRefresh(cmdArgs *settings.Arguments) error {
|
|
|
|
arguments := cmdArgs.Copy()
|
|
|
|
cmdArgs.DelArg("y", "refresh")
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.DelArg("u", "sysupgrade")
|
|
|
|
arguments.DelArg("s", "search")
|
|
|
|
arguments.DelArg("i", "info")
|
|
|
|
arguments.DelArg("l", "list")
|
|
|
|
arguments.ClearTargets()
|
2020-08-18 23:48:07 +00:00
|
|
|
return config.Runtime.CmdRunner.Show(passToPacman(arguments))
|
2018-07-19 18:53:17 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 21:41:38 +00:00
|
|
|
func getIncompatible(bases []dep.Base, srcinfos map[string]*gosrc.Srcinfo, dbExecutor db.Executor) (stringset.StringSet, error) {
|
2019-10-16 21:25:40 +00:00
|
|
|
incompatible := make(stringset.StringSet)
|
2020-07-10 00:36:45 +00:00
|
|
|
basesMap := make(map[string]dep.Base)
|
2020-07-31 23:20:00 +00:00
|
|
|
alpmArch, err := dbExecutor.AlpmArch()
|
2018-03-19 16:51:11 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2018-03-21 00:26:56 +00:00
|
|
|
nextpkg:
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, base := range bases {
|
|
|
|
for _, arch := range srcinfos[base.Pkgbase()].Arch {
|
2018-03-19 16:51:11 +00:00
|
|
|
if arch == "any" || arch == alpmArch {
|
|
|
|
continue nextpkg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
incompatible.Set(base.Pkgbase())
|
2018-08-11 04:21:06 +00:00
|
|
|
basesMap[base.Pkgbase()] = base
|
2018-03-19 16:51:11 +00:00
|
|
|
}
|
|
|
|
|
2018-04-01 17:54:33 +00:00
|
|
|
if len(incompatible) > 0 {
|
2020-05-04 07:24:32 +00:00
|
|
|
text.Warnln(gotext.Get("The following packages are not compatible with your architecture:"))
|
2018-04-01 17:54:33 +00:00
|
|
|
for pkg := range incompatible {
|
2020-08-16 22:09:43 +00:00
|
|
|
fmt.Print(" " + text.Cyan(basesMap[pkg].String()))
|
2018-03-19 16:51:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println()
|
|
|
|
|
2020-08-18 22:17:35 +00:00
|
|
|
if !text.ContinueTask(gotext.Get("Try to build them anyway?"), true, settings.NoConfirm) {
|
2020-05-04 07:24:32 +00:00
|
|
|
return nil, errors.New(gotext.Get("aborting due to user"))
|
2018-03-19 16:51:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-01 17:54:33 +00:00
|
|
|
return incompatible, nil
|
2018-03-19 16:51:11 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
func parsePackageList(dir string) (pkgdests map[string]string, pkgVersion string, err error) {
|
2020-08-21 23:24:52 +00:00
|
|
|
stdout, stderr, err := config.Runtime.CmdRunner.Capture(
|
|
|
|
config.Runtime.CmdBuilder.BuildMakepkgCmd(dir, "--packagelist"), 0)
|
2018-04-12 15:39:01 +00:00
|
|
|
if err != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
return nil, "", fmt.Errorf("%s %s", stderr, err)
|
2018-04-12 15:39:01 +00:00
|
|
|
}
|
|
|
|
|
2018-05-31 03:37:08 +00:00
|
|
|
lines := strings.Split(stdout, "\n")
|
2020-05-02 14:17:20 +00:00
|
|
|
pkgdests = make(map[string]string)
|
2018-04-12 15:39:01 +00:00
|
|
|
|
2018-05-31 03:37:08 +00:00
|
|
|
for _, line := range lines {
|
|
|
|
if line == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
fileName := filepath.Base(line)
|
|
|
|
split := strings.Split(fileName, "-")
|
|
|
|
|
|
|
|
if len(split) < 4 {
|
2020-05-04 07:24:32 +00:00
|
|
|
return nil, "", errors.New(gotext.Get("cannot find package name: %v", split))
|
2018-05-31 03:37:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// pkgname-pkgver-pkgrel-arch.pkgext
|
|
|
|
// This assumes 3 dashes after the pkgname, Will cause an error
|
|
|
|
// if the PKGEXT contains a dash. Please no one do that.
|
2020-05-02 14:17:20 +00:00
|
|
|
pkgName := strings.Join(split[:len(split)-3], "-")
|
|
|
|
pkgVersion = strings.Join(split[len(split)-3:len(split)-1], "-")
|
|
|
|
pkgdests[pkgName] = line
|
2018-04-12 15:39:01 +00:00
|
|
|
}
|
2018-05-31 03:37:08 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
return pkgdests, pkgVersion, nil
|
2018-04-12 15:39:01 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func anyExistInCache(bases []dep.Base) bool {
|
2018-08-18 19:50:20 +00:00
|
|
|
for _, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg)
|
|
|
|
|
|
|
|
if _, err := os.Stat(dir); !os.IsNotExist(err) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func pkgbuildNumberMenu(bases []dep.Base, installed stringset.StringSet) bool {
|
2018-03-09 22:11:30 +00:00
|
|
|
toPrint := ""
|
|
|
|
askClean := false
|
|
|
|
|
2018-08-10 03:40:27 +00:00
|
|
|
for n, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg)
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2020-08-16 22:09:43 +00:00
|
|
|
toPrint += fmt.Sprintf(text.Magenta("%3d")+" %-40s", len(bases)-n,
|
|
|
|
text.Bold(base.String()))
|
2018-08-10 03:40:27 +00:00
|
|
|
|
|
|
|
anyInstalled := false
|
|
|
|
for _, b := range base {
|
2019-10-05 17:39:31 +00:00
|
|
|
anyInstalled = anyInstalled || installed.Get(b.Name)
|
2018-08-10 03:40:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if anyInstalled {
|
2020-08-16 22:09:43 +00:00
|
|
|
toPrint += text.Bold(text.Green(gotext.Get(" (Installed)")))
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := os.Stat(dir); !os.IsNotExist(err) {
|
2020-08-16 22:09:43 +00:00
|
|
|
toPrint += text.Bold(text.Green(gotext.Get(" (Build Files Exist)")))
|
2018-03-09 22:11:30 +00:00
|
|
|
askClean = true
|
|
|
|
}
|
|
|
|
|
|
|
|
toPrint += "\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Print(toPrint)
|
|
|
|
|
2018-06-10 14:56:57 +00:00
|
|
|
return askClean
|
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func cleanNumberMenu(bases []dep.Base, installed stringset.StringSet, hasClean bool) ([]dep.Base, error) {
|
|
|
|
toClean := make([]dep.Base, 0)
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2018-06-10 14:56:57 +00:00
|
|
|
if !hasClean {
|
|
|
|
return toClean, nil
|
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2020-05-04 07:24:32 +00:00
|
|
|
text.Infoln(gotext.Get("Packages to cleanBuild?"))
|
2020-08-16 22:09:43 +00:00
|
|
|
text.Infoln(gotext.Get("%s [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)", text.Cyan(gotext.Get("[N]one"))))
|
2018-06-10 14:56:57 +00:00
|
|
|
cleanInput, err := getInput(config.AnswerClean)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2019-10-16 21:36:08 +00:00
|
|
|
cInclude, cExclude, cOtherInclude, cOtherExclude := intrange.ParseNumberMenu(cleanInput)
|
2018-06-10 14:56:57 +00:00
|
|
|
cIsInclude := len(cExclude) == 0 && len(cOtherExclude) == 0
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if cOtherInclude.Get("abort") || cOtherInclude.Get("ab") {
|
2020-05-04 07:24:32 +00:00
|
|
|
return nil, fmt.Errorf(gotext.Get("aborting due to user"))
|
2018-06-10 14:56:57 +00:00
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if !cOtherInclude.Get("n") && !cOtherInclude.Get("none") {
|
2018-08-10 03:40:27 +00:00
|
|
|
for i, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
|
|
|
anyInstalled := false
|
|
|
|
for _, b := range base {
|
2019-10-05 17:39:31 +00:00
|
|
|
anyInstalled = anyInstalled || installed.Get(b.Name)
|
2018-08-10 03:40:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg)
|
2018-06-10 14:56:57 +00:00
|
|
|
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
|
|
|
continue
|
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2019-10-05 18:23:13 +00:00
|
|
|
if !cIsInclude && cExclude.Get(len(bases)-i) {
|
2018-06-10 14:56:57 +00:00
|
|
|
continue
|
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if anyInstalled && (cOtherInclude.Get("i") || cOtherInclude.Get("installed")) {
|
2018-08-10 03:40:27 +00:00
|
|
|
toClean = append(toClean, base)
|
2018-06-10 14:56:57 +00:00
|
|
|
continue
|
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if !anyInstalled && (cOtherInclude.Get("no") || cOtherInclude.Get("notinstalled")) {
|
2018-08-10 03:40:27 +00:00
|
|
|
toClean = append(toClean, base)
|
2018-06-10 14:56:57 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if cOtherInclude.Get("a") || cOtherInclude.Get("all") {
|
2018-08-10 03:40:27 +00:00
|
|
|
toClean = append(toClean, base)
|
2018-06-10 14:56:57 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2019-10-05 18:23:13 +00:00
|
|
|
if cIsInclude && (cInclude.Get(len(bases)-i) || cOtherInclude.Get(pkg)) {
|
2018-08-10 03:40:27 +00:00
|
|
|
toClean = append(toClean, base)
|
2018-06-10 14:56:57 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2019-10-05 18:23:13 +00:00
|
|
|
if !cIsInclude && (!cExclude.Get(len(bases)-i) && !cOtherExclude.Get(pkg)) {
|
2018-08-10 03:40:27 +00:00
|
|
|
toClean = append(toClean, base)
|
2018-06-10 14:56:57 +00:00
|
|
|
continue
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-10 14:56:57 +00:00
|
|
|
return toClean, nil
|
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func editNumberMenu(bases []dep.Base, installed stringset.StringSet) ([]dep.Base, error) {
|
2018-08-10 03:40:27 +00:00
|
|
|
return editDiffNumberMenu(bases, installed, false)
|
2018-06-10 14:56:57 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func diffNumberMenu(bases []dep.Base, installed stringset.StringSet) ([]dep.Base, error) {
|
2018-08-10 03:40:27 +00:00
|
|
|
return editDiffNumberMenu(bases, installed, true)
|
2018-06-10 14:56:57 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func editDiffNumberMenu(bases []dep.Base, installed stringset.StringSet, diff bool) ([]dep.Base, error) {
|
|
|
|
toEdit := make([]dep.Base, 0)
|
2018-06-11 18:13:40 +00:00
|
|
|
var editInput string
|
|
|
|
var err error
|
|
|
|
|
2018-06-10 14:56:57 +00:00
|
|
|
if diff {
|
2020-05-04 07:24:32 +00:00
|
|
|
text.Infoln(gotext.Get("Diffs to show?"))
|
2020-08-16 22:09:43 +00:00
|
|
|
text.Infoln(gotext.Get("%s [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)", text.Cyan(gotext.Get("[N]one"))))
|
2018-06-11 18:13:40 +00:00
|
|
|
editInput, err = getInput(config.AnswerDiff)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-05-31 19:31:45 +00:00
|
|
|
} else {
|
2020-05-04 07:24:32 +00:00
|
|
|
text.Infoln(gotext.Get("PKGBUILDs to edit?"))
|
2020-08-16 22:09:43 +00:00
|
|
|
text.Infoln(gotext.Get("%s [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)", text.Cyan(gotext.Get("[N]one"))))
|
2018-06-11 18:13:40 +00:00
|
|
|
editInput, err = getInput(config.AnswerEdit)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
|
2019-10-16 21:36:08 +00:00
|
|
|
eInclude, eExclude, eOtherInclude, eOtherExclude := intrange.ParseNumberMenu(editInput)
|
2018-03-09 22:11:30 +00:00
|
|
|
eIsInclude := len(eExclude) == 0 && len(eOtherExclude) == 0
|
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if eOtherInclude.Get("abort") || eOtherInclude.Get("ab") {
|
2020-05-04 07:24:32 +00:00
|
|
|
return nil, fmt.Errorf(gotext.Get("aborting due to user"))
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if !eOtherInclude.Get("n") && !eOtherInclude.Get("none") {
|
2018-08-10 03:40:27 +00:00
|
|
|
for i, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
|
|
|
anyInstalled := false
|
|
|
|
for _, b := range base {
|
2019-10-05 17:39:31 +00:00
|
|
|
anyInstalled = anyInstalled || installed.Get(b.Name)
|
2018-08-10 03:40:27 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 18:23:13 +00:00
|
|
|
if !eIsInclude && eExclude.Get(len(bases)-i) {
|
2018-03-09 22:11:30 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if anyInstalled && (eOtherInclude.Get("i") || eOtherInclude.Get("installed")) {
|
2018-08-10 03:40:27 +00:00
|
|
|
toEdit = append(toEdit, base)
|
2018-03-09 22:11:30 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if !anyInstalled && (eOtherInclude.Get("no") || eOtherInclude.Get("notinstalled")) {
|
2018-08-10 03:40:27 +00:00
|
|
|
toEdit = append(toEdit, base)
|
2018-03-09 22:11:30 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if eOtherInclude.Get("a") || eOtherInclude.Get("all") {
|
2018-08-10 03:40:27 +00:00
|
|
|
toEdit = append(toEdit, base)
|
2018-03-09 22:11:30 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2019-10-05 18:23:13 +00:00
|
|
|
if eIsInclude && (eInclude.Get(len(bases)-i) || eOtherInclude.Get(pkg)) {
|
2018-08-10 03:40:27 +00:00
|
|
|
toEdit = append(toEdit, base)
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
|
2019-10-05 18:23:13 +00:00
|
|
|
if !eIsInclude && (!eExclude.Get(len(bases)-i) && !eOtherExclude.Get(pkg)) {
|
2018-08-10 03:40:27 +00:00
|
|
|
toEdit = append(toEdit, base)
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-10 14:56:57 +00:00
|
|
|
return toEdit, nil
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func updatePkgbuildSeenRef(bases []dep.Base) error {
|
2019-10-16 21:38:54 +00:00
|
|
|
var errMulti multierror.MultiError
|
2019-10-07 10:24:19 +00:00
|
|
|
for _, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
2019-11-04 04:20:50 +00:00
|
|
|
err := gitUpdateSeenRef(config.BuildDir, pkg)
|
|
|
|
if err != nil {
|
|
|
|
errMulti.Add(err)
|
2019-10-07 10:24:19 +00:00
|
|
|
}
|
|
|
|
}
|
2019-10-13 22:23:55 +00:00
|
|
|
return errMulti.Return()
|
2019-10-07 10:24:19 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func showPkgbuildDiffs(bases []dep.Base, cloned stringset.StringSet) error {
|
2019-10-16 21:38:54 +00:00
|
|
|
var errMulti multierror.MultiError
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg)
|
2019-11-04 04:20:50 +00:00
|
|
|
start, err := getLastSeenHash(config.BuildDir, pkg)
|
|
|
|
if err != nil {
|
|
|
|
errMulti.Add(err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if cloned.Get(pkg) {
|
|
|
|
start = gitEmptyTree
|
|
|
|
} else {
|
|
|
|
hasDiff, err := gitHasDiff(config.BuildDir, pkg)
|
2019-10-07 10:24:19 +00:00
|
|
|
if err != nil {
|
2019-10-13 22:23:55 +00:00
|
|
|
errMulti.Add(err)
|
|
|
|
continue
|
2019-10-07 10:24:19 +00:00
|
|
|
}
|
2018-05-31 19:31:45 +00:00
|
|
|
|
2019-11-04 04:20:50 +00:00
|
|
|
if !hasDiff {
|
2020-08-16 22:09:43 +00:00
|
|
|
text.Warnln(gotext.Get("%s: No changes -- skipping", text.Cyan(base.String())))
|
2019-11-04 04:20:50 +00:00
|
|
|
continue
|
2018-05-31 19:31:45 +00:00
|
|
|
}
|
2019-11-04 04:20:50 +00:00
|
|
|
}
|
2018-05-31 19:31:45 +00:00
|
|
|
|
2020-07-08 01:40:50 +00:00
|
|
|
args := []string{
|
|
|
|
"diff",
|
2020-05-02 14:17:20 +00:00
|
|
|
start + "..HEAD@{upstream}", "--src-prefix",
|
2020-07-08 01:40:50 +00:00
|
|
|
dir + "/", "--dst-prefix", dir + "/", "--", ".", ":(exclude).SRCINFO",
|
|
|
|
}
|
2020-06-26 07:03:45 +00:00
|
|
|
if text.UseColor {
|
2019-11-04 04:20:50 +00:00
|
|
|
args = append(args, "--color=always")
|
2018-05-31 19:31:45 +00:00
|
|
|
} else {
|
2019-11-04 04:20:50 +00:00
|
|
|
args = append(args, "--color=never")
|
2018-05-31 19:31:45 +00:00
|
|
|
}
|
2020-08-21 23:24:52 +00:00
|
|
|
_ = config.Runtime.CmdRunner.Show(config.Runtime.CmdBuilder.BuildGitCmd(dir, args...))
|
2018-05-31 19:31:45 +00:00
|
|
|
}
|
|
|
|
|
2019-10-13 22:23:55 +00:00
|
|
|
return errMulti.Return()
|
2018-05-31 19:31:45 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func editPkgbuilds(bases []dep.Base, srcinfos map[string]*gosrc.Srcinfo) error {
|
2018-08-10 03:40:27 +00:00
|
|
|
pkgbuilds := make([]string, 0, len(bases))
|
|
|
|
for _, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg)
|
2018-04-17 00:32:31 +00:00
|
|
|
pkgbuilds = append(pkgbuilds, filepath.Join(dir, "PKGBUILD"))
|
2018-07-17 21:54:13 +00:00
|
|
|
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, splitPkg := range srcinfos[pkg].SplitPackages() {
|
2018-07-17 21:54:13 +00:00
|
|
|
if splitPkg.Install != "" {
|
|
|
|
pkgbuilds = append(pkgbuilds, filepath.Join(dir, splitPkg.Install))
|
|
|
|
}
|
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
|
2018-05-31 19:31:45 +00:00
|
|
|
if len(pkgbuilds) > 0 {
|
|
|
|
editor, editorArgs := editor()
|
|
|
|
editorArgs = append(editorArgs, pkgbuilds...)
|
|
|
|
editcmd := exec.Command(editor, editorArgs...)
|
|
|
|
editcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
|
|
|
err := editcmd.Run()
|
|
|
|
if err != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("editor did not exit successfully, aborting: %s", err))
|
2018-05-31 19:31:45 +00:00
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func parseSrcinfoFiles(bases []dep.Base, errIsFatal bool) (map[string]*gosrc.Srcinfo, error) {
|
2018-08-11 04:00:46 +00:00
|
|
|
srcinfos := make(map[string]*gosrc.Srcinfo)
|
2018-08-10 03:40:27 +00:00
|
|
|
for k, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg)
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2020-08-16 22:09:43 +00:00
|
|
|
text.OperationInfoln(gotext.Get("(%d/%d) Parsing SRCINFO: %s", k+1, len(bases), text.Cyan(base.String())))
|
2018-02-19 06:52:11 +00:00
|
|
|
|
2018-07-16 14:28:18 +00:00
|
|
|
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
|
2018-02-19 06:52:11 +00:00
|
|
|
if err != nil {
|
2018-08-11 03:51:10 +00:00
|
|
|
if !errIsFatal {
|
2020-05-04 07:24:32 +00:00
|
|
|
text.Warnln(gotext.Get("failed to parse %s -- skipping: %s", base.String(), err))
|
2018-08-11 03:51:10 +00:00
|
|
|
continue
|
|
|
|
}
|
2020-05-04 07:24:32 +00:00
|
|
|
return nil, errors.New(gotext.Get("failed to parse %s: %s", base.String(), err))
|
2018-02-19 06:52:11 +00:00
|
|
|
}
|
|
|
|
|
2018-08-10 03:40:27 +00:00
|
|
|
srcinfos[pkg] = pkgbuild
|
2018-02-19 06:52:11 +00:00
|
|
|
}
|
|
|
|
|
2018-08-11 04:00:46 +00:00
|
|
|
return srcinfos, nil
|
2018-02-19 06:52:11 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func pkgbuildsToSkip(bases []dep.Base, targets stringset.StringSet) stringset.StringSet {
|
2019-10-16 21:25:40 +00:00
|
|
|
toSkip := make(stringset.StringSet)
|
2018-05-31 19:31:45 +00:00
|
|
|
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, base := range bases {
|
|
|
|
isTarget := false
|
|
|
|
for _, pkg := range base {
|
2019-10-05 17:39:31 +00:00
|
|
|
isTarget = isTarget || targets.Get(pkg.Name)
|
2018-08-10 03:40:27 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 17:23:05 +00:00
|
|
|
if (config.ReDownload == "yes" && isTarget) || config.ReDownload == "all" {
|
|
|
|
continue
|
|
|
|
}
|
2018-03-06 03:42:26 +00:00
|
|
|
|
2018-09-04 17:23:05 +00:00
|
|
|
dir := filepath.Join(config.BuildDir, base.Pkgbase(), ".SRCINFO")
|
|
|
|
pkgbuild, err := gosrc.ParseFile(dir)
|
|
|
|
|
|
|
|
if err == nil {
|
|
|
|
if alpm.VerCmp(pkgbuild.Version(), base.Version()) >= 0 {
|
2019-10-05 17:39:31 +00:00
|
|
|
toSkip.Set(base.Pkgbase())
|
2018-03-06 03:42:26 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-31 19:31:45 +00:00
|
|
|
}
|
|
|
|
|
2018-06-10 00:04:04 +00:00
|
|
|
return toSkip
|
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func mergePkgbuilds(bases []dep.Base) error {
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, base := range bases {
|
2019-11-04 04:20:50 +00:00
|
|
|
err := gitMerge(config.BuildDir, base.Pkgbase())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-10 00:29:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func downloadPkgbuilds(bases []dep.Base, toSkip stringset.StringSet, buildDir string) (stringset.StringSet, error) {
|
2019-10-16 21:25:40 +00:00
|
|
|
cloned := make(stringset.StringSet)
|
2018-08-02 15:49:30 +00:00
|
|
|
downloaded := 0
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
var mux sync.Mutex
|
2019-10-16 21:38:54 +00:00
|
|
|
var errs multierror.MultiError
|
2018-08-02 15:49:30 +00:00
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
download := func(base dep.Base) {
|
2018-08-02 15:49:30 +00:00
|
|
|
defer wg.Done()
|
2018-08-10 03:40:27 +00:00
|
|
|
pkg := base.Pkgbase()
|
2018-06-10 02:41:25 +00:00
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if toSkip.Get(pkg) {
|
2018-08-02 15:49:30 +00:00
|
|
|
mux.Lock()
|
|
|
|
downloaded++
|
2020-05-04 07:24:32 +00:00
|
|
|
text.OperationInfoln(
|
|
|
|
gotext.Get("PKGBUILD up to date, Skipping (%d/%d): %s",
|
2020-08-16 22:09:43 +00:00
|
|
|
downloaded, len(bases), text.Cyan(base.String())))
|
2018-08-02 15:49:30 +00:00
|
|
|
mux.Unlock()
|
|
|
|
return
|
2018-05-31 19:31:45 +00:00
|
|
|
}
|
2018-03-06 03:42:26 +00:00
|
|
|
|
2019-11-04 04:20:50 +00:00
|
|
|
clone, err := gitDownload(config.AURURL+"/"+pkg+".git", buildDir, pkg)
|
|
|
|
if err != nil {
|
|
|
|
errs.Add(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if clone {
|
|
|
|
mux.Lock()
|
|
|
|
cloned.Set(pkg)
|
|
|
|
mux.Unlock()
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
2018-08-02 15:49:30 +00:00
|
|
|
|
|
|
|
mux.Lock()
|
|
|
|
downloaded++
|
2020-08-16 22:09:43 +00:00
|
|
|
text.OperationInfoln(gotext.Get("Downloaded PKGBUILD (%d/%d): %s", downloaded, len(bases), text.Cyan(base.String())))
|
2018-08-02 15:49:30 +00:00
|
|
|
mux.Unlock()
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 17:28:36 +00:00
|
|
|
count := 0
|
2020-05-02 14:17:20 +00:00
|
|
|
for _, base := range bases {
|
2018-08-02 15:49:30 +00:00
|
|
|
wg.Add(1)
|
2020-05-02 14:17:20 +00:00
|
|
|
go download(base)
|
2018-09-04 17:28:36 +00:00
|
|
|
count++
|
|
|
|
if count%25 == 0 {
|
|
|
|
wg.Wait()
|
|
|
|
}
|
2018-08-02 15:49:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wg.Wait()
|
|
|
|
|
|
|
|
return cloned, errs.Return()
|
2018-01-17 21:48:23 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
func downloadPkgbuildsSources(bases []dep.Base, incompatible stringset.StringSet) (err error) {
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, base := range bases {
|
|
|
|
pkg := base.Pkgbase()
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg)
|
2018-04-12 15:39:01 +00:00
|
|
|
args := []string{"--verifysource", "-Ccf"}
|
2018-03-19 16:51:11 +00:00
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if incompatible.Get(pkg) {
|
2018-03-19 16:51:11 +00:00
|
|
|
args = append(args, "--ignorearch")
|
|
|
|
}
|
|
|
|
|
2020-08-21 23:24:52 +00:00
|
|
|
err = config.Runtime.CmdRunner.Show(
|
|
|
|
config.Runtime.CmdBuilder.BuildMakepkgCmd(dir, args...))
|
2018-01-17 21:48:23 +00:00
|
|
|
if err != nil {
|
2020-08-16 22:09:43 +00:00
|
|
|
return errors.New(gotext.Get("error downloading sources: %s", text.Cyan(base.String())))
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-17 21:48:23 +00:00
|
|
|
return
|
|
|
|
}
|
2018-01-05 22:12:14 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
func buildInstallPkgbuilds(
|
2020-07-08 01:31:35 +00:00
|
|
|
cmdArgs *settings.Arguments,
|
2020-08-16 21:41:38 +00:00
|
|
|
dbExecutor db.Executor,
|
2020-07-10 00:36:45 +00:00
|
|
|
dp *dep.Pool,
|
|
|
|
do *dep.Order,
|
2020-05-02 14:17:20 +00:00
|
|
|
srcinfos map[string]*gosrc.Srcinfo,
|
|
|
|
incompatible stringset.StringSet,
|
2020-07-05 14:58:35 +00:00
|
|
|
conflicts stringset.MapStringSet,
|
2020-07-08 01:31:35 +00:00
|
|
|
) error {
|
2020-07-08 01:22:01 +00:00
|
|
|
arguments := cmdArgs.Copy()
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.ClearTargets()
|
|
|
|
arguments.Op = "U"
|
|
|
|
arguments.DelArg("confirm")
|
|
|
|
arguments.DelArg("noconfirm")
|
|
|
|
arguments.DelArg("c", "clean")
|
|
|
|
arguments.DelArg("q", "quiet")
|
|
|
|
arguments.DelArg("q", "quiet")
|
|
|
|
arguments.DelArg("y", "refresh")
|
|
|
|
arguments.DelArg("u", "sysupgrade")
|
|
|
|
arguments.DelArg("w", "downloadonly")
|
2019-10-10 14:55:43 +00:00
|
|
|
|
|
|
|
deps := make([]string, 0)
|
|
|
|
exp := make([]string, 0)
|
2020-08-18 22:17:35 +00:00
|
|
|
oldConfirm := settings.NoConfirm
|
|
|
|
settings.NoConfirm = true
|
2019-10-10 14:55:43 +00:00
|
|
|
|
|
|
|
//remotenames: names of all non repo packages on the system
|
2020-07-31 23:20:00 +00:00
|
|
|
localNames, remoteNames, err := query.GetPackageNamesBySource(dbExecutor)
|
2019-10-10 14:55:43 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
// cache as a stringset. maybe make it return a string set in the first
|
|
|
|
// place
|
2019-10-16 21:58:55 +00:00
|
|
|
remoteNamesCache := stringset.FromSlice(remoteNames)
|
|
|
|
localNamesCache := stringset.FromSlice(localNames)
|
2019-10-10 14:55:43 +00:00
|
|
|
|
|
|
|
doInstall := func() error {
|
2020-07-05 00:45:23 +00:00
|
|
|
if len(arguments.Targets) == 0 {
|
2019-10-10 14:55:43 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-18 23:48:07 +00:00
|
|
|
if errShow := config.Runtime.CmdRunner.Show(passToPacman(arguments)); errShow != nil {
|
2020-05-02 14:17:20 +00:00
|
|
|
return errShow
|
2019-10-10 14:55:43 +00:00
|
|
|
}
|
|
|
|
|
2020-08-21 00:39:52 +00:00
|
|
|
if errStore := config.Runtime.VCSStore.Save(); err != nil {
|
|
|
|
fmt.Fprintln(os.Stderr, errStore)
|
2019-10-10 14:55:43 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 01:22:01 +00:00
|
|
|
if errDeps := asdeps(cmdArgs, deps); err != nil {
|
2020-05-02 14:17:20 +00:00
|
|
|
return errDeps
|
2019-10-10 14:55:43 +00:00
|
|
|
}
|
2020-07-08 01:22:01 +00:00
|
|
|
if errExps := asexp(cmdArgs, exp); err != nil {
|
2020-05-02 14:17:20 +00:00
|
|
|
return errExps
|
2019-10-10 14:55:43 +00:00
|
|
|
}
|
|
|
|
|
2020-08-18 22:17:35 +00:00
|
|
|
settings.NoConfirm = oldConfirm
|
2019-10-10 14:55:43 +00:00
|
|
|
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.ClearTargets()
|
2019-10-10 14:55:43 +00:00
|
|
|
deps = make([]string, 0)
|
|
|
|
exp = make([]string, 0)
|
2020-08-18 22:17:35 +00:00
|
|
|
settings.NoConfirm = true
|
2019-10-10 14:55:43 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-01-15 18:41:38 +00:00
|
|
|
for _, base := range do.Aur {
|
2018-08-10 03:40:27 +00:00
|
|
|
pkg := base.Pkgbase()
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg)
|
2018-02-15 21:23:34 +00:00
|
|
|
built := true
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2019-10-10 14:55:43 +00:00
|
|
|
satisfied := true
|
|
|
|
all:
|
|
|
|
for _, pkg := range base {
|
|
|
|
for _, deps := range [3][]string{pkg.Depends, pkg.MakeDepends, pkg.CheckDepends} {
|
|
|
|
for _, dep := range deps {
|
2020-07-28 23:53:25 +00:00
|
|
|
if !dp.AlpmExecutor.LocalSatisfierExists(dep) {
|
2019-10-10 14:55:43 +00:00
|
|
|
satisfied = false
|
2020-05-04 07:24:32 +00:00
|
|
|
text.Warnln(gotext.Get("%s not satisfied, flushing install queue", dep))
|
2019-10-10 14:55:43 +00:00
|
|
|
break all
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !satisfied || !config.BatchInstall {
|
|
|
|
err = doInstall()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-10 03:40:27 +00:00
|
|
|
srcinfo := srcinfos[pkg]
|
2018-04-12 15:39:01 +00:00
|
|
|
|
2018-06-02 13:16:00 +00:00
|
|
|
args := []string{"--nobuild", "-fC"}
|
2018-05-10 19:56:12 +00:00
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if incompatible.Get(pkg) {
|
2018-05-10 19:56:12 +00:00
|
|
|
args = append(args, "--ignorearch")
|
|
|
|
}
|
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
// pkgver bump
|
2020-08-21 23:24:52 +00:00
|
|
|
if err = config.Runtime.CmdRunner.Show(
|
|
|
|
config.Runtime.CmdBuilder.BuildMakepkgCmd(dir, args...)); err != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("error making: %s", base.String()))
|
2018-04-12 15:39:01 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
pkgdests, pkgVersion, errList := parsePackageList(dir)
|
|
|
|
if errList != nil {
|
|
|
|
return errList
|
2018-04-12 15:39:01 +00:00
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2018-08-10 03:40:27 +00:00
|
|
|
isExplicit := false
|
|
|
|
for _, b := range base {
|
2019-10-05 17:39:31 +00:00
|
|
|
isExplicit = isExplicit || dp.Explicit.Get(b.Name)
|
2018-08-10 03:40:27 +00:00
|
|
|
}
|
2018-09-04 19:01:49 +00:00
|
|
|
if config.ReBuild == "no" || (config.ReBuild == "yes" && !isExplicit) {
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, split := range base {
|
2018-05-31 03:37:08 +00:00
|
|
|
pkgdest, ok := pkgdests[split.Name]
|
|
|
|
if !ok {
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("could not find PKGDEST for: %s", split.Name))
|
2018-03-14 01:48:33 +00:00
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
if _, errStat := os.Stat(pkgdest); os.IsNotExist(errStat) {
|
2018-03-14 01:48:33 +00:00
|
|
|
built = false
|
2020-05-02 14:17:20 +00:00
|
|
|
} else if errStat != nil {
|
|
|
|
return errStat
|
2018-03-14 01:48:33 +00:00
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
}
|
2018-03-14 01:48:33 +00:00
|
|
|
} else {
|
|
|
|
built = false
|
2018-02-15 21:23:34 +00:00
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2020-07-05 00:45:23 +00:00
|
|
|
if cmdArgs.ExistsArg("needed") {
|
2018-08-18 16:32:40 +00:00
|
|
|
installed := true
|
|
|
|
for _, split := range base {
|
2020-07-28 23:53:25 +00:00
|
|
|
installed = dp.AlpmExecutor.IsCorrectVersionInstalled(split.Name, pkgVersion)
|
2018-08-18 16:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if installed {
|
2020-08-21 23:24:52 +00:00
|
|
|
err = config.Runtime.CmdRunner.Show(
|
|
|
|
config.Runtime.CmdBuilder.BuildMakepkgCmd(
|
|
|
|
dir, "-c", "--nobuild", "--noextract", "--ignorearch"))
|
2019-10-13 11:15:51 +00:00
|
|
|
if err != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("error making: %s", err))
|
2019-10-13 11:15:51 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 22:09:43 +00:00
|
|
|
fmt.Fprintln(os.Stdout, gotext.Get("%s is up to date -- skipping", text.Cyan(pkg+"-"+pkgVersion)))
|
2018-08-18 16:32:40 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
if built {
|
2020-08-21 23:24:52 +00:00
|
|
|
err = config.Runtime.CmdRunner.Show(
|
|
|
|
config.Runtime.CmdBuilder.BuildMakepkgCmd(
|
|
|
|
dir, "-c", "--nobuild", "--noextract", "--ignorearch"))
|
2019-10-13 11:15:51 +00:00
|
|
|
if err != nil {
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("error making: %s", err))
|
2019-10-13 11:15:51 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 22:09:43 +00:00
|
|
|
text.Warnln(gotext.Get("%s already made -- skipping build", text.Cyan(pkg+"-"+pkgVersion)))
|
2018-02-15 21:23:34 +00:00
|
|
|
} else {
|
2018-06-02 13:16:00 +00:00
|
|
|
args := []string{"-cf", "--noconfirm", "--noextract", "--noprepare", "--holdver"}
|
2018-03-19 16:51:11 +00:00
|
|
|
|
2019-10-05 17:39:31 +00:00
|
|
|
if incompatible.Get(pkg) {
|
2018-03-19 16:51:11 +00:00
|
|
|
args = append(args, "--ignorearch")
|
|
|
|
}
|
|
|
|
|
2020-08-21 23:24:52 +00:00
|
|
|
if errMake := config.Runtime.CmdRunner.Show(
|
|
|
|
config.Runtime.CmdBuilder.BuildMakepkgCmd(
|
|
|
|
dir, args...)); errMake != nil {
|
2020-08-07 21:59:55 +00:00
|
|
|
return errors.New(gotext.Get("error making: %s", base.String()))
|
2018-02-15 19:43:16 +00:00
|
|
|
}
|
2018-01-04 00:59:57 +00:00
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
// conflicts have been checked so answer y for them
|
2020-07-05 22:28:04 +00:00
|
|
|
if config.UseAsk && cmdArgs.ExistsArg("ask") {
|
|
|
|
ask, _ := strconv.Atoi(cmdArgs.Options["ask"].First())
|
2018-06-22 14:17:34 +00:00
|
|
|
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
|
2020-07-05 22:28:04 +00:00
|
|
|
cmdArgs.Options["ask"].Set(fmt.Sprint(uask))
|
2018-06-22 14:17:34 +00:00
|
|
|
} else {
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, split := range base {
|
2018-06-22 14:17:34 +00:00
|
|
|
if _, ok := conflicts[split.Name]; ok {
|
2020-08-18 22:17:35 +00:00
|
|
|
settings.NoConfirm = false
|
2019-10-10 14:55:43 +00:00
|
|
|
break
|
2018-06-22 14:17:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-16 22:20:53 +00:00
|
|
|
doAddTarget := func(name string, optional bool) error {
|
|
|
|
pkgdest, ok := pkgdests[name]
|
2018-05-31 03:37:08 +00:00
|
|
|
if !ok {
|
2020-02-18 14:22:07 +00:00
|
|
|
if optional {
|
|
|
|
return nil
|
2020-02-16 22:20:53 +00:00
|
|
|
}
|
2020-02-16 23:18:29 +00:00
|
|
|
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(gotext.Get("could not find PKGDEST for: %s", name))
|
2018-02-15 21:23:34 +00:00
|
|
|
}
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
if _, errStat := os.Stat(pkgdest); os.IsNotExist(errStat) {
|
2020-02-28 15:02:00 +00:00
|
|
|
if optional {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-05-04 07:24:32 +00:00
|
|
|
return errors.New(
|
|
|
|
gotext.Get(
|
|
|
|
"the PKGDEST for %s is listed by makepkg but does not exist: %s",
|
|
|
|
name, pkgdest))
|
2020-02-28 15:02:00 +00:00
|
|
|
}
|
|
|
|
|
2020-07-05 00:45:23 +00:00
|
|
|
arguments.AddTarget(pkgdest)
|
2020-07-08 01:22:01 +00:00
|
|
|
if cmdArgs.ExistsArg("asdeps", "asdep") {
|
2020-02-16 22:20:53 +00:00
|
|
|
deps = append(deps, name)
|
2020-07-08 01:22:01 +00:00
|
|
|
} else if cmdArgs.ExistsArg("asexplicit", "asexp") {
|
2020-02-16 22:20:53 +00:00
|
|
|
exp = append(exp, name)
|
|
|
|
} else if !dp.Explicit.Get(name) && !localNamesCache.Get(name) && !remoteNamesCache.Get(name) {
|
|
|
|
deps = append(deps, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, split := range base {
|
2020-05-02 14:17:20 +00:00
|
|
|
if errAdd := doAddTarget(split.Name, false); errAdd != nil {
|
|
|
|
return errAdd
|
2020-02-16 22:20:53 +00:00
|
|
|
}
|
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
if errAddDebug := doAddTarget(split.Name+"-debug", true); errAddDebug != nil {
|
|
|
|
return errAddDebug
|
2018-05-29 21:35:58 +00:00
|
|
|
}
|
2018-02-15 21:23:34 +00:00
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2018-08-02 22:30:48 +00:00
|
|
|
var mux sync.Mutex
|
|
|
|
var wg sync.WaitGroup
|
2018-08-10 03:40:27 +00:00
|
|
|
for _, pkg := range base {
|
2018-08-02 22:30:48 +00:00
|
|
|
wg.Add(1)
|
2020-08-21 00:39:52 +00:00
|
|
|
go config.Runtime.VCSStore.Update(pkg.Name, srcinfo.Source, &mux, &wg)
|
2018-03-05 22:15:34 +00:00
|
|
|
}
|
|
|
|
|
2018-08-02 22:30:48 +00:00
|
|
|
wg.Wait()
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
|
2019-10-10 14:55:43 +00:00
|
|
|
err = doInstall()
|
2020-08-18 22:17:35 +00:00
|
|
|
settings.NoConfirm = oldConfirm
|
2019-10-10 14:55:43 +00:00
|
|
|
return err
|
2018-02-15 19:43:16 +00:00
|
|
|
}
|