yay/install.go

1181 lines
29 KiB
Go
Raw Normal View History

package main
import (
"errors"
"fmt"
"os"
"os/exec"
"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"
"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"
"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"
"github.com/Jguer/yay/v10/pkg/query"
2020-07-05 00:45:23 +00:00
"github.com/Jguer/yay/v10/pkg/settings"
"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"
)
const gitEmptyTree = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
func asdeps(cmdArgs *settings.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...)
err = config.Runtime.CmdRunner.Show(passToPacman(cmdArgs))
if err != nil {
return fmt.Errorf(gotext.Get("error updating package install reason to dependency"))
}
return nil
}
func asexp(cmdArgs *settings.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...)
err = config.Runtime.CmdRunner.Show(passToPacman(cmdArgs))
if err != nil {
return fmt.Errorf(gotext.Get("error updating package install reason to explicit"))
}
return nil
}
// Install handles package installs
2020-08-16 21:41:38 +00:00
func install(cmdArgs *settings.Arguments, dbExecutor db.Executor, ignoreProviders bool) (err error) {
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
var srcinfos map[string]*gosrc.Srcinfo
2020-07-10 00:36:45 +00:00
warnings := query.NewWarnings()
2020-07-05 00:45:23 +00:00
if config.Runtime.Mode == settings.ModeAny || config.Runtime.Mode == settings.ModeRepo {
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 {
2020-07-08 01:22:01 +00:00
if cmdArgs.ExistsArg("y", "refresh") {
err = earlyRefresh(cmdArgs)
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 err != 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
}
}
2020-07-08 01:22:01 +00:00
} else if cmdArgs.ExistsArg("y", "refresh") || cmdArgs.ExistsArg("u", "sysupgrade") || len(cmdArgs.Targets) > 0 {
err = earlyPacmanCall(cmdArgs, dbExecutor)
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 err != nil {
return err
}
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.
err = dbExecutor.RefreshHandle()
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
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
2020-07-05 00:45:23 +00:00
if config.Runtime.Mode == settings.ModeAUR {
arguments.DelArg("u", "sysupgrade")
}
// if we are doing -u also request all packages needing update
2020-07-08 01:22:01 +00:00
if cmdArgs.ExistsArg("u", "sysupgrade") {
aurUp, repoUp, err = upList(warnings, dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"), func(upgrade.Upgrade) bool { return true })
if err != nil {
return err
}
2020-07-10 00:36:45 +00:00
warnings.Print()
2018-05-30 02:21:17 +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 {
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 {
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
}
if len(ignore) > 0 {
arguments.CreateOrAppendOption("ignore", ignore.ToSlice()...)
}
}
2020-07-08 01:22:01 +00:00
targets := stringset.FromSlice(cmdArgs.Targets)
2020-07-10 00:36:45 +00:00
dp, err := dep.GetPool(requestTargets,
warnings, dbExecutor, config.Runtime.Mode,
ignoreProviders, settings.NoConfirm, config.Provides, config.ReBuild, config.RequestSplitN)
if err != nil {
return err
}
2020-07-08 01:22:01 +00:00
if !cmdArgs.ExistsDouble("d", "nodeps") {
err = dp.CheckMissing()
if err != nil {
return err
}
}
if len(dp.Aur) == 0 {
if !config.CombinedUpgrade {
2020-07-08 01:22:01 +00:00
if cmdArgs.ExistsArg("u", "sysupgrade") {
fmt.Println(gotext.Get(" there is nothing to do"))
}
return nil
}
2020-07-08 01:22:01 +00:00
cmdArgs.Op = "S"
cmdArgs.DelArg("y", "refresh")
if arguments.ExistsArg("ignore") {
cmdArgs.CreateOrAppendOption("ignore", arguments.GetArgs("ignore")...)
}
return config.Runtime.CmdRunner.Show(passToPacman(cmdArgs))
}
if len(dp.Aur) > 0 && os.Geteuid() == 0 {
return fmt.Errorf(gotext.Get("refusing to install AUR packages as root, aborting"))
}
var conflicts stringset.MapStringSet
2020-07-08 01:22:01 +00:00
if !cmdArgs.ExistsDouble("d", "nodeps") {
conflicts, err = dp.CheckConflicts(config.UseAsk, settings.NoConfirm)
if err != nil {
return err
}
}
2020-07-10 00:36:45 +00:00
do = dep.GetOrder(dp)
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())
}
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
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) {
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 {
defer cleanAfter(do.Aur)
}
if do.HasMake() {
switch config.RemoveMake {
case "yes":
defer func() {
err = removeMake(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() {
err = removeMake(do)
}()
2019-06-11 13:54:24 +00:00
}
}
}
if config.CleanMenu {
if anyExistInCache(do.Aur) {
askClean := pkgbuildNumberMenu(do.Aur, remoteNamesCache)
toClean, errClean := cleanNumberMenu(do.Aur, remoteNamesCache, askClean)
if errClean != nil {
return errClean
}
cleanBuilds(toClean)
}
}
toSkip := pkgbuildsToSkip(do.Aur, targets)
cloned, err := downloadPkgbuilds(do.Aur, toSkip, config.BuildDir)
if err != nil {
return err
}
2020-07-10 00:36:45 +00:00
var toDiff []dep.Base
var toEdit []dep.Base
if config.DiffMenu {
pkgbuildNumberMenu(do.Aur, remoteNamesCache)
toDiff, err = diffNumberMenu(do.Aur, remoteNamesCache)
if err != nil {
return err
}
2018-06-10 01:02:24 +00:00
if len(toDiff) > 0 {
err = showPkgbuildDiffs(toDiff, cloned)
if err != nil {
return err
}
}
}
if len(toDiff) > 0 {
oldValue := settings.NoConfirm
settings.NoConfirm = false
fmt.Println()
if !text.ContinueTask(gotext.Get("Proceed with install?"), true, settings.NoConfirm) {
return fmt.Errorf(gotext.Get("aborting due to user"))
}
err = updatePkgbuildSeenRef(toDiff)
if err != nil {
text.Errorln(err.Error())
}
settings.NoConfirm = oldValue
}
err = mergePkgbuilds(do.Aur)
if err != nil {
return err
}
srcinfos, err = parseSrcinfoFiles(do.Aur, true)
if err != nil {
return err
}
if config.EditMenu {
pkgbuildNumberMenu(do.Aur, remoteNamesCache)
toEdit, err = editNumberMenu(do.Aur, remoteNamesCache)
if err != nil {
return err
}
if len(toEdit) > 0 {
err = editPkgbuilds(toEdit, srcinfos)
if err != nil {
return err
}
}
}
if len(toEdit) > 0 {
oldValue := settings.NoConfirm
settings.NoConfirm = false
fmt.Println()
if !text.ContinueTask(gotext.Get("Proceed with install?"), true, settings.NoConfirm) {
return errors.New(gotext.Get("aborting due to user"))
}
settings.NoConfirm = oldValue
}
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 {
err = pgp.CheckPgpKeys(do.Aur, srcinfos, config.GpgBin, config.GpgFlags, settings.NoConfirm)
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
if err != nil {
return err
}
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") {
if errShow := config.Runtime.CmdRunner.Show(passToPacman(arguments)); 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())
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
}
2020-07-08 01:22:01 +00:00
if errDeps := asdeps(cmdArgs, deps); errDeps != nil {
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 {
return errExp
}
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)
}()
err = downloadPkgbuildsSources(do.Aur, incompatible)
if err != nil {
return err
}
2020-07-31 23:20:00 +00:00
err = buildInstallPkgbuilds(cmdArgs, dbExecutor, dp, do, srcinfos, incompatible, conflicts)
if err != nil {
return err
}
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
}
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")
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
err = config.Runtime.CmdRunner.Show(passToPacman(removeArguments))
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 = 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 {
// 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 {
if err := config.Runtime.CmdRunner.Show(passToPacman(arguments)); err != nil {
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()
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) {
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()
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 arch == "any" || arch == alpmArch {
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:"))
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, errors.New(gotext.Get("aborting due to user"))
}
}
return incompatible, nil
}
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)
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 anyExistInCache(bases []dep.Base) bool {
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 {
toPrint := ""
askClean := false
for n, base := range bases {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
2020-08-16 22:09:43 +00:00
toPrint += fmt.Sprintf(text.Magenta("%3d")+" %-40s", len(bases)-n,
text.Bold(base.String()))
anyInstalled := false
for _, b := range base {
anyInstalled = anyInstalled || installed.Get(b.Name)
}
if anyInstalled {
2020-08-16 22:09:43 +00:00
toPrint += text.Bold(text.Green(gotext.Get(" (Installed)")))
}
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)")))
askClean = true
}
toPrint += "\n"
}
fmt.Print(toPrint)
return askClean
}
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)
if !hasClean {
return toClean, nil
}
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"))))
cleanInput, err := getInput(config.AnswerClean)
if err != nil {
return nil, err
}
cInclude, cExclude, cOtherInclude, cOtherExclude := intrange.ParseNumberMenu(cleanInput)
cIsInclude := len(cExclude) == 0 && len(cOtherExclude) == 0
if cOtherInclude.Get("abort") || cOtherInclude.Get("ab") {
return nil, fmt.Errorf(gotext.Get("aborting due to user"))
}
if !cOtherInclude.Get("n") && !cOtherInclude.Get("none") {
for i, base := range bases {
pkg := base.Pkgbase()
anyInstalled := false
for _, b := range base {
anyInstalled = anyInstalled || installed.Get(b.Name)
}
dir := filepath.Join(config.BuildDir, pkg)
if _, err := os.Stat(dir); os.IsNotExist(err) {
continue
}
if !cIsInclude && cExclude.Get(len(bases)-i) {
continue
}
if anyInstalled && (cOtherInclude.Get("i") || cOtherInclude.Get("installed")) {
toClean = append(toClean, base)
continue
}
if !anyInstalled && (cOtherInclude.Get("no") || cOtherInclude.Get("notinstalled")) {
toClean = append(toClean, base)
continue
}
if cOtherInclude.Get("a") || cOtherInclude.Get("all") {
toClean = append(toClean, base)
continue
}
if cIsInclude && (cInclude.Get(len(bases)-i) || cOtherInclude.Get(pkg)) {
toClean = append(toClean, base)
continue
}
if !cIsInclude && (!cExclude.Get(len(bases)-i) && !cOtherExclude.Get(pkg)) {
toClean = append(toClean, base)
continue
}
}
}
return toClean, nil
}
2020-07-10 00:36:45 +00:00
func editNumberMenu(bases []dep.Base, installed stringset.StringSet) ([]dep.Base, error) {
return editDiffNumberMenu(bases, installed, false)
}
2020-07-10 00:36:45 +00:00
func diffNumberMenu(bases []dep.Base, installed stringset.StringSet) ([]dep.Base, error) {
return editDiffNumberMenu(bases, installed, true)
}
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)
var editInput string
var err error
if diff {
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"))))
editInput, err = getInput(config.AnswerDiff)
if err != nil {
return nil, err
}
} else {
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"))))
editInput, err = getInput(config.AnswerEdit)
if err != nil {
return nil, err
}
}
eInclude, eExclude, eOtherInclude, eOtherExclude := intrange.ParseNumberMenu(editInput)
eIsInclude := len(eExclude) == 0 && len(eOtherExclude) == 0
if eOtherInclude.Get("abort") || eOtherInclude.Get("ab") {
return nil, fmt.Errorf(gotext.Get("aborting due to user"))
}
if !eOtherInclude.Get("n") && !eOtherInclude.Get("none") {
for i, base := range bases {
pkg := base.Pkgbase()
anyInstalled := false
for _, b := range base {
anyInstalled = anyInstalled || installed.Get(b.Name)
}
if !eIsInclude && eExclude.Get(len(bases)-i) {
continue
}
if anyInstalled && (eOtherInclude.Get("i") || eOtherInclude.Get("installed")) {
toEdit = append(toEdit, base)
continue
}
if !anyInstalled && (eOtherInclude.Get("no") || eOtherInclude.Get("notinstalled")) {
toEdit = append(toEdit, base)
continue
}
if eOtherInclude.Get("a") || eOtherInclude.Get("all") {
toEdit = append(toEdit, base)
continue
}
if eIsInclude && (eInclude.Get(len(bases)-i) || eOtherInclude.Get(pkg)) {
toEdit = append(toEdit, base)
}
if !eIsInclude && (!eExclude.Get(len(bases)-i) && !eOtherExclude.Get(pkg)) {
toEdit = append(toEdit, base)
}
}
}
return toEdit, nil
}
2020-07-10 00:36:45 +00:00
func updatePkgbuildSeenRef(bases []dep.Base) error {
var errMulti multierror.MultiError
for _, base := range bases {
pkg := base.Pkgbase()
err := gitUpdateSeenRef(config.BuildDir, pkg)
if err != nil {
errMulti.Add(err)
}
}
return errMulti.Return()
}
2020-07-10 00:36:45 +00:00
func showPkgbuildDiffs(bases []dep.Base, cloned stringset.StringSet) error {
var errMulti multierror.MultiError
for _, base := range bases {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
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)
if err != nil {
errMulti.Add(err)
continue
}
if !hasDiff {
2020-08-16 22:09:43 +00:00
text.Warnln(gotext.Get("%s: No changes -- skipping", text.Cyan(base.String())))
continue
}
}
2020-07-08 01:40:50 +00:00
args := []string{
"diff",
start + "..HEAD@{upstream}", "--src-prefix",
2020-07-08 01:40:50 +00:00
dir + "/", "--dst-prefix", dir + "/", "--", ".", ":(exclude).SRCINFO",
}
if text.UseColor {
args = append(args, "--color=always")
} else {
args = append(args, "--color=never")
}
2020-08-21 23:24:52 +00:00
_ = config.Runtime.CmdRunner.Show(config.Runtime.CmdBuilder.BuildGitCmd(dir, args...))
}
return errMulti.Return()
}
2020-07-10 00:36:45 +00:00
func editPkgbuilds(bases []dep.Base, srcinfos map[string]*gosrc.Srcinfo) error {
pkgbuilds := make([]string, 0, len(bases))
for _, base := range bases {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
pkgbuilds = append(pkgbuilds, filepath.Join(dir, "PKGBUILD"))
for _, splitPkg := range srcinfos[pkg].SplitPackages() {
if splitPkg.Install != "" {
pkgbuilds = append(pkgbuilds, filepath.Join(dir, splitPkg.Install))
}
}
}
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 {
return errors.New(gotext.Get("editor did not exit successfully, aborting: %s", err))
}
}
return 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)
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
}
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
}
2020-07-10 00:36:45 +00:00
func mergePkgbuilds(bases []dep.Base) error {
for _, base := range bases {
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) {
cloned := make(stringset.StringSet)
2018-08-02 15:49:30 +00:00
downloaded := 0
var wg sync.WaitGroup
var mux sync.Mutex
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()
pkg := base.Pkgbase()
if toSkip.Get(pkg) {
2018-08-02 15:49:30 +00:00
mux.Lock()
downloaded++
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
}
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()
}
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()
}
count := 0
for _, base := range bases {
2018-08-02 15:49:30 +00:00
wg.Add(1)
go download(base)
count++
if count%25 == 0 {
wg.Wait()
}
2018-08-02 15:49:30 +00:00
}
wg.Wait()
return cloned, errs.Return()
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
}
2020-07-10 00:36:45 +00:00
func downloadPkgbuildsSources(bases []dep.Base, incompatible stringset.StringSet) (err error) {
for _, base := range bases {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
args := []string{"--verifysource", "-Ccf"}
if incompatible.Get(pkg) {
args = append(args, "--ignorearch")
}
2020-08-21 23:24:52 +00:00
err = config.Runtime.CmdRunner.Show(
config.Runtime.CmdBuilder.BuildMakepkgCmd(dir, args...))
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
if err != nil {
2020-08-16 22:09:43 +00:00
return errors.New(gotext.Get("error downloading sources: %s", text.Cyan(base.String())))
}
}
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
return
}
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,
srcinfos map[string]*gosrc.Srcinfo,
incompatible stringset.StringSet,
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")
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)
doInstall := func() error {
2020-07-05 00:45:23 +00:00
if len(arguments.Targets) == 0 {
return nil
}
if errShow := config.Runtime.CmdRunner.Show(passToPacman(arguments)); errShow != nil {
return errShow
}
if errStore := config.Runtime.VCSStore.Save(); err != nil {
fmt.Fprintln(os.Stderr, errStore)
}
2020-07-08 01:22:01 +00:00
if errDeps := asdeps(cmdArgs, deps); err != nil {
return errDeps
}
2020-07-08 01:22:01 +00:00
if errExps := asexp(cmdArgs, exp); err != nil {
return errExps
}
settings.NoConfirm = oldConfirm
2020-07-05 00:45:23 +00:00
arguments.ClearTargets()
deps = make([]string, 0)
exp = make([]string, 0)
settings.NoConfirm = true
return nil
}
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 [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) {
satisfied = false
text.Warnln(gotext.Get("%s not satisfied, flushing install queue", dep))
break all
}
}
}
}
if !satisfied || !config.BatchInstall {
err = doInstall()
if err != nil {
return err
}
}
srcinfo := srcinfos[pkg]
args := []string{"--nobuild", "-fC"}
if incompatible.Get(pkg) {
args = append(args, "--ignorearch")
}
// pkgver bump
2020-08-21 23:24:52 +00:00
if err = config.Runtime.CmdRunner.Show(
config.Runtime.CmdBuilder.BuildMakepkgCmd(dir, args...)); err != nil {
return errors.New(gotext.Get("error making: %s", base.String()))
}
pkgdests, pkgVersion, errList := parsePackageList(dir)
if errList != nil {
return errList
}
isExplicit := false
for _, b := range base {
isExplicit = isExplicit || dp.Explicit.Get(b.Name)
}
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 {
2020-08-21 23:24:52 +00:00
err = config.Runtime.CmdRunner.Show(
config.Runtime.CmdBuilder.BuildMakepkgCmd(
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)))
continue
}
}
if built {
2020-08-21 23:24:52 +00:00
err = config.Runtime.CmdRunner.Show(
config.Runtime.CmdBuilder.BuildMakepkgCmd(
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")
}
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()))
}
}
// 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
break
}
}
}
doAddTarget := func(name string, optional bool) error {
pkgdest, ok := pkgdests[name]
if !ok {
if optional {
return nil
}
return errors.New(gotext.Get("could not find PKGDEST for: %s", name))
}
2018-02-16 17:18:59 +00:00
if _, errStat := os.Stat(pkgdest); os.IsNotExist(errStat) {
if optional {
return nil
}
return errors.New(
gotext.Get(
"the PKGDEST for %s is listed by makepkg but does not exist: %s",
name, pkgdest))
}
2020-07-05 00:45:23 +00:00
arguments.AddTarget(pkgdest)
2020-07-08 01:22:01 +00:00
if cmdArgs.ExistsArg("asdeps", "asdep") {
deps = append(deps, name)
2020-07-08 01:22:01 +00:00
} else if cmdArgs.ExistsArg("asexplicit", "asexp") {
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 {
if errAdd := doAddTarget(split.Name, false); errAdd != nil {
return errAdd
}
if errAddDebug := doAddTarget(split.Name+"-debug", true); errAddDebug != nil {
return errAddDebug
}
}
2018-08-02 22:30:48 +00:00
var mux sync.Mutex
var wg sync.WaitGroup
for _, pkg := range base {
2018-08-02 22:30:48 +00:00
wg.Add(1)
go config.Runtime.VCSStore.Update(pkg.Name, srcinfo.Source, &mux, &wg)
}
2018-08-02 22:30:48 +00:00
wg.Wait()
}
err = doInstall()
settings.NoConfirm = oldConfirm
return err
}