Merge pull request #192 from Morganamilo/fixdeps

Correctly mark packages as dependencies
This commit is contained in:
J Guerreiro 2018-03-01 09:45:58 +00:00 committed by GitHub
commit 2c2cb22d6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 9 deletions

33
cmd.go
View file

@ -2,6 +2,7 @@ package main
import (
"bufio"
"bytes"
"encoding/json"
"errors"
"fmt"
@ -692,6 +693,38 @@ func passToPacman(args *arguments) error {
return err
}
//passToPacman but return the output instead of showing the user
func passToPacmanCapture(args *arguments) (string, string, error) {
var outbuf, errbuf bytes.Buffer
var cmd *exec.Cmd
argArr := make([]string, 0)
if args.needRoot() {
argArr = append(argArr, "sudo")
}
argArr = append(argArr, config.PacmanBin)
argArr = append(argArr, cmdArgs.formatGlobals()...)
argArr = append(argArr, args.formatArgs()...)
if config.NoConfirm {
argArr = append(argArr, "--noconfirm")
}
argArr = append(argArr, "--")
argArr = append(argArr, args.formatTargets()...)
cmd = exec.Command(argArr[0], argArr[1:]...)
cmd.Stdout = &outbuf
cmd.Stderr = &errbuf
err := cmd.Run()
stdout := outbuf.String()
stderr := errbuf.String()
return stdout, stderr, err
}
// passToMakepkg outsources execution to makepkg binary without modifications.
func passToMakepkg(dir string, args ...string) (err error) {

View file

@ -16,7 +16,7 @@ import (
// Install handles package installs
func install(parser *arguments) error {
removeMake := false
aur, repo, err := packageSlices(parser.targets.toSlice())
aurTargets, repoTargets, err := packageSlices(parser.targets.toSlice())
if err != nil {
return err
}
@ -25,7 +25,7 @@ func install(parser *arguments) error {
var dc *depCatagories
//fmt.Println(greenFg(arrow), greenFg("Resolving Dependencies"))
requestTargets := append(aur, repo...)
requestTargets := append(aurTargets, repoTargets...)
//remotenames: names of all non repo packages on the system
_, _, _, remoteNames, err := filterPackages()
@ -45,7 +45,7 @@ func install(parser *arguments) error {
requestTargets = append(requestTargets, remoteNames...)
}
if len(aur) > 0 || parser.existsArg("u", "sysupgrade") && len(remoteNames) > 0 {
if len(aurTargets) > 0 || parser.existsArg("u", "sysupgrade") && len(remoteNames) > 0 {
fmt.Println(boldCyanFg("::"), boldFg("Querying AUR..."))
}
dt, err := getDepTree(requestTargets)
@ -105,9 +105,9 @@ func install(parser *arguments) error {
arguments.addTarget(pkg.Name())
}
for _, pkg := range repo {
arguments.addTarget(pkg)
}
//for _, pkg := range repoTargets {
//arguments.addTarget(pkg)
//}
if len(dc.Aur) == 0 && len(arguments.targets) == 0 {
fmt.Println("There is nothing to do")
@ -124,6 +124,24 @@ func install(parser *arguments) error {
if err != nil {
return fmt.Errorf("Error installing repo packages.")
}
depArguments := makeArguments()
depArguments.addArg("D", "asdeps")
for _, pkg := range dc.Repo {
depArguments.addTarget(pkg.Name())
}
for _, pkg := range repoTargets {
depArguments.delTarget(pkg)
}
if len(depArguments.targets) > 0 {
_, stderr, err := passToPacmanCapture(depArguments)
if err != nil {
return fmt.Errorf("%s%s", stderr, err)
}
}
}
if hasAur {
@ -208,8 +226,12 @@ func install(parser *arguments) error {
oldValue := config.NoConfirm
config.NoConfirm = true
passToPacman(removeArguments)
err = passToPacman(removeArguments)
config.NoConfirm = oldValue
if err != nil {
return err
}
}
if config.CleanAfter {
@ -473,9 +495,9 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
updateVSCdb(bases[pkg.PackageBase], srcinfo)
if len(depArguments.targets) > 0 {
err = passToPacman(depArguments)
_, stderr, err := passToPacmanCapture(depArguments)
if err != nil {
return err
return fmt.Errorf("%s%s", stderr, err)
}
}
config.NoConfirm = oldConfirm