tags 179850 + patch
tags 292169 + patch
tags 291565 + patch
thanks

Dear Julien,

I have made a primary attempt to fix this bug, with the attached
patch. It solves the following two problems:

1. If one gives the name of a source package to apt-build install, it
works with the default source version it finds.

2. For packages such as pine (in non-free), there exist source
packages but no binaries. This also handles that (seemingly) corner
case.

Disclaimer:
- The workaround is not efficient, as it calls another round
of apt-cache.
- I don't know Perl. I copied stuff from your code elsewhere, and read
up minimal things to get things rolling.

I hope you are able to use the patch to fix these bugs. If you need me
to do something more, please tell me (anything except learning Perl! ;-)).

Thanks.

Kumar
-- 
Kumar Appaiah
From 19c8f9d94ee5a2613e83d0de183589b3932f0a6c Mon Sep 17 00:00:00 2001
From: Kumar Appaiah <[EMAIL PROTECTED]>
Date: Thu, 23 Oct 2008 23:34:03 -0500
Subject: [PATCH] Fall back to default source package version if binary unavailable.

In case a version of a binary package is not available, this commit makes apt-build fall back to the default version of the source package with the same name. This is useful in the following cases:

- When apt-build is called with the name of a source package.

- When apt-build is called on a package which has a source, but no
  binary (for example, pine has its source in non-free, but no binary
  for any architecture, as I write this).

This commit is a basic attempt to fix bugs #179850, #291565
and #292169 on the Debian BTS.
---
 apt-build |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/apt-build b/apt-build
index 7a4871b..74fde9f 100755
--- a/apt-build
+++ b/apt-build
@@ -447,6 +447,26 @@ sub get_pkg_version
     }
     close(APTCIN);
 
+    if ($pkg_version && $pkg_version !~ m/\(none\)/) {
+	return $pkg_version;
+    }
+
+    # In case we fail to find a valid candidate, which may happen if,
+    # for example, the package has no binary version but a source
+    # version, we fall back to the source version in order to avoid
+    # dying.
+    open APTCIN, "LANGUAGE=C " . $conf->apt_cache . " showsrc $pkg_name |";
+    while(<APTCIN>)
+    {
+        $pkg_version = $1 if(/^Version: (.*)$/ and $release eq "" );
+        if( $release )
+        {
+            last if ( /$release/ ); ## quit from while,but keep the version from the row before
+            $pkg_version = $2 if( /^\s(\*\*\*)?\s+(.*) \d/ );
+        }
+    }
+    close(APTCIN);
+    print $pkg_version;
     return $pkg_version;
 }
 
-- 
1.5.6.5

Attachment: signature.asc
Description: Digital signature

Reply via email to