<?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>3214</bug_id>
          
          <creation_ts>2012-10-03 14:04:18 +0000</creation_ts>
          <short_desc>Emit helpful message when SRC_URI=&quot;http://&quot; is used with &quot;protocol=git&quot;</short_desc>
          <delta_ts>2012-10-04 17:27:20 +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>BitBake</product>
          <component>bitbake</component>
          <version>1.3</version>
          <rep_platform>x86</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>Undecided</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Evadeflow">evadeflow</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>bluelightning</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</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>26137</commentid>
    <comment_count>0</comment_count>
    <who name="Evadeflow">evadeflow</who>
    <bug_when>2012-10-03 14:04:18 +0000</bug_when>
    <thetext>For the motivation for this ticket, see the following mailing list
message:

  http://lists.yoctoproject.org/pipermail/yocto/2012-October/012022.html

Basically, SRC_URI&apos;s like the following:

&gt; SRC_URI = &quot;http://dev.omapzoom.org/pub/scm/integration/kernel ubuntu.git;protocol=git;branch=ti-ubuntu-3.1-1282 \
&gt;            file://0001-Makefile.fwinst-fix-install-breakage-for-FW-images-r.patch \
&gt;            file://defconfig \

do not work, and they&apos;re not supposed to work. Whenever the source is a
git repository, SRC_URI should start with &apos;git://&apos;; if git over http is
desired, this should be specified by including &quot;protocol=http&quot; in the
SRC_URI string.  However, new users of bitbake who are familiar with git
are extremely likely to make the mistake of specifying git SRC_URI&apos;s
that begin with &apos;http://&apos;, because this is how it&apos;s done on the git
command line.

When a user mistakenly enters a SRC_URI that points at a git repository,
but begins with &apos;http://&apos;, the error generated seems pretty mysterious:


&gt; ERROR: Command Error: exit status: 1  Output:
&gt; Applying patch 0001-Makefile.fwinst-fix-install-breakage-for-FW-images-r.patch
&gt; patching file scripts/Makefile.fwinst
&gt; Hunk #1 FAILED at 27.
&gt; 1 out of 1 hunk FAILED -- rejects in file scripts/Makefile.fwinst
&gt; Patch 0001-Makefile.fwinst-fix-install-breakage-for-FW-images-r.patch does not apply (enforce with -f)
&gt; ERROR: Function failed: patch_do_patch


Huh? It would be nice if bitbake would:

1) Exit with an error if SRC_URI contains &quot;protocol=git&quot;, but starts
   with &quot;http://&quot;, since this (apparently) does not work under any
   circumstances and is clearly incorrect

2) Exit with an error if:
   1. SRC_URI begins with &quot;http://&quot;
   2. The pointed-to URL ends in &quot;.git&quot;
      (e.g. &quot;http://github.com/foo/project.git&quot;), and
   3. SRC_URI Does NOT contain &quot;protocol=http&quot;

3) Issue a warning if SRC_URI begins with &quot;http://&quot; and
   &quot;protocol=&lt;whatever&gt;&quot; or &quot;branch=&lt;whatever&gt;&quot; are specified
   [OPTIONAL]


The rationale for the last two items is that not all git repositories
end in &quot;.git&quot;; this is merely a common convention. It&apos;s possible (though
VERY unlikely) that someone might want to download a URI that ends in
&apos;.git&apos; via http. If this is REALLY what they want, they should
(redundantly) specify &quot;protocol=http&quot; to indicate this.

If someone specifies a SRC_URI like:

&gt; SRC_URI = &quot;http://foo.bar.com/pub/myrepo;protocol=http;branch=mybranch&quot;


it&apos;s pretty clear that they don&apos;t intend to download via http. Even if
they only say:

&gt; SRC_URI = &quot;http://foo.bar.com/pub/myrepo;protocol=http&quot;

it seems like a red flag that &quot;protocol=http&quot; is (redundantly)
specified, so a warning seems advisable, in case the user actually
intended to point at a git or svn repo.

Maybe what I&apos;ve suggested above isn&apos;t ideal, but it definitely seems
like error-handling for malformed git SRC_URI&apos;s could be tightened up a
bit...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26141</commentid>
    <comment_count>1</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2012-10-03 14:47:14 +0000</bug_when>
    <thetext>I&apos;ve already submitted a patch to raise an error explicitly with advice if protocol=git is detected with http:// or https:// URIs (your #1 above); it catches the most common mistake. I&apos;m not convinced we can really apply the check in #2 as this is still a valid URI. #3 might be useful perhaps but that&apos;s probably something to fix in the next release.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26146</commentid>
    <comment_count>2</comment_count>
    <who name="Evadeflow">evadeflow</who>
    <bug_when>2012-10-03 15:40:06 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; I&apos;ve already submitted a patch to raise an error explicitly with advice if
&gt; protocol=git is detected with http:// or https:// URIs (your #1 above); it
&gt; catches the most common mistake. I&apos;m not convinced we can really apply the
&gt; check in #2 as this is still a valid URI. #3 might be useful perhaps but
&gt; that&apos;s probably something to fix in the next release.

Is it mandatory for SRC_URIs starting with &quot;git://&quot; to also contain
&quot;protocol=XXX&quot;?  I had the impression that this was optional, and that
bitbake would default to &quot;protocol=git&quot; if omitted[?] If this is the
case, then the check for #1 won&apos;t help users who try to change:

&gt; SRC_URI = &quot;git://github.com/zeromq/pyzmq.git;...&quot; [protocol unspecified]

to:

&gt; SRC_URI = &quot;http://github.com/zeromq/pyzmq.git;...&quot; [protocol unspecified]

thinking that this will work just like git works. A gentle
nudge towards the right syntax will, I think, be very much appreciated
by new users.  If &quot;protocol=&quot; is NOT optional when SRC_URI starts with
&quot;git://&quot;, then I agree that #1 takes care of just about every posible
case, and the rest of this comment probably doesn&apos;t apply. (I assume
that making it mandatory--if it currently is not--would break a lot of
recipes.)

Regarding #2, if someone puts:

&gt; SRC_URI = &quot;http://github.com/zeromq/pyzmq.git;...&quot;

in a recipe, you can be 99% certain he actually meant to type:

&gt; SRC_URI = &quot;git://github.com/zeromq/pyzmq.git;...&quot;

or possibly:

&gt; SRC_URI = &quot;git://github.com/zeromq/pyzmq.git;protocol=http;...&quot;


I think it&apos;s reasonable to force them to type this instead:

&gt; SRC_URI = &quot;http://github.com/zeromq/pyzmq.git;protocol=http&quot;

if they REALLY want to download the HTML source of a web page.  The
&apos;protocol=http&apos; would normally be redundant, but the fact that the URL
ends in &apos;.git&apos; is a big enough red flag that making it mandatory in this
case--and throwing a fatal error if it&apos;s omitted--seems warranted.

Granted, it feels slightly &apos;odd&apos; when combined with #3, where a warning
is issued if &quot;protocol=http&quot; is given where it normally isn&apos;t needed.
Slap users on the wrist for supplying &apos;http=&apos; in one case, then slap
them for *not* supplying it in another? It&apos;s... subtle. But the whole
business of having git-over-http SRC_URIs start with &quot;git://&quot; is equally
subtle. The SRC_URI syntax is immediately familiar to users, but it&apos;s
misleading in the case of git-over-http. It&apos;s a kind of &apos;false friend&apos;,
so I think it&apos;s reasonable for bitbake to work extra hard to protect
users from misuse of this variable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26149</commentid>
    <comment_count>3</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2012-10-03 15:51:50 +0000</bug_when>
    <thetext>protocol= is optional for the git fetcher, so in principle I agree it is possible for a user to change git:// to http:// where protocol= is not specified and therefore not get any kind of warning or error. Unfortunately though whilst it is most likely that .git at the end signifies a git repository, it doesn&apos;t guarantee it; and as you point out, .git is often not there in valid git repository URLs at all.

For the wget fetcher (which is responsible for handling http://, https:// and ftp://, protocol= is not used at all, and I would be loath to introduce it just for the sake of preventing a warning that is only somewhat effective.

We&apos;ve introduced an explicit check and error for http:// + protocol=git which is the most common case of this that I have observed based on questions on the mailing list over the years, and in that case it is almost guaranteed that the user meant git:// + protocol=http. All other cases are less clear and much more difficult to handle practically.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26156</commentid>
    <comment_count>4</comment_count>
    <who name="Evadeflow">evadeflow</who>
    <bug_when>2012-10-03 16:08:30 +0000</bug_when>
    <thetext>Maybe there&apos;s some other way to address the &apos;quality&apos; of the error message, then? This is what I see if I change &quot;git://&quot; to &quot;http://&quot; and &quot;protocol=&quot; is omitted:

&gt; ERROR: Command Error: exit status: 1  Output:
&gt; Applying patch 0001-Makefile.fwinst-fix-install-breakage-for-FW-images-r.patch
&gt; patching file scripts/Makefile.fwinst
&gt; Hunk #1 FAILED at 27.
&gt; 1 out of 1 hunk FAILED -- rejects in file scripts/Makefile.fwinst
&gt; Patch 0001-Makefile.fwinst-fix-install-breakage-for-FW-images-r.patch does not apply (enforce with -f)
&gt; ERROR: Function failed: patch_do_patch

It just seems a little &apos;rude&apos;. Is there some other way to make bitbake say the equivalent of: &quot;That source tree you thought you were downloading? I can&apos;t find it, so... not only did the patch fail to apply, but.. there&apos;s nothing *to* patch!&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26160</commentid>
    <comment_count>5</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2012-10-03 16:17:15 +0000</bug_when>
    <thetext>The thing is as I mentioned in the other bug report, this is a failure at do_patch. The fetch itself must have actually succeeded - the remote server just sent an html page with no error. There&apos;s no intrinsic way we can determine here that the result has not matched up with the user&apos;s intent, in the absence of protocol=git and branch= of course.

As far as the error message within do_patch is concerned, we&apos;re just repeating what the &quot;patch&quot; utility outputs; I&apos;m not sure if there&apos;s a lot that can be done at our level about that if it&apos;s not satisfactory.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26166</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2012-10-03 16:38:26 +0000</bug_when>
    <thetext>Fixed in master: http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=0e6cc44a111ff3189011d503217223745055a643</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26254</commentid>
    <comment_count>7</comment_count>
    <who name="Evadeflow">evadeflow</who>
    <bug_when>2012-10-04 17:25:06 +0000</bug_when>
    <thetext>Issue #5
--------
With my local.conf mods set this way:

&gt; MACHINE = &quot;qemux86&quot;
&gt; CONNECTIVITY_CHECK_URIS=&quot;&quot;
&gt; BB_GENERATE_MIRROR_TARBALLS = &quot;1&quot; 
&gt; BB_FETCH_PREMIRRORONLY = &quot;1&quot;
&gt; PREMIRRORS_prepend = &quot;\
&gt;      git://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
&gt;      ftp://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
&gt;      http://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
&gt;      https://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n \
&gt;      svn://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \n&quot;
&gt; SOURCE_MIRROR_URL ?= &quot;file:///home/evadeflow/projects/poky-mirror/&quot;
&gt; INHERIT += &quot;own-mirrors&quot;

when I execute:

&gt; bitbake -c fetchall universe

the following packages are compiled:

&gt; NOTE: package quilt-native-0.51-r1: task do_compile: Started
&gt; NOTE: package gettext-minimal-native-0.18.1.1-r3: task do_compile: Started
&gt; NOTE: package gnu-config-native-20111111-r1: task do_compile: Started
&gt; NOTE: package m4-native-1.4.16-r2: task do_compile: Started
&gt; NOTE: package autoconf-native-2.68-r7: task do_compile: Started
&gt; NOTE: package automake-native-1.11.2-r3: task do_compile: Started
&gt; NOTE: package libtool-native-2.4.2-r3.0: task do_compile: Started
&gt; NOTE: package pkgconfig-native-0.25-r3: task do_compile: Started
&gt; NOTE: package sqlite3-native-3.7.10-r2: task do_compile: Started
&gt; NOTE: package tar-replacement-native-1.26-r1: task do_compile: Started
&gt; NOTE: package pseudo-native-1.3-r10: task do_compile: Started
&gt; NOTE: package ocf-linux-native-20100325-r3.0: task do_compile: Started
&gt; NOTE: package zlib-native-1.2.6-r1: task do_compile: Started
&gt; NOTE: package pigz-native-2.2.4-r2: task do_compile: Started
&gt; NOTE: package openssl-native-1.0.0i-r0.2: task do_compile: Started
&gt; NOTE: package expat-native-2.0.1-r1: task do_compile: Started
&gt; NOTE: package perl-native-5.14.2-r0: task do_compile: Started
&gt; NOTE: package curl-native-7.24.0-r2: task do_compile: Started
&gt; NOTE: package git-native-1.7.7-r2: task do_compile: Started

This is &apos;expected behavior&apos;, as far as I can tell, I&apos;m merely documenting
precisely what gets built on my machine to support the notion that it may be
worthwhile to pursue adding a &apos;create-mirror&apos; command that does not build
anything.

Honestly, this is less of a problem for me now that I understand that the
default HTTP premirror(s) can be used as a kind of &apos;back door&apos; to save my
builds from aborting when run from behind a firewall with missing
dependencies. The whole key for me has been realizing:

1. I need to export http_proxy=http://user:passwd@myproxy.com:8080

2. I have to add a PREMIRRORS_prepend line to explicitly steer bitbake
   to my desired fallback mirror(s)

(#2 may actually be required due to a bug that has been fixed on master[??])

The thing I&apos;m (still) worried about is what happens when I build using layers
that aren&apos;t part of Yocto proper, such as meta-ivi and meta-ti. I&apos;m assuming
these contain recipes pointing at sources that are not part of the Yocto HTTP
mirror.  If this is the case, I still find myself wishing for a way to quickly
download all the required dependencies. I suppose this could be sufficient:

&gt; bitbake -c fetchall some-image-name

I&apos;ll try to build core-image-sato for my Pandaboard ES this way, using
meta-ti, and see what happens...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26255</commentid>
    <comment_count>8</comment_count>
    <who name="Evadeflow">evadeflow</who>
    <bug_when>2012-10-04 17:27:20 +0000</bug_when>
    <thetext>(In reply to comment #7)

Sorry, mis-posted this to the wrong issue, please ignore...</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>