<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>81</bug_id>
          
          <creation_ts>2010-02-12 19:47:52 +0000</creation_ts>
          <short_desc>SRC_URI with http or ftp path having &quot;/download&quot; at end fails to retrieve source</short_desc>
          <delta_ts>2010-12-21 06:07:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>Meta-yocto</product>
          <component>meta-yocto</component>
          <version>0.9</version>
          <rep_platform>All</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>0.9 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Levant Tinaz">levant.tinaz</reporter>
          <assigned_to name="Joshua Lock - Disabled">josh</assigned_to>
          <cc>levant.tinaz</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>---</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>7981</commentid>
    <comment_count>0</comment_count>
    <who name="Levant Tinaz">levant.tinaz</who>
    <bug_when>2010-02-12 19:47:52 +0000</bug_when>
    <thetext>I had in a recipe (.bb) file the following:

SRC_URI = &quot;http://sourceforge.net/projects/cunit/files/CUnit/2.1-0/CUnit-${PV}-src.tar.gz/download&quot;

which did correctly retrieve the .gz file into sources/CUnit-2.1-0-src.tar.gz
but the fetch failed after trying all default mirrors. The md5 checksum file
sources/CUnit-2.1-0-src.tar.gz.md5 wasn&apos;t created either as the fetch failed.
There are download sites that have such URLs.

I fixed this bug with the addition of the lines marked with &quot;&gt;&quot; below in the file bitbake/lib/bb/fetch/wget.py:

    def localpath(self, url, ud, d):
        url = bb.encodeurl([ud.type, ud.host, ud.path, ud.user, ud.pswd, {}])
&gt;       # Handle the special case of download URLs like
&gt;       # http://&lt;path&gt;/&lt;file&gt;/download
&gt;       # Most download URLs are like http://path/file
&gt;       if os.path.basename(url) == &quot;download&quot;:
&gt;          ud.basename = os.path.basename(os.path.dirname(ud.path))
        ud.localfile = data.expand(ud.basename, d)

        return os.path.join(data.getVar(&quot;DL_DIR&quot;, d, True), ud.localfile)

Our Poky/bitbake source appears to be version 1.8.13.

Levant Tinaz</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>7999</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2010-02-15 17:38:27 +0000</bug_when>
    <thetext>Hardcoding behaviour like that is not acceptable, its not generic. 

Have you tried a url like:

http://sourceforge.net/projects/cunit/files/CUnit/2.1-0/CUnit-${PV}-src.tar.gz/download;localpath=${DL_DIR}/CUnit-${PV}-src.tar.gz

?

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>8000</commentid>
    <comment_count>2</comment_count>
    <who name="Levant Tinaz">levant.tinaz</who>
    <bug_when>2010-02-16 13:39:06 +0000</bug_when>
    <thetext>Yes, I&apos;ve tried &quot;download=&quot; as you suggest. That downloads to the correct location with the correct file name but then I get this error:

NOTE: package cunit-2.1-0: started
NOTE: package cunit-2.1-0-r0: task do_fetch: started
NOTE: fetch http://sourceforge.net/projects/cunit/files/CUnit/2.1-0/CUnit-2.1-0-src.tar.gz/download
NOTE: localpath=/home/levant/src/PreOlive/Poky/sources/cunit-2.1-0-src.tar.gz
NOTE: Task failed: Unknown fetch Error: &apos;FetchData&apos; object has no attribute &apos;basename&apos;
NOTE: package cunit-2.1-0-r0: task do_fetch: failed
ERROR: TaskFailed event exception, aborting
NOTE: package cunit-2.1-0: failed

which is due to ud.localpath being set explicitly in the SRC_URI so the localpath method is not called to set ud.localpath which is where basename is set to the download file name. Any SRC_URI that has &quot;localpath=&quot; option will generate this error due to that reason. I can fix that by adding the following: 

        def fetch_uri(uri, ud, d):
        .
        .
            if ud.localpath == &quot;&quot;:
                fetchcmd = fetchcmd.replace(&quot;${FILE}&quot;, ud.basename)

Then my download works just fine but now the bug to be fixed is as noted above so this bug report Summary should be changed to &quot;SRC_URI with localpath= doesn&apos;t work&quot;.

Levant Tinaz

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9605</commentid>
    <comment_count>3</comment_count>
    <who name="Joshua Lock - Disabled">josh</who>
    <bug_when>2010-09-06 06:33:20 +0000</bug_when>
    <thetext>I have fixed this issue in commit b78d5368ccd333587ec475be3f3fe058ec9045f2:

fetch: fix setting of localpath in SRC_URI parameters

When setting localpath in the SRC_URI parameters the basename should be set
explicitly as the localpath() method is not called.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>