2017-08-02 17:24:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-03-09 22:11:30 +00:00
|
|
|
"bufio"
|
2017-08-02 17:24:03 +00:00
|
|
|
"fmt"
|
2018-02-16 17:18:59 +00:00
|
|
|
"io/ioutil"
|
2017-08-02 17:24:03 +00:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
2018-02-16 21:45:19 +00:00
|
|
|
"strconv"
|
2018-02-21 08:41:25 +00:00
|
|
|
"strings"
|
2018-03-22 02:09:32 +00:00
|
|
|
"sync"
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-02-07 12:36:51 +00:00
|
|
|
alpm "github.com/jguer/go-alpm"
|
2017-08-02 17:24:03 +00:00
|
|
|
rpc "github.com/mikkeloscar/aur"
|
2017-08-04 09:26:53 +00:00
|
|
|
gopkg "github.com/mikkeloscar/gopkgbuild"
|
2017-08-02 17:24:03 +00:00
|
|
|
)
|
|
|
|
|
2018-01-20 22:37:10 +00:00
|
|
|
// Install handles package installs
|
2018-01-04 00:59:57 +00:00
|
|
|
func install(parser *arguments) error {
|
2018-03-10 19:14:37 +00:00
|
|
|
requestTargets := parser.targets.toSlice()
|
2018-03-16 19:30:14 +00:00
|
|
|
var err error
|
2018-02-18 23:46:25 +00:00
|
|
|
if err != nil {
|
2018-02-21 08:41:25 +00:00
|
|
|
return err
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
var incompatable stringSet
|
|
|
|
removeMake := false
|
|
|
|
srcinfosStale := make(map[string]*gopkg.PKGBUILD)
|
2018-02-15 19:43:16 +00:00
|
|
|
srcinfos := make(map[string]*gopkg.PKGBUILD)
|
2018-02-18 23:46:25 +00:00
|
|
|
var dc *depCatagories
|
|
|
|
|
|
|
|
//remotenames: names of all non repo packages on the system
|
|
|
|
_, _, _, remoteNames, err := filterPackages()
|
|
|
|
if err != nil {
|
2018-02-21 08:41:25 +00:00
|
|
|
return err
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//cache as a stringset. maybe make it return a string set in the first
|
|
|
|
//place
|
2018-03-16 19:30:14 +00:00
|
|
|
remoteNamesCache := sliceToStringSet(remoteNames)
|
2018-02-18 23:46:25 +00:00
|
|
|
|
|
|
|
//if we are doing -u also request every non repo package on the system
|
|
|
|
if parser.existsArg("u", "sysupgrade") {
|
|
|
|
requestTargets = append(requestTargets, remoteNames...)
|
|
|
|
}
|
|
|
|
|
2018-03-16 19:30:14 +00:00
|
|
|
//if len(aurTargets) > 0 || parser.existsArg("u", "sysupgrade") && len(remoteNames) > 0 {
|
|
|
|
// fmt.Println(bold(cyan("::") + " Querying AUR..."))
|
|
|
|
//}
|
2018-02-21 08:41:25 +00:00
|
|
|
dt, err := getDepTree(requestTargets)
|
2018-01-17 21:48:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-02-18 23:46:25 +00:00
|
|
|
//only error if direct targets or deps are missing
|
2018-02-19 06:52:11 +00:00
|
|
|
for missingName := range dt.Missing {
|
2018-03-17 02:05:16 +00:00
|
|
|
if !remoteNamesCache.get(missingName) || parser.targets.get(missingName) {
|
2018-03-15 13:51:37 +00:00
|
|
|
str := bold(red(arrow+" Error: ")) + "Could not find all required packages:"
|
|
|
|
|
|
|
|
for name := range dt.Missing {
|
|
|
|
str += "\n\t" + name
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Errorf("%s", str)
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//create the arguments to pass for the repo install
|
2018-01-04 08:13:47 +00:00
|
|
|
arguments := parser.copy()
|
|
|
|
arguments.delArg("u", "sysupgrade")
|
|
|
|
arguments.delArg("y", "refresh")
|
2018-01-21 11:48:09 +00:00
|
|
|
arguments.op = "S"
|
2018-01-04 08:13:47 +00:00
|
|
|
arguments.targets = make(stringSet)
|
2018-02-21 08:41:25 +00:00
|
|
|
|
2018-02-18 23:46:25 +00:00
|
|
|
if parser.existsArg("u", "sysupgrade") {
|
2018-02-21 08:41:25 +00:00
|
|
|
repoUp, aurUp, err := upgradePkgs(dt)
|
2018-01-04 00:59:57 +00:00
|
|
|
if err != nil {
|
2018-02-18 23:46:25 +00:00
|
|
|
return err
|
2018-01-04 00:59:57 +00:00
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-02-21 12:16:30 +00:00
|
|
|
fmt.Println()
|
|
|
|
|
2018-02-18 23:46:25 +00:00
|
|
|
for pkg := range aurUp {
|
|
|
|
parser.addTarget(pkg)
|
|
|
|
}
|
2018-02-21 08:41:25 +00:00
|
|
|
|
2018-02-18 23:46:25 +00:00
|
|
|
for pkg := range repoUp {
|
|
|
|
arguments.addTarget(pkg)
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
|
2018-02-18 23:46:25 +00:00
|
|
|
//discard stuff thats
|
|
|
|
//not a target and
|
|
|
|
//not an upgrade and
|
|
|
|
//is installed
|
|
|
|
for pkg := range dt.Aur {
|
|
|
|
if !parser.targets.get(pkg) && remoteNamesCache.get(pkg) {
|
|
|
|
delete(dt.Aur, pkg)
|
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
}
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
|
|
|
|
2018-02-19 19:38:34 +00:00
|
|
|
hasAur := len(dt.Aur) != 0
|
2018-03-14 13:04:14 +00:00
|
|
|
if hasAur && 0 == os.Geteuid() {
|
|
|
|
return fmt.Errorf(red(arrow + " Refusing to install AUR Packages as root, Aborting."))
|
|
|
|
}
|
2018-02-19 19:38:34 +00:00
|
|
|
dc, err = getDepCatagories(parser.formatTargets(), dt)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
|
|
|
|
2018-02-19 19:38:34 +00:00
|
|
|
for _, pkg := range dc.Repo {
|
2018-03-16 01:14:34 +00:00
|
|
|
arguments.addTarget(pkg.DB().Name() + "/" + pkg.Name())
|
2018-02-19 19:38:34 +00:00
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-03-16 19:30:14 +00:00
|
|
|
for pkg := range dt.Groups {
|
|
|
|
arguments.addTarget(pkg)
|
2018-03-16 01:14:34 +00:00
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
|
2018-02-20 01:23:16 +00:00
|
|
|
if len(dc.Aur) == 0 && len(arguments.targets) == 0 {
|
2018-02-21 12:16:30 +00:00
|
|
|
fmt.Println("There is nothing to do")
|
2018-02-20 01:23:16 +00:00
|
|
|
return nil
|
|
|
|
}
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2018-02-19 19:38:34 +00:00
|
|
|
if hasAur {
|
2018-02-15 21:23:34 +00:00
|
|
|
printDepCatagories(dc)
|
2018-03-03 04:14:35 +00:00
|
|
|
hasAur = len(dc.Aur) != 0
|
2018-02-16 21:45:19 +00:00
|
|
|
fmt.Println()
|
2018-03-09 22:11:30 +00:00
|
|
|
|
|
|
|
if !parser.existsArg("gendb") {
|
2018-03-22 02:09:32 +00:00
|
|
|
err = checkForAllConflicts(dc)
|
2018-03-09 22:11:30 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
2018-02-20 01:23:16 +00:00
|
|
|
|
|
|
|
if !parser.existsArg("gendb") && len(arguments.targets) > 0 {
|
2018-02-18 23:46:25 +00:00
|
|
|
err := passToPacman(arguments)
|
|
|
|
if err != nil {
|
2018-03-19 15:30:44 +00:00
|
|
|
return fmt.Errorf("Error installing repo packages")
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
2018-02-28 15:20:26 +00:00
|
|
|
|
|
|
|
depArguments := makeArguments()
|
|
|
|
depArguments.addArg("D", "asdeps")
|
|
|
|
|
|
|
|
for _, pkg := range dc.Repo {
|
|
|
|
depArguments.addTarget(pkg.Name())
|
|
|
|
}
|
2018-03-16 19:30:14 +00:00
|
|
|
for pkg := range dt.Repo {
|
2018-02-28 15:20:26 +00:00
|
|
|
depArguments.delTarget(pkg)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(depArguments.targets) > 0 {
|
2018-02-28 17:39:57 +00:00
|
|
|
_, stderr, err := passToPacmanCapture(depArguments)
|
2018-02-28 15:20:26 +00:00
|
|
|
if err != nil {
|
2018-02-28 17:39:57 +00:00
|
|
|
return fmt.Errorf("%s%s", stderr, err)
|
2018-02-28 15:20:26 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
2018-02-16 21:45:19 +00:00
|
|
|
|
2018-02-18 23:46:25 +00:00
|
|
|
if hasAur {
|
2018-02-21 12:16:30 +00:00
|
|
|
if len(dc.MakeOnly) > 0 {
|
|
|
|
if !continueTask("Remove make dependencies after install?", "yY") {
|
|
|
|
removeMake = true
|
|
|
|
}
|
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-03-09 22:11:30 +00:00
|
|
|
toClean, toEdit, err := cleanEditNumberMenu(dc.Aur, dc.Bases, remoteNamesCache)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-02-21 12:16:30 +00:00
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
cleanBuilds(toClean)
|
2018-02-15 20:51:18 +00:00
|
|
|
|
2018-03-07 21:32:55 +00:00
|
|
|
err = downloadPkgBuilds(dc.Aur, parser.targets, dc.Bases)
|
2018-02-16 15:33:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-09 22:11:30 +00:00
|
|
|
if len(toEdit) > 0 {
|
|
|
|
err = editPkgBuilds(toEdit)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-16 15:33:17 +00:00
|
|
|
}
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2018-03-09 22:11:30 +00:00
|
|
|
if len(toEdit) > 0 && !continueTask("Proceed with install?", "nN") {
|
2018-02-21 12:16:30 +00:00
|
|
|
return fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
2018-02-21 08:41:25 +00:00
|
|
|
|
2018-02-21 12:16:30 +00:00
|
|
|
//conflicts have been checked so answer y for them
|
|
|
|
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
|
2018-03-16 00:18:13 +00:00
|
|
|
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
|
2018-02-21 12:16:30 +00:00
|
|
|
cmdArgs.globals["ask"] = fmt.Sprint(uask)
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
//inital srcinfo parse before pkgver() bump
|
|
|
|
err = parsesrcinfosFile(dc.Aur, srcinfosStale, dc.Bases)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-02-21 08:41:25 +00:00
|
|
|
if arguments.existsArg("gendb") {
|
2018-03-19 16:51:11 +00:00
|
|
|
for _, pkg := range dc.Aur {
|
|
|
|
pkgbuild := srcinfosStale[pkg.PackageBase]
|
|
|
|
|
|
|
|
for _, pkg := range dc.Bases[pkg.PackageBase] {
|
|
|
|
updateVCSData(pkg.Name, pkgbuild.Source)
|
|
|
|
}
|
2018-02-19 06:52:11 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 04:03:09 +00:00
|
|
|
fmt.Println(bold(green(arrow + " GenDB finished. No packages were installed")))
|
2018-02-19 06:52:11 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
incompatable, err = getIncompatable(dc.Aur, srcinfosStale, dc.Bases)
|
2018-01-17 21:48:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
|
|
|
|
err = checkPgpKeys(dc.Aur, dc.Bases, srcinfosStale)
|
2018-03-11 03:00:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
err = downloadPkgBuildsSources(dc.Aur, dc.Bases, incompatable)
|
2018-02-15 07:25:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
err = parsesrcinfosGenerate(dc.Aur, srcinfos, dc.Bases)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = buildInstallPkgBuilds(dc.Aur, srcinfos, parser.targets, parser, dc.Bases, incompatable)
|
2018-01-17 21:48:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
if len(dc.MakeOnly) > 0 {
|
2018-02-21 12:16:30 +00:00
|
|
|
if !removeMake {
|
2018-01-17 21:48:23 +00:00
|
|
|
return nil
|
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-01-17 21:48:23 +00:00
|
|
|
removeArguments := makeArguments()
|
2018-02-15 03:38:19 +00:00
|
|
|
removeArguments.addArg("R", "u")
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
for pkg := range dc.MakeOnly {
|
|
|
|
removeArguments.addTarget(pkg)
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
|
2018-02-07 12:36:51 +00:00
|
|
|
oldValue := config.NoConfirm
|
|
|
|
config.NoConfirm = true
|
2018-02-28 15:20:26 +00:00
|
|
|
err = passToPacman(removeArguments)
|
2018-02-07 12:36:51 +00:00
|
|
|
config.NoConfirm = oldValue
|
2018-02-28 15:20:26 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
if config.CleanAfter {
|
|
|
|
clean(dc.Aur)
|
|
|
|
}
|
|
|
|
|
2018-01-17 21:48:23 +00:00
|
|
|
return nil
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
|
|
|
|
return nil
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
func getIncompatable(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, bases map[string][]*rpc.Pkg) (stringSet, error) {
|
|
|
|
incompatable := make(stringSet)
|
|
|
|
alpmArch, err := alpmHandle.Arch()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
nextpkg:
|
|
|
|
for _, pkg := range pkgs {
|
|
|
|
for _, arch := range srcinfos[pkg.PackageBase].Arch {
|
|
|
|
if arch == "any" || arch == alpmArch {
|
|
|
|
continue nextpkg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
incompatable.set(pkg.PackageBase)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(incompatable) > 0 {
|
|
|
|
fmt.Print(
|
|
|
|
bold(green(("\nThe following packages are not compatable with your architecture:"))))
|
|
|
|
for pkg := range incompatable {
|
|
|
|
fmt.Print(" " + cyan(pkg))
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println()
|
|
|
|
|
|
|
|
if !continueTask("Try to build them anyway?", "nN") {
|
|
|
|
return nil, fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return incompatable, nil
|
|
|
|
}
|
|
|
|
|
2018-03-09 22:11:30 +00:00
|
|
|
func cleanEditNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, []*rpc.Pkg, error) {
|
|
|
|
toPrint := ""
|
|
|
|
askClean := false
|
|
|
|
|
|
|
|
toClean := make([]*rpc.Pkg, 0)
|
|
|
|
toEdit := make([]*rpc.Pkg, 0)
|
|
|
|
|
|
|
|
if config.NoConfirm {
|
|
|
|
return toClean, toEdit, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
for n, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
|
|
|
|
2018-03-12 21:01:53 +00:00
|
|
|
toPrint += fmt.Sprintf("%s %-40s", magenta(strconv.Itoa(len(pkgs)-n)),
|
|
|
|
bold(formatPkgbase(pkg, bases)))
|
2018-03-09 22:11:30 +00: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)
|
|
|
|
|
|
|
|
if askClean {
|
2018-03-12 21:01:53 +00:00
|
|
|
fmt.Println(bold(green(arrow + " Packages to cleanBuild?")))
|
2018-03-09 22:11:30 +00:00
|
|
|
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + green("[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)")))
|
|
|
|
fmt.Print(bold(green(arrow + " ")))
|
|
|
|
reader := bufio.NewReader(os.Stdin)
|
|
|
|
|
|
|
|
numberBuf, overflow, err := reader.ReadLine()
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if overflow {
|
|
|
|
return nil, nil, fmt.Errorf("Input too long")
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanInput := string(numberBuf)
|
|
|
|
|
|
|
|
cInclude, cExclude, cOtherInclude, cOtherExclude := parseNumberMenu(cleanInput)
|
|
|
|
cIsInclude := len(cExclude) == 0 && len(cOtherExclude) == 0
|
|
|
|
|
|
|
|
if cOtherInclude.get("abort") || cOtherInclude.get("ab") {
|
|
|
|
return nil, nil, fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
|
|
|
|
|
|
|
if !cOtherInclude.get("n") && !cOtherInclude.get("none") {
|
|
|
|
for i, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
|
|
|
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if !cIsInclude && cExclude.get(len(pkgs)-i) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if installed.get(pkg.Name) && (cOtherInclude.get("i") || cOtherInclude.get("installed")) {
|
|
|
|
toClean = append(toClean, pkg)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
toClean = append(toClean, pkg)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !cIsInclude && !cExclude.get(len(pkgs)-i) {
|
|
|
|
toClean = append(toClean, pkg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-12 21:01:53 +00:00
|
|
|
fmt.Println(bold(green(arrow + " PKGBUILDs to edit?")))
|
|
|
|
fmt.Println(bold(green(arrow) + cyan(" [N]one ") + green("[A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)")))
|
2018-03-09 22:11:30 +00:00
|
|
|
|
|
|
|
fmt.Print(bold(green(arrow + " ")))
|
|
|
|
reader := bufio.NewReader(os.Stdin)
|
|
|
|
|
|
|
|
numberBuf, overflow, err := reader.ReadLine()
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
if overflow {
|
|
|
|
return nil, nil, fmt.Errorf("Input too long")
|
|
|
|
}
|
|
|
|
|
|
|
|
editInput := string(numberBuf)
|
|
|
|
|
|
|
|
eInclude, eExclude, eOtherInclude, eOtherExclude := parseNumberMenu(editInput)
|
|
|
|
eIsInclude := len(eExclude) == 0 && len(eOtherExclude) == 0
|
|
|
|
|
|
|
|
if eOtherInclude.get("abort") || eOtherInclude.get("ab") {
|
|
|
|
return nil, nil, fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
if eIsInclude && eInclude.get(len(pkgs)-i) {
|
|
|
|
toEdit = append(toEdit, pkg)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !eIsInclude && !eExclude.get(len(pkgs)-i) {
|
|
|
|
toEdit = append(toEdit, pkg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return toClean, toEdit, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func cleanBuilds(pkgs []*rpc.Pkg) {
|
|
|
|
for i, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase
|
|
|
|
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(pkgs), dir)
|
|
|
|
os.RemoveAll(dir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-22 02:09:32 +00:00
|
|
|
func checkInnerConflict(name string, conflict string, conflicts map[string]stringSet, dc *depCatagories) {
|
|
|
|
add := func(h map[string]stringSet, n string, v string) {
|
|
|
|
_, ok := h[n]
|
|
|
|
if !ok {
|
|
|
|
h[n] = make(stringSet)
|
|
|
|
}
|
|
|
|
h[n].set(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
deps, err := gopkg.ParseDeps([]string{conflict})
|
2018-02-07 12:36:51 +00:00
|
|
|
if err != nil {
|
2018-03-22 02:09:32 +00:00
|
|
|
return
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
2018-03-22 02:09:32 +00:00
|
|
|
dep := deps[0]
|
2018-02-07 12:36:51 +00:00
|
|
|
|
2018-02-16 21:45:19 +00:00
|
|
|
for _, pkg := range dc.Aur {
|
2018-03-22 02:09:32 +00:00
|
|
|
if name == pkg.Name {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
version, err := gopkg.NewCompleteVersion(pkg.Version)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if dep.Name == pkg.Name && version.Satisfies(dep) {
|
|
|
|
add(conflicts, name, pkg.Name)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, provide := range pkg.Provides {
|
|
|
|
// Provides are not versioned unless explicitly defined as
|
|
|
|
// such. If a conflict is versioned but a provide is
|
|
|
|
// not it can not conflict.
|
|
|
|
if (dep.MaxVer != nil || dep.MinVer != nil) && !strings.ContainsAny(provide, "><=") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
var version *gopkg.CompleteVersion
|
|
|
|
var err error
|
|
|
|
|
|
|
|
pname, pversion := splitNameFromDep(provide)
|
|
|
|
|
|
|
|
if dep.Name != pname {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if pversion != "" {
|
|
|
|
version, err = gopkg.NewCompleteVersion(provide)
|
|
|
|
if err != nil {
|
|
|
|
return
|
2018-02-16 21:45:19 +00:00
|
|
|
}
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
2018-03-22 02:09:32 +00:00
|
|
|
|
|
|
|
if version != nil && version.Satisfies(dep) {
|
|
|
|
add(conflicts, name, pkg.Name)
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-16 21:45:19 +00:00
|
|
|
for _, pkg := range dc.Repo {
|
2018-03-22 02:09:32 +00:00
|
|
|
if name == pkg.Name() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
version, err := gopkg.NewCompleteVersion(pkg.Version())
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if dep.Name == pkg.Name() && version.Satisfies(dep) {
|
|
|
|
add(conflicts, name, pkg.Name())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg.Provides().ForEach(func(provide alpm.Depend) error {
|
|
|
|
// Provides are not versioned unless explicitly defined as
|
|
|
|
// such. If a conflict is versioned but a provide is
|
|
|
|
// not it can not conflict.
|
|
|
|
if (dep.MaxVer != nil || dep.MinVer != nil) && provide.Mod == alpm.DepModAny {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if dep.Name != pkg.Name() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if provide.Mod == alpm.DepModAny {
|
|
|
|
add(conflicts, name, pkg.Name())
|
|
|
|
return fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
version, err := gopkg.NewCompleteVersion(provide.Version)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
2018-03-22 02:09:32 +00:00
|
|
|
|
|
|
|
if version.Satisfies(dep) {
|
|
|
|
add(conflicts, name, pkg.Name())
|
|
|
|
return fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func checkForInnerConflicts(dc *depCatagories) (map[string]stringSet) {
|
|
|
|
conflicts := make(map[string]stringSet)
|
|
|
|
|
|
|
|
for _, pkg := range dc.Aur {
|
|
|
|
for _, cpkg := range pkg.Conflicts {
|
|
|
|
checkInnerConflict(pkg.Name, cpkg, conflicts, dc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range dc.Repo {
|
|
|
|
pkg.Conflicts().ForEach(func(conflict alpm.Depend) error {
|
|
|
|
checkInnerConflict(pkg.Name(), conflict.String(), conflicts, dc)
|
2018-02-07 12:36:51 +00:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
2018-03-22 02:09:32 +00:00
|
|
|
|
|
|
|
return conflicts
|
|
|
|
}
|
|
|
|
|
|
|
|
func checkReverseConflict(name string, provide string, conflicts map[string]stringSet) error {
|
|
|
|
add := func(h map[string]stringSet, n string, v string) {
|
|
|
|
_, ok := h[n]
|
|
|
|
if !ok {
|
|
|
|
h[n] = make(stringSet)
|
|
|
|
}
|
|
|
|
h[n].set(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
var version *gopkg.CompleteVersion
|
|
|
|
var err error
|
2018-02-07 12:36:51 +00:00
|
|
|
|
2018-03-22 02:09:32 +00:00
|
|
|
localDb, err := alpmHandle.LocalDb()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
pname, pversion := splitNameFromDep(provide)
|
|
|
|
if pversion != "" {
|
|
|
|
version, err = gopkg.NewCompleteVersion(pversion)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
localDb.PkgCache().ForEach(func(pkg alpm.Package) error {
|
|
|
|
if name == pkg.Name() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg.Conflicts().ForEach(func(conflict alpm.Depend) error {
|
|
|
|
deps, err := gopkg.ParseDeps([]string{conflict.String()})
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
dep := deps[0]
|
|
|
|
// Provides are not versioned unless explicitly defined as
|
|
|
|
// such. If a conflict is versioned but a provide is
|
|
|
|
// not it can not conflict.
|
|
|
|
if (dep.MaxVer != nil || dep.MinVer != nil) && version == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if dep.Name != pname {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if version == nil || version.Satisfies(dep) {
|
|
|
|
// Todo
|
|
|
|
add(conflicts, name, pkg.Name() + " (" + provide + ")")
|
|
|
|
return fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func checkConflict(name string, conflict string, conflicts map[string]stringSet) error {
|
|
|
|
add := func(h map[string]stringSet, n string, v string) {
|
|
|
|
_, ok := h[n]
|
|
|
|
if !ok {
|
|
|
|
h[n] = make(stringSet)
|
|
|
|
}
|
|
|
|
h[n].set(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
localDb, err := alpmHandle.LocalDb()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
deps, err := gopkg.ParseDeps([]string{conflict})
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
dep := deps[0]
|
|
|
|
|
|
|
|
localDb.PkgCache().ForEach(func(pkg alpm.Package) error {
|
|
|
|
if name == pkg.Name() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
version, err := gopkg.NewCompleteVersion(pkg.Version())
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if dep.Name == pkg.Name() && version.Satisfies(dep) {
|
|
|
|
add(conflicts, name, pkg.Name())
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg.Provides().ForEach(func(provide alpm.Depend) error {
|
|
|
|
if dep.Name != provide.Name {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Provides arent version unless explicitly defined as
|
|
|
|
// such. If a conflict is versioned but a provide is
|
|
|
|
// not it can not conflict.
|
|
|
|
if (dep.MaxVer != nil || dep.MinVer != nil) && provide.Mod == alpm.DepModAny {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if provide.Mod == alpm.DepModAny {
|
|
|
|
add(conflicts, name, pkg.Name() + " (" + provide.Name + ")")
|
|
|
|
return fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
version, err := gopkg.NewCompleteVersion(provide.Version)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if version.Satisfies(dep) {
|
|
|
|
add(conflicts, name, pkg.Name() + " (" + provide.Name + ")")
|
|
|
|
return fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func checkForConflicts(dc *depCatagories) (map[string]stringSet, error) {
|
|
|
|
conflicts := make(map[string]stringSet)
|
|
|
|
|
|
|
|
for _, pkg := range dc.Aur {
|
|
|
|
for _, cpkg := range pkg.Conflicts {
|
|
|
|
checkConflict(pkg.Name, cpkg, conflicts)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range dc.Repo {
|
|
|
|
pkg.Conflicts().ForEach(func(conflict alpm.Depend) error {
|
|
|
|
checkConflict(pkg.Name(), conflict.String(), conflicts)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range dc.Aur {
|
|
|
|
checkReverseConflict(pkg.Name, pkg.Name, conflicts)
|
|
|
|
for _, ppkg := range pkg.Provides {
|
|
|
|
checkReverseConflict(pkg.Name, ppkg, conflicts)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range dc.Repo {
|
|
|
|
checkReverseConflict(pkg.Name(), pkg.Name(), conflicts)
|
|
|
|
pkg.Provides().ForEach(func(provide alpm.Depend) error {
|
|
|
|
checkReverseConflict(pkg.Name(), provide.String(), conflicts)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return conflicts, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func checkForAllConflicts(dc *depCatagories) error {
|
|
|
|
var err error
|
|
|
|
var conflicts map[string]stringSet
|
|
|
|
var innerConflicts map[string]stringSet
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(2)
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println(bold(cyan("::")+ " Checking for conflicts..."))
|
|
|
|
go func() {
|
|
|
|
conflicts, err = checkForConflicts(dc)
|
|
|
|
wg.Done()
|
|
|
|
}()
|
|
|
|
|
|
|
|
fmt.Println(bold(cyan("::")+ " Checking for inner conflicts..."))
|
|
|
|
go func() {
|
|
|
|
innerConflicts = checkForInnerConflicts(dc)
|
|
|
|
wg.Done()
|
|
|
|
}()
|
|
|
|
|
|
|
|
wg.Wait()
|
|
|
|
if len(innerConflicts) != 0 {
|
2018-02-07 12:36:51 +00:00
|
|
|
fmt.Println(
|
2018-03-22 02:09:32 +00:00
|
|
|
red("\nInner conflicts found:"))
|
|
|
|
for name, pkgs := range innerConflicts {
|
|
|
|
str := "\t" + name + ":"
|
|
|
|
for pkg := range pkgs {
|
|
|
|
str += " " + magenta(pkg)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(str)
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Errorf("Aborting")
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(conflicts) != 0 {
|
|
|
|
fmt.Println(
|
|
|
|
red("\nPackage conflicts found:"))
|
|
|
|
for name, pkgs := range conflicts {
|
|
|
|
str := "\tInstalling " + magenta(name) + " will remove:"
|
2018-02-16 21:45:19 +00:00
|
|
|
for pkg := range pkgs {
|
2018-03-02 04:54:38 +00:00
|
|
|
str += " " + magenta(pkg)
|
2018-02-16 21:45:19 +00:00
|
|
|
}
|
2018-02-07 12:36:51 +00:00
|
|
|
|
2018-02-16 21:45:19 +00:00
|
|
|
fmt.Println(str)
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
2018-03-09 22:11:30 +00:00
|
|
|
|
|
|
|
fmt.Println()
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-03-09 22:11:30 +00:00
|
|
|
func editPkgBuilds(pkgs []*rpc.Pkg) error {
|
|
|
|
pkgbuilds := make([]string, 0, len(pkgs))
|
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
|
|
|
pkgbuilds = append(pkgbuilds, dir+"PKGBUILD")
|
|
|
|
}
|
|
|
|
|
|
|
|
editcmd := exec.Command(editor(), pkgbuilds...)
|
|
|
|
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, Abotring: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-19 06:52:11 +00:00
|
|
|
func parsesrcinfosFile(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, bases map[string][]*rpc.Pkg) error {
|
|
|
|
for k, pkg := range pkgs {
|
2018-02-15 06:17:27 +00:00
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2018-03-02 04:03:09 +00:00
|
|
|
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
|
2018-02-20 01:23:16 +00:00
|
|
|
fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases))
|
2018-02-19 06:52:11 +00:00
|
|
|
|
|
|
|
pkgbuild, err := gopkg.ParseSRCINFO(dir + ".SRCINFO")
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("%s: %s", pkg.Name, err)
|
|
|
|
}
|
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
srcinfos[pkg.PackageBase] = pkgbuild
|
2018-02-19 06:52:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func parsesrcinfosGenerate(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, bases map[string][]*rpc.Pkg) error {
|
|
|
|
for k, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
|
|
|
|
2018-03-02 04:03:09 +00:00
|
|
|
str := bold(cyan("::") + " Parsing SRCINFO (%d/%d): %s\n")
|
2018-02-20 01:23:16 +00:00
|
|
|
fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases))
|
2018-02-21 08:41:25 +00:00
|
|
|
|
2018-02-15 19:43:16 +00:00
|
|
|
cmd := exec.Command(config.MakepkgBin, "--printsrcinfo")
|
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
cmd.Dir = dir
|
|
|
|
srcinfo, err := cmd.Output()
|
2018-02-15 05:36:42 +00:00
|
|
|
|
2018-02-15 19:43:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
pkgbuild, err := gopkg.ParseSRCINFOContent(srcinfo)
|
2018-02-18 14:48:49 +00:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("%s: %s", pkg.Name, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
srcinfos[pkg.PackageBase] = pkgbuild
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
2018-02-15 05:36:42 +00:00
|
|
|
|
|
|
|
return nil
|
2018-01-17 21:48:23 +00:00
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-03-07 21:32:55 +00:00
|
|
|
func downloadPkgBuilds(pkgs []*rpc.Pkg, targets stringSet, bases map[string][]*rpc.Pkg) error {
|
2018-02-19 06:52:11 +00:00
|
|
|
for k, pkg := range pkgs {
|
2018-03-07 21:32:55 +00:00
|
|
|
if config.ReDownload == "no" || (config.ReDownload == "yes" && !targets.get(pkg.Name)) {
|
2018-03-06 03:42:26 +00:00
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/.SRCINFO"
|
|
|
|
pkgbuild, err := gopkg.ParseSRCINFO(dir)
|
|
|
|
|
|
|
|
if err == nil {
|
|
|
|
version, err := gopkg.NewCompleteVersion(pkg.Version)
|
|
|
|
if err == nil {
|
|
|
|
if !version.Newer(pkgbuild.Version()) {
|
|
|
|
str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n")
|
|
|
|
fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases))
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
str := bold(cyan("::") + " Downloading PKGBUILD (%d/%d): %s\n")
|
2018-02-20 01:23:16 +00:00
|
|
|
|
2018-02-21 08:41:25 +00:00
|
|
|
fmt.Printf(str, k+1, len(pkgs), formatPkgbase(pkg, bases))
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-03-06 03:42:26 +00:00
|
|
|
err := downloadAndUnpack(baseURL+pkg.URLPath, config.BuildDir, false)
|
2018-01-20 22:37:10 +00:00
|
|
|
if err != nil {
|
2018-03-06 03:42:26 +00:00
|
|
|
return err
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-06 03:42:26 +00:00
|
|
|
return nil
|
2018-01-17 21:48:23 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
func downloadPkgBuildsSources(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, incompatable stringSet) (err error) {
|
2018-01-17 21:48:23 +00:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-03-19 16:51:11 +00:00
|
|
|
args := []string{"--nobuild", "--nocheck", "--noprepare", "--nodeps"}
|
|
|
|
|
|
|
|
if incompatable.get(pkg.PackageBase) {
|
|
|
|
args = append(args, "--ignorearch")
|
|
|
|
}
|
|
|
|
|
|
|
|
err = passToMakepkg(dir, args...)
|
2018-01-17 21:48:23 +00:00
|
|
|
if err != nil {
|
2018-02-27 03:41:39 +00:00
|
|
|
return fmt.Errorf("Error downloading sources: %s", formatPkgbase(pkg, bases))
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-17 21:48:23 +00:00
|
|
|
return
|
|
|
|
}
|
2018-01-05 22:12:14 +00:00
|
|
|
|
2018-03-19 16:51:11 +00:00
|
|
|
func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, targets stringSet, parser *arguments, bases map[string][]*rpc.Pkg, incompatable stringSet) error {
|
2018-03-19 10:05:47 +00:00
|
|
|
alpmArch, err := alpmHandle.Arch()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-02-27 12:06:30 +00:00
|
|
|
for _, pkg := range pkgs {
|
2018-03-19 10:05:47 +00:00
|
|
|
var arch string
|
2018-01-17 21:48:23 +00:00
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-02-15 21:23:34 +00:00
|
|
|
built := true
|
2018-02-15 19:43:16 +00:00
|
|
|
|
|
|
|
srcinfo := srcinfos[pkg.PackageBase]
|
|
|
|
version := srcinfo.CompleteVersion()
|
|
|
|
|
2018-03-19 10:05:47 +00:00
|
|
|
if srcinfos[pkg.PackageBase].Arch[0] == "any" {
|
|
|
|
arch = "any"
|
|
|
|
} else {
|
|
|
|
arch = alpmArch
|
|
|
|
}
|
|
|
|
|
2018-03-14 01:48:33 +00:00
|
|
|
if config.ReBuild == "no" || (config.ReBuild == "yes" && !targets.get(pkg.Name)) {
|
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
2018-03-19 10:05:47 +00:00
|
|
|
file, err := completeFileName(dir, split.Name+"-"+version.String()+"-"+arch+".pkg")
|
2018-03-14 01:48:33 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2018-03-14 01:48:33 +00:00
|
|
|
if file == "" {
|
|
|
|
built = false
|
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
}
|
2018-03-14 01:48:33 +00:00
|
|
|
} else {
|
|
|
|
built = false
|
2018-02-15 21:23:34 +00:00
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
if built {
|
2018-03-02 04:54:38 +00:00
|
|
|
fmt.Println(bold(red(arrow+" Warning:")),
|
|
|
|
pkg.Name+"-"+pkg.Version+" Already made -- skipping build")
|
2018-02-15 21:23:34 +00:00
|
|
|
} else {
|
2018-03-19 16:51:11 +00:00
|
|
|
args := []string{"-Ccf", "--noconfirm"}
|
|
|
|
|
|
|
|
if incompatable.get(pkg.PackageBase) {
|
|
|
|
args = append(args, "--ignorearch")
|
|
|
|
}
|
|
|
|
|
|
|
|
err := passToMakepkg(dir, args...)
|
2018-02-15 21:23:34 +00:00
|
|
|
if err != nil {
|
2018-02-20 01:23:16 +00:00
|
|
|
return fmt.Errorf("Error making: %s", pkg.Name)
|
2018-02-15 19:43:16 +00:00
|
|
|
}
|
2018-01-04 00:59:57 +00:00
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
|
|
|
arguments := parser.copy()
|
|
|
|
arguments.targets = make(stringSet)
|
|
|
|
arguments.op = "U"
|
|
|
|
arguments.delArg("confirm")
|
|
|
|
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-02-15 21:23:34 +00:00
|
|
|
depArguments := makeArguments()
|
|
|
|
depArguments.addArg("D", "asdeps")
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
2018-03-19 10:05:47 +00:00
|
|
|
file, err := completeFileName(dir, split.Name+"-"+version.String()+"-"+arch+".pkg")
|
2018-02-15 21:23:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
if file == "" {
|
2018-03-19 10:05:47 +00:00
|
|
|
return fmt.Errorf("Could not find built package " + split.Name + "-" + version.String() + "-" + arch + ".pkg")
|
2018-02-15 21:23:34 +00:00
|
|
|
}
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
arguments.addTarget(file)
|
|
|
|
if !targets.get(split.Name) {
|
|
|
|
depArguments.addTarget(split.Name)
|
|
|
|
}
|
|
|
|
}
|
2018-02-15 19:43:16 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
oldConfirm := config.NoConfirm
|
|
|
|
config.NoConfirm = true
|
|
|
|
err := passToPacman(arguments)
|
|
|
|
if err != nil {
|
2018-02-15 19:43:16 +00:00
|
|
|
return err
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
2018-02-27 12:06:30 +00:00
|
|
|
|
2018-03-05 22:15:34 +00:00
|
|
|
for _, pkg := range bases[pkg.PackageBase] {
|
|
|
|
updateVCSData(pkg.Name, srcinfo.Source)
|
|
|
|
}
|
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
if len(depArguments.targets) > 0 {
|
2018-02-28 17:39:57 +00:00
|
|
|
_, stderr, err := passToPacmanCapture(depArguments)
|
2018-02-15 21:23:34 +00:00
|
|
|
if err != nil {
|
2018-02-28 17:39:57 +00:00
|
|
|
return fmt.Errorf("%s%s", stderr, err)
|
2018-02-15 21:23:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
config.NoConfirm = oldConfirm
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
|
2018-02-15 19:43:16 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
func clean(pkgs []*rpc.Pkg) {
|
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
|
|
|
|
2018-03-02 04:03:09 +00:00
|
|
|
fmt.Println(bold(green(arrow +
|
|
|
|
" CleanAfter enabled. Deleting " + pkg.Name + " source folder.")))
|
2018-02-15 21:23:34 +00:00
|
|
|
os.RemoveAll(dir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 19:43:16 +00:00
|
|
|
func completeFileName(dir, name string) (string, error) {
|
2018-03-22 02:09:32 +00:00
|
|
|
|
2018-02-16 17:18:59 +00:00
|
|
|
files, err := ioutil.ReadDir(dir)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, file := range files {
|
|
|
|
if file.IsDir() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if strings.HasPrefix(file.Name(), name) {
|
|
|
|
return dir + file.Name(), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return "", nil
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|