2017-08-02 19:24:03 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
2018-02-15 20:43:16 +01:00
|
|
|
"io/ioutil"
|
|
|
|
"strings"
|
2017-08-02 19:24:03 +02:00
|
|
|
|
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"
|
2017-08-04 11:26:53 +02:00
|
|
|
gopkg "github.com/mikkeloscar/gopkgbuild"
|
2017-08-02 19:24:03 +02:00
|
|
|
)
|
|
|
|
|
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-01-17 22:48:23 +01:00
|
|
|
aurs, repos, missing, err := packageSlices(parser.targets.toSlice())
|
2018-02-15 20:43:16 +01:00
|
|
|
srcinfos := make(map[string]*gopkg.PKGBUILD)
|
2018-01-17 22:48:23 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(missing) > 0 {
|
|
|
|
fmt.Println(missing)
|
2018-02-08 23:51:43 +01:00
|
|
|
fmt.Println("Could not find all Targets")
|
2018-01-17 22:48:23 +01:00
|
|
|
}
|
2018-01-04 01:59:57 +01:00
|
|
|
|
2018-01-04 09:13:47 +01:00
|
|
|
arguments := parser.copy()
|
|
|
|
arguments.delArg("u", "sysupgrade")
|
|
|
|
arguments.delArg("y", "refresh")
|
2018-01-21 12:48:09 +01:00
|
|
|
arguments.op = "S"
|
2018-01-04 09:13:47 +01:00
|
|
|
arguments.targets = make(stringSet)
|
2018-01-04 01:59:57 +01:00
|
|
|
arguments.addTarget(repos...)
|
2018-01-05 23:12:14 +01:00
|
|
|
|
2017-08-02 19:24:03 +02:00
|
|
|
if len(repos) != 0 {
|
2018-01-04 01:59:57 +01:00
|
|
|
err := passToPacman(arguments)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Error installing repo packages.")
|
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(aurs) != 0 {
|
2018-02-15 22:23:34 +01:00
|
|
|
//todo mamakeke pretty
|
2018-02-07 13:36:51 +01:00
|
|
|
fmt.Println(greenFg(arrow), greenFg("Resolving Dependencies"))
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
dt, err := getDepTree(aurs)
|
2017-08-02 19:24:03 +02:00
|
|
|
if err != nil {
|
2018-01-17 22:48:23 +01:00
|
|
|
return err
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
|
2018-01-20 23:37:10 +01:00
|
|
|
if len(dt.Missing) > 0 {
|
2018-01-17 22:48:23 +01:00
|
|
|
fmt.Println(dt.Missing)
|
|
|
|
return fmt.Errorf("Could not find all Deps")
|
|
|
|
}
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
dc, err := getDepCatagories(aurs, dt)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range dc.Aur {
|
|
|
|
if pkg.Maintainer == "" {
|
2018-02-08 23:51:43 +01:00
|
|
|
fmt.Println(boldRedFgBlackBg(arrow+" Warning:"),
|
|
|
|
blackBg(pkg.Name+"-"+pkg.Version+" is orphaned"))
|
2018-01-17 22:48:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
//printDownloadsFromRepo("Repo", dc.Repo)
|
|
|
|
//printDownloadsFromRepo("Repo Make", dc.RepoMake)
|
|
|
|
//printDownloadsFromAur("AUR", dc.Aur)
|
|
|
|
//printDownloadsFromAur("AUR Make", dc.AurMake)
|
|
|
|
|
|
|
|
//fmt.Println(dc.MakeOnly)
|
|
|
|
//fmt.Println(dc.AurSet)
|
|
|
|
|
|
|
|
printDepCatagories(dc)
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
askCleanBuilds(dc.Aur, dc.Bases)
|
2018-01-17 22:48:23 +01:00
|
|
|
fmt.Println()
|
|
|
|
|
2018-02-07 13:36:51 +01:00
|
|
|
if !continueTask("Proceed with install?", "nN") {
|
2018-01-17 22:48:23 +01:00
|
|
|
return fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
2018-02-15 21:51:18 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
if len(dc.Repo) > 0 {
|
2018-02-15 21:51:18 +01: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-07 13:36:51 +01:00
|
|
|
// if !continueTask("Proceed with download?", "nN") {
|
|
|
|
// return fmt.Errorf("Aborting due to user")
|
|
|
|
// }
|
|
|
|
|
2018-02-08 23:51:43 +01:00
|
|
|
if _, ok := arguments.options["gendb"]; !ok {
|
2018-02-15 22:23:34 +01:00
|
|
|
//err = checkForConflicts(dc.Aur, dc.AurMake, dc.Repo, dc.RepoMake)
|
2018-02-08 23:51:43 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-07 13:36:51 +01:00
|
|
|
}
|
2018-01-17 22:48:23 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
err = dowloadPkgBuilds(dc.Aur, dc.Bases)
|
2018-01-17 22:48:23 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
err = askEditPkgBuilds(dc.Aur, dc.Bases)
|
2018-02-15 06:36:42 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-15 08:25:20 +01:00
|
|
|
|
2018-02-08 23:51:43 +01:00
|
|
|
if _, ok := arguments.options["gendb"]; ok {
|
|
|
|
fmt.Println("GenDB finished. No packages were installed")
|
|
|
|
return nil
|
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-02-07 13:36:51 +01:00
|
|
|
// if !continueTask("Proceed with install?", "nN") {
|
|
|
|
// return fmt.Errorf("Aborting due to user")
|
|
|
|
// }
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
err = downloadPkgBuildsSources(dc.Aur)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-02-15 20:43:16 +01:00
|
|
|
err = parsesrcinfos(dc.Aur, srcinfos)
|
2018-02-15 08:25:20 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
err = buildInstallPkgBuilds(dc.Aur, srcinfos, parser.targets, parser, dc.Bases)
|
2018-01-17 22:48:23 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
if len(dc.MakeOnly) > 0 {
|
2018-01-31 22:04:21 +01:00
|
|
|
if continueTask("Remove make dependencies?", "yY") {
|
2018-01-17 22:48:23 +01:00
|
|
|
return nil
|
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
removeArguments := makeArguments()
|
2018-02-15 04:38:19 +01:00
|
|
|
removeArguments.addArg("R", "u")
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
for pkg := range dc.MakeOnly {
|
|
|
|
removeArguments.addTarget(pkg)
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
2018-01-17 22:48:23 +01:00
|
|
|
|
2018-02-07 13:36:51 +01:00
|
|
|
oldValue := config.NoConfirm
|
|
|
|
config.NoConfirm = true
|
2018-01-17 22:48:23 +01:00
|
|
|
passToPacman(removeArguments)
|
2018-02-07 13:36:51 +01:00
|
|
|
config.NoConfirm = oldValue
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
if config.CleanAfter {
|
|
|
|
clean(dc.Aur)
|
|
|
|
}
|
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
return nil
|
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-02-15 22:23:34 +01:00
|
|
|
func askCleanBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) {
|
2018-01-17 22:48:23 +01:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
if _, err := os.Stat(dir); !os.IsNotExist(err) {
|
2018-02-15 22:23:34 +01: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] + ")"
|
|
|
|
}
|
|
|
|
|
|
|
|
if !continueTask(str + " Directory exists. Clean Build?", "yY") {
|
2018-01-17 22:48:23 +01:00
|
|
|
_ = os.RemoveAll(config.BuildDir + pkg.PackageBase)
|
|
|
|
}
|
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
2018-01-17 22:48:23 +01:00
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-02-07 13:36:51 +01:00
|
|
|
func checkForConflicts(aur []*rpc.Pkg, aurMake []*rpc.Pkg, repo []*alpm.Package,
|
|
|
|
repoMake []*alpm.Package) error {
|
|
|
|
|
|
|
|
localDb, err := alpmHandle.LocalDb()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
var toRemove []string
|
|
|
|
|
|
|
|
for _, pkg := range aur {
|
|
|
|
for _, cpkg := range pkg.Conflicts {
|
|
|
|
if _, err := localDb.PkgByName(cpkg); err == nil {
|
|
|
|
toRemove = append(toRemove, cpkg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range aurMake {
|
|
|
|
for _, cpkg := range pkg.Conflicts {
|
|
|
|
if _, err := localDb.PkgByName(cpkg); err == nil {
|
|
|
|
toRemove = append(toRemove, cpkg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range repo {
|
|
|
|
pkg.Conflicts().ForEach(func(conf alpm.Depend) error {
|
|
|
|
if _, err := localDb.PkgByName(conf.Name); err == nil {
|
|
|
|
toRemove = append(toRemove, conf.Name)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pkg := range repoMake {
|
|
|
|
pkg.Conflicts().ForEach(func(conf alpm.Depend) error {
|
|
|
|
if _, err := localDb.PkgByName(conf.Name); err == nil {
|
|
|
|
toRemove = append(toRemove, conf.Name)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(toRemove) != 0 {
|
|
|
|
fmt.Println(
|
|
|
|
redFg("The following packages conflict with packages to install:"))
|
|
|
|
for _, pkg := range toRemove {
|
|
|
|
fmt.Println(yellowFg(pkg))
|
|
|
|
}
|
|
|
|
|
|
|
|
if !continueTask("Remove conflicting package(s)?", "nN") {
|
|
|
|
return fmt.Errorf("Aborting due to user")
|
|
|
|
}
|
|
|
|
|
|
|
|
removeArguments := makeArguments()
|
|
|
|
removeArguments.addArg("R", "d", "d")
|
|
|
|
|
|
|
|
for _, pkg := range toRemove {
|
|
|
|
removeArguments.addTarget(pkg)
|
|
|
|
}
|
|
|
|
|
|
|
|
oldValue := config.NoConfirm
|
|
|
|
config.NoConfirm = true
|
|
|
|
passToPacman(removeArguments)
|
|
|
|
config.NoConfirm = oldValue
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
func askEditPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) (error) {
|
2018-01-17 22:48:23 +01:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-01-20 23:37:10 +01:00
|
|
|
|
2018-02-15 22:23:34 +01: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 22:48:23 +01:00
|
|
|
editcmd := exec.Command(editor(), dir+"PKGBUILD")
|
|
|
|
editcmd.Stdin, editcmd.Stdout, editcmd.Stderr = os.Stdin, os.Stdout, os.Stderr
|
|
|
|
editcmd.Run()
|
2018-02-15 20:43:16 +01:00
|
|
|
}
|
2018-02-15 07:17:27 +01:00
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-02-15 07:17:27 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-02-15 20:43:16 +01:00
|
|
|
|
|
|
|
func parsesrcinfos(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD) (error) {
|
|
|
|
|
2018-02-15 07:17:27 +01:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-02-15 20:43:16 +01:00
|
|
|
|
|
|
|
cmd := exec.Command(config.MakepkgBin, "--printsrcinfo")
|
|
|
|
cmd.Stderr = os.Stderr
|
|
|
|
cmd.Dir = dir
|
|
|
|
srcinfo, err := cmd.Output()
|
2018-02-15 06:36:42 +01:00
|
|
|
|
2018-02-15 20:43:16 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
pkgbuild, err := gopkg.ParseSRCINFOContent(srcinfo)
|
2018-01-17 22:48:23 +01:00
|
|
|
if err == nil {
|
2018-02-15 20:43:16 +01:00
|
|
|
srcinfos[pkg.PackageBase] = pkgbuild
|
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
for _, pkgsource := range pkgbuild.Source {
|
|
|
|
owner, repo := parseSource(pkgsource)
|
|
|
|
if owner != "" && repo != "" {
|
|
|
|
err = branchInfo(pkg.Name, owner, repo)
|
|
|
|
if err != nil {
|
2018-02-15 07:17:27 +01:00
|
|
|
return err
|
2018-01-17 22:48:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
2018-02-15 06:36:42 +01:00
|
|
|
|
|
|
|
return nil
|
2018-01-17 22:48:23 +01:00
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
func dowloadPkgBuilds(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg) (err error) {
|
2018-01-17 22:48:23 +01:00
|
|
|
for _, pkg := range pkgs {
|
|
|
|
//todo make pretty
|
2018-02-15 22:23:34 +01:00
|
|
|
str := "Downloading: " + pkg.PackageBase+"-"+pkg.Version
|
|
|
|
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] + ")"
|
|
|
|
}
|
|
|
|
fmt.Println(str)
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2018-01-20 23:37:10 +01:00
|
|
|
err = downloadAndUnpack(baseURL+pkg.URLPath, config.BuildDir, false)
|
|
|
|
if err != nil {
|
2018-01-17 22:48:23 +01:00
|
|
|
return
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func downloadPkgBuildsSources(pkgs []*rpc.Pkg) (err error) {
|
|
|
|
for _, pkg := range pkgs {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
2018-02-15 08:25:20 +01:00
|
|
|
err = passToMakepkg(dir, "--nobuild", "--nocheck", "--noprepare", "--nodeps")
|
2018-01-17 22:48:23 +01:00
|
|
|
if err != nil {
|
|
|
|
return
|
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-02-15 22:23:34 +01:00
|
|
|
func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, targets stringSet, parser *arguments, bases map[string][]*rpc.Pkg) (error) {
|
2018-01-17 22:48:23 +01:00
|
|
|
//for n := len(pkgs) -1 ; n > 0; n-- {
|
|
|
|
for n := 0; n < len(pkgs); n++ {
|
|
|
|
pkg := pkgs[n]
|
2018-02-15 22:23:34 +01:00
|
|
|
|
2018-01-17 22:48:23 +01:00
|
|
|
dir := 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]
|
|
|
|
version := srcinfo.CompleteVersion()
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
for _, split:= range bases[pkg.PackageBase] {
|
|
|
|
file, err := completeFileName(dir, split.Name + "-" + version.String())
|
2018-02-15 20:43:16 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
if file == "" {
|
|
|
|
built = false
|
2018-02-15 20:43:16 +01:00
|
|
|
}
|
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 {
|
|
|
|
fmt.Println(boldRedFgBlackBg(arrow+" Warning:"),
|
|
|
|
blackBg(pkg.Name+"-"+pkg.Version+ " Already made -- skipping build"))
|
|
|
|
} else {
|
|
|
|
err := passToMakepkg(dir, "-Cscf", "--noconfirm")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
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()
|
|
|
|
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 22:23:34 +01:00
|
|
|
depArguments := makeArguments()
|
|
|
|
depArguments.addArg("D", "asdeps")
|
2018-02-15 20:43:16 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
for _, split := range bases[pkg.PackageBase] {
|
|
|
|
file, err := completeFileName(dir, split.Name + "-" + version.String())
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-02-15 20:43:16 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
if file == "" {
|
|
|
|
return fmt.Errorf("Could not find built package " + split.Name + "-" + version.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
arguments.addTarget(file)
|
|
|
|
if !targets.get(split.Name) {
|
|
|
|
depArguments.addTarget(split.Name)
|
|
|
|
}
|
|
|
|
}
|
2018-02-15 20:43:16 +01:00
|
|
|
|
2018-02-15 22:23:34 +01:00
|
|
|
oldConfirm := config.NoConfirm
|
|
|
|
config.NoConfirm = true
|
|
|
|
err := passToPacman(arguments)
|
|
|
|
if err != nil {
|
2018-02-15 20:43:16 +01:00
|
|
|
return err
|
2017-08-02 19:24:03 +02:00
|
|
|
}
|
2018-02-15 22:23:34 +01:00
|
|
|
if len(depArguments.targets) > 0 {
|
|
|
|
err = passToPacman(depArguments)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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 {
|
|
|
|
dir := config.BuildDir + pkg.PackageBase + "/"
|
|
|
|
|
|
|
|
fmt.Println(boldGreenFg(arrow +
|
|
|
|
" CleanAfter enabled. Deleting " + pkg.Name +" source folder."))
|
|
|
|
os.RemoveAll(dir)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-15 20:43:16 +01:00
|
|
|
func completeFileName(dir, name string) (string, error) {
|
|
|
|
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 19:24:03 +02:00
|
|
|
}
|