Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use wnpp-check to check for existing wnpp bugs #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions make.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bufio"
"errors"
"flag"
"fmt"
Expand Down Expand Up @@ -742,6 +743,44 @@ func copyFile(src, dest string) error {
return output.Close()
}

func isCommandAvailable(name string) bool {
cmd := exec.Command("which", name)
err := cmd.Run()
return err == nil
}

func checkWnppProceedPrompt() {
fmt.Fprint(os.Stderr, "Would you like to proceed? (Y/n): ")
r := bufio.NewReader(os.Stdin)
input, err := r.ReadString('\n')
if err != nil {
log.Fatalf("error occurred while reading input: %v\n", err)
}
switch strings.ToLower(strings.TrimSpace(input)) {
case "y", "yes":
fmt.Fprintf(os.Stderr, "Yes recieved, proceeding\n")
case "n", "no":
log.Fatalf("No recieved, exiting")
default:
fmt.Fprintf(os.Stderr, "Unknown response recieved\n")
checkWnppProceedPrompt()
}
}

func checkWnpp(name string) {
if isCommandAvailable("wnpp-check") {
cmd := exec.Command("wnpp-check", name)
cmd.Stderr = os.Stderr
out, err := cmd.Output()
if err != nil {
fmt.Fprintf(os.Stderr, "The following wnpp bug entries were found for \"%s\":\n%s", name, out)
checkWnppProceedPrompt()
}
} else {
fmt.Fprintf(os.Stderr, "Could not find wnpp-check, skipping\n")
}
}

func execMake(args []string, usage func()) {
fs := flag.NewFlagSet("make", flag.ExitOnError)
if usage != nil {
Expand Down Expand Up @@ -929,6 +968,9 @@ func execMake(args []string, usage func()) {
gopkg, strings.ToLower(gopkg))
}

// Check if wnpp bug exists (using wnpp-check from devscripts)
checkWnpp(debsrc)

var (
eg errgroup.Group
golangBinaries map[string]string // map[goImportPath]debianBinaryPackage
Expand Down
Loading