2017-08-02 17:24:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-02-16 17:18:59 +00:00
|
|
|
"io/ioutil"
|
2017-08-02 17:24:03 +00:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
2018-02-15 19:43:16 +00:00
|
|
|
"strings"
|
2018-02-16 21:45:19 +00:00
|
|
|
"strconv"
|
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-02-18 23:46:25 +00:00
|
|
|
aur, repo, err := packageSlices(parser.targets.toSlice())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
//fmt.Println(greenFg(arrow), greenFg("Resolving Dependencies"))
|
2018-02-19 19:38:34 +00:00
|
|
|
requestTargets := append(aur, repo...)
|
2018-02-18 23:46:25 +00:00
|
|
|
|
|
|
|
//remotenames: names of all non repo packages on the system
|
|
|
|
_, _, _, remoteNames, err := filterPackages()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
//cache as a stringset. maybe make it return a string set in the first
|
|
|
|
//place
|
|
|
|
remoteNamesCache := make(stringSet)
|
|
|
|
for _, name := range remoteNames {
|
|
|
|
remoteNamesCache.set(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
//if we are doing -u also request every non repo package on the system
|
|
|
|
if parser.existsArg("u", "sysupgrade") {
|
|
|
|
requestTargets = append(requestTargets, remoteNames...)
|
|
|
|
}
|
|
|
|
|
2018-02-19 19:38:34 +00:00
|
|
|
if len(aur) > 0 {
|
2018-02-19 17:35:47 +00:00
|
|
|
fmt.Println(boldCyanFg("::"), boldFg("Querying AUR..."))
|
|
|
|
}
|
2018-02-18 23:46: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-02-18 23:46:25 +00:00
|
|
|
if !remoteNamesCache.get(missingName) {
|
2018-02-19 06:52:11 +00:00
|
|
|
return fmt.Errorf(boldRedFgBlackBg(arrow+" Error: ") +
|
|
|
|
blackBg("Could not find all required package"))
|
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-18 23:46:25 +00:00
|
|
|
|
|
|
|
if parser.existsArg("u", "sysupgrade") {
|
|
|
|
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-18 23:46:25 +00:00
|
|
|
for pkg := range aurUp {
|
|
|
|
parser.addTarget(pkg)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
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 {
|
|
|
|
arguments.addTarget(pkg.Name())
|
|
|
|
}
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-02-19 19:38:34 +00:00
|
|
|
for _, pkg := range repo {
|
|
|
|
arguments.addTarget(pkg)
|
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
|
2018-02-19 19:38:34 +00:00
|
|
|
if hasAur {
|
2018-02-15 21:23:34 +00:00
|
|
|
printDepCatagories(dc)
|
2018-02-16 21:45:19 +00:00
|
|
|
fmt.Println()
|
2018-02-19 19:38:34 +00:00
|
|
|
|
|
|
|
if !parser.existsArg("gendb") {
|
|
|
|
err = checkForConflicts(dc)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2018-02-18 23:46:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(arguments.targets) > 0 {
|
|
|
|
err := passToPacman(arguments)
|
|
|
|
if err != nil {
|
2018-02-19 06:52:11 +00:00
|
|
|
fmt.Errorf("Error installing repo packages.")
|
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-19 19:38:34 +00:00
|
|
|
//conflicts have been checked so answer y for them
|
|
|
|
ask, _ := strconv.Atoi(cmdArgs.globals["ask"])
|
|
|
|
uask := alpm.Question(ask) | alpm.QuestionConflictPkg
|
|
|
|
cmdArgs.globals["ask"] = fmt.Sprint(uask)
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
askCleanBuilds(dc.Aur, dc.Bases)
|
2018-01-17 21:48:23 +00:00
|
|
|
fmt.Println()
|
|
|
|
|
2018-02-07 12:36:51 +00:00
|
|
|
if !continueTask("Proceed with install?", "nN") {
|
2018-01-17 21:48:23 +00:00
|
|
|
return fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2018-02-16 15:33:17 +00:00
|
|
|
// if !continueTask("Proceed with download?", "nN") {
|
|
|
|
// return fmt.Errorf("Aborting due to user")
|
2018-02-16 21:45:19 +00:00
|
|
|
// }
|
2018-02-15 20:51:18 +00:00
|
|
|
|
2018-02-16 15:33:17 +00:00
|
|
|
err = dowloadPkgBuilds(dc.Aur, dc.Bases)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = askEditPkgBuilds(dc.Aur, dc.Bases)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-16 17:18:59 +00:00
|
|
|
|
2018-02-18 23:46:25 +00:00
|
|
|
/*if len(dc.Repo) > 0 {
|
2018-02-15 20:51:18 +00:00
|
|
|
arguments := parser.copy()
|
|
|
|
arguments.delArg("u", "sysupgrade")
|
|
|
|
arguments.delArg("y", "refresh")
|
|
|
|
arguments.op = "S"
|
|
|
|
arguments.targets = make(stringSet)
|
|
|
|
arguments.addArg("needed", "asdeps")
|
|
|
|
for _, pkg := range dc.Repo {
|
|
|
|
arguments.addTarget(pkg.Name())
|
|
|
|
}
|
|
|
|
|
|
|
|
oldConfirm := config.NoConfirm
|
|
|
|
config.NoConfirm = true
|
|
|
|
passToPacman(arguments)
|
|
|
|
config.NoConfirm = oldConfirm
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-18 23:46:25 +00:00
|
|
|
}*/
|
2018-02-19 06:52:11 +00:00
|
|
|
|
2018-02-07 12:36:51 +00:00
|
|
|
// if !continueTask("Proceed with install?", "nN") {
|
|
|
|
// return fmt.Errorf("Aborting due to user")
|
|
|
|
// }
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-02-19 06:52:11 +00:00
|
|
|
//this downloads the package build sources but also causes
|
|
|
|
//a version bumb for vsc packages
|
|
|
|
//that should not edit the sources so we should be safe to skip
|
|
|
|
//it and parse the srcinfo at the current version
|
|
|
|
if arguments.existsArg("gendb") {
|
|
|
|
err = parsesrcinfosFile(dc.Aur, srcinfos, dc.Bases)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println(boldGreenFg(arrow+" GenDB finished. No packages were installed"))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-01-17 21:48:23 +00:00
|
|
|
err = downloadPkgBuildsSources(dc.Aur)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-02-19 06:52:11 +00:00
|
|
|
|
|
|
|
err = parsesrcinfosGenerate(dc.Aur, srcinfos, dc.Bases)
|
2018-02-15 07:25:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
err = buildInstallPkgBuilds(dc.Aur, srcinfos, parser.targets, parser, dc.Bases)
|
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-01-31 21:04:21 +00:00
|
|
|
if continueTask("Remove make dependencies?", "yY") {
|
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-01-17 21:48:23 +00:00
|
|
|
passToPacman(removeArguments)
|
2018-02-07 12:36:51 +00:00
|
|
|
config.NoConfirm = oldValue
|
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-02-15 21:23:34 +00:00
|
|
|
func askCleanBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) {
|
2018-01-17 21:48:23 +00:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-01-17 21:48:23 +00:00
|
|
|
if _, err := os.Stat(dir); !os.IsNotExist(err) {
|
2018-02-15 21:23:34 +00:00
|
|
|
str := pkg.Name
|
|
|
|
if len(bases[pkg.PackageBase]) > 1 || pkg.PackageBase != pkg.Name {
|
|
|
|
str += " ("
|
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
|
|
|
str += split.Name + " "
|
|
|
|
}
|
|
|
|
str = str[:len(str)-1] + ")"
|
|
|
|
}
|
|
|
|
|
2018-02-16 17:18:59 +00:00
|
|
|
if !continueTask(str+" Directory exists. Clean Build?", "yY") {
|
2018-01-17 21:48:23 +00:00
|
|
|
_ = os.RemoveAll(config.BuildDir + pkg.PackageBase)
|
|
|
|
}
|
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
2018-01-17 21:48:23 +00:00
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-02-16 21:45:19 +00:00
|
|
|
func checkForConflicts(dc *depCatagories) error {
|
2018-02-07 12:36:51 +00:00
|
|
|
localDb, err := alpmHandle.LocalDb()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-16 21:45:19 +00:00
|
|
|
toRemove := make(map[string]stringSet)
|
2018-02-07 12:36:51 +00:00
|
|
|
|
2018-02-16 21:45:19 +00:00
|
|
|
for _, pkg := range dc.Aur {
|
2018-02-07 12:36:51 +00:00
|
|
|
for _, cpkg := range pkg.Conflicts {
|
|
|
|
if _, err := localDb.PkgByName(cpkg); err == nil {
|
2018-02-16 21:45:19 +00:00
|
|
|
_, ok := toRemove[pkg.Name]
|
|
|
|
if !ok {
|
|
|
|
toRemove[pkg.Name] = make(stringSet)
|
|
|
|
}
|
|
|
|
toRemove[pkg.Name].set(cpkg)
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-16 21:45:19 +00:00
|
|
|
for _, pkg := range dc.Repo {
|
2018-02-07 12:36:51 +00:00
|
|
|
pkg.Conflicts().ForEach(func(conf alpm.Depend) error {
|
|
|
|
if _, err := localDb.PkgByName(conf.Name); err == nil {
|
2018-02-16 21:45:19 +00:00
|
|
|
_, ok := toRemove[pkg.Name()]
|
|
|
|
if !ok {
|
|
|
|
toRemove[pkg.Name()] = make(stringSet)
|
|
|
|
}
|
|
|
|
toRemove[pkg.Name()].set(conf.Name)
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(toRemove) != 0 {
|
|
|
|
fmt.Println(
|
2018-02-16 21:45:19 +00:00
|
|
|
redFg("Package conflicts found:"))
|
|
|
|
for name, pkgs := range toRemove {
|
|
|
|
str := yellowFg("\t" + name) + " Replaces"
|
|
|
|
for pkg := range pkgs {
|
|
|
|
str += " " + yellowFg(pkg)
|
|
|
|
}
|
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-02-16 21:45:19 +00:00
|
|
|
if !continueTask("Continue with install?", "nN") {
|
|
|
|
return fmt.Errorf("Aborting due to user")
|
2018-02-07 12:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-16 17:18:59 +00:00
|
|
|
func askEditPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) error {
|
2018-01-17 21:48:23 +00:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-01-20 22:37:10 +00:00
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
str := "Edit PKGBUILD? " + pkg.PackageBase
|
|
|
|
if len(bases[pkg.PackageBase]) > 1 || pkg.PackageBase != pkg.Name {
|
|
|
|
str += " ("
|
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
|
|
|
str += split.Name + " "
|
|
|
|
}
|
|
|
|
str = str[:len(str)-1] + ")"
|
|
|
|
}
|
|
|
|
|
|
|
|
if !continueTask(str, "yY") {
|
2018-01-17 21:48:23 +00:00
|
|
|
editcmd := exec.Command(editor(), dir+"PKGBUILD")
|
|
|
|
editcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
|
|
|
editcmd.Run()
|
2018-02-15 19:43:16 +00:00
|
|
|
}
|
2018-02-15 06:17:27 +00:00
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-02-15 06:17:27 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-19 06:52:11 +00:00
|
|
|
func updateVSCdb(pkgbuild *gopkg.PKGBUILD) {
|
|
|
|
for _, pkgsource := range pkgbuild.Source {
|
|
|
|
owner, repo := parseSource(pkgsource)
|
|
|
|
if owner != "" && repo != "" {
|
|
|
|
err := branchInfo(pkgbuild.Pkgbase, owner, repo)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-02-19 06:52:11 +00:00
|
|
|
str := boldCyanFg("::") + boldFg(" Parsing SRCINFO (%d/%d): %s-%s")
|
|
|
|
str2 := ""
|
|
|
|
if len(bases[pkg.PackageBase]) > 1 || pkg.PackageBase != pkg.Name {
|
|
|
|
str2 += " ("
|
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
|
|
|
str2 += split.Name + " "
|
|
|
|
}
|
|
|
|
str2 = str2[:len(str2)-1] + ")"
|
|
|
|
}
|
|
|
|
fmt.Printf(str, k+1, len(pkgs), pkg.PackageBase, pkg.Version)
|
|
|
|
fmt.Print(str2)
|
|
|
|
fmt.Println()
|
|
|
|
|
|
|
|
|
|
|
|
pkgbuild, err := gopkg.ParseSRCINFO(dir + ".SRCINFO")
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("%s: %s", pkg.Name, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
srcinfos[pkg.PackageBase] = pkgbuild
|
|
|
|
updateVSCdb(pkgbuild)
|
|
|
|
}
|
|
|
|
|
|
|
|
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 + "/"
|
|
|
|
|
|
|
|
str := "Parsing SRCINFO (%d/%d): %s-%s"
|
|
|
|
str2 := ""
|
|
|
|
if len(bases[pkg.PackageBase]) > 1 || pkg.PackageBase != pkg.Name {
|
|
|
|
str2 += " ("
|
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
|
|
|
str2 += split.Name + " "
|
|
|
|
}
|
|
|
|
str2 = str2[:len(str2)-1] + ")"
|
|
|
|
}
|
|
|
|
fmt.Printf(str, k+1, len(pkgs), pkg.PackageBase, pkg.Version)
|
|
|
|
fmt.Print(str2)
|
|
|
|
fmt.Println()
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2018-02-19 06:52:11 +00:00
|
|
|
updateVSCdb(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-02-15 21:23:34 +00:00
|
|
|
func dowloadPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) (err error) {
|
2018-02-19 06:52:11 +00:00
|
|
|
for k, pkg := range pkgs {
|
2018-01-17 21:48:23 +00:00
|
|
|
//todo make pretty
|
2018-02-19 06:52:11 +00:00
|
|
|
str := boldCyanFg("::") + boldFg(" Downloading (%d/%d): %s-%s")
|
|
|
|
str2 := ""
|
2018-02-15 21:23:34 +00:00
|
|
|
if len(bases[pkg.PackageBase]) > 1 || pkg.PackageBase != pkg.Name {
|
2018-02-19 06:52:11 +00:00
|
|
|
str2 += " ("
|
2018-02-15 21:23:34 +00:00
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
2018-02-19 06:52:11 +00:00
|
|
|
str2 += split.Name + " "
|
2018-02-15 21:23:34 +00:00
|
|
|
}
|
2018-02-19 06:52:11 +00:00
|
|
|
str2 = str2[:len(str2)-1] + ")"
|
2018-02-15 21:23:34 +00:00
|
|
|
}
|
2018-02-19 06:52:11 +00:00
|
|
|
fmt.Printf(str, k+1, len(pkgs), pkg.PackageBase, pkg.Version)
|
|
|
|
fmt.Print(str2)
|
|
|
|
fmt.Println()
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2018-01-20 22:37:10 +00:00
|
|
|
err = downloadAndUnpack(baseURL+pkg.URLPath, config.BuildDir, false)
|
|
|
|
if err != nil {
|
2018-01-17 21:48:23 +00:00
|
|
|
return
|
2017-08-02 17:24:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-17 21:48:23 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func downloadPkgBuildsSources(pkgs []*rpc.Pkg) (err error) {
|
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-02-15 07:25:20 +00:00
|
|
|
err = passToMakepkg(dir, "--nobuild", "--nocheck", "--noprepare", "--nodeps")
|
2018-01-17 21:48:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return
|
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-02-16 17:18:59 +00:00
|
|
|
func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, targets stringSet, parser *arguments, bases map[string][]*rpc.Pkg) error {
|
2018-01-17 21:48:23 +00:00
|
|
|
//for n := len(pkgs) -1 ; n > 0; n-- {
|
|
|
|
for n := 0; n < len(pkgs); n++ {
|
|
|
|
pkg := pkgs[n]
|
2018-02-15 21:23:34 +00:00
|
|
|
|
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-02-16 17:18:59 +00:00
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
|
|
|
file, err := completeFileName(dir, split.Name+"-"+version.String())
|
2018-02-15 19:43:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-02-15 21:23:34 +00:00
|
|
|
if file == "" {
|
|
|
|
built = false
|
2018-02-15 19:43:16 +00:00
|
|
|
}
|
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 {
|
|
|
|
fmt.Println(boldRedFgBlackBg(arrow+" Warning:"),
|
2018-02-16 17:18:59 +00:00
|
|
|
blackBg(pkg.Name+"-"+pkg.Version+" Already made -- skipping build"))
|
2018-02-15 21:23:34 +00:00
|
|
|
} else {
|
2018-02-19 18:06:23 +00:00
|
|
|
err := passToMakepkg(dir, "-Ccf", "--noconfirm")
|
2018-02-15 21:23:34 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
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-02-16 17:18:59 +00:00
|
|
|
file, err := completeFileName(dir, split.Name+"-"+version.String())
|
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 == "" {
|
|
|
|
return fmt.Errorf("Could not find built package " + split.Name + "-" + version.String())
|
|
|
|
}
|
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-15 21:23:34 +00:00
|
|
|
if len(depArguments.targets) > 0 {
|
|
|
|
err = passToPacman(depArguments)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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 + "/"
|
|
|
|
|
|
|
|
fmt.Println(boldGreenFg(arrow +
|
2018-02-16 17:18:59 +00:00
|
|
|
" 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-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
|
|
|
}
|