From 6a5b791d8eae388c94f3d5a7c32cf0ce21e78c3c Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.dos.anjos@gmail.com>
Date: Fri, 18 Oct 2019 16:53:29 +0200
Subject: [PATCH] [build] exists_on_channel() now checks for a matching package
 type

---
 bob/devtools/build.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/bob/devtools/build.py b/bob/devtools/build.py
index 5f3b673c..2486af22 100644
--- a/bob/devtools/build.py
+++ b/bob/devtools/build.py
@@ -65,8 +65,8 @@ def should_skip_build(metadata_tuples):
 def next_build_number(channel_url, basename):
     """Calculates the next build number of a package given the channel.
 
-    This function returns the next build number (integer) for a package given its
-    resulting tarball base filename (can be obtained with
+    This function returns the next build number (integer) for a package given
+    its resulting tarball base filename (can be obtained with
     :py:func:`get_output_path`).
 
 
@@ -212,7 +212,8 @@ def get_parsed_recipe(metadata):
 def exists_on_channel(channel_url, basename):
     """Checks on the given channel if a package with the specs exist.
 
-    This procedure always ignores the package hash code, if one is set
+    This procedure always ignores the package hash code, if one is set.  It
+    differentiates between `.conda` and `.tar.bz2` packages.
 
     Args:
 
@@ -230,10 +231,10 @@ def exists_on_channel(channel_url, basename):
 
         # remove .tar.bz2/.conda from name, then split from the end twice, on
         # '-'
-        if name.endswith('.tar.bz2'):
-            name, version, build = name[:-8].rsplit("-", 2)
-        elif name.endswith('.conda'):
+        if name.endswith('.conda'):
             name, version, build = name[:-6].rsplit("-", 2)
+        elif name.endswith('.tar.bz2'):
+            name, version, build = name[:-8].rsplit("-", 2)
         else:
             raise RuntimeError("Package name %s does not end in either " \
                     ".tar.bz2 or .conda" % (name,))
@@ -252,9 +253,10 @@ def exists_on_channel(channel_url, basename):
     other_build_numbers = [_get_build_number(os.path.basename(k)) for k in urls]
 
     if self_build_number in other_build_numbers:
-        return "".join(
-            (channel_url, urls[other_build_numbers.index(self_build_number)])
-        )
+        candidate = urls[other_build_numbers.index(self_build_number)]
+        pkg_type = '.conda' if basename.endswidth('.conda') else '.tar.bz2'
+        if candidate.endswith(pkg_type):  #match
+            return "".join(channel_url, candidate)
 
 
 def remove_pins(deps):
-- 
GitLab