Thanks for the clarification. The attached patch seems to work for me. Does
it look good to you as well?

On Mon, Oct 19, 2015 at 7:56 AM, Johannes Schauer <[email protected]> wrote:

> Hi,
>
> Quoting Michael Stapelberg (2015-10-18 23:10:06)
> > I can’t figure out how to specify multiple binary packages when calling
> > dose-ceve. The manpage for -r says:
> >
> >        -r pkgspec
> >            Using the same syntax as in -c, this option use the reverse
> > dependency relation to make the transitive closure.
> >            This option can also be specified as --rcone=pkgspec.
> >
> > So the manpage for -c says:
> >
> >        -c pkgspec
> >            The match of an atomic dependency (a package name p possibly
> > together with a version constraint c) is the set of all packages in the
> > repository with name p, and a version that satisfies the constraint c.
> The
> > dependency cone of a package p is the set of all matches of all atomic
> > dependencies of p, together with their respective dependency cones.  The
> > package specification pkgspec is a list of packages (separated by a
> > semicolon), where each package is specified as follows: (name,version).
>
> Right, unfortunately it turns out that when we recently implemented the
> feature
> that the -c and -r option would take a string in the Debian dependency
> format
> when handling Debian packages, we forgot to document it :(
>
> > Now I tried specifying multiple binary packages, but couldn’t get any
> > combination to work:
> >
> > https://paste.debian.net/316796/ (so as to not make this email too long)
> >
> > So, I’m at a loss. What am I misunderstanding here? Can you please
> provide
> > an example invocation of how you think ratt should call dose-ceve in this
> > specific case?
>
> The following will work:
>
> dose-ceve --deb-native-arch=amd64 -T debsrc -r 'golang-golang-x-tools (=
> 1:0.0~git20150716.0.87156cb+dfsg1-4),golang-golang-x-tools-dev' -G pkg
> deb://Packages debsrc://Sources
>
> You can see that the format of the -r option is the same as in a Depends
> field.
>
> > Also, may I suggest the following improvements to dose-ceve:
> >
> > 1. When -r is specified multiple times, it should not overwrite the
> package
> > spec, but amend it. If you think -r should only be specified exactly
> once,
> > I suggest dose-ceve should error out when users specify multiple -r
> values.
> >
> > 2. The manpage ceve(1) should come with an example for pkgspec.
> >
> > 3. Instead of merely stating that the provided pkgspec is invalid,
> > dose-ceve should tell the user why the pkgspec is invalid, and ideally
> > include a valid example.
> >
> > (4. Possibly, the manpage ceve(1) should be worded a bit more clearly
> with
> > regards to pkgspec, but perhaps it’s just me…)
>
> No it's not just you and I agree with all your suggestions.
>
> To not forget about your valuable input, I submitted a bug to the upstream
> bugtracker:
>
>
> https://gforge.inria.fr/tracker/index.php?func=detail&aid=19616&group_id=4395&atid=13808
>
> Thanks!
>
> cheers, josch
>



-- 
Best regards,
Michael
From 20731fa3f65b04e4e030221f95d524baf83aa42d Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <[email protected]>
Date: Mon, 19 Oct 2015 09:02:23 +0200
Subject: [PATCH] Use dose-ceve(1) if available for determining
 revers-build-deps.

See http://bugs.debian.org/801593 for context.
---
 ratt.go | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 67 insertions(+), 2 deletions(-)

diff --git a/ratt.go b/ratt.go
index 6c0a25e..e5c6726 100644
--- a/ratt.go
+++ b/ratt.go
@@ -11,6 +11,7 @@ import (
 	"bufio"
 	"flag"
 	"fmt"
+	"io"
 	"log"
 	"os"
 	"os/exec"
@@ -108,6 +109,7 @@ func main() {
 	}
 
 	var sourcesPaths []string
+	var packagesPaths []string
 	indexTargets := exec.Command("apt-get",
 		"indextargets",
 		"--format",
@@ -121,6 +123,23 @@ func main() {
 				sourcesPaths = append(sourcesPaths, line)
 			}
 		}
+		binaryIndexTargets := exec.Command(
+			"apt-get",
+			"indextargets",
+			"--format",
+			"$(FILENAME)",
+			"Codename: sid",
+			"ShortDesc: Packages")
+		lines, err = binaryIndexTargets.Output()
+		if err != nil {
+			log.Fatal("Could not get packages files using %+v: %v", binaryIndexTargets.Args, err)
+		}
+		for _, line := range strings.Split(string(lines), "\n") {
+			trimmed := strings.TrimSpace(line)
+			if trimmed != "" {
+				packagesPaths = append(packagesPaths, line)
+			}
+		}
 	} else {
 		// Fallback for older versions of apt-get. See
 		// https://bugs.debian.org/801594 for context.
@@ -151,6 +170,11 @@ func main() {
 				log.Fatal(err)
 			}
 			sourcesPaths = append(sourcesPaths, sourceMatches...)
+			packagesMatches, err := filepath.Glob(fmt.Sprintf("/var/lib/apt/lists/%s_*_Packages", listsPrefix[1]))
+			if err != nil {
+				log.Fatal(err)
+			}
+			packagesPaths = append(packagesPaths, packagesMatches...)
 		}
 	}
 
@@ -160,9 +184,50 @@ func main() {
 
 	rebuild := make(map[string][]version.Version)
 
+	archCmd := exec.Command(
+		"dpkg-architecture",
+		"--query=DEB_BUILD_ARCH")
+	archOut, err := archCmd.Output()
+	if err != nil {
+		log.Fatal(err)
+	}
+	arch := strings.TrimSpace(string(archOut))
+
+	// TODO: Cache this output based on the .changes file. dose-ceve takes quite a while.
+	ceve := exec.Command(
+		"dose-ceve",
+		"--deb-native-arch="+arch,
+		"-T", "debsrc",
+		"-r", strings.Join(changes.Binaries, ","),
+		"-G", "pkg")
+	for _, packagesPath := range packagesPaths {
+		ceve.Args = append(ceve.Args, "deb://"+packagesPath)
+	}
 	for _, sourcesPath := range sourcesPaths {
-		if err := addReverseBuildDeps(sourcesPath, binaries, rebuild); err != nil {
-			log.Fatal(err)
+		ceve.Args = append(ceve.Args, "debsrc://"+sourcesPath)
+	}
+
+	log.Printf("Figuring out reverse build dependencies using dose-ceve(1). This might take a while\n")
+	if out, err := ceve.Output(); err == nil {
+		r := bufio.NewReader(strings.NewReader(string(out)))
+		for {
+			paragraph, err := control.ParseParagraph(r)
+			if paragraph == nil || err == io.EOF {
+				break
+			}
+			pkg := paragraph.Values["Package"]
+			ver, err := version.Parse(paragraph.Values["Version"])
+			if err != nil {
+				log.Fatalf("Cannot parse version number %q in dose-ceve(1) output: %v", paragraph.Values["Version"], err)
+			}
+			rebuild[pkg] = append(rebuild[pkg], ver)
+		}
+	} else {
+		log.Printf("dose-ceve(1) failed (%v), falling back to interpreting Sources directly\n", err)
+		for _, sourcesPath := range sourcesPaths {
+			if err := addReverseBuildDeps(sourcesPath, binaries, rebuild); err != nil {
+				log.Fatal(err)
+			}
 		}
 	}
 
-- 
2.1.4

_______________________________________________
Pkg-go-maintainers mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-go-maintainers

Reply via email to