1
0
mirror of https://github.com/Jguer/yay synced 2024-07-08 04:16:16 +00:00
yay/install.go

848 lines
22 KiB
Go
Raw Normal View History

package main
import (
2021-08-12 16:56:23 +00:00
"context"
"errors"
"fmt"
"os"
"path/filepath"
"strconv"
2018-02-21 08:41:25 +00:00
"strings"
2018-08-02 15:49:30 +00:00
"sync"
2020-10-01 11:38:03 +00:00
alpm "github.com/Jguer/go-alpm/v2"
gosrc "github.com/Morganamilo/go-srcinfo"
"github.com/leonelquinteros/gotext"
2021-09-08 20:28:08 +00:00
"github.com/Jguer/yay/v11/pkg/completion"
"github.com/Jguer/yay/v11/pkg/db"
"github.com/Jguer/yay/v11/pkg/dep"
"github.com/Jguer/yay/v11/pkg/download"
2021-10-11 20:22:03 +00:00
"github.com/Jguer/yay/v11/pkg/menus"
2021-09-08 20:28:08 +00:00
"github.com/Jguer/yay/v11/pkg/pgp"
"github.com/Jguer/yay/v11/pkg/query"
"github.com/Jguer/yay/v11/pkg/settings"
"github.com/Jguer/yay/v11/pkg/settings/parser"
"github.com/Jguer/yay/v11/pkg/stringset"
"github.com/Jguer/yay/v11/pkg/text"
)
2021-08-12 16:56:23 +00:00
func asdeps(ctx context.Context, cmdArgs *parser.Arguments, pkgs []string) (err error) {
if len(pkgs) == 0 {
return nil
}
2020-07-08 01:22:01 +00:00
cmdArgs = cmdArgs.CopyGlobal()
_ = cmdArgs.AddArg("q", "D", "asdeps")
2020-07-08 01:22:01 +00:00
cmdArgs.AddTarget(pkgs...)
2021-08-11 18:13:28 +00:00
2021-08-12 16:56:23 +00:00
err = config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm))
if err != nil {
return fmt.Errorf(gotext.Get("error updating package install reason to dependency"))
}
return nil
}
2021-08-12 16:56:23 +00:00
func asexp(ctx context.Context, cmdArgs *parser.Arguments, pkgs []string) (err error) {
if len(pkgs) == 0 {
return nil
}
2020-07-08 01:22:01 +00:00
cmdArgs = cmdArgs.CopyGlobal()
_ = cmdArgs.AddArg("q", "D", "asexplicit")
2020-07-08 01:22:01 +00:00
cmdArgs.AddTarget(pkgs...)
2021-08-11 18:13:28 +00:00
2021-08-12 16:56:23 +00:00
err = config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm))
if err != nil {
return fmt.Errorf(gotext.Get("error updating package install reason to explicit"))
}
return nil
}
2021-08-11 18:13:28 +00:00
// Install handles package installs.
2021-08-23 15:37:58 +00:00
func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Executor, ignoreProviders bool) error {
var (
incompatible stringset.StringSet
do *dep.Order
srcinfos map[string]*gosrc.Srcinfo
noDeps = cmdArgs.ExistsDouble("d", "nodeps")
noCheck = strings.Contains(config.MFlags, "--nocheck")
assumeInstalled = cmdArgs.GetArgs("assume-installed")
sysupgradeArg = cmdArgs.ExistsArg("u", "sysupgrade")
refreshArg = cmdArgs.ExistsArg("y", "refresh")
warnings = query.NewWarnings()
)
if noDeps {
config.Runtime.CmdBuilder.AddMakepkgFlag("-d")
}
2021-08-09 11:26:32 +00:00
if config.Runtime.Mode.AtLeastRepo() {
Separate Pacman upgrade and AUR Upgrade by default Currently When performing a system upgrade, Yay will first refresh the database then perform the repo and AUR upgrade. This allows Yay to add some features such as better batch interaction, showing potential dependency problems before the upgrade starts and combined menus showing AUR and repo upgrades together. There has been discussion that this approach is a bad idea. The main issue people have is that the separation of the database refresh and the upgrade could lead to a partial upgrade if Yay fails between the two stages. Personally I do not like this argument, there are valid reasons to Yay to fail between these points. For example there may be dependency or conflict issues during the AUR upgrade. Yay can detect these before any installing actually starts and exit, just like how pacman will when there are dependency problems. If Yay does fail between these points, for the previously mentioned reasons or even a crash then a simple refresh will not cause a partial upgrade by itself. It is then the user's responsibility to either resolve these issues or instead perform an upgrade using pacman directly. My opinions aside, The discussions on the Arch wiki has reached a decision, this method is not recommended. So to follow the decided best practises this behaviour has been disabled by default. This behaviour can be toggled using the --[no]combinedupgrade flag It should be noted that Yay's upgrade menu will not show repo packages unless --combinedupgrade is used.
2018-06-22 13:44:38 +00:00
if config.CombinedUpgrade {
2021-03-14 22:39:55 +00:00
if refreshArg {
2021-08-23 15:37:58 +00:00
if errR := earlyRefresh(ctx, cmdArgs); errR != nil {
return fmt.Errorf(gotext.Get("error refreshing databases"))
Separate Pacman upgrade and AUR Upgrade by default Currently When performing a system upgrade, Yay will first refresh the database then perform the repo and AUR upgrade. This allows Yay to add some features such as better batch interaction, showing potential dependency problems before the upgrade starts and combined menus showing AUR and repo upgrades together. There has been discussion that this approach is a bad idea. The main issue people have is that the separation of the database refresh and the upgrade could lead to a partial upgrade if Yay fails between the two stages. Personally I do not like this argument, there are valid reasons to Yay to fail between these points. For example there may be dependency or conflict issues during the AUR upgrade. Yay can detect these before any installing actually starts and exit, just like how pacman will when there are dependency problems. If Yay does fail between these points, for the previously mentioned reasons or even a crash then a simple refresh will not cause a partial upgrade by itself. It is then the user's responsibility to either resolve these issues or instead perform an upgrade using pacman directly. My opinions aside, The discussions on the Arch wiki has reached a decision, this method is not recommended. So to follow the decided best practises this behaviour has been disabled by default. This behaviour can be toggled using the --[no]combinedupgrade flag It should be noted that Yay's upgrade menu will not show repo packages unless --combinedupgrade is used.
2018-06-22 13:44:38 +00:00
}
}
2021-03-14 22:39:55 +00:00
} else if refreshArg || sysupgradeArg || len(cmdArgs.Targets) > 0 {
2021-08-23 15:37:58 +00:00
if errP := earlyPacmanCall(ctx, cmdArgs, dbExecutor); errP != nil {
return errP
Separate Pacman upgrade and AUR Upgrade by default Currently When performing a system upgrade, Yay will first refresh the database then perform the repo and AUR upgrade. This allows Yay to add some features such as better batch interaction, showing potential dependency problems before the upgrade starts and combined menus showing AUR and repo upgrades together. There has been discussion that this approach is a bad idea. The main issue people have is that the separation of the database refresh and the upgrade could lead to a partial upgrade if Yay fails between the two stages. Personally I do not like this argument, there are valid reasons to Yay to fail between these points. For example there may be dependency or conflict issues during the AUR upgrade. Yay can detect these before any installing actually starts and exit, just like how pacman will when there are dependency problems. If Yay does fail between these points, for the previously mentioned reasons or even a crash then a simple refresh will not cause a partial upgrade by itself. It is then the user's responsibility to either resolve these issues or instead perform an upgrade using pacman directly. My opinions aside, The discussions on the Arch wiki has reached a decision, this method is not recommended. So to follow the decided best practises this behaviour has been disabled by default. This behaviour can be toggled using the --[no]combinedupgrade flag It should be noted that Yay's upgrade menu will not show repo packages unless --combinedupgrade is used.
2018-06-22 13:44:38 +00:00
}
2018-07-19 18:53:17 +00:00
}
}
Separate Pacman upgrade and AUR Upgrade by default Currently When performing a system upgrade, Yay will first refresh the database then perform the repo and AUR upgrade. This allows Yay to add some features such as better batch interaction, showing potential dependency problems before the upgrade starts and combined menus showing AUR and repo upgrades together. There has been discussion that this approach is a bad idea. The main issue people have is that the separation of the database refresh and the upgrade could lead to a partial upgrade if Yay fails between the two stages. Personally I do not like this argument, there are valid reasons to Yay to fail between these points. For example there may be dependency or conflict issues during the AUR upgrade. Yay can detect these before any installing actually starts and exit, just like how pacman will when there are dependency problems. If Yay does fail between these points, for the previously mentioned reasons or even a crash then a simple refresh will not cause a partial upgrade by itself. It is then the user's responsibility to either resolve these issues or instead perform an upgrade using pacman directly. My opinions aside, The discussions on the Arch wiki has reached a decision, this method is not recommended. So to follow the decided best practises this behaviour has been disabled by default. This behaviour can be toggled using the --[no]combinedupgrade flag It should be noted that Yay's upgrade menu will not show repo packages unless --combinedupgrade is used.
2018-06-22 13:44:38 +00:00
// we may have done -Sy, our handle now has an old
// database.
2021-08-23 15:37:58 +00:00
if errRefresh := dbExecutor.RefreshHandle(); errRefresh != nil {
return errRefresh
}
Separate Pacman upgrade and AUR Upgrade by default Currently When performing a system upgrade, Yay will first refresh the database then perform the repo and AUR upgrade. This allows Yay to add some features such as better batch interaction, showing potential dependency problems before the upgrade starts and combined menus showing AUR and repo upgrades together. There has been discussion that this approach is a bad idea. The main issue people have is that the separation of the database refresh and the upgrade could lead to a partial upgrade if Yay fails between the two stages. Personally I do not like this argument, there are valid reasons to Yay to fail between these points. For example there may be dependency or conflict issues during the AUR upgrade. Yay can detect these before any installing actually starts and exit, just like how pacman will when there are dependency problems. If Yay does fail between these points, for the previously mentioned reasons or even a crash then a simple refresh will not cause a partial upgrade by itself. It is then the user's responsibility to either resolve these issues or instead perform an upgrade using pacman directly. My opinions aside, The discussions on the Arch wiki has reached a decision, this method is not recommended. So to follow the decided best practises this behaviour has been disabled by default. This behaviour can be toggled using the --[no]combinedupgrade flag It should be noted that Yay's upgrade menu will not show repo packages unless --combinedupgrade is used.
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
Separate Pacman upgrade and AUR Upgrade by default Currently When performing a system upgrade, Yay will first refresh the database then perform the repo and AUR upgrade. This allows Yay to add some features such as better batch interaction, showing potential dependency problems before the upgrade starts and combined menus showing AUR and repo upgrades together. There has been discussion that this approach is a bad idea. The main issue people have is that the separation of the database refresh and the upgrade could lead to a partial upgrade if Yay fails between the two stages. Personally I do not like this argument, there are valid reasons to Yay to fail between these points. For example there may be dependency or conflict issues during the AUR upgrade. Yay can detect these before any installing actually starts and exit, just like how pacman will when there are dependency problems. If Yay does fail between these points, for the previously mentioned reasons or even a crash then a simple refresh will not cause a partial upgrade by itself. It is then the user's responsibility to either resolve these issues or instead perform an upgrade using pacman directly. My opinions aside, The discussions on the Arch wiki has reached a decision, this method is not recommended. So to follow the decided best practises this behaviour has been disabled by default. This behaviour can be toggled using the --[no]combinedupgrade flag It should be noted that Yay's upgrade menu will not show repo packages unless --combinedupgrade is used.
2018-06-22 13:44:38 +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
Separate Pacman upgrade and AUR Upgrade by default Currently When performing a system upgrade, Yay will first refresh the database then perform the repo and AUR upgrade. This allows Yay to add some features such as better batch interaction, showing potential dependency problems before the upgrade starts and combined menus showing AUR and repo upgrades together. There has been discussion that this approach is a bad idea. The main issue people have is that the separation of the database refresh and the upgrade could lead to a partial upgrade if Yay fails between the two stages. Personally I do not like this argument, there are valid reasons to Yay to fail between these points. For example there may be dependency or conflict issues during the AUR upgrade. Yay can detect these before any installing actually starts and exit, just like how pacman will when there are dependency problems. If Yay does fail between these points, for the previously mentioned reasons or even a crash then a simple refresh will not cause a partial upgrade by itself. It is then the user's responsibility to either resolve these issues or instead perform an upgrade using pacman directly. My opinions aside, The discussions on the Arch wiki has reached a decision, this method is not recommended. So to follow the decided best practises this behaviour has been disabled by default. This behaviour can be toggled using the --[no]combinedupgrade flag It should be noted that Yay's upgrade menu will not show repo packages unless --combinedupgrade is used.
2018-06-22 13:44:38 +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
if config.Runtime.Mode == parser.ModeAUR {
2020-07-05 00:45:23 +00:00
arguments.DelArg("u", "sysupgrade")
}
// if we are doing -u also request all packages needing update
2021-03-14 22:39:55 +00:00
if sysupgradeArg {
2021-08-12 16:56:23 +00:00
ignore, targets, errUp := sysupgradeTargets(ctx, dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"))
if errUp != nil {
return errUp
2018-05-30 02:21:17 +00:00
}
2018-04-04 20:51:57 +00:00
2021-03-14 21:41:32 +00:00
for _, up := range targets {
cmdArgs.AddTarget(up)
requestTargets = append(requestTargets, up)
2018-04-04 20:51:57 +00:00
}
if len(ignore) > 0 {
arguments.CreateOrAppendOption("ignore", ignore.ToSlice()...)
}
}
2020-07-08 01:22:01 +00:00
targets := stringset.FromSlice(cmdArgs.Targets)
2021-08-12 16:56:23 +00:00
dp, err := dep.GetPool(ctx, requestTargets,
2021-05-13 05:27:24 +00:00
warnings, dbExecutor, config.Runtime.AURClient, config.Runtime.Mode,
2021-07-27 17:35:56 +00:00
ignoreProviders, settings.NoConfirm, config.Provides, config.ReBuild, config.RequestSplitN, noDeps, noCheck, assumeInstalled)
if err != nil {
return err
}
2021-08-23 15:37:58 +00:00
if errC := dp.CheckMissing(noDeps, noCheck); errC != nil {
return errC
}
if len(dp.Aur) == 0 {
if !config.CombinedUpgrade {
2021-03-14 22:39:55 +00:00
if sysupgradeArg {
fmt.Println(gotext.Get(" there is nothing to do"))
}
2021-08-11 18:13:28 +00:00
return nil
}
2020-07-08 01:22:01 +00:00
cmdArgs.Op = "S"
cmdArgs.DelArg("y", "refresh")
2021-08-11 18:13:28 +00:00
if arguments.ExistsArg("ignore") {
cmdArgs.CreateOrAppendOption("ignore", arguments.GetArgs("ignore")...)
}
2021-08-11 18:13:28 +00:00
2021-08-12 16:56:23 +00:00
return config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm))
}
2021-08-23 15:37:58 +00:00
conflicts, errCC := dp.CheckConflicts(config.UseAsk, settings.NoConfirm, noDeps)
if errCC != nil {
return errCC
}
do = dep.GetOrder(dp, noDeps, noCheck)
for _, pkg := range do.Repo {
2020-07-05 00:45:23 +00:00
arguments.AddTarget(pkg.DB().Name() + "/" + pkg.Name())
}
for _, pkg := range dp.Groups {
2020-07-05 00:45:23 +00:00
arguments.AddTarget(pkg)
2018-03-16 01:14:34 +00:00
}
New install algorithm I have replaced the old install and dependancy algorithms with a new design that attemps to be more pacaur like. Mostly in minimizing user input. Ask every thing first then do everything with no need for more user input. It is not yet fully complete but is finished enough so that it works, should not fail in most cases and provides a base for more contributors to help address the existing problems. The new install chain is as follows: Source info about the provided targets Fetch a list of all dependancies needed to install targets I put alot of effort into fetching the dependancy tree while making the least amount of aur requests as possible. I'm actually very happy with how it turned out and yay wil now resolve dependancies noticably faster than pacaur when there are many aur dependancies. Install repo targets by passing to pacman Print dependancy tree and ask to confirm Ask to clean build if directory already exists Download all pkgbuilds Ask to edit all pkgbuilds Ask to continue with the install Download the sources for each packagebuild Build and install every package using -s to get repo deps and -i to install Ask to remove make dependancies There are still a lot of things that need to be done for a fully working system. Here are the problems I found with this system, either new or existing: Formating I am not so good at formatting myself, I thought best to leave it until last so I could get feedback on how it should look and help implementing it. Dependancy tree The dependancy tree is usually correct although I have noticed times where it doesnt detect all the dependancies that it should. I have only noticed this when there are circular dependancies so i think this might be the cause. It's not a big deal currently because makepkg -i installed repo deps for us which handles the repo deps for us and will get the correct ones. So yay might not list all the dependancies. but they will get installed so I consider this a visual bug. I have yet to see any circular dependancies in the AUR so I can not say what will happend but I#m guessing that it will break. Versioned packages/dependencies Targets and dependancies with version constriants such as 'linux>=4.1' will not be checked on the aur side of things but will be checked on the repo side. Ignorepkg/Ignoregroup Currently I do not handle this in any way but it shouldn't be too hard to implement. Conflict checking This is not currently implemented either Split Paclages Split packages are not Handles properly. If we only specify one package so install from a split package makepkg -i ends up installing them all anyway. If we specify more than one (n) package it will actually build the package base n times and reinstall every split package n times. Makepkg To get things working I decided to keep using the makepkg -i method. I plan to eventually replace this with a pacman -U based method. This should allow passing args such as --dbpath and --config to aur packages aswell as help solve some problems such as the split packages. Clean build I plan to improve the clean build choice to be a little more smart and instead of check if the directory exists, check if the package is already build and if so skip the build all together.
2018-01-17 21:48:23 +00:00
2021-08-09 11:26:32 +00:00
if len(do.Aur) == 0 && len(arguments.Targets) == 0 &&
(!cmdArgs.ExistsArg("u", "sysupgrade") || config.Runtime.Mode == parser.ModeAUR) {
fmt.Println(gotext.Get(" there is nothing to do"))
return nil
}
2018-02-16 17:18:59 +00:00
do.Print()
fmt.Println()
2019-06-11 13:54:24 +00:00
if config.CleanAfter {
2021-08-12 16:56:23 +00:00
defer cleanAfter(ctx, do.Aur)
2019-06-11 13:54:24 +00:00
}
if do.HasMake() {
switch config.RemoveMake {
case "yes":
defer func() {
2021-08-12 16:56:23 +00:00
err = removeMake(ctx, do)
}()
case "no":
2019-06-11 13:54:24 +00:00
break
default:
if text.ContinueTask(gotext.Get("Remove make dependencies after install?"), false, settings.NoConfirm) {
defer func() {
2021-08-12 16:56:23 +00:00
err = removeMake(ctx, do)
}()
2019-06-11 13:54:24 +00:00
}
}
}
2021-10-11 20:22:03 +00:00
if errCleanMenu := menus.Clean(config.CleanMenu,
config.BuildDir, do.Aur,
remoteNamesCache, settings.NoConfirm, config.AnswerClean); errCleanMenu != nil {
if errors.As(errCleanMenu, &settings.ErrUserAbort{}) {
return errCleanMenu
}
text.Errorln(errCleanMenu)
}
toSkip := pkgbuildsToSkip(do.Aur, targets)
toClone := make([]string, 0, len(do.Aur))
2021-08-11 18:13:28 +00:00
for _, base := range do.Aur {
if !toSkip.Get(base.Pkgbase()) {
toClone = append(toClone, base.Pkgbase())
}
}
if toSkipSlice := toSkip.ToSlice(); len(toSkipSlice) != 0 {
text.OperationInfoln(
gotext.Get("PKGBUILD up to date, Skipping (%d/%d): %s",
len(toSkipSlice), len(toClone), text.Cyan(strings.Join(toSkipSlice, ", "))))
}
2021-08-12 16:56:23 +00:00
cloned, errA := download.AURPKGBUILDRepos(ctx,
config.Runtime.CmdBuilder, toClone, config.AURURL, config.BuildDir, false)
if errA != nil {
return errA
}
2021-10-11 20:22:03 +00:00
if errDiffMenu := menus.Diff(ctx, config.Runtime.CmdBuilder, config.BuildDir,
config.DiffMenu, do.Aur, remoteNamesCache,
cloned, settings.NoConfirm, config.AnswerDiff); errDiffMenu != nil {
if errors.As(errDiffMenu, &settings.ErrUserAbort{}) {
return errDiffMenu
}
2021-08-11 18:13:28 +00:00
text.Errorln(errDiffMenu)
}
2021-08-23 15:37:58 +00:00
if errM := mergePkgbuilds(ctx, do.Aur); errM != nil {
return errM
}
srcinfos, err = parseSrcinfoFiles(do.Aur, true)
if err != nil {
return err
}
2021-10-11 20:22:03 +00:00
if errEditMenu := menus.Edit(config.EditMenu, config.BuildDir, do.Aur,
config.Editor, config.EditorFlags, remoteNamesCache, srcinfos,
settings.NoConfirm, config.AnswerEdit); errEditMenu != nil {
if errors.As(errEditMenu, &settings.ErrUserAbort{}) {
return errEditMenu
}
text.Errorln(errEditMenu)
}
2018-02-16 17:18:59 +00:00
2020-07-31 23:20:00 +00:00
incompatible, err = getIncompatible(do.Aur, srcinfos, dbExecutor)
if err != nil {
return err
}
if config.PGPFetch {
2021-08-23 15:37:58 +00:00
if errCPK := pgp.CheckPgpKeys(do.Aur, srcinfos, config.GpgBin, config.GpgFlags, settings.NoConfirm); errCPK != nil {
return errCPK
New install algorithm I have replaced the old install and dependancy algorithms with a new design that attemps to be more pacaur like. Mostly in minimizing user input. Ask every thing first then do everything with no need for more user input. It is not yet fully complete but is finished enough so that it works, should not fail in most cases and provides a base for more contributors to help address the existing problems. The new install chain is as follows: Source info about the provided targets Fetch a list of all dependancies needed to install targets I put alot of effort into fetching the dependancy tree while making the least amount of aur requests as possible. I'm actually very happy with how it turned out and yay wil now resolve dependancies noticably faster than pacaur when there are many aur dependancies. Install repo targets by passing to pacman Print dependancy tree and ask to confirm Ask to clean build if directory already exists Download all pkgbuilds Ask to edit all pkgbuilds Ask to continue with the install Download the sources for each packagebuild Build and install every package using -s to get repo deps and -i to install Ask to remove make dependancies There are still a lot of things that need to be done for a fully working system. Here are the problems I found with this system, either new or existing: Formating I am not so good at formatting myself, I thought best to leave it until last so I could get feedback on how it should look and help implementing it. Dependancy tree The dependancy tree is usually correct although I have noticed times where it doesnt detect all the dependancies that it should. I have only noticed this when there are circular dependancies so i think this might be the cause. It's not a big deal currently because makepkg -i installed repo deps for us which handles the repo deps for us and will get the correct ones. So yay might not list all the dependancies. but they will get installed so I consider this a visual bug. I have yet to see any circular dependancies in the AUR so I can not say what will happend but I#m guessing that it will break. Versioned packages/dependencies Targets and dependancies with version constriants such as 'linux>=4.1' will not be checked on the aur side of things but will be checked on the repo side. Ignorepkg/Ignoregroup Currently I do not handle this in any way but it shouldn't be too hard to implement. Conflict checking This is not currently implemented either Split Paclages Split packages are not Handles properly. If we only specify one package so install from a split package makepkg -i ends up installing them all anyway. If we specify more than one (n) package it will actually build the package base n times and reinstall every split package n times. Makepkg To get things working I decided to keep using the makepkg -i method. I plan to eventually replace this with a pacman -U based method. This should allow passing args such as --dbpath and --config to aur packages aswell as help solve some problems such as the split packages. Clean build I plan to improve the clean build choice to be a little more smart and instead of check if the directory exists, check if the package is already build and if so skip the build all together.
2018-01-17 21:48:23 +00:00
}
2018-03-21 00:26:56 +00:00
}
if !config.CombinedUpgrade {
2020-07-05 00:45:23 +00:00
arguments.DelArg("u", "sysupgrade")
}
2020-07-05 00:45:23 +00:00
if len(arguments.Targets) > 0 || arguments.ExistsArg("u") {
2021-08-12 16:56:23 +00:00
if errShow := config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
arguments, config.Runtime.Mode, settings.NoConfirm)); errShow != nil {
return errors.New(gotext.Get("error installing repo packages"))
2018-03-21 00:26:56 +00:00
}
deps := make([]string, 0)
exp := make([]string, 0)
2018-03-21 00:26:56 +00:00
for _, pkg := range do.Repo {
if !dp.Explicit.Get(pkg.Name()) && !localNamesCache.Get(pkg.Name()) && !remoteNamesCache.Get(pkg.Name()) {
deps = append(deps, pkg.Name())
2021-08-11 18:13:28 +00:00
continue
}
2020-07-08 01:22:01 +00:00
if cmdArgs.ExistsArg("asdeps", "asdep") && dp.Explicit.Get(pkg.Name()) {
deps = append(deps, pkg.Name())
2020-07-08 01:22:01 +00:00
} else if cmdArgs.ExistsArg("asexp", "asexplicit") && dp.Explicit.Get(pkg.Name()) {
exp = append(exp, pkg.Name())
2018-03-22 15:22:05 +00:00
}
2018-03-21 00:26:56 +00:00
}
2021-08-12 16:56:23 +00:00
if errDeps := asdeps(ctx, cmdArgs, deps); errDeps != nil {
return errDeps
2018-03-21 00:26:56 +00:00
}
2021-08-11 18:13:28 +00:00
2021-08-12 16:56:23 +00:00
if errExp := asexp(ctx, cmdArgs, exp); errExp != nil {
return errExp
}
2018-03-21 00:26:56 +00:00
}
2020-08-08 16:43:37 +00:00
go func() {
2021-08-12 16:56:23 +00:00
_ = completion.Update(ctx, config.Runtime.HTTPClient, dbExecutor,
config.AURURL, config.Runtime.CompletionPath, config.CompletionInterval, false)
2020-08-08 16:43:37 +00:00
}()
2021-08-23 15:37:58 +00:00
if errP := downloadPKGBUILDSourceFanout(ctx, config.Runtime.CmdBuilder, config.BuildDir, do.Aur, incompatible); errP != nil {
text.Errorln(errP)
}
2021-08-23 15:37:58 +00:00
if errB := buildInstallPkgbuilds(ctx, cmdArgs, dbExecutor, dp, do, srcinfos, incompatible, conflicts, noDeps, noCheck); errB != nil {
return errB
}
New install algorithm I have replaced the old install and dependancy algorithms with a new design that attemps to be more pacaur like. Mostly in minimizing user input. Ask every thing first then do everything with no need for more user input. It is not yet fully complete but is finished enough so that it works, should not fail in most cases and provides a base for more contributors to help address the existing problems. The new install chain is as follows: Source info about the provided targets Fetch a list of all dependancies needed to install targets I put alot of effort into fetching the dependancy tree while making the least amount of aur requests as possible. I'm actually very happy with how it turned out and yay wil now resolve dependancies noticably faster than pacaur when there are many aur dependancies. Install repo targets by passing to pacman Print dependancy tree and ask to confirm Ask to clean build if directory already exists Download all pkgbuilds Ask to edit all pkgbuilds Ask to continue with the install Download the sources for each packagebuild Build and install every package using -s to get repo deps and -i to install Ask to remove make dependancies There are still a lot of things that need to be done for a fully working system. Here are the problems I found with this system, either new or existing: Formating I am not so good at formatting myself, I thought best to leave it until last so I could get feedback on how it should look and help implementing it. Dependancy tree The dependancy tree is usually correct although I have noticed times where it doesnt detect all the dependancies that it should. I have only noticed this when there are circular dependancies so i think this might be the cause. It's not a big deal currently because makepkg -i installed repo deps for us which handles the repo deps for us and will get the correct ones. So yay might not list all the dependancies. but they will get installed so I consider this a visual bug. I have yet to see any circular dependancies in the AUR so I can not say what will happend but I#m guessing that it will break. Versioned packages/dependencies Targets and dependancies with version constriants such as 'linux>=4.1' will not be checked on the aur side of things but will be checked on the repo side. Ignorepkg/Ignoregroup Currently I do not handle this in any way but it shouldn't be too hard to implement. Conflict checking This is not currently implemented either Split Paclages Split packages are not Handles properly. If we only specify one package so install from a split package makepkg -i ends up installing them all anyway. If we specify more than one (n) package it will actually build the package base n times and reinstall every split package n times. Makepkg To get things working I decided to keep using the makepkg -i method. I plan to eventually replace this with a pacman -U based method. This should allow passing args such as --dbpath and --config to aur packages aswell as help solve some problems such as the split packages. Clean build I plan to improve the clean build choice to be a little more smart and instead of check if the directory exists, check if the package is already build and if so skip the build all together.
2018-01-17 21:48:23 +00:00
2019-06-11 13:54:24 +00:00
return nil
}
2021-08-12 16:56:23 +00:00
func removeMake(ctx context.Context, do *dep.Order) error {
removeArguments := parser.MakeArguments()
2021-08-11 18:13:28 +00:00
2020-07-05 00:45:23 +00:00
err := removeArguments.AddArg("R", "u")
if err != nil {
return err
}
2020-07-10 00:36:45 +00:00
for _, pkg := range do.GetMake() {
2020-07-05 00:45:23 +00:00
removeArguments.AddTarget(pkg)
}
New install algorithm I have replaced the old install and dependancy algorithms with a new design that attemps to be more pacaur like. Mostly in minimizing user input. Ask every thing first then do everything with no need for more user input. It is not yet fully complete but is finished enough so that it works, should not fail in most cases and provides a base for more contributors to help address the existing problems. The new install chain is as follows: Source info about the provided targets Fetch a list of all dependancies needed to install targets I put alot of effort into fetching the dependancy tree while making the least amount of aur requests as possible. I'm actually very happy with how it turned out and yay wil now resolve dependancies noticably faster than pacaur when there are many aur dependancies. Install repo targets by passing to pacman Print dependancy tree and ask to confirm Ask to clean build if directory already exists Download all pkgbuilds Ask to edit all pkgbuilds Ask to continue with the install Download the sources for each packagebuild Build and install every package using -s to get repo deps and -i to install Ask to remove make dependancies There are still a lot of things that need to be done for a fully working system. Here are the problems I found with this system, either new or existing: Formating I am not so good at formatting myself, I thought best to leave it until last so I could get feedback on how it should look and help implementing it. Dependancy tree The dependancy tree is usually correct although I have noticed times where it doesnt detect all the dependancies that it should. I have only noticed this when there are circular dependancies so i think this might be the cause. It's not a big deal currently because makepkg -i installed repo deps for us which handles the repo deps for us and will get the correct ones. So yay might not list all the dependancies. but they will get installed so I consider this a visual bug. I have yet to see any circular dependancies in the AUR so I can not say what will happend but I#m guessing that it will break. Versioned packages/dependencies Targets and dependancies with version constriants such as 'linux>=4.1' will not be checked on the aur side of things but will be checked on the repo side. Ignorepkg/Ignoregroup Currently I do not handle this in any way but it shouldn't be too hard to implement. Conflict checking This is not currently implemented either Split Paclages Split packages are not Handles properly. If we only specify one package so install from a split package makepkg -i ends up installing them all anyway. If we specify more than one (n) package it will actually build the package base n times and reinstall every split package n times. Makepkg To get things working I decided to keep using the makepkg -i method. I plan to eventually replace this with a pacman -U based method. This should allow passing args such as --dbpath and --config to aur packages aswell as help solve some problems such as the split packages. Clean build I plan to improve the clean build choice to be a little more smart and instead of check if the directory exists, check if the package is already build and if so skip the build all together.
2018-01-17 21:48:23 +00:00
oldValue := settings.NoConfirm
settings.NoConfirm = true
2021-08-12 16:56:23 +00:00
err = config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
removeArguments, config.Runtime.Mode, settings.NoConfirm))
settings.NoConfirm = oldValue
return err
}
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 = true
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
}
2021-08-12 16:56:23 +00:00
func earlyPacmanCall(ctx context.Context, cmdArgs *parser.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
if config.Runtime.Mode == parser.ModeRepo {
2020-07-05 00:45:23 +00:00
arguments.Targets = targets
2018-07-19 18:53:17 +00:00
} else {
// 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 {
2021-08-12 16:56:23 +00:00
if err := config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
arguments, config.Runtime.Mode, settings.NoConfirm)); err != nil {
return errors.New(gotext.Get("error installing repo packages"))
2018-07-19 18:53:17 +00:00
}
}
return nil
}
2021-08-12 16:56:23 +00:00
func earlyRefresh(ctx context.Context, cmdArgs *parser.Arguments) error {
2020-07-08 01:22:01 +00:00
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()
2021-08-11 18:13:28 +00:00
2021-08-12 16:56:23 +00:00
return config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
arguments, config.Runtime.Mode, settings.NoConfirm))
2018-07-19 18:53:17 +00:00
}
func alpmArchIsSupported(alpmArch []string, arch string) bool {
if arch == "any" {
return true
}
for _, a := range alpmArch {
if a == arch {
return true
}
}
return false
}
2020-08-16 21:41:38 +00:00
func getIncompatible(bases []dep.Base, srcinfos map[string]*gosrc.Srcinfo, dbExecutor db.Executor) (stringset.StringSet, error) {
incompatible := make(stringset.StringSet)
2020-07-10 00:36:45 +00:00
basesMap := make(map[string]dep.Base)
2021-08-11 18:13:28 +00:00
alpmArch, err := dbExecutor.AlpmArchitectures()
if err != nil {
return nil, err
}
2018-03-21 00:26:56 +00:00
nextpkg:
for _, base := range bases {
for _, arch := range srcinfos[base.Pkgbase()].Arch {
if alpmArchIsSupported(alpmArch, arch) {
continue nextpkg
}
}
incompatible.Set(base.Pkgbase())
basesMap[base.Pkgbase()] = base
}
if len(incompatible) > 0 {
text.Warnln(gotext.Get("The following packages are not compatible with your architecture:"))
2021-08-11 18:13:28 +00:00
for pkg := range incompatible {
2020-08-16 22:09:43 +00:00
fmt.Print(" " + text.Cyan(basesMap[pkg].String()))
}
fmt.Println()
if !text.ContinueTask(gotext.Get("Try to build them anyway?"), true, settings.NoConfirm) {
return nil, &settings.ErrUserAbort{}
}
}
return incompatible, nil
}
2021-08-12 16:56:23 +00:00
func parsePackageList(ctx context.Context, dir string) (pkgdests map[string]string, pkgVersion string, err error) {
stdout, stderr, err := config.Runtime.CmdBuilder.Capture(
2021-08-12 16:56:23 +00:00
config.Runtime.CmdBuilder.BuildMakepkgCmd(ctx, dir, "--packagelist"))
if err != nil {
return nil, "", fmt.Errorf("%s %s", stderr, err)
}
lines := strings.Split(stdout, "\n")
pkgdests = make(map[string]string)
for _, line := range lines {
if line == "" {
continue
}
fileName := filepath.Base(line)
split := strings.Split(fileName, "-")
if len(split) < 4 {
return nil, "", errors.New(gotext.Get("cannot find package name: %v", split))
}
// 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.
pkgName := strings.Join(split[:len(split)-3], "-")
pkgVersion = strings.Join(split[len(split)-3:len(split)-1], "-")
pkgdests[pkgName] = line
}
return pkgdests, pkgVersion, nil
}
2020-07-10 00:36:45 +00:00
func parseSrcinfoFiles(bases []dep.Base, errIsFatal bool) (map[string]*gosrc.Srcinfo, error) {
srcinfos := make(map[string]*gosrc.Srcinfo)
2021-08-11 18:13:28 +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())))
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
if err != nil {
if !errIsFatal {
text.Warnln(gotext.Get("failed to parse %s -- skipping: %s", base.String(), err))
continue
}
2021-08-11 18:13:28 +00:00
return nil, errors.New(gotext.Get("failed to parse %s: %s", base.String(), err))
}
srcinfos[pkg] = pkgbuild
}
return srcinfos, nil
}
2020-07-10 00:36:45 +00:00
func pkgbuildsToSkip(bases []dep.Base, targets stringset.StringSet) stringset.StringSet {
toSkip := make(stringset.StringSet)
for _, base := range bases {
isTarget := false
for _, pkg := range base {
isTarget = isTarget || targets.Get(pkg.Name)
}
if (config.ReDownload == "yes" && isTarget) || config.ReDownload == "all" {
continue
}
dir := filepath.Join(config.BuildDir, base.Pkgbase(), ".SRCINFO")
pkgbuild, err := gosrc.ParseFile(dir)
if err == nil {
if alpm.VerCmp(pkgbuild.Version(), base.Version()) >= 0 {
toSkip.Set(base.Pkgbase())
}
}
}
return toSkip
}
func gitMerge(ctx context.Context, path, name string) error {
_, stderr, err := config.Runtime.CmdBuilder.Capture(
config.Runtime.CmdBuilder.BuildGitCmd(ctx,
filepath.Join(path, name), "reset", "--hard", "HEAD"))
if err != nil {
return fmt.Errorf(gotext.Get("error resetting %s: %s", name, stderr))
}
_, stderr, err = config.Runtime.CmdBuilder.Capture(
config.Runtime.CmdBuilder.BuildGitCmd(ctx,
filepath.Join(path, name), "merge", "--no-edit", "--ff"))
if err != nil {
return fmt.Errorf(gotext.Get("error merging %s: %s", name, stderr))
}
return nil
}
2021-08-12 16:56:23 +00:00
func mergePkgbuilds(ctx context.Context, bases []dep.Base) error {
for _, base := range bases {
2021-08-12 16:56:23 +00:00
err := gitMerge(ctx, config.BuildDir, base.Pkgbase())
if err != nil {
return err
2018-06-10 00:29:54 +00:00
}
}
return nil
}
func buildInstallPkgbuilds(
2021-08-12 16:56:23 +00:00
ctx context.Context,
cmdArgs *parser.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,
srcinfos map[string]*gosrc.Srcinfo,
incompatible stringset.StringSet,
conflicts stringset.MapStringSet, noDeps, noCheck bool,
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")
deps := make([]string, 0)
exp := make([]string, 0)
oldConfirm := settings.NoConfirm
settings.NoConfirm = true
// remotenames: names of all non repo packages on the system
2020-07-31 23:20:00 +00:00
localNames, remoteNames, err := query.GetPackageNamesBySource(dbExecutor)
if err != nil {
return err
}
// cache as a stringset. maybe make it return a string set in the first
// place
remoteNamesCache := stringset.FromSlice(remoteNames)
localNamesCache := stringset.FromSlice(localNames)
for _, base := range do.Aur {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
built := true
satisfied := true
all:
for _, pkg := range base {
for _, deps := range dep.ComputeCombinedDepList(pkg, noDeps, noCheck) {
for _, dep := range deps {
2020-07-28 23:53:25 +00:00
if !dp.AlpmExecutor.LocalSatisfierExists(dep) {
satisfied = false
text.Warnln(gotext.Get("%s not satisfied, flushing install queue", dep))
2021-08-11 18:13:28 +00:00
break all
}
}
}
}
if !satisfied || !config.BatchInstall {
2021-08-12 16:56:23 +00:00
err = doInstall(ctx, arguments, cmdArgs, deps, exp)
arguments.ClearTargets()
2021-08-11 18:13:28 +00:00
deps = make([]string, 0)
exp = make([]string, 0)
2021-08-11 18:13:28 +00:00
if err != nil {
return err
}
}
srcinfo := srcinfos[pkg]
args := []string{"--nobuild", "-fC"}
if incompatible.Get(pkg) {
args = append(args, "--ignorearch")
}
// pkgver bump
if err = config.Runtime.CmdBuilder.Show(
2021-08-12 16:56:23 +00:00
config.Runtime.CmdBuilder.BuildMakepkgCmd(ctx, dir, args...)); err != nil {
return errors.New(gotext.Get("error making: %s", base.String()))
}
2021-08-12 16:56:23 +00:00
pkgdests, pkgVersion, errList := parsePackageList(ctx, dir)
if errList != nil {
return errList
}
isExplicit := false
for _, b := range base {
isExplicit = isExplicit || dp.Explicit.Get(b.Name)
}
2021-08-11 18:13:28 +00:00
2018-09-04 19:01:49 +00:00
if config.ReBuild == "no" || (config.ReBuild == "yes" && !isExplicit) {
for _, split := range base {
pkgdest, ok := pkgdests[split.Name]
if !ok {
return errors.New(gotext.Get("could not find PKGDEST for: %s", split.Name))
}
if _, errStat := os.Stat(pkgdest); os.IsNotExist(errStat) {
built = false
} else if errStat != nil {
return errStat
}
}
} else {
built = false
}
2020-07-05 00:45:23 +00:00
if cmdArgs.ExistsArg("needed") {
installed := true
for _, split := range base {
2020-07-28 23:53:25 +00:00
installed = dp.AlpmExecutor.IsCorrectVersionInstalled(split.Name, pkgVersion)
}
if installed {
err = config.Runtime.CmdBuilder.Show(
2021-08-12 16:56:23 +00:00
config.Runtime.CmdBuilder.BuildMakepkgCmd(ctx,
2020-08-21 23:24:52 +00:00
dir, "-c", "--nobuild", "--noextract", "--ignorearch"))
if err != nil {
return errors.New(gotext.Get("error making: %s", err))
}
2020-08-16 22:09:43 +00:00
fmt.Fprintln(os.Stdout, gotext.Get("%s is up to date -- skipping", text.Cyan(pkg+"-"+pkgVersion)))
2021-08-11 18:13:28 +00:00
continue
}
}
if built {
err = config.Runtime.CmdBuilder.Show(
2021-08-12 16:56:23 +00:00
config.Runtime.CmdBuilder.BuildMakepkgCmd(ctx,
2020-08-21 23:24:52 +00:00
dir, "-c", "--nobuild", "--noextract", "--ignorearch"))
if err != nil {
return errors.New(gotext.Get("error making: %s", err))
}
2020-08-16 22:09:43 +00:00
text.Warnln(gotext.Get("%s already made -- skipping build", text.Cyan(pkg+"-"+pkgVersion)))
} else {
args := []string{"-cf", "--noconfirm", "--noextract", "--noprepare", "--holdver"}
if incompatible.Get(pkg) {
args = append(args, "--ignorearch")
}
if errMake := config.Runtime.CmdBuilder.Show(
2021-08-12 16:56:23 +00:00
config.Runtime.CmdBuilder.BuildMakepkgCmd(ctx,
2020-08-21 23:24:52 +00:00
dir, args...)); errMake != nil {
2020-08-07 21:59:55 +00:00
return errors.New(gotext.Get("error making: %s", base.String()))
}
}
// conflicts have been checked so answer y for them
if config.UseAsk && cmdArgs.ExistsArg("ask") {
ask, _ := strconv.Atoi(cmdArgs.Options["ask"].First())
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
cmdArgs.Options["ask"].Set(fmt.Sprint(uask))
} else {
for _, split := range base {
if _, ok := conflicts[split.Name]; ok {
settings.NoConfirm = false
2021-08-11 18:13:28 +00:00
break
}
}
}
var errAdd error
2021-08-11 18:13:28 +00:00
for _, split := range base {
2021-08-11 20:24:51 +00:00
for suffix, optional := range map[string]bool{"": false, "-debug": true} {
deps, exp, errAdd = doAddTarget(dp, localNamesCache, remoteNamesCache,
2021-08-11 20:24:51 +00:00
arguments, cmdArgs, pkgdests, deps, exp, split.Name+suffix, optional)
if errAdd != nil {
return errAdd
}
}
}
2021-08-11 18:13:28 +00:00
var (
mux sync.Mutex
wg sync.WaitGroup
)
for _, pkg := range base {
2018-08-02 22:30:48 +00:00
wg.Add(1)
2021-08-11 18:13:28 +00:00
2021-08-12 16:56:23 +00:00
go config.Runtime.VCSStore.Update(ctx, pkg.Name, srcinfo.Source, &mux, &wg)
}
2018-08-02 22:30:48 +00:00
wg.Wait()
}
2021-08-12 16:56:23 +00:00
err = doInstall(ctx, arguments, cmdArgs, deps, exp)
settings.NoConfirm = oldConfirm
2021-08-11 18:13:28 +00:00
return err
}
2021-08-12 16:56:23 +00:00
func doInstall(ctx context.Context, arguments, cmdArgs *parser.Arguments, pkgDeps, pkgExp []string) error {
if len(arguments.Targets) == 0 {
return nil
}
2021-08-12 16:56:23 +00:00
if errShow := config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
arguments, config.Runtime.Mode, settings.NoConfirm)); errShow != nil {
return errShow
}
if errStore := config.Runtime.VCSStore.Save(); errStore != nil {
fmt.Fprintln(os.Stderr, errStore)
}
2021-08-12 16:56:23 +00:00
if errDeps := asdeps(ctx, cmdArgs, pkgDeps); errDeps != nil {
return errDeps
}
2021-08-12 16:56:23 +00:00
return asexp(ctx, cmdArgs, pkgExp)
}
func doAddTarget(dp *dep.Pool, localNamesCache, remoteNamesCache stringset.StringSet,
arguments, cmdArgs *parser.Arguments, pkgdests map[string]string,
deps, exp []string, name string, optional bool) (newDeps, newExp []string, err error) {
pkgdest, ok := pkgdests[name]
if !ok {
if optional {
return deps, exp, nil
}
return deps, exp, errors.New(gotext.Get("could not find PKGDEST for: %s", name))
}
if _, errStat := os.Stat(pkgdest); os.IsNotExist(errStat) {
if optional {
return deps, exp, nil
}
return deps, exp, errors.New(
gotext.Get(
"the PKGDEST for %s is listed by makepkg but does not exist: %s",
name, pkgdest))
}
arguments.AddTarget(pkgdest)
2021-08-11 18:13:28 +00:00
switch {
case cmdArgs.ExistsArg("asdeps", "asdep"):
deps = append(deps, name)
2021-08-11 18:13:28 +00:00
case cmdArgs.ExistsArg("asexplicit", "asexp"):
exp = append(exp, name)
2021-08-11 18:13:28 +00:00
case !dp.Explicit.Get(name) && !localNamesCache.Get(name) && !remoteNamesCache.Get(name):
deps = append(deps, name)
}
return deps, exp, nil
}