yay/install.go

1136 lines
26 KiB
Go
Raw Normal View History

package main
import (
"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"
2019-04-23 15:53:20 +00:00
alpm "github.com/Jguer/go-alpm"
2019-10-05 01:02:30 +00:00
"github.com/Jguer/yay/v9/pkg/completion"
2019-10-05 16:35:46 +00:00
"github.com/Jguer/yay/v9/pkg/types"
2019-06-11 13:54:24 +00:00
gosrc "github.com/Morganamilo/go-srcinfo"
)
// Install handles package installs
2019-06-11 13:54:24 +00:00
func install(parser *arguments) (err error) {
var incompatible types.StringSet
var do *depOrder
2018-03-21 00:26:56 +00:00
var aurUp upSlice
var repoUp upSlice
var srcinfos map[string]*gosrc.Srcinfo
warnings := &aurWarnings{}
if mode == modeAny || mode == 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 {
if parser.existsArg("y", "refresh") {
2018-07-19 18:53:17 +00:00
err = earlyRefresh(parser)
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 {
2018-07-19 18:53:17 +00:00
return fmt.Errorf("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
}
}
} else if parser.existsArg("y", "refresh") || parser.existsArg("u", "sysupgrade") || len(parser.targets) > 0 {
2018-07-19 18:53:17 +00:00
err = earlyPacmanCall(parser)
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
2018-07-19 18:53:17 +00:00
//we may have done -Sy, our handle now has an old
//database.
err = initAlpmHandle()
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
2018-07-19 18:53:17 +00:00
_, _, localNames, remoteNames, err := filterPackages()
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 := types.SliceToStringSet(remoteNames)
localNamesCache := types.SliceToStringSet(localNames)
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
requestTargets := parser.copy().targets
//create the arguments to pass for the repo install
arguments := parser.copy()
arguments.delArg("asdeps", "asdep")
arguments.delArg("asexplicit", "asexp")
arguments.op = "S"
arguments.clearTargets()
2018-02-21 08:41:25 +00:00
if mode == modeAUR {
arguments.delArg("u", "sysupgrade")
}
2018-05-30 02:21:17 +00:00
//if we are doing -u also request all packages needing update
if parser.existsArg("u", "sysupgrade") {
2018-05-30 02:21:17 +00:00
aurUp, repoUp, err = upList(warnings)
if err != nil {
return err
}
2018-05-30 02:21:17 +00:00
warnings.print()
ignore, aurUp, err := upgradePkgs(aurUp, repoUp)
if err != nil {
return err
}
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)
parser.addTarget(up.Name)
2018-04-04 20:51:57 +00:00
}
}
for up := range aurUp {
requestTargets = append(requestTargets, "aur/"+up)
parser.addTarget("aur/" + up)
2018-04-04 20:51:57 +00:00
}
value, _, exists := cmdArgs.getArg("ignore")
if len(ignore) > 0 {
ignoreStr := strings.Join(ignore.ToSlice(), ",")
if exists {
ignoreStr += "," + value
}
arguments.options["ignore"] = ignoreStr
}
}
targets := types.SliceToStringSet(parser.targets)
dp, err := getDepPool(requestTargets, warnings)
if err != nil {
return err
}
err = dp.CheckMissing()
if err != nil {
return err
}
if len(dp.Aur) == 0 {
if !config.CombinedUpgrade {
if parser.existsArg("u", "sysupgrade") {
fmt.Println(" there is nothing to do")
}
return nil
}
parser.op = "S"
parser.delArg("y", "refresh")
parser.options["ignore"] = arguments.options["ignore"]
return show(passToPacman(parser))
}
if len(dp.Aur) > 0 && os.Geteuid() == 0 {
return fmt.Errorf(bold(red(arrow)) + " Refusing to install AUR Packages as root, Aborting.")
}
conflicts, err := dp.CheckConflicts()
if err != nil {
return err
}
do = getDepOrder(dp)
if err != nil {
return err
}
for _, pkg := range do.Repo {
2018-03-16 01:14:34 +00:00
arguments.addTarget(pkg.DB().Name() + "/" + pkg.Name())
}
for _, pkg := range dp.Groups {
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
if len(do.Aur) == 0 && len(arguments.targets) == 0 && (!parser.existsArg("u", "sysupgrade") || mode == modeAUR) {
fmt.Println(" 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:
2019-06-11 13:54:24 +00:00
if continueTask("Remove make dependencies after install?", false) {
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, err := cleanNumberMenu(do.Aur, remoteNamesCache, askClean)
if err != nil {
return err
}
cleanBuilds(toClean)
}
}
toSkip := pkgbuildsToSkip(do.Aur, targets)
cloned, err := downloadPkgbuilds(do.Aur, toSkip, config.BuildDir)
if err != nil {
return err
}
var toDiff []Base
var toEdit []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 {
// TODO: PKGBUILD diffs should not return in case of err. Just print and continue
err = showPkgbuildDiffs(toDiff, cloned)
if err != nil {
return err
}
}
}
if len(toDiff) > 0 {
oldValue := config.NoConfirm
config.NoConfirm = false
fmt.Println()
if !continueTask(bold(green("Proceed with install?")), true) {
return fmt.Errorf("Aborting due to user")
}
err = updatePkgbuildSeenRef(toDiff, cloned)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
}
config.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 := config.NoConfirm
config.NoConfirm = false
fmt.Println()
if !continueTask(bold(green("Proceed with install?")), true) {
return fmt.Errorf("Aborting due to user")
}
config.NoConfirm = oldValue
}
2018-02-16 17:18:59 +00:00
incompatible, err = getIncompatible(do.Aur, srcinfos)
if err != nil {
return err
}
if config.PGPFetch {
err = checkPgpKeys(do.Aur, srcinfos)
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 {
arguments.delArg("u", "sysupgrade")
}
2018-03-22 18:23:20 +00:00
if len(arguments.targets) > 0 || arguments.existsArg("u") {
err := show(passToPacman(arguments))
2018-03-21 00:26:56 +00:00
if err != nil {
return fmt.Errorf("Error installing repo packages")
}
depArguments := makeArguments()
err = depArguments.addArg("D", "asdeps")
if err != nil {
return err
}
expArguments := makeArguments()
err = expArguments.addArg("D", "asexplicit")
if err != nil {
return err
}
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()) {
depArguments.addTarget(pkg.Name())
continue
}
if parser.existsArg("asdeps", "asdep") && dp.Explicit.Get(pkg.Name()) {
depArguments.addTarget(pkg.Name())
} else if parser.existsArg("asexp", "asexplicit") && dp.Explicit.Get(pkg.Name()) {
expArguments.addTarget(pkg.Name())
2018-03-22 15:22:05 +00:00
}
2018-03-21 00:26:56 +00:00
}
if len(depArguments.targets) > 0 {
_, stderr, err := capture(passToPacman(depArguments))
if err != nil {
return fmt.Errorf("%s%s", stderr, err)
}
2018-03-21 00:26:56 +00:00
}
if len(expArguments.targets) > 0 {
_, stderr, err := capture(passToPacman(expArguments))
if err != nil {
return fmt.Errorf("%s%s", stderr, err)
}
}
2018-03-21 00:26:56 +00:00
}
go exitOnError(completion.Update(alpmHandle, config.AURURL, cacheHome, config.CompletionInterval, false))
err = downloadPkgbuildsSources(do.Aur, incompatible)
if err != nil {
return err
}
err = buildInstallPkgbuilds(dp, do, srcinfos, parser, 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
}
func removeMake(do *depOrder) error {
2019-06-11 13:54:24 +00:00
removeArguments := makeArguments()
err := removeArguments.addArg("R", "u")
if err != nil {
return err
}
2019-06-11 13:54:24 +00:00
for _, pkg := range do.getMake() {
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
2019-06-11 13:54:24 +00:00
oldValue := config.NoConfirm
config.NoConfirm = true
err = show(passToPacman(removeArguments))
2019-06-11 13:54:24 +00:00
config.NoConfirm = oldValue
return err
}
2019-02-04 16:56:02 +00:00
func inRepos(syncDB alpm.DBList, pkg string) bool {
2018-07-19 18:53:17 +00:00
target := toTarget(pkg)
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
}
previousHideMenus := hideMenus
hideMenus = false
2019-02-04 16:56:02 +00:00
_, err := syncDB.FindSatisfier(target.DepString())
hideMenus = previousHideMenus
2018-07-19 18:53:17 +00:00
if err == nil {
return true
}
2019-02-14 20:44:39 +00:00
return !syncDB.FindGroupPkgs(target.Name).Empty()
2018-07-19 18:53:17 +00:00
}
func earlyPacmanCall(parser *arguments) error {
arguments := parser.copy()
arguments.op = "S"
targets := parser.targets
parser.clearTargets()
arguments.clearTargets()
2019-02-04 16:56:02 +00:00
syncDB, err := alpmHandle.SyncDBs()
2018-07-19 18:53:17 +00:00
if err != nil {
return err
}
if mode == modeRepo {
2018-07-19 18:53:17 +00:00
arguments.targets = targets
} else {
2018-10-02 20:30:18 +00:00
//separate aur and repo targets
2018-07-19 18:53:17 +00:00
for _, target := range targets {
2019-02-04 16:56:02 +00:00
if inRepos(syncDB, target) {
2018-07-19 18:53:17 +00:00
arguments.addTarget(target)
} else {
parser.addTarget(target)
}
}
}
if parser.existsArg("y", "refresh") || parser.existsArg("u", "sysupgrade") || len(arguments.targets) > 0 {
err = show(passToPacman(arguments))
if err != nil {
return fmt.Errorf("Error installing repo packages")
}
}
return nil
}
func earlyRefresh(parser *arguments) error {
arguments := parser.copy()
parser.delArg("y", "refresh")
arguments.delArg("u", "sysupgrade")
arguments.delArg("s", "search")
arguments.delArg("i", "info")
arguments.delArg("l", "list")
arguments.clearTargets()
return show(passToPacman(arguments))
}
func getIncompatible(bases []Base, srcinfos map[string]*gosrc.Srcinfo) (types.StringSet, error) {
incompatible := make(types.StringSet)
basesMap := make(map[string]Base)
alpmArch, err := alpmHandle.Arch()
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 {
fmt.Println()
2018-12-01 14:58:40 +00:00
fmt.Print(bold(yellow(arrow)) + " The following packages are not compatible with your architecture:")
for pkg := range incompatible {
2018-12-01 14:58:40 +00:00
fmt.Print(" " + cyan(basesMap[pkg].String()))
}
fmt.Println()
if !continueTask("Try to build them anyway?", true) {
return nil, fmt.Errorf("Aborting due to user")
}
}
return incompatible, nil
}
2018-06-05 13:47:55 +00:00
func parsePackageList(dir string) (map[string]string, string, error) {
stdout, stderr, err := capture(passToMakepkg(dir, "--packagelist"))
if err != nil {
2018-06-05 13:47:55 +00:00
return nil, "", fmt.Errorf("%s%s", stderr, err)
}
2018-06-05 13:47:55 +00:00
var version string
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 {
2018-06-05 13:47:55 +00:00
return nil, "", fmt.Errorf("Can not find package name : %s", 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], "-")
version = strings.Join(split[len(split)-3:len(split)-1], "-")
pkgdests[pkgname] = line
}
2018-06-05 13:47:55 +00:00
return pkgdests, version, nil
}
func anyExistInCache(bases []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
}
func pkgbuildNumberMenu(bases []Base, installed types.StringSet) bool {
toPrint := ""
askClean := false
for n, base := range bases {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
toPrint += fmt.Sprintf(magenta("%3d")+" %-40s", len(bases)-n,
bold(base.String()))
anyInstalled := false
for _, b := range base {
anyInstalled = anyInstalled || installed.Get(b.Name)
}
if anyInstalled {
toPrint += bold(green(" (Installed)"))
}
if _, err := os.Stat(dir); !os.IsNotExist(err) {
toPrint += bold(green(" (Build Files Exist)"))
askClean = true
}
toPrint += "\n"
}
fmt.Print(toPrint)
return askClean
}
func cleanNumberMenu(bases []Base, installed types.StringSet, hasClean bool) ([]Base, error) {
toClean := make([]Base, 0)
if !hasClean {
return toClean, nil
}
fmt.Println(bold(green(arrow + " Packages to cleanBuild?")))
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + "[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)"))
fmt.Print(bold(green(arrow + " ")))
cleanInput, err := getInput(config.AnswerClean)
if err != nil {
return nil, err
}
cInclude, cExclude, cOtherInclude, cOtherExclude := types.ParseNumberMenu(cleanInput)
cIsInclude := len(cExclude) == 0 && len(cOtherExclude) == 0
if cOtherInclude.Get("abort") || cOtherInclude.Get("ab") {
return nil, fmt.Errorf("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
}
func editNumberMenu(bases []Base, installed types.StringSet) ([]Base, error) {
return editDiffNumberMenu(bases, installed, false)
}
func diffNumberMenu(bases []Base, installed types.StringSet) ([]Base, error) {
return editDiffNumberMenu(bases, installed, true)
}
func editDiffNumberMenu(bases []Base, installed types.StringSet, diff bool) ([]Base, error) {
toEdit := make([]Base, 0)
var editInput string
var err error
if diff {
fmt.Println(bold(green(arrow + " Diffs to show?")))
2019-03-29 22:05:04 +00:00
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + "[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)"))
fmt.Print(bold(green(arrow + " ")))
editInput, err = getInput(config.AnswerDiff)
if err != nil {
return nil, err
}
} else {
fmt.Println(bold(green(arrow + " PKGBUILDs to edit?")))
2019-03-29 22:05:04 +00:00
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + "[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)"))
fmt.Print(bold(green(arrow + " ")))
editInput, err = getInput(config.AnswerEdit)
if err != nil {
return nil, err
}
}
eInclude, eExclude, eOtherInclude, eOtherExclude := types.ParseNumberMenu(editInput)
eIsInclude := len(eExclude) == 0 && len(eOtherExclude) == 0
if eOtherInclude.Get("abort") || eOtherInclude.Get("ab") {
return nil, fmt.Errorf("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
}
func updatePkgbuildSeenRef(bases []Base, cloned types.StringSet) error {
var errMulti types.MultiError
for _, base := range bases {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
if shouldUseGit(dir) {
err := gitUpdateSeenRef(config.BuildDir, pkg)
if err != nil {
errMulti.Add(err)
}
}
}
return errMulti.Return()
}
func showPkgbuildDiffs(bases []Base, cloned types.StringSet) error {
var errMulti types.MultiError
for _, base := range bases {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
if shouldUseGit(dir) {
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 {
fmt.Printf("%s %s: %s\n", bold(yellow(arrow)), cyan(base.String()), bold("No changes -- skipping"))
continue
}
}
2018-08-02 14:21:01 +00:00
args := []string{"diff", start + "..HEAD@{upstream}", "--src-prefix", dir + "/", "--dst-prefix", dir + "/", "--", ".", ":(exclude).SRCINFO"}
if useColor {
args = append(args, "--color=always")
} else {
args = append(args, "--color=never")
}
err = show(passToGit(dir, args...))
if err != nil {
errMulti.Add(err)
continue
}
} else {
args := []string{"diff"}
if useColor {
args = append(args, "--color=always")
} else {
args = append(args, "--color=never")
}
args = append(args, "--no-index", "/var/empty", dir)
// git always returns 1. why? I have no idea
err := show(passToGit(dir, args...))
if err != nil {
errMulti.Add(err)
continue
}
}
}
return errMulti.Return()
}
func editPkgbuilds(bases []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 fmt.Errorf("Editor did not exit successfully, Aborting: %s", err)
}
}
return nil
}
func parseSrcinfoFiles(bases []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
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
fmt.Printf(str, k+1, len(bases), cyan(base.String()))
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
if err != nil {
if !errIsFatal {
fmt.Fprintf(os.Stderr, "failed to parse %s -- skipping: %s\n", base.String(), err)
continue
}
return nil, fmt.Errorf("failed to parse %s: %s", base.String(), err)
}
srcinfos[pkg] = pkgbuild
}
return srcinfos, nil
}
func pkgbuildsToSkip(bases []Base, targets types.StringSet) types.StringSet {
toSkip := make(types.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 mergePkgbuilds(bases []Base) error {
for _, base := range bases {
if shouldUseGit(filepath.Join(config.BuildDir, base.Pkgbase())) {
err := gitMerge(config.BuildDir, base.Pkgbase())
2018-06-10 00:29:54 +00:00
if err != nil {
return err
}
}
}
return nil
}
func downloadPkgbuilds(bases []Base, toSkip types.StringSet, buildDir string) (types.StringSet, error) {
cloned := make(types.StringSet)
2018-08-02 15:49:30 +00:00
downloaded := 0
var wg sync.WaitGroup
var mux sync.Mutex
2019-10-05 16:35:46 +00:00
var errs types.MultiError
2018-08-02 15:49:30 +00:00
download := func(k int, base 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++
str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n")
fmt.Printf(str, downloaded, len(bases), cyan(base.String()))
2018-08-02 15:49:30 +00:00
mux.Unlock()
return
}
if shouldUseGit(filepath.Join(config.BuildDir, pkg)) {
2018-08-19 04:05:16 +00:00
clone, err := gitDownload(config.AURURL+"/"+pkg+".git", buildDir, pkg)
if err != nil {
2018-08-02 15:49:30 +00:00
errs.Add(err)
return
}
if clone {
2018-08-02 15:49:30 +00:00
mux.Lock()
cloned.Set(pkg)
2018-08-02 15:49:30 +00:00
mux.Unlock()
}
} else {
2018-08-19 04:05:16 +00:00
err := downloadAndUnpack(config.AURURL+base.URLPath(), buildDir)
if err != nil {
2018-08-02 15:49:30 +00:00
errs.Add(err)
return
}
}
2018-08-02 15:49:30 +00:00
mux.Lock()
downloaded++
str := bold(cyan("::") + " Downloaded PKGBUILD (%d/%d): %s\n")
fmt.Printf(str, downloaded, len(bases), cyan(base.String()))
2018-08-02 15:49:30 +00:00
mux.Unlock()
}
count := 0
for k, base := range bases {
2018-08-02 15:49:30 +00:00
wg.Add(1)
go download(k, 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
}
func downloadPkgbuildsSources(bases []Base, incompatible types.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")
}
err = show(passToMakepkg(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 {
return fmt.Errorf("Error downloading sources: %s", 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(dp *depPool, do *depOrder, srcinfos map[string]*gosrc.Srcinfo, parser *arguments, incompatible types.StringSet, conflicts types.MapStringSet) error {
for _, base := range do.Aur {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
built := true
srcinfo := srcinfos[pkg]
args := []string{"--nobuild", "-fC"}
if incompatible.Get(pkg) {
args = append(args, "--ignorearch")
}
//pkgver bump
err := show(passToMakepkg(dir, args...))
if err != nil {
return fmt.Errorf("Error making: %s", base.String())
}
2018-06-05 13:47:55 +00:00
pkgdests, version, err := parsePackageList(dir)
if err != nil {
return err
}
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 fmt.Errorf("Could not find PKGDEST for: %s", split.Name)
}
_, err := os.Stat(pkgdest)
if os.IsNotExist(err) {
built = false
} else if err != nil {
return err
}
}
} else {
built = false
}
if cmdArgs.existsArg("needed") {
installed := true
for _, split := range base {
2019-02-14 20:44:39 +00:00
if alpmpkg := dp.LocalDB.Pkg(split.Name); alpmpkg == nil || alpmpkg.Version() != version {
installed = false
}
}
if installed {
err = show(passToMakepkg(dir, "-c", "--nobuild", "--noextract", "--ignorearch"))
if err != nil {
return fmt.Errorf("Error making: %s", err)
}
fmt.Println(cyan(pkg+"-"+version) + bold(" is up to date -- skipping"))
continue
}
}
if built {
err = show(passToMakepkg(dir, "-c", "--nobuild", "--noextract", "--ignorearch"))
if err != nil {
return fmt.Errorf("Error making: %s", err)
}
fmt.Println(bold(yellow(arrow)),
cyan(pkg+"-"+version)+bold(" already made -- skipping build"))
} else {
args := []string{"-cf", "--noconfirm", "--noextract", "--noprepare", "--holdver"}
if incompatible.Get(pkg) {
args = append(args, "--ignorearch")
}
err := show(passToMakepkg(dir, args...))
if err != nil {
return fmt.Errorf("Error making: %s", base.String())
}
}
arguments := parser.copy()
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")
oldConfirm := config.NoConfirm
//conflicts have been checked so answer y for them
if config.UseAsk {
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
cmdArgs.globals["ask"] = fmt.Sprint(uask)
} else {
conflict := false
for _, split := range base {
if _, ok := conflicts[split.Name]; ok {
conflict = true
}
}
if !conflict {
config.NoConfirm = true
}
}
depArguments := makeArguments()
err = depArguments.addArg("D", "asdeps")
if err != nil {
return err
}
expArguments := makeArguments()
err = expArguments.addArg("D", "asexplicit")
if err != nil {
return err
}
//remotenames: names of all non repo packages on the system
_, _, localNames, remoteNames, err := filterPackages()
if err != nil {
return err
}
//cache as a stringset. maybe make it return a string set in the first
//place
remoteNamesCache := types.SliceToStringSet(remoteNames)
localNamesCache := types.SliceToStringSet(localNames)
for _, split := range base {
pkgdest, ok := pkgdests[split.Name]
if !ok {
return fmt.Errorf("Could not find PKGDEST for: %s", split.Name)
}
2018-02-16 17:18:59 +00:00
arguments.addTarget(pkgdest)
if !dp.Explicit.Get(split.Name) && !localNamesCache.Get(split.Name) && !remoteNamesCache.Get(split.Name) {
depArguments.addTarget(split.Name)
}
if dp.Explicit.Get(split.Name) {
if parser.existsArg("asdeps", "asdep") {
depArguments.addTarget(split.Name)
} else if parser.existsArg("asexplicit", "asexp") {
expArguments.addTarget(split.Name)
}
}
}
err = show(passToPacman(arguments))
if err != nil {
return err
}
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 updateVCSData(pkg.Name, srcinfo.Source, &mux, &wg)
}
2018-08-02 22:30:48 +00:00
wg.Wait()
err = saveVCSInfo()
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
if len(depArguments.targets) > 0 {
_, stderr, err := capture(passToPacman(depArguments))
if err != nil {
return fmt.Errorf("%s%s", stderr, err)
}
}
config.NoConfirm = oldConfirm
}
return nil
}