2017-08-02 19:24:03 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
2018-03-28 16:52:20 +02:00
|
|
|
"path/filepath"
|
2018-02-16 22:45:19 +01:00
|
|
|
"strconv"
|
2018-02-21 09:41:25 +01:00
|
|
|
"strings"
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-07-16 16:28:18 +02:00
|
|
|
gosrc "github.com/Morganamilo/go-srcinfo"
|
2018-02-07 13:36:51 +01:00
|
|
|
alpm "github.com/jguer/go-alpm"
|
2017-08-02 19:24:03 +02:00
|
|
|
rpc "github.com/mikkeloscar/aur"
|
|
|
|
)
|
|
|
|
|
2018-01-20 23:37:10 +01:00
|
|
|
// Install handles package installs
|
2018-01-04 01:59:57 +01:00
|
|
|
func install(parser *arguments) error {
|
2018-03-16 20:30:14 +01:00
|
|
|
var err error
|
2018-04-01 19:54:33 +02:00
|
|
|
var incompatible stringSet
|
2018-05-08 06:41:04 +02:00
|
|
|
var do *depOrder
|
2018-03-21 01:26:56 +01:00
|
|
|
|
2018-03-29 04:42:11 +02:00
|
|
|
var aurUp upSlice
|
|
|
|
var repoUp upSlice
|
|
|
|
|
2018-04-11 05:43:51 +02:00
|
|
|
warnings := &aurWarnings{}
|
|
|
|
|
2018-03-19 17:51:11 +01:00
|
|
|
removeMake := false
|
2018-07-16 16:28:18 +02:00
|
|
|
srcinfosStale := make(map[string]*gosrc.Srcinfo)
|
2018-03-29 04:42:11 +02:00
|
|
|
|
2018-06-22 15:44:38 +02:00
|
|
|
if mode == ModeAny || mode == ModeRepo {
|
|
|
|
if config.CombinedUpgrade {
|
|
|
|
if parser.existsArg("y", "refresh") {
|
2018-07-19 20:53:17 +02:00
|
|
|
err = earlyRefresh(parser)
|
2018-06-22 15:44:38 +02:00
|
|
|
if err != nil {
|
2018-07-19 20:53:17 +02:00
|
|
|
return fmt.Errorf("Error refreshing databases")
|
2018-06-22 15:44:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if parser.existsArg("y", "refresh") || parser.existsArg("u", "sysupgrade") || len(parser.targets) > 0 {
|
2018-07-19 20:53:17 +02:00
|
|
|
err = earlyPacmanCall(parser)
|
2018-06-22 15:44:38 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-07-19 20:53:17 +02:00
|
|
|
}
|
|
|
|
}
|
2018-06-22 15:44:38 +02:00
|
|
|
|
2018-07-19 20:53:17 +02:00
|
|
|
//we may have done -Sy, our handle now has an old
|
|
|
|
//database.
|
|
|
|
err = initAlpmHandle()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-22 15:44:38 +02:00
|
|
|
|
2018-07-19 20:53:17 +02:00
|
|
|
_, _, localNames, remoteNames, err := filterPackages()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-22 15:44:38 +02:00
|
|
|
}
|
|
|
|
|
2018-07-19 20:53:17 +02:00
|
|
|
remoteNamesCache := sliceToStringSet(remoteNames)
|
|
|
|
localNamesCache := sliceToStringSet(localNames)
|
|
|
|
|
2018-06-22 15:44:38 +02:00
|
|
|
requestTargets := parser.copy().targets
|
|
|
|
|
2018-02-19 00:46:25 +01:00
|
|
|
//create the arguments to pass for the repo install
|
2018-01-04 09:13:47 +01:00
|
|
|
arguments := parser.copy()
|
2018-05-29 23:35:58 +02:00
|
|
|
arguments.delArg("asdeps", "asdep")
|
|
|
|
arguments.delArg("asexplicit", "asexp")
|
2018-01-21 12:48:09 +01:00
|
|
|
arguments.op = "S"
|
2018-06-02 16:01:39 +02:00
|
|
|
arguments.clearTargets()
|
2018-02-21 09:41:25 +01:00
|
|
|
|
2018-05-31 17:23:15 +02:00
|
|
|
if mode == ModeAUR {
|
|
|
|
arguments.delArg("u", "sysupgrade")
|
|
|
|
}
|
|
|
|
|
2018-05-30 04:21:17 +02:00
|
|
|
//if we are doing -u also request all packages needing update
|
2018-02-19 00:46:25 +01:00
|
|
|
if parser.existsArg("u", "sysupgrade") {
|
2018-05-30 04:21:17 +02:00
|
|
|
aurUp, repoUp, err = upList(warnings)
|
2018-01-04 01:59:57 +01:00
|
|
|
if err != nil {
|
2018-02-19 00:46:25 +01:00
|
|
|
return err
|
2018-01-04 01:59:57 +01:00
|
|
|
}
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-05-30 04:21:17 +02:00
|
|
|
warnings.print()
|
|
|
|
|
|
|
|
ignore, aurUp, err := upgradePkgs(aurUp, repoUp)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-04-04 22:51:57 +02:00
|
|
|
|
|
|
|
for _, up := range repoUp {
|
|
|
|
if !ignore.get(up.Name) {
|
|
|
|
requestTargets = append(requestTargets, up.Name)
|
2018-04-11 05:53:33 +02:00
|
|
|
parser.addTarget(up.Name)
|
2018-04-04 22:51:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for up := range aurUp {
|
|
|
|
requestTargets = append(requestTargets, up)
|
|
|
|
}
|
|
|
|
|
2018-05-12 01:12:33 +02:00
|
|
|
value, _, exists := cmdArgs.getArg("ignore")
|
2018-05-12 01:24:47 +02:00
|
|
|
|
|
|
|
if len(ignore) > 0 {
|
|
|
|
ignoreStr := strings.Join(ignore.toSlice(), ",")
|
|
|
|
if exists {
|
|
|
|
ignoreStr += "," + value
|
|
|
|
}
|
|
|
|
arguments.options["ignore"] = ignoreStr
|
2018-05-12 01:12:33 +02:00
|
|
|
}
|
|
|
|
|
2018-02-19 00:46:25 +01:00
|
|
|
for pkg := range aurUp {
|
|
|
|
parser.addTarget(pkg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-02 16:01:39 +02:00
|
|
|
targets := sliceToStringSet(parser.targets)
|
|
|
|
|
2018-05-10 15:36:38 +02:00
|
|
|
dp, err := getDepPool(requestTargets, warnings)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = dp.CheckMissing()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-11 20:48:20 +02:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if len(dp.Aur) == 0 {
|
2018-07-03 14:42:13 +02:00
|
|
|
if !config.CombinedUpgrade {
|
2018-07-24 01:13:34 +02:00
|
|
|
if parser.existsArg("u", "sysupgrade") {
|
|
|
|
fmt.Println(" there is nothing to do")
|
|
|
|
}
|
2018-07-03 14:42:13 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-06-11 19:49:35 +02:00
|
|
|
parser.op = "S"
|
2018-06-11 01:26:36 +02:00
|
|
|
parser.delArg("y", "refresh")
|
2018-06-11 19:49:35 +02:00
|
|
|
parser.options["ignore"] = arguments.options["ignore"]
|
2018-07-19 19:37:28 +02:00
|
|
|
return show(passToPacman(parser))
|
2018-06-11 01:26:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(dp.Aur) > 0 && 0 == os.Geteuid() {
|
|
|
|
return fmt.Errorf(bold(red(arrow)) + " Refusing to install AUR Packages as root, Aborting.")
|
|
|
|
}
|
2018-05-10 15:36:38 +02:00
|
|
|
|
2018-06-22 16:17:34 +02:00
|
|
|
conflicts, err := dp.CheckConflicts()
|
2018-05-10 15:36:38 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-05-08 06:41:04 +02:00
|
|
|
do = getDepOrder(dp)
|
2018-02-19 20:38:34 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-02-19 00:46:25 +01:00
|
|
|
}
|
|
|
|
|
2018-05-08 06:41:04 +02:00
|
|
|
for _, pkg := range do.Repo {
|
2018-03-16 02:14:34 +01:00
|
|
|
arguments.addTarget(pkg.DB().Name() + "/" + pkg.Name())
|
2018-02-19 20:38:34 +01:00
|
|
|
}
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-05-08 06:41:04 +02:00
|
|
|
for _, pkg := range dp.Groups {
|
2018-03-16 20:30:14 +01:00
|
|
|
arguments.addTarget(pkg)
|
2018-03-16 02:14:34 +01:00
|
|
|
}
|
2018-01-17 22:48:23 +01:00
|
|
|
|
2018-05-31 17:23:15 +02:00
|
|
|
if len(do.Aur) == 0 && len(arguments.targets) == 0 && (!parser.existsArg("u", "sysupgrade") || mode == ModeAUR) {
|
2018-07-19 23:36:06 +02:00
|
|
|
fmt.Println(" there is nothing to do")
|
2018-02-20 02:23:16 +01:00
|
|
|
return nil
|
|
|
|
}
|
2018-02-16 18:18:59 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
do.Print()
|
|
|
|
fmt.Println()
|
2018-02-16 22:45:19 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if do.HasMake() {
|
2018-07-21 15:20:00 +02:00
|
|
|
if config.RemoveMake == "yes" {
|
|
|
|
removeMake = true
|
|
|
|
} else if config.RemoveMake == "no" {
|
|
|
|
removeMake = false
|
2018-07-22 01:46:55 +02:00
|
|
|
} else if continueTask("Remove make dependencies after install?", false) {
|
2018-06-11 01:26:36 +02:00
|
|
|
removeMake = true
|
|
|
|
}
|
|
|
|
}
|
2018-04-11 05:43:51 +02:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if config.CleanMenu {
|
|
|
|
askClean := pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache)
|
2018-07-30 15:14:16 +02:00
|
|
|
toClean, err := cleanNumberMenu(do.Aur, remoteNamesCache, askClean)
|
2018-06-11 01:26:36 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-02-21 13:16:30 +01:00
|
|
|
}
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
cleanBuilds(toClean)
|
|
|
|
}
|
2018-04-11 17:47:00 +02:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
toSkip := pkgBuildsToSkip(do.Aur, targets)
|
|
|
|
cloned, err := downloadPkgBuilds(do.Aur, do.Bases, toSkip)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
var toDiff []*rpc.Pkg
|
|
|
|
var toEdit []*rpc.Pkg
|
2018-02-15 21:51:18 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if config.DiffMenu {
|
|
|
|
pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache)
|
2018-07-30 15:14:16 +02:00
|
|
|
toDiff, err = diffNumberMenu(do.Aur, remoteNamesCache)
|
2018-02-16 16:33:17 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-10 03:02:24 +02:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if len(toDiff) > 0 {
|
2018-07-19 23:19:24 +02:00
|
|
|
err = showPkgBuildDiffs(toDiff, do.Bases, cloned)
|
2018-06-10 16:56:57 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-11 01:26:36 +02:00
|
|
|
}
|
|
|
|
}
|
2018-06-10 16:56:57 +02:00
|
|
|
|
2018-06-12 22:06:21 +02:00
|
|
|
if len(toDiff) > 0 {
|
|
|
|
oldValue := config.NoConfirm
|
|
|
|
config.NoConfirm = false
|
|
|
|
fmt.Println()
|
2018-07-22 01:46:55 +02:00
|
|
|
if !continueTask(bold(green("Proceed with install?")), true) {
|
2018-06-12 22:06:21 +02:00
|
|
|
return fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
|
|
|
config.NoConfirm = oldValue
|
|
|
|
}
|
|
|
|
|
|
|
|
err = mergePkgBuilds(do.Aur)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-07-19 23:19:24 +02:00
|
|
|
//initial srcinfo parse before pkgver() bump
|
|
|
|
err = parseSRCINFOFiles(do.Aur, srcinfosStale, do.Bases)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if config.EditMenu {
|
|
|
|
pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache)
|
2018-07-30 15:14:16 +02:00
|
|
|
toEdit, err = editNumberMenu(do.Aur, remoteNamesCache)
|
2018-06-11 01:26:36 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-06-10 16:56:57 +02:00
|
|
|
}
|
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if len(toEdit) > 0 {
|
2018-07-30 15:14:16 +02:00
|
|
|
err = editPkgBuilds(toEdit, srcinfosStale)
|
2018-03-09 23:11:30 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-06-10 16:56:57 +02:00
|
|
|
}
|
2018-06-11 01:26:36 +02:00
|
|
|
}
|
2018-06-10 16:56:57 +02:00
|
|
|
|
2018-06-12 22:06:21 +02:00
|
|
|
if len(toEdit) > 0 {
|
2018-06-11 01:26:36 +02:00
|
|
|
oldValue := config.NoConfirm
|
|
|
|
config.NoConfirm = false
|
|
|
|
fmt.Println()
|
2018-07-22 01:46:55 +02:00
|
|
|
if !continueTask(bold(green("Proceed with install?")), true) {
|
2018-06-11 01:26:36 +02:00
|
|
|
return fmt.Errorf("Aborting due to user")
|
2018-02-16 16:33:17 +01:00
|
|
|
}
|
2018-06-11 01:26:36 +02:00
|
|
|
config.NoConfirm = oldValue
|
|
|
|
}
|
2018-02-16 18:18:59 +01:00
|
|
|
|
2018-07-30 15:14:16 +02:00
|
|
|
incompatible, err = getIncompatible(do.Aur, srcinfosStale)
|
2018-06-11 01:26:36 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-19 17:51:11 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if config.PGPFetch {
|
|
|
|
err = checkPgpKeys(do.Aur, do.Bases, srcinfosStale)
|
2018-01-17 22:48:23 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-21 01:26:56 +01:00
|
|
|
}
|
|
|
|
|
2018-07-03 14:42:13 +02:00
|
|
|
if !config.CombinedUpgrade {
|
|
|
|
arguments.delArg("u", "sysupgrade")
|
|
|
|
}
|
|
|
|
|
2018-03-22 19:23:20 +01:00
|
|
|
if len(arguments.targets) > 0 || arguments.existsArg("u") {
|
2018-07-19 19:37:28 +02:00
|
|
|
err := show(passToPacman(arguments))
|
2018-03-21 01:26:56 +01:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Error installing repo packages")
|
|
|
|
}
|
|
|
|
|
|
|
|
depArguments := makeArguments()
|
|
|
|
depArguments.addArg("D", "asdeps")
|
2018-05-29 23:35:58 +02:00
|
|
|
expArguments := makeArguments()
|
|
|
|
expArguments.addArg("D", "asexplicit")
|
2018-03-21 01:26:56 +01:00
|
|
|
|
2018-05-08 06:41:04 +02:00
|
|
|
for _, pkg := range do.Repo {
|
2018-05-29 17:47:43 +02:00
|
|
|
if !dp.Explicit.get(pkg.Name()) && !localNamesCache.get(pkg.Name()) && !remoteNamesCache.get(pkg.Name()) {
|
2018-03-22 16:22:05 +01:00
|
|
|
depArguments.addTarget(pkg.Name())
|
2018-05-29 23:35:58 +02:00
|
|
|
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 16:22:05 +01:00
|
|
|
}
|
2018-03-21 01:26:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(depArguments.targets) > 0 {
|
2018-07-19 19:37:28 +02:00
|
|
|
_, stderr, err := capture(passToPacman(depArguments))
|
2018-03-21 01:26:56 +01:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("%s%s", stderr, err)
|
|
|
|
}
|
|
|
|
}
|
2018-05-29 23:35:58 +02:00
|
|
|
|
|
|
|
if len(expArguments.targets) > 0 {
|
2018-07-19 19:37:28 +02:00
|
|
|
_, stderr, err := capture(passToPacman(expArguments))
|
2018-05-29 23:35:58 +02:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("%s%s", stderr, err)
|
|
|
|
}
|
|
|
|
}
|
2018-03-21 01:26:56 +01:00
|
|
|
}
|
|
|
|
|
2018-07-24 15:16:12 +02:00
|
|
|
go updateCompletion(false)
|
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
err = downloadPkgBuildsSources(do.Aur, do.Bases, incompatible)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-06-22 16:17:34 +02:00
|
|
|
err = buildInstallPkgBuilds(dp, do, srcinfosStale, parser, incompatible, conflicts)
|
2018-06-11 01:26:36 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-01-17 22:48:23 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if removeMake {
|
|
|
|
removeArguments := makeArguments()
|
|
|
|
removeArguments.addArg("R", "u")
|
2018-02-28 16:20:26 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
for _, pkg := range do.getMake() {
|
|
|
|
removeArguments.addTarget(pkg)
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
oldValue := config.NoConfirm
|
|
|
|
config.NoConfirm = true
|
2018-07-19 19:37:28 +02:00
|
|
|
err = show(passToPacman(removeArguments))
|
2018-06-11 01:26:36 +02:00
|
|
|
config.NoConfirm = oldValue
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-02-15 22:23:34 +01:00
|
|
|
}
|
2018-06-11 01:26:36 +02:00
|
|
|
}
|
2018-02-15 22:23:34 +01:00
|
|
|
|
2018-06-11 01:26:36 +02:00
|
|
|
if config.CleanAfter {
|
|
|
|
clean(do.Aur)
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
2018-01-17 22:48:23 +01:00
|
|
|
|
|
|
|
return nil
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
|
2018-07-19 20:53:17 +02:00
|
|
|
func inRepos(syncDb alpm.DbList, pkg string) bool {
|
|
|
|
target := toTarget(pkg)
|
|
|
|
|
|
|
|
if target.Db == "aur" {
|
|
|
|
return false
|
|
|
|
} else if target.Db != "" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := syncDb.FindSatisfier(target.DepString())
|
|
|
|
if err == nil {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = syncDb.PkgCachebyGroup(target.Name)
|
|
|
|
if err == nil {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func earlyPacmanCall(parser *arguments) error {
|
|
|
|
arguments := parser.copy()
|
|
|
|
arguments.op = "S"
|
|
|
|
targets := parser.targets
|
|
|
|
parser.clearTargets()
|
|
|
|
arguments.clearTargets()
|
|
|
|
|
|
|
|
syncDb, err := alpmHandle.SyncDbs()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if mode == ModeRepo {
|
|
|
|
arguments.targets = targets
|
|
|
|
} else {
|
|
|
|
alpmHandle.SetQuestionCallback(func(alpm.QuestionAny) {})
|
|
|
|
//seperate aur and repo targets
|
|
|
|
for _, target := range targets {
|
|
|
|
if inRepos(syncDb, target) {
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
|
2018-07-30 15:14:16 +02:00
|
|
|
func getIncompatible(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo) (stringSet, error) {
|
2018-04-01 19:54:33 +02:00
|
|
|
incompatible := make(stringSet)
|
2018-03-19 17:51:11 +01:00
|
|
|
alpmArch, err := alpmHandle.Arch()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2018-03-21 01:26:56 +01:00
|
|
|
nextpkg:
|
2018-03-19 17:51:11 +01:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
for _, arch := range srcinfos[pkg.PackageBase].Arch {
|
|
|
|
if arch == "any" || arch == alpmArch {
|
|
|
|
continue nextpkg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-01 19:54:33 +02:00
|
|
|
incompatible.set(pkg.PackageBase)
|
2018-03-19 17:51:11 +01:00
|
|
|
}
|
|
|
|
|
2018-04-01 19:54:33 +02:00
|
|
|
if len(incompatible) > 0 {
|
2018-04-11 01:45:58 +02:00
|
|
|
fmt.Println()
|
2018-04-16 14:26:15 +02:00
|
|
|
fmt.Print(bold(yellow(arrow)) + " The following packages are not compatible with your architecture:")
|
2018-04-01 19:54:33 +02:00
|
|
|
for pkg := range incompatible {
|
2018-03-19 17:51:11 +01:00
|
|
|
fmt.Print(" " + cyan(pkg))
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println()
|
|
|
|
|
2018-07-22 01:46:55 +02:00
|
|
|
if !continueTask("Try to build them anyway?", true) {
|
2018-03-19 17:51:11 +01:00
|
|
|
return nil, fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-01 19:54:33 +02:00
|
|
|
return incompatible, nil
|
2018-03-19 17:51:11 +01:00
|
|
|
}
|
|
|
|
|
2018-06-05 15:47:55 +02:00
|
|
|
func parsePackageList(dir string) (map[string]string, string, error) {
|
2018-07-19 19:37:28 +02:00
|
|
|
stdout, stderr, err := capture(passToMakepkg(dir, "--packagelist"))
|
2018-04-12 17:39:01 +02:00
|
|
|
|
|
|
|
if err != nil {
|
2018-06-05 15:47:55 +02:00
|
|
|
return nil, "", fmt.Errorf("%s%s", stderr, err)
|
2018-04-12 17:39:01 +02:00
|
|
|
}
|
|
|
|
|
2018-06-05 15:47:55 +02:00
|
|
|
var version string
|
2018-05-31 05:37:08 +02:00
|
|
|
lines := strings.Split(stdout, "\n")
|
|
|
|
pkgdests := make(map[string]string)
|
2018-04-12 17:39:01 +02:00
|
|
|
|
2018-05-31 05:37:08 +02:00
|
|
|
for _, line := range lines {
|
|
|
|
if line == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
fileName := filepath.Base(line)
|
|
|
|
split := strings.Split(fileName, "-")
|
|
|
|
|
|
|
|
if len(split) < 4 {
|
2018-06-05 15:47:55 +02:00
|
|
|
return nil, "", fmt.Errorf("Can not find package name : %s", split)
|
2018-05-31 05:37:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// pkgname-pkgver-pkgrel-arch.pkgext
|
|
|
|
// This assumes 3 dashes after the pkgname, Will cause an error
|
|
|
|
// if the PKGEXT contains a dash. Please no one do that.
|
|
|
|
pkgname := strings.Join(split[:len(split)-3], "-")
|
2018-06-05 15:47:55 +02:00
|
|
|
version = strings.Join(split[len(split)-3:len(split)-2], "-")
|
2018-05-31 05:37:08 +02:00
|
|
|
pkgdests[pkgname] = line
|
2018-04-12 17:39:01 +02:00
|
|
|
}
|
2018-05-31 05:37:08 +02:00
|
|
|
|
2018-06-05 15:47:55 +02:00
|
|
|
return pkgdests, version, nil
|
2018-04-12 17:39:01 +02:00
|
|
|
}
|
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
func pkgbuildNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet) bool {
|
2018-03-09 23:11:30 +01:00
|
|
|
toPrint := ""
|
|
|
|
askClean := false
|
|
|
|
|
|
|
|
for n, pkg := range pkgs {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-04-11 05:43:51 +02:00
|
|
|
toPrint += fmt.Sprintf(magenta("%3d")+" %-40s", len(pkgs)-n,
|
2018-03-12 22:01:53 +01:00
|
|
|
bold(formatPkgbase(pkg, bases)))
|
2018-03-09 23:11:30 +01:00
|
|
|
if installed.get(pkg.Name) {
|
|
|
|
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)
|
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
return askClean
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-07-30 15:14:16 +02:00
|
|
|
func cleanNumberMenu(pkgs []*rpc.Pkg, installed stringSet, hasClean bool) ([]*rpc.Pkg, error) {
|
2018-06-10 16:56:57 +02:00
|
|
|
toClean := make([]*rpc.Pkg, 0)
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
if !hasClean {
|
|
|
|
return toClean, nil
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
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
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
cInclude, cExclude, cOtherInclude, cOtherExclude := parseNumberMenu(cleanInput)
|
|
|
|
cIsInclude := len(cExclude) == 0 && len(cOtherExclude) == 0
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
if cOtherInclude.get("abort") || cOtherInclude.get("ab") {
|
|
|
|
return nil, fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
if !cOtherInclude.get("n") && !cOtherInclude.get("none") {
|
|
|
|
for i, pkg := range pkgs {
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
|
|
|
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
|
|
|
continue
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
if !cIsInclude && cExclude.get(len(pkgs)-i) {
|
|
|
|
continue
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
if installed.get(pkg.Name) && (cOtherInclude.get("i") || cOtherInclude.get("installed")) {
|
|
|
|
toClean = append(toClean, pkg)
|
|
|
|
continue
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
if !installed.get(pkg.Name) && (cOtherInclude.get("no") || cOtherInclude.get("notinstalled")) {
|
|
|
|
toClean = append(toClean, pkg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if cOtherInclude.get("a") || cOtherInclude.get("all") {
|
|
|
|
toClean = append(toClean, pkg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if cIsInclude && (cInclude.get(len(pkgs)-i) || cOtherInclude.get(pkg.PackageBase)) {
|
|
|
|
toClean = append(toClean, pkg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if !cIsInclude && (!cExclude.get(len(pkgs)-i) && !cOtherExclude.get(pkg.PackageBase)) {
|
|
|
|
toClean = append(toClean, pkg)
|
|
|
|
continue
|
2018-03-09 23:11:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
return toClean, nil
|
|
|
|
}
|
|
|
|
|
2018-07-30 15:14:16 +02:00
|
|
|
func editNumberMenu(pkgs []*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) {
|
|
|
|
return editDiffNumberMenu(pkgs, installed, false)
|
2018-06-10 16:56:57 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 15:14:16 +02:00
|
|
|
func diffNumberMenu(pkgs []*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) {
|
|
|
|
return editDiffNumberMenu(pkgs, installed, true)
|
2018-06-10 16:56:57 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 15:14:16 +02:00
|
|
|
func editDiffNumberMenu(pkgs []*rpc.Pkg, installed stringSet, diff bool) ([]*rpc.Pkg, error) {
|
2018-06-10 16:56:57 +02:00
|
|
|
toEdit := make([]*rpc.Pkg, 0)
|
2018-06-11 20:13:40 +02:00
|
|
|
var editInput string
|
|
|
|
var err error
|
|
|
|
|
|
|
|
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + "[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)"))
|
2018-06-10 16:56:57 +02:00
|
|
|
|
|
|
|
if diff {
|
2018-05-31 21:31:45 +02:00
|
|
|
fmt.Println(bold(green(arrow + " Diffs to show?")))
|
2018-06-11 20:13:40 +02:00
|
|
|
fmt.Print(bold(green(arrow + " ")))
|
|
|
|
editInput, err = getInput(config.AnswerDiff)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-05-31 21:31:45 +02:00
|
|
|
} else {
|
|
|
|
fmt.Println(bold(green(arrow + " PKGBUILDs to edit?")))
|
2018-06-11 20:13:40 +02:00
|
|
|
fmt.Print(bold(green(arrow + " ")))
|
|
|
|
editInput, err = getInput(config.AnswerEdit)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
eInclude, eExclude, eOtherInclude, eOtherExclude := parseNumberMenu(editInput)
|
|
|
|
eIsInclude := len(eExclude) == 0 && len(eOtherExclude) == 0
|
|
|
|
|
|
|
|
if eOtherInclude.get("abort") || eOtherInclude.get("ab") {
|
2018-06-10 16:56:57 +02:00
|
|
|
return nil, fmt.Errorf("Aborting due to user")
|
2018-03-09 23:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if !eOtherInclude.get("n") && !eOtherInclude.get("none") {
|
|
|
|
for i, pkg := range pkgs {
|
|
|
|
if !eIsInclude && eExclude.get(len(pkgs)-i) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if installed.get(pkg.Name) && (eOtherInclude.get("i") || eOtherInclude.get("installed")) {
|
|
|
|
toEdit = append(toEdit, pkg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if !installed.get(pkg.Name) && (eOtherInclude.get("no") || eOtherInclude.get("notinstalled")) {
|
|
|
|
toEdit = append(toEdit, pkg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if eOtherInclude.get("a") || eOtherInclude.get("all") {
|
|
|
|
toEdit = append(toEdit, pkg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2018-04-12 14:01:54 +02:00
|
|
|
if eIsInclude && (eInclude.get(len(pkgs)-i) || eOtherInclude.get(pkg.PackageBase)) {
|
2018-03-09 23:11:30 +01:00
|
|
|
toEdit = append(toEdit, pkg)
|
|
|
|
}
|
|
|
|
|
2018-04-12 14:01:54 +02:00
|
|
|
if !eIsInclude && (!eExclude.get(len(pkgs)-i) && !eOtherExclude.get(pkg.PackageBase)) {
|
2018-03-09 23:11:30 +01:00
|
|
|
toEdit = append(toEdit, pkg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-10 16:56:57 +02:00
|
|
|
return toEdit, nil
|
2018-03-09 23:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func cleanBuilds(pkgs []*rpc.Pkg) {
|
|
|
|
for i, pkg := range pkgs {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
2018-04-11 01:45:58 +02:00
|
|
|
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(pkgs), cyan(dir))
|
2018-03-09 23:11:30 +01:00
|
|
|
os.RemoveAll(dir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-19 23:19:24 +02:00
|
|
|
func showPkgBuildDiffs(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, cloned stringSet) error {
|
2018-05-31 21:31:45 +02:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
|
|
|
if shouldUseGit(dir) {
|
2018-06-10 04:41:25 +02:00
|
|
|
start := "HEAD"
|
2018-05-31 21:31:45 +02:00
|
|
|
|
2018-06-10 04:41:25 +02:00
|
|
|
if cloned.get(pkg.PackageBase) {
|
|
|
|
start = gitEmptyTree
|
|
|
|
} else {
|
|
|
|
hasDiff, err := gitHasDiff(config.BuildDir, pkg.PackageBase)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if !hasDiff {
|
|
|
|
fmt.Printf("%s %s: %s\n", bold(yellow(arrow)), cyan(formatPkgbase(pkg, bases)), bold("No changes -- skipping"))
|
|
|
|
continue
|
|
|
|
}
|
2018-05-31 21:31:45 +02:00
|
|
|
}
|
|
|
|
|
2018-06-10 04:41:25 +02:00
|
|
|
args := []string{"diff", start + "..HEAD@{upstream}", "--src-prefix", dir + "/", "--dst-prefix", dir + "/"}
|
2018-05-31 21:31:45 +02:00
|
|
|
if useColor {
|
|
|
|
args = append(args, "--color=always")
|
|
|
|
} else {
|
|
|
|
args = append(args, "--color=never")
|
|
|
|
}
|
2018-07-19 19:37:28 +02:00
|
|
|
err := show(passToGit(dir, args...))
|
2018-05-31 21:31:45 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
2018-07-19 23:19:24 +02:00
|
|
|
args := []string{"diff"}
|
|
|
|
if useColor {
|
|
|
|
args = append(args, "--color=always")
|
|
|
|
} else {
|
|
|
|
args = append(args, "--color=never")
|
2018-05-31 21:31:45 +02:00
|
|
|
}
|
2018-07-19 23:19:24 +02:00
|
|
|
args = append(args, "--no-index", "/var/empty", dir)
|
|
|
|
// git always returns 1. why? I have no idea
|
|
|
|
show(passToGit(dir, args...))
|
2018-05-31 21:31:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-30 15:14:16 +02:00
|
|
|
func editPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo) error {
|
2018-03-09 23:11:30 +01:00
|
|
|
pkgbuilds := make([]string, 0, len(pkgs))
|
|
|
|
for _, pkg := range pkgs {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
|
|
|
pkgbuilds = append(pkgbuilds, filepath.Join(dir, "PKGBUILD"))
|
2018-07-17 23:54:13 +02:00
|
|
|
|
|
|
|
for _, splitPkg := range srcinfos[pkg.PackageBase].SplitPackages() {
|
|
|
|
if splitPkg.Install != "" {
|
|
|
|
pkgbuilds = append(pkgbuilds, filepath.Join(dir, splitPkg.Install))
|
|
|
|
}
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
}
|
|
|
|
|
2018-05-31 21:31:45 +02:00
|
|
|
if len(pkgbuilds) > 0 {
|
|
|
|
editor, editorArgs := editor()
|
|
|
|
editorArgs = append(editorArgs, pkgbuilds...)
|
|
|
|
editcmd := exec.Command(editor, editorArgs...)
|
|
|
|
editcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
|
|
|
err := editcmd.Run()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Editor did not exit successfully, Aborting: %s", err)
|
|
|
|
}
|
2018-03-09 23:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-16 16:28:18 +02:00
|
|
|
func parseSRCINFOFiles(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, bases map[string][]*rpc.Pkg) error {
|
2018-02-19 07:52:11 +01:00
|
|
|
for k, pkg := range pkgs {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
2018-02-16 18:18:59 +01:00
|
|
|
|
2018-03-02 05:03:09 +01:00
|
|
|
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
|
2018-04-11 01:45:58 +02:00
|
|
|
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
|
2018-02-19 07:52:11 +01:00
|
|
|
|
2018-07-16 16:28:18 +02:00
|
|
|
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
|
2018-02-19 07:52:11 +01:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("%s: %s", pkg.Name, err)
|
|
|
|
}
|
|
|
|
|
2018-03-21 01:26:56 +01:00
|
|
|
srcinfos[pkg.PackageBase] = pkgbuild
|
2018-02-19 07:52:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-07-16 16:28:18 +02:00
|
|
|
func tryParsesrcinfosFile(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, bases map[string][]*rpc.Pkg) {
|
2018-04-02 20:16:49 +02:00
|
|
|
for k, pkg := range pkgs {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
2018-04-02 20:16:49 +02:00
|
|
|
|
|
|
|
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
|
2018-04-11 01:45:58 +02:00
|
|
|
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
|
2018-04-02 20:16:49 +02:00
|
|
|
|
2018-07-16 16:28:18 +02:00
|
|
|
pkgbuild, err := gosrc.ParseFile(filepath.Join(dir, ".SRCINFO"))
|
2018-04-02 20:16:49 +02:00
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("cannot parse %s skipping: %s\n", pkg.Name, err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
srcinfos[pkg.PackageBase] = pkgbuild
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-10 02:04:04 +02:00
|
|
|
func pkgBuildsToSkip(pkgs []*rpc.Pkg, targets stringSet) stringSet {
|
2018-05-31 21:31:45 +02:00
|
|
|
toSkip := make(stringSet)
|
|
|
|
|
|
|
|
for _, pkg := range pkgs {
|
2018-03-07 22:32:55 +01:00
|
|
|
if config.ReDownload == "no" || (config.ReDownload == "yes" && !targets.get(pkg.Name)) {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase, ".SRCINFO")
|
2018-07-16 16:28:18 +02:00
|
|
|
pkgbuild, err := gosrc.ParseFile(dir)
|
2018-03-06 04:42:26 +01:00
|
|
|
|
|
|
|
if err == nil {
|
2018-07-16 16:28:18 +02:00
|
|
|
if alpm.VerCmp(pkgbuild.Version(), pkg.Version) > 0 {
|
|
|
|
toSkip.set(pkg.PackageBase)
|
2018-03-06 04:42:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-31 21:31:45 +02:00
|
|
|
}
|
|
|
|
|
2018-06-10 02:04:04 +02:00
|
|
|
return toSkip
|
|
|
|
}
|
|
|
|
|
2018-06-10 02:29:54 +02:00
|
|
|
func mergePkgBuilds(pkgs []*rpc.Pkg) error {
|
|
|
|
for _, pkg := range pkgs {
|
|
|
|
if shouldUseGit(filepath.Join(config.BuildDir, pkg.PackageBase)) {
|
2018-07-30 15:14:16 +02:00
|
|
|
err := gitMerge(config.BuildDir, pkg.PackageBase)
|
2018-06-10 02:29:54 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-06-10 04:41:25 +02:00
|
|
|
func downloadPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, toSkip stringSet) (stringSet, error) {
|
|
|
|
cloned := make(stringSet)
|
|
|
|
|
2018-06-10 02:21:20 +02:00
|
|
|
for k, pkg := range pkgs {
|
2018-05-31 21:31:45 +02:00
|
|
|
if toSkip.get(pkg.PackageBase) {
|
|
|
|
str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n")
|
|
|
|
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
|
|
|
|
continue
|
|
|
|
}
|
2018-03-06 04:42:26 +01:00
|
|
|
|
|
|
|
str := bold(cyan("::") + " Downloading PKGBUILD (%d/%d): %s\n")
|
2018-02-20 02:23:16 +01:00
|
|
|
|
2018-04-11 01:45:58 +02:00
|
|
|
fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases)))
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-03-28 16:52:20 +02:00
|
|
|
if shouldUseGit(filepath.Join(config.BuildDir, pkg.PackageBase)) {
|
2018-06-10 04:41:25 +02:00
|
|
|
clone, err := gitDownload(baseURL+"/"+pkg.PackageBase+".git", config.BuildDir, pkg.PackageBase)
|
2018-05-31 21:31:45 +02:00
|
|
|
if err != nil {
|
2018-06-10 04:41:25 +02:00
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if clone {
|
|
|
|
cloned.set(pkg.PackageBase)
|
2018-05-31 21:31:45 +02:00
|
|
|
}
|
2018-03-28 16:52:20 +02:00
|
|
|
} else {
|
2018-06-10 02:21:20 +02:00
|
|
|
err := downloadAndUnpack(baseURL+pkg.URLPath, config.BuildDir)
|
|
|
|
if err != nil {
|
2018-06-10 04:41:25 +02:00
|
|
|
return nil, err
|
2018-06-10 02:21:20 +02:00
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-10 04:41:25 +02:00
|
|
|
return cloned, nil
|
2018-01-17 22:48:23 +01:00
|
|
|
}
|
|
|
|
|
2018-04-17 19:01:34 +02:00
|
|
|
func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, incompatible stringSet) (err error) {
|
2018-01-17 22:48:23 +01:00
|
|
|
for _, pkg := range pkgs {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
2018-04-12 17:39:01 +02:00
|
|
|
args := []string{"--verifysource", "-Ccf"}
|
2018-03-19 17:51:11 +01:00
|
|
|
|
2018-04-17 19:01:34 +02:00
|
|
|
if incompatible.get(pkg.PackageBase) {
|
2018-03-19 17:51:11 +01:00
|
|
|
args = append(args, "--ignorearch")
|
|
|
|
}
|
|
|
|
|
2018-07-19 19:37:28 +02:00
|
|
|
err = show(passToMakepkg(dir, args...))
|
2018-01-17 22:48:23 +01:00
|
|
|
if err != nil {
|
2018-04-11 01:45:58 +02:00
|
|
|
return fmt.Errorf("Error downloading sources: %s", cyan(formatPkgbase(pkg, bases)))
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
return
|
|
|
|
}
|
2018-01-05 23:12:14 +01:00
|
|
|
|
2018-07-16 16:28:18 +02:00
|
|
|
func buildInstallPkgBuilds(dp *depPool, do *depOrder, srcinfos map[string]*gosrc.Srcinfo, parser *arguments, incompatible stringSet, conflicts mapStringSet) error {
|
2018-05-29 23:35:58 +02:00
|
|
|
for _, pkg := range do.Aur {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
2018-02-15 22:23:34 +01:00
|
|
|
built := true
|
2018-02-15 20:43:16 +01:00
|
|
|
|
|
|
|
srcinfo := srcinfos[pkg.PackageBase]
|
2018-04-12 17:39:01 +02:00
|
|
|
|
2018-06-02 15:16:00 +02:00
|
|
|
args := []string{"--nobuild", "-fC"}
|
2018-05-10 21:56:12 +02:00
|
|
|
|
|
|
|
if incompatible.get(pkg.PackageBase) {
|
|
|
|
args = append(args, "--ignorearch")
|
|
|
|
}
|
|
|
|
|
2018-04-12 17:39:01 +02:00
|
|
|
//pkgver bump
|
2018-07-19 19:37:28 +02:00
|
|
|
err := show(passToMakepkg(dir, args...))
|
2018-04-12 17:39:01 +02:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Error making: %s", pkg.Name)
|
|
|
|
}
|
|
|
|
|
2018-06-05 15:47:55 +02:00
|
|
|
pkgdests, version, err := parsePackageList(dir)
|
2018-04-12 17:39:01 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-15 20:43:16 +01:00
|
|
|
|
2018-05-29 23:35:58 +02:00
|
|
|
if config.ReBuild == "no" || (config.ReBuild == "yes" && !dp.Explicit.get(pkg.Name)) {
|
|
|
|
for _, split := range do.Bases[pkg.PackageBase] {
|
2018-05-31 05:37:08 +02:00
|
|
|
pkgdest, ok := pkgdests[split.Name]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Could not find PKGDEST for: %s", split.Name)
|
2018-03-14 02:48:33 +01:00
|
|
|
}
|
2018-02-15 20:43:16 +01:00
|
|
|
|
2018-05-31 05:37:08 +02:00
|
|
|
_, err := os.Stat(pkgdest)
|
|
|
|
if os.IsNotExist(err) {
|
2018-03-14 02:48:33 +01:00
|
|
|
built = false
|
2018-05-31 05:37:08 +02:00
|
|
|
} else if err != nil {
|
|
|
|
return err
|
2018-03-14 02:48:33 +01:00
|
|
|
}
|
2018-02-15 20:43:16 +01:00
|
|
|
}
|
2018-03-14 02:48:33 +01:00
|
|
|
} else {
|
|
|
|
built = false
|
2018-02-15 22:23:34 +01:00
|
|
|
}
|
2018-02-15 20:43:16 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
if built {
|
2018-04-11 01:45:58 +02:00
|
|
|
fmt.Println(bold(yellow(arrow)),
|
2018-06-05 15:47:55 +02:00
|
|
|
cyan(pkg.Name+"-"+version)+bold(" Already made -- skipping build"))
|
2018-02-15 22:23:34 +01:00
|
|
|
} else {
|
2018-06-02 15:16:00 +02:00
|
|
|
args := []string{"-cf", "--noconfirm", "--noextract", "--noprepare", "--holdver"}
|
2018-03-19 17:51:11 +01:00
|
|
|
|
2018-04-17 19:01:34 +02:00
|
|
|
if incompatible.get(pkg.PackageBase) {
|
2018-03-19 17:51:11 +01:00
|
|
|
args = append(args, "--ignorearch")
|
|
|
|
}
|
|
|
|
|
2018-07-19 19:37:28 +02:00
|
|
|
err := show(passToMakepkg(dir, args...))
|
2018-02-15 22:23:34 +01:00
|
|
|
if err != nil {
|
2018-02-20 02:23:16 +01:00
|
|
|
return fmt.Errorf("Error making: %s", pkg.Name)
|
2018-02-15 20:43:16 +01:00
|
|
|
}
|
2018-01-04 01:59:57 +01:00
|
|
|
}
|
2018-02-15 20:43:16 +01:00
|
|
|
|
|
|
|
arguments := parser.copy()
|
2018-06-02 16:01:39 +02:00
|
|
|
arguments.clearTargets()
|
2018-02-15 20:43:16 +01:00
|
|
|
arguments.op = "U"
|
|
|
|
arguments.delArg("confirm")
|
2018-06-22 16:17:34 +02:00
|
|
|
arguments.delArg("noconfirm")
|
2018-02-15 20:43:16 +01:00
|
|
|
arguments.delArg("c", "clean")
|
|
|
|
arguments.delArg("q", "quiet")
|
|
|
|
arguments.delArg("q", "quiet")
|
|
|
|
arguments.delArg("y", "refresh")
|
|
|
|
arguments.delArg("u", "sysupgrade")
|
|
|
|
arguments.delArg("w", "downloadonly")
|
|
|
|
|
2018-06-22 16:17:34 +02:00
|
|
|
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 do.Bases[pkg.PackageBase] {
|
|
|
|
if _, ok := conflicts[split.Name]; ok {
|
|
|
|
conflict = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !conflict {
|
|
|
|
config.NoConfirm = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
depArguments := makeArguments()
|
|
|
|
depArguments.addArg("D", "asdeps")
|
2018-05-29 23:35:58 +02:00
|
|
|
expArguments := makeArguments()
|
|
|
|
expArguments.addArg("D", "asexplicit")
|
2018-02-15 20:43:16 +01:00
|
|
|
|
2018-04-11 05:53:33 +02:00
|
|
|
//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 := sliceToStringSet(remoteNames)
|
|
|
|
localNamesCache := sliceToStringSet(localNames)
|
|
|
|
|
2018-05-29 23:35:58 +02:00
|
|
|
for _, split := range do.Bases[pkg.PackageBase] {
|
2018-05-31 05:37:08 +02:00
|
|
|
pkgdest, ok := pkgdests[split.Name]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Could not find PKGDEST for: %s", split.Name)
|
2018-02-15 22:23:34 +01:00
|
|
|
}
|
2018-02-16 18:18:59 +01:00
|
|
|
|
2018-05-31 05:37:08 +02:00
|
|
|
arguments.addTarget(pkgdest)
|
2018-05-29 23:35:58 +02:00
|
|
|
if !dp.Explicit.get(split.Name) && !localNamesCache.get(split.Name) && !remoteNamesCache.get(split.Name) {
|
2018-02-15 22:23:34 +01:00
|
|
|
depArguments.addTarget(split.Name)
|
|
|
|
}
|
2018-05-29 23:35:58 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2018-02-15 22:23:34 +01:00
|
|
|
}
|
2018-02-15 20:43:16 +01:00
|
|
|
|
2018-07-19 19:37:28 +02:00
|
|
|
err = show(passToPacman(arguments))
|
2018-02-15 22:23:34 +01:00
|
|
|
if err != nil {
|
2018-02-15 20:43:16 +01:00
|
|
|
return err
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
2018-02-27 13:06:30 +01:00
|
|
|
|
2018-05-29 23:35:58 +02:00
|
|
|
for _, pkg := range do.Bases[pkg.PackageBase] {
|
2018-03-05 23:15:34 +01:00
|
|
|
updateVCSData(pkg.Name, srcinfo.Source)
|
|
|
|
}
|
|
|
|
|
2018-07-19 19:37:28 +02:00
|
|
|
err = saveVCSInfo()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
if len(depArguments.targets) > 0 {
|
2018-07-19 19:37:28 +02:00
|
|
|
_, stderr, err := capture(passToPacman(depArguments))
|
2018-02-15 22:23:34 +01:00
|
|
|
if err != nil {
|
2018-02-28 18:39:57 +01:00
|
|
|
return fmt.Errorf("%s%s", stderr, err)
|
2018-02-15 22:23:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
config.NoConfirm = oldConfirm
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
|
2018-02-15 20:43:16 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
func clean(pkgs []*rpc.Pkg) {
|
|
|
|
for _, pkg := range pkgs {
|
2018-04-17 02:32:31 +02:00
|
|
|
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
|
2018-02-15 22:23:34 +01:00
|
|
|
|
2018-03-02 05:03:09 +01:00
|
|
|
fmt.Println(bold(green(arrow +
|
|
|
|
" CleanAfter enabled. Deleting " + pkg.Name + " source folder.")))
|
2018-02-15 22:23:34 +01:00
|
|
|
os.RemoveAll(dir)
|
|
|
|
}
|
|
|
|
}
|