Skip to contentSkip to conversation

fetch: Extend testing of subdir unpack parameter and fix

PATCH New Richard Purdie 1 participant 1 message Sep 24, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch: Extend testing of subdir unpack parameter and fix

This fixes urls of the form file://some/path/file;subdir=b. It also adds in a couple of tests so we now tests these corner cases.

bitbake/lib/bb/fetch2/__init__.py +2 -0
index 66f0e36..2e147ec 100644
@@ -1264,6 +1264,8 @@ class FetchMethod(object):
                     # items.  So, only do so for file:// entries.
                     if urldata.type == "file" and urldata.path.find("/") != -1:
                        destdir = urldata.path.rsplit("/", 1)[0]
+                       if urldata.parm.get('subdir') != None:
+                          destdir = urldata.parm.get('subdir') + "/" + destdir
                     else:
                        if urldata.parm.get('subdir') != None:
                           destdir = urldata.parm.get('subdir')
bitbake/lib/bb/tests/fetch.py +7 -0
index 0476541..8db7575 100644
@@ -445,6 +445,13 @@ class FetcherLocalTest(FetcherTest):
         tree = self.fetchUnpack(['file://dir/subdir/e'])
         self.assertEqual(tree, ['dir/subdir/e'])
 
+    def test_local_subdirparam(self):
+        tree = self.fetchUnpack(['file://a;subdir=bar'])
+        self.assertEqual(tree, ['bar/a'])
+
+    def test_local_deepsubdirparam(self):
+        tree = self.fetchUnpack(['file://dir/subdir/e;subdir=bar'])
+        self.assertEqual(tree, ['bar/dir/subdir/e'])
 
 class FetcherNetworkTest(FetcherTest):