bitbake-user-manual-fetching.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  3. <chapter>
  4. <title>File Download Support</title>
  5. <para>
  6. BitBake's fetch module is a standalone piece of library code
  7. that deals with the intricacies of downloading source code
  8. and files from remote systems.
  9. Fetching source code is one of the cornerstones of building software.
  10. As such, this module forms an important part of BitBake.
  11. </para>
  12. <para>
  13. The current fetch module is called "fetch2" and refers to the
  14. fact that it is the second major version of the API.
  15. The original version is obsolete and has been removed from the codebase.
  16. Thus, in all cases, "fetch" refers to "fetch2" in this
  17. manual.
  18. </para>
  19. <section id='the-download-fetch'>
  20. <title>The Download (Fetch)</title>
  21. <para>
  22. BitBake takes several steps when fetching source code or files.
  23. The fetcher codebase deals with two distinct processes in order:
  24. obtaining the files from somewhere (cached or otherwise)
  25. and then unpacking those files into a specific location and
  26. perhaps in a specific way.
  27. Getting and unpacking the files is often optionally followed
  28. by patching.
  29. Patching, however, is not covered by this module.
  30. </para>
  31. <para>
  32. The code to execute the first part of this process, a fetch,
  33. looks something like the following:
  34. <literallayout class='monospaced'>
  35. src_uri = (d.getVar('SRC_URI') or "").split()
  36. fetcher = bb.fetch2.Fetch(src_uri, d)
  37. fetcher.download()
  38. </literallayout>
  39. This code sets up an instance of the fetch class.
  40. The instance uses a space-separated list of URLs from the
  41. <link linkend='var-bb-SRC_URI'><filename>SRC_URI</filename></link>
  42. variable and then calls the <filename>download</filename>
  43. method to download the files.
  44. </para>
  45. <para>
  46. The instantiation of the fetch class is usually followed by:
  47. <literallayout class='monospaced'>
  48. rootdir = l.getVar('WORKDIR')
  49. fetcher.unpack(rootdir)
  50. </literallayout>
  51. This code unpacks the downloaded files to the
  52. specified by <filename>WORKDIR</filename>.
  53. <note>
  54. For convenience, the naming in these examples matches
  55. the variables used by OpenEmbedded.
  56. If you want to see the above code in action, examine
  57. the OpenEmbedded class file <filename>base.bbclass</filename>.
  58. </note>
  59. The <filename>SRC_URI</filename> and <filename>WORKDIR</filename>
  60. variables are not hardcoded into the fetcher, since those fetcher
  61. methods can be (and are) called with different variable names.
  62. In OpenEmbedded for example, the shared state (sstate) code uses
  63. the fetch module to fetch the sstate files.
  64. </para>
  65. <para>
  66. When the <filename>download()</filename> method is called,
  67. BitBake tries to resolve the URLs by looking for source files
  68. in a specific search order:
  69. <itemizedlist>
  70. <listitem><para><emphasis>Pre-mirror Sites:</emphasis>
  71. BitBake first uses pre-mirrors to try and find source files.
  72. These locations are defined using the
  73. <link linkend='var-bb-PREMIRRORS'><filename>PREMIRRORS</filename></link>
  74. variable.
  75. </para></listitem>
  76. <listitem><para><emphasis>Source URI:</emphasis>
  77. If pre-mirrors fail, BitBake uses the original URL (e.g from
  78. <filename>SRC_URI</filename>).
  79. </para></listitem>
  80. <listitem><para><emphasis>Mirror Sites:</emphasis>
  81. If fetch failures occur, BitBake next uses mirror locations as
  82. defined by the
  83. <link linkend='var-bb-MIRRORS'><filename>MIRRORS</filename></link>
  84. variable.
  85. </para></listitem>
  86. </itemizedlist>
  87. </para>
  88. <para>
  89. For each URL passed to the fetcher, the fetcher
  90. calls the submodule that handles that particular URL type.
  91. This behavior can be the source of some confusion when you
  92. are providing URLs for the <filename>SRC_URI</filename>
  93. variable.
  94. Consider the following two URLs:
  95. <literallayout class='monospaced'>
  96. http://git.yoctoproject.org/git/poky;protocol=git
  97. git://git.yoctoproject.org/git/poky;protocol=http
  98. </literallayout>
  99. In the former case, the URL is passed to the
  100. <filename>wget</filename> fetcher, which does not
  101. understand "git".
  102. Therefore, the latter case is the correct form since the
  103. Git fetcher does know how to use HTTP as a transport.
  104. </para>
  105. <para>
  106. Here are some examples that show commonly used mirror
  107. definitions:
  108. <literallayout class='monospaced'>
  109. PREMIRRORS ?= "\
  110. bzr://.*/.* http://somemirror.org/sources/ \n \
  111. cvs://.*/.* http://somemirror.org/sources/ \n \
  112. git://.*/.* http://somemirror.org/sources/ \n \
  113. hg://.*/.* http://somemirror.org/sources/ \n \
  114. osc://.*/.* http://somemirror.org/sources/ \n \
  115. p4://.*/.* http://somemirror.org/sources/ \n \
  116. svn://.*/.* http://somemirror.org/sources/ \n"
  117. MIRRORS =+ "\
  118. ftp://.*/.* http://somemirror.org/sources/ \n \
  119. http://.*/.* http://somemirror.org/sources/ \n \
  120. https://.*/.* http://somemirror.org/sources/ \n"
  121. </literallayout>
  122. It is useful to note that BitBake supports
  123. cross-URLs.
  124. It is possible to mirror a Git repository on an HTTP
  125. server as a tarball.
  126. This is what the <filename>git://</filename> mapping in
  127. the previous example does.
  128. </para>
  129. <para>
  130. Since network accesses are slow, BitBake maintains a
  131. cache of files downloaded from the network.
  132. Any source files that are not local (i.e.
  133. downloaded from the Internet) are placed into the download
  134. directory, which is specified by the
  135. <link linkend='var-bb-DL_DIR'><filename>DL_DIR</filename></link>
  136. variable.
  137. </para>
  138. <para>
  139. File integrity is of key importance for reproducing builds.
  140. For non-local archive downloads, the fetcher code can verify
  141. SHA-256 and MD5 checksums to ensure the archives have been
  142. downloaded correctly.
  143. You can specify these checksums by using the
  144. <filename>SRC_URI</filename> variable with the appropriate
  145. varflags as follows:
  146. <literallayout class='monospaced'>
  147. SRC_URI[md5sum] = "<replaceable>value</replaceable>"
  148. SRC_URI[sha256sum] = "<replaceable>value</replaceable>"
  149. </literallayout>
  150. You can also specify the checksums as parameters on the
  151. <filename>SRC_URI</filename> as shown below:
  152. <literallayout class='monospaced'>
  153. SRC_URI = "http://example.com/foobar.tar.bz2;md5sum=4a8e0f237e961fd7785d19d07fdb994d"
  154. </literallayout>
  155. If multiple URIs exist, you can specify the checksums either
  156. directly as in the previous example, or you can name the URLs.
  157. The following syntax shows how you name the URIs:
  158. <literallayout class='monospaced'>
  159. SRC_URI = "http://example.com/foobar.tar.bz2;name=foo"
  160. SRC_URI[foo.md5sum] = 4a8e0f237e961fd7785d19d07fdb994d
  161. </literallayout>
  162. After a file has been downloaded and has had its checksum checked,
  163. a ".done" stamp is placed in <filename>DL_DIR</filename>.
  164. BitBake uses this stamp during subsequent builds to avoid
  165. downloading or comparing a checksum for the file again.
  166. <note>
  167. It is assumed that local storage is safe from data corruption.
  168. If this were not the case, there would be bigger issues to worry about.
  169. </note>
  170. </para>
  171. <para>
  172. If
  173. <link linkend='var-bb-BB_STRICT_CHECKSUM'><filename>BB_STRICT_CHECKSUM</filename></link>
  174. is set, any download without a checksum triggers an
  175. error message.
  176. The
  177. <link linkend='var-bb-BB_NO_NETWORK'><filename>BB_NO_NETWORK</filename></link>
  178. variable can be used to make any attempted network access a fatal
  179. error, which is useful for checking that mirrors are complete
  180. as well as other things.
  181. </para>
  182. </section>
  183. <section id='bb-the-unpack'>
  184. <title>The Unpack</title>
  185. <para>
  186. The unpack process usually immediately follows the download.
  187. For all URLs except Git URLs, BitBake uses the common
  188. <filename>unpack</filename> method.
  189. </para>
  190. <para>
  191. A number of parameters exist that you can specify within the
  192. URL to govern the behavior of the unpack stage:
  193. <itemizedlist>
  194. <listitem><para><emphasis>unpack:</emphasis>
  195. Controls whether the URL components are unpacked.
  196. If set to "1", which is the default, the components
  197. are unpacked.
  198. If set to "0", the unpack stage leaves the file alone.
  199. This parameter is useful when you want an archive to be
  200. copied in and not be unpacked.
  201. </para></listitem>
  202. <listitem><para><emphasis>dos:</emphasis>
  203. Applies to <filename>.zip</filename> and
  204. <filename>.jar</filename> files and specifies whether to
  205. use DOS line ending conversion on text files.
  206. </para></listitem>
  207. <listitem><para><emphasis>basepath:</emphasis>
  208. Instructs the unpack stage to strip the specified
  209. directories from the source path when unpacking.
  210. </para></listitem>
  211. <listitem><para><emphasis>subdir:</emphasis>
  212. Unpacks the specific URL to the specified subdirectory
  213. within the root directory.
  214. </para></listitem>
  215. </itemizedlist>
  216. The unpack call automatically decompresses and extracts files
  217. with ".Z", ".z", ".gz", ".xz", ".zip", ".jar", ".ipk", ".rpm".
  218. ".srpm", ".deb" and ".bz2" extensions as well as various combinations
  219. of tarball extensions.
  220. </para>
  221. <para>
  222. As mentioned, the Git fetcher has its own unpack method that
  223. is optimized to work with Git trees.
  224. Basically, this method works by cloning the tree into the final
  225. directory.
  226. The process is completed using references so that there is
  227. only one central copy of the Git metadata needed.
  228. </para>
  229. </section>
  230. <section id='bb-fetchers'>
  231. <title>Fetchers</title>
  232. <para>
  233. As mentioned earlier, the URL prefix determines which
  234. fetcher submodule BitBake uses.
  235. Each submodule can support different URL parameters,
  236. which are described in the following sections.
  237. </para>
  238. <section id='local-file-fetcher'>
  239. <title>Local file fetcher (<filename>file://</filename>)</title>
  240. <para>
  241. This submodule handles URLs that begin with
  242. <filename>file://</filename>.
  243. The filename you specify within the URL can be
  244. either an absolute or relative path to a file.
  245. If the filename is relative, the contents of the
  246. <link linkend='var-bb-FILESPATH'><filename>FILESPATH</filename></link>
  247. variable is used in the same way
  248. <filename>PATH</filename> is used to find executables.
  249. If the file cannot be found, it is assumed that it is available in
  250. <link linkend='var-bb-DL_DIR'><filename>DL_DIR</filename></link>
  251. by the time the <filename>download()</filename> method is called.
  252. </para>
  253. <para>
  254. If you specify a directory, the entire directory is
  255. unpacked.
  256. </para>
  257. <para>
  258. Here are a couple of example URLs, the first relative and
  259. the second absolute:
  260. <literallayout class='monospaced'>
  261. SRC_URI = "file://relativefile.patch"
  262. SRC_URI = "file:///Users/ich/very_important_software"
  263. </literallayout>
  264. </para>
  265. </section>
  266. <section id='http-ftp-fetcher'>
  267. <title>HTTP/FTP wget fetcher (<filename>http://</filename>, <filename>ftp://</filename>, <filename>https://</filename>)</title>
  268. <para>
  269. This fetcher obtains files from web and FTP servers.
  270. Internally, the fetcher uses the wget utility.
  271. </para>
  272. <para>
  273. The executable and parameters used are specified by the
  274. <filename>FETCHCMD_wget</filename> variable, which defaults
  275. to sensible values.
  276. The fetcher supports a parameter "downloadfilename" that
  277. allows the name of the downloaded file to be specified.
  278. Specifying the name of the downloaded file is useful
  279. for avoiding collisions in
  280. <link linkend='var-bb-DL_DIR'><filename>DL_DIR</filename></link>
  281. when dealing with multiple files that have the same name.
  282. </para>
  283. <para>
  284. Some example URLs are as follows:
  285. <literallayout class='monospaced'>
  286. SRC_URI = "http://oe.handhelds.org/not_there.aac"
  287. SRC_URI = "ftp://oe.handhelds.org/not_there_as_well.aac"
  288. SRC_URI = "ftp://you@oe.handhelds.org/home/you/secret.plan"
  289. </literallayout>
  290. </para>
  291. <note>
  292. Because URL parameters are delimited by semi-colons, this can
  293. introduce ambiguity when parsing URLs that also contain semi-colons,
  294. for example:
  295. <literallayout class='monospaced'>
  296. SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git;a=snapshot;h=a5dd47"
  297. </literallayout>
  298. Such URLs should should be modified by replacing semi-colons with '&amp;' characters:
  299. <literallayout class='monospaced'>
  300. SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git&amp;a=snapshot&amp;h=a5dd47"
  301. </literallayout>
  302. In most cases this should work. Treating semi-colons and '&amp;' in queries
  303. identically is recommended by the World Wide Web Consortium (W3C).
  304. Note that due to the nature of the URL, you may have to specify the name
  305. of the downloaded file as well:
  306. <literallayout class='monospaced'>
  307. SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git&amp;a=snapshot&amp;h=a5dd47;downloadfilename=myfile.bz2"
  308. </literallayout>
  309. </note>
  310. </section>
  311. <section id='cvs-fetcher'>
  312. <title>CVS fetcher (<filename>(cvs://</filename>)</title>
  313. <para>
  314. This submodule handles checking out files from the
  315. CVS version control system.
  316. You can configure it using a number of different variables:
  317. <itemizedlist>
  318. <listitem><para><emphasis><filename>FETCHCMD_cvs</filename>:</emphasis>
  319. The name of the executable to use when running
  320. the <filename>cvs</filename> command.
  321. This name is usually "cvs".
  322. </para></listitem>
  323. <listitem><para><emphasis><filename>SRCDATE</filename>:</emphasis>
  324. The date to use when fetching the CVS source code.
  325. A special value of "now" causes the checkout to
  326. be updated on every build.
  327. </para></listitem>
  328. <listitem><para><emphasis><link linkend='var-bb-CVSDIR'><filename>CVSDIR</filename></link>:</emphasis>
  329. Specifies where a temporary checkout is saved.
  330. The location is often <filename>DL_DIR/cvs</filename>.
  331. </para></listitem>
  332. <listitem><para><emphasis><filename>CVS_PROXY_HOST</filename>:</emphasis>
  333. The name to use as a "proxy=" parameter to the
  334. <filename>cvs</filename> command.
  335. </para></listitem>
  336. <listitem><para><emphasis><filename>CVS_PROXY_PORT</filename>:</emphasis>
  337. The port number to use as a "proxyport=" parameter to
  338. the <filename>cvs</filename> command.
  339. </para></listitem>
  340. </itemizedlist>
  341. As well as the standard username and password URL syntax,
  342. you can also configure the fetcher with various URL parameters:
  343. </para>
  344. <para>
  345. The supported parameters are as follows:
  346. <itemizedlist>
  347. <listitem><para><emphasis>"method":</emphasis>
  348. The protocol over which to communicate with the CVS
  349. server.
  350. By default, this protocol is "pserver".
  351. If "method" is set to "ext", BitBake examines the
  352. "rsh" parameter and sets <filename>CVS_RSH</filename>.
  353. You can use "dir" for local directories.
  354. </para></listitem>
  355. <listitem><para><emphasis>"module":</emphasis>
  356. Specifies the module to check out.
  357. You must supply this parameter.
  358. </para></listitem>
  359. <listitem><para><emphasis>"tag":</emphasis>
  360. Describes which CVS TAG should be used for
  361. the checkout.
  362. By default, the TAG is empty.
  363. </para></listitem>
  364. <listitem><para><emphasis>"date":</emphasis>
  365. Specifies a date.
  366. If no "date" is specified, the
  367. <link linkend='var-bb-SRCDATE'><filename>SRCDATE</filename></link>
  368. of the configuration is used to checkout a specific date.
  369. The special value of "now" causes the checkout to be
  370. updated on every build.
  371. </para></listitem>
  372. <listitem><para><emphasis>"localdir":</emphasis>
  373. Used to rename the module.
  374. Effectively, you are renaming the output directory
  375. to which the module is unpacked.
  376. You are forcing the module into a special
  377. directory relative to
  378. <link linkend='var-bb-CVSDIR'><filename>CVSDIR</filename></link>.
  379. </para></listitem>
  380. <listitem><para><emphasis>"rsh"</emphasis>
  381. Used in conjunction with the "method" parameter.
  382. </para></listitem>
  383. <listitem><para><emphasis>"scmdata":</emphasis>
  384. Causes the CVS metadata to be maintained in the tarball
  385. the fetcher creates when set to "keep".
  386. The tarball is expanded into the work directory.
  387. By default, the CVS metadata is removed.
  388. </para></listitem>
  389. <listitem><para><emphasis>"fullpath":</emphasis>
  390. Controls whether the resulting checkout is at the
  391. module level, which is the default, or is at deeper
  392. paths.
  393. </para></listitem>
  394. <listitem><para><emphasis>"norecurse":</emphasis>
  395. Causes the fetcher to only checkout the specified
  396. directory with no recurse into any subdirectories.
  397. </para></listitem>
  398. <listitem><para><emphasis>"port":</emphasis>
  399. The port to which the CVS server connects.
  400. </para></listitem>
  401. </itemizedlist>
  402. Some example URLs are as follows:
  403. <literallayout class='monospaced'>
  404. SRC_URI = "cvs://CVSROOT;module=mymodule;tag=some-version;method=ext"
  405. SRC_URI = "cvs://CVSROOT;module=mymodule;date=20060126;localdir=usethat"
  406. </literallayout>
  407. </para>
  408. </section>
  409. <section id='svn-fetcher'>
  410. <title>Subversion (SVN) Fetcher (<filename>svn://</filename>)</title>
  411. <para>
  412. This fetcher submodule fetches code from the
  413. Subversion source control system.
  414. The executable used is specified by
  415. <filename>FETCHCMD_svn</filename>, which defaults
  416. to "svn".
  417. The fetcher's temporary working directory is set by
  418. <link linkend='var-bb-SVNDIR'><filename>SVNDIR</filename></link>,
  419. which is usually <filename>DL_DIR/svn</filename>.
  420. </para>
  421. <para>
  422. The supported parameters are as follows:
  423. <itemizedlist>
  424. <listitem><para><emphasis>"module":</emphasis>
  425. The name of the svn module to checkout.
  426. You must provide this parameter.
  427. You can think of this parameter as the top-level
  428. directory of the repository data you want.
  429. </para></listitem>
  430. <listitem><para><emphasis>"path_spec":</emphasis>
  431. A specific directory in which to checkout the
  432. specified svn module.
  433. </para></listitem>
  434. <listitem><para><emphasis>"protocol":</emphasis>
  435. The protocol to use, which defaults to "svn".
  436. If "protocol" is set to "svn+ssh", the "ssh"
  437. parameter is also used.
  438. </para></listitem>
  439. <listitem><para><emphasis>"rev":</emphasis>
  440. The revision of the source code to checkout.
  441. </para></listitem>
  442. <listitem><para><emphasis>"scmdata":</emphasis>
  443. Causes the “.svn” directories to be available during
  444. compile-time when set to "keep".
  445. By default, these directories are removed.
  446. </para></listitem>
  447. <listitem><para><emphasis>"ssh":</emphasis>
  448. An optional parameter used when "protocol" is set
  449. to "svn+ssh".
  450. You can use this parameter to specify the ssh
  451. program used by svn.
  452. </para></listitem>
  453. <listitem><para><emphasis>"transportuser":</emphasis>
  454. When required, sets the username for the transport.
  455. By default, this parameter is empty.
  456. The transport username is different than the username
  457. used in the main URL, which is passed to the subversion
  458. command.
  459. </para></listitem>
  460. </itemizedlist>
  461. Following are three examples using svn:
  462. <literallayout class='monospaced'>
  463. SRC_URI = "svn://myrepos/proj1;module=vip;protocol=http;rev=667"
  464. SRC_URI = "svn://myrepos/proj1;module=opie;protocol=svn+ssh"
  465. SRC_URI = "svn://myrepos/proj1;module=trunk;protocol=http;path_spec=${MY_DIR}/proj1"
  466. </literallayout>
  467. </para>
  468. </section>
  469. <section id='git-fetcher'>
  470. <title>Git Fetcher (<filename>git://</filename>)</title>
  471. <para>
  472. This fetcher submodule fetches code from the Git
  473. source control system.
  474. The fetcher works by creating a bare clone of the
  475. remote into
  476. <link linkend='var-bb-GITDIR'><filename>GITDIR</filename></link>,
  477. which is usually <filename>DL_DIR/git2</filename>.
  478. This bare clone is then cloned into the work directory during the
  479. unpack stage when a specific tree is checked out.
  480. This is done using alternates and by reference to
  481. minimize the amount of duplicate data on the disk and
  482. make the unpack process fast.
  483. The executable used can be set with
  484. <filename>FETCHCMD_git</filename>.
  485. </para>
  486. <para>
  487. This fetcher supports the following parameters:
  488. <itemizedlist>
  489. <listitem><para><emphasis>"protocol":</emphasis>
  490. The protocol used to fetch the files.
  491. The default is "git" when a hostname is set.
  492. If a hostname is not set, the Git protocol is "file".
  493. You can also use "http", "https", "ssh" and "rsync".
  494. </para></listitem>
  495. <listitem><para><emphasis>"nocheckout":</emphasis>
  496. Tells the fetcher to not checkout source code when
  497. unpacking when set to "1".
  498. Set this option for the URL where there is a custom
  499. routine to checkout code.
  500. The default is "0".
  501. </para></listitem>
  502. <listitem><para><emphasis>"rebaseable":</emphasis>
  503. Indicates that the upstream Git repository can be rebased.
  504. You should set this parameter to "1" if
  505. revisions can become detached from branches.
  506. In this case, the source mirror tarball is done per
  507. revision, which has a loss of efficiency.
  508. Rebasing the upstream Git repository could cause the
  509. current revision to disappear from the upstream repository.
  510. This option reminds the fetcher to preserve the local cache
  511. carefully for future use.
  512. The default value for this parameter is "0".
  513. </para></listitem>
  514. <listitem><para><emphasis>"nobranch":</emphasis>
  515. Tells the fetcher to not check the SHA validation
  516. for the branch when set to "1".
  517. The default is "0".
  518. Set this option for the recipe that refers to
  519. the commit that is valid for a tag instead of
  520. the branch.
  521. </para></listitem>
  522. <listitem><para><emphasis>"bareclone":</emphasis>
  523. Tells the fetcher to clone a bare clone into the
  524. destination directory without checking out a working tree.
  525. Only the raw Git metadata is provided.
  526. This parameter implies the "nocheckout" parameter as well.
  527. </para></listitem>
  528. <listitem><para><emphasis>"branch":</emphasis>
  529. The branch(es) of the Git tree to clone.
  530. If unset, this is assumed to be "master".
  531. The number of branch parameters much match the number of
  532. name parameters.
  533. </para></listitem>
  534. <listitem><para><emphasis>"rev":</emphasis>
  535. The revision to use for the checkout.
  536. The default is "master".
  537. </para></listitem>
  538. <listitem><para><emphasis>"tag":</emphasis>
  539. Specifies a tag to use for the checkout.
  540. To correctly resolve tags, BitBake must access the
  541. network.
  542. For that reason, tags are often not used.
  543. As far as Git is concerned, the "tag" parameter behaves
  544. effectively the same as the "rev" parameter.
  545. </para></listitem>
  546. <listitem><para><emphasis>"subpath":</emphasis>
  547. Limits the checkout to a specific subpath of the tree.
  548. By default, the whole tree is checked out.
  549. </para></listitem>
  550. <listitem><para><emphasis>"destsuffix":</emphasis>
  551. The name of the path in which to place the checkout.
  552. By default, the path is <filename>git/</filename>.
  553. </para></listitem>
  554. <listitem><para><emphasis>"usehead":</emphasis>
  555. Enables local <filename>git://</filename> URLs to use the
  556. current branch HEAD as the revision for use with
  557. <filename>AUTOREV</filename>.
  558. The "usehead" parameter implies no branch and only works
  559. when the transfer protocol is
  560. <filename>file://</filename>.
  561. </para></listitem>
  562. </itemizedlist>
  563. Here are some example URLs:
  564. <literallayout class='monospaced'>
  565. SRC_URI = "git://git.oe.handhelds.org/git/vip.git;tag=version-1"
  566. SRC_URI = "git://git.oe.handhelds.org/git/vip.git;protocol=http"
  567. </literallayout>
  568. </para>
  569. </section>
  570. <section id='gitsm-fetcher'>
  571. <title>Git Submodule Fetcher (<filename>gitsm://</filename>)</title>
  572. <para>
  573. This fetcher submodule inherits from the
  574. <link linkend='git-fetcher'>Git fetcher</link> and extends
  575. that fetcher's behavior by fetching a repository's submodules.
  576. <link linkend='var-bb-SRC_URI'><filename>SRC_URI</filename></link>
  577. is passed to the Git fetcher as described in the
  578. "<link linkend='git-fetcher'>Git Fetcher (<filename>git://</filename>)</link>"
  579. section.
  580. <note>
  581. <title>Notes and Warnings</title>
  582. <para>
  583. You must clean a recipe when switching between
  584. '<filename>git://</filename>' and
  585. '<filename>gitsm://</filename>' URLs.
  586. </para>
  587. <para>
  588. The Git Submodules fetcher is not a complete fetcher
  589. implementation.
  590. The fetcher has known issues where it does not use the
  591. normal source mirroring infrastructure properly. Further,
  592. the submodule sources it fetches are not visible to the
  593. licensing and source archiving infrastructures.
  594. </para>
  595. </note>
  596. </para>
  597. </section>
  598. <section id='clearcase-fetcher'>
  599. <title>ClearCase Fetcher (<filename>ccrc://</filename>)</title>
  600. <para>
  601. This fetcher submodule fetches code from a
  602. <ulink url='http://en.wikipedia.org/wiki/Rational_ClearCase'>ClearCase</ulink>
  603. repository.
  604. </para>
  605. <para>
  606. To use this fetcher, make sure your recipe has proper
  607. <link linkend='var-bb-SRC_URI'><filename>SRC_URI</filename></link>,
  608. <link linkend='var-bb-SRCREV'><filename>SRCREV</filename></link>, and
  609. <link linkend='var-bb-PV'><filename>PV</filename></link> settings.
  610. Here is an example:
  611. <literallayout class='monospaced'>
  612. SRC_URI = "ccrc://cc.example.org/ccrc;vob=/example_vob;module=/example_module"
  613. SRCREV = "EXAMPLE_CLEARCASE_TAG"
  614. PV = "${@d.getVar("SRCREV", False).replace("/", "+")}"
  615. </literallayout>
  616. The fetcher uses the <filename>rcleartool</filename> or
  617. <filename>cleartool</filename> remote client, depending on
  618. which one is available.
  619. </para>
  620. <para>
  621. Following are options for the <filename>SRC_URI</filename>
  622. statement:
  623. <itemizedlist>
  624. <listitem><para><emphasis><filename>vob</filename></emphasis>:
  625. The name, which must include the
  626. prepending "/" character, of the ClearCase VOB.
  627. This option is required.
  628. </para></listitem>
  629. <listitem><para><emphasis><filename>module</filename></emphasis>:
  630. The module, which must include the
  631. prepending "/" character, in the selected VOB.
  632. <note>
  633. The <filename>module</filename> and <filename>vob</filename>
  634. options are combined to create the <filename>load</filename> rule in
  635. the view config spec.
  636. As an example, consider the <filename>vob</filename> and
  637. <filename>module</filename> values from the
  638. <filename>SRC_URI</filename> statement at the start of this section.
  639. Combining those values results in the following:
  640. <literallayout class='monospaced'>
  641. load /example_vob/example_module
  642. </literallayout>
  643. </note>
  644. </para></listitem>
  645. <listitem><para><emphasis><filename>proto</filename></emphasis>:
  646. The protocol, which can be either <filename>http</filename> or
  647. <filename>https</filename>.
  648. </para></listitem>
  649. </itemizedlist>
  650. </para>
  651. <para>
  652. By default, the fetcher creates a configuration specification.
  653. If you want this specification written to an area other than the default,
  654. use the <filename>CCASE_CUSTOM_CONFIG_SPEC</filename> variable
  655. in your recipe to define where the specification is written.
  656. <note>
  657. the <filename>SRCREV</filename> loses its functionality if you
  658. specify this variable.
  659. However, <filename>SRCREV</filename> is still used to label the
  660. archive after a fetch even though it does not define what is
  661. fetched.
  662. </note>
  663. </para>
  664. <para>
  665. Here are a couple of other behaviors worth mentioning:
  666. <itemizedlist>
  667. <listitem><para>
  668. When using <filename>cleartool</filename>, the login of
  669. <filename>cleartool</filename> is handled by the system.
  670. The login require no special steps.
  671. </para></listitem>
  672. <listitem><para>
  673. In order to use <filename>rcleartool</filename> with authenticated
  674. users, an "rcleartool login" is necessary before using the fetcher.
  675. </para></listitem>
  676. </itemizedlist>
  677. </para>
  678. </section>
  679. <section id='perforce-fetcher'>
  680. <title>Perforce Fetcher (<filename>p4://</filename>)</title>
  681. <para>
  682. This fetcher submodule fetches code from the
  683. <ulink url='https://www.perforce.com/'>Perforce</ulink>
  684. source control system.
  685. The executable used is specified by
  686. <filename>FETCHCMD_p4</filename>, which defaults
  687. to "p4".
  688. The fetcher's temporary working directory is set by
  689. <link linkend='var-bb-P4DIR'><filename>P4DIR</filename></link>,
  690. which defaults to "DL_DIR/p4".
  691. The fetcher does not make use of a perforce client, instead it
  692. relies on <filename>p4 files</filename> to retrieve a list of
  693. files and <filename>p4 print</filename> to transfer the content
  694. of those files locally.
  695. </para>
  696. <para>
  697. To use this fetcher, make sure your recipe has proper
  698. <link linkend='var-bb-SRC_URI'><filename>SRC_URI</filename></link>,
  699. <link linkend='var-bb-SRCREV'><filename>SRCREV</filename></link>, and
  700. <link linkend='var-bb-PV'><filename>PV</filename></link> values.
  701. The p4 executable is able to use the config file defined by your
  702. system's <filename>P4CONFIG</filename> environment variable in
  703. order to define the Perforce server URL and port, username, and
  704. password if you do not wish to keep those values in a recipe
  705. itself.
  706. If you choose not to use <filename>P4CONFIG</filename>,
  707. or to explicitly set variables that <filename>P4CONFIG</filename>
  708. can contain, you can specify the <filename>P4PORT</filename> value,
  709. which is the server's URL and port number, and you can
  710. specify a username and password directly in your recipe within
  711. <filename>SRC_URI</filename>.
  712. </para>
  713. <para>
  714. Here is an example that relies on <filename>P4CONFIG</filename>
  715. to specify the server URL and port, username, and password, and
  716. fetches the Head Revision:
  717. <literallayout class='monospaced'>
  718. SRC_URI = "p4://example-depot/main/source/..."
  719. SRCREV = "${AUTOREV}"
  720. PV = "p4-${SRCPV}"
  721. S = "${WORKDIR}/p4"
  722. </literallayout>
  723. </para>
  724. <para>
  725. Here is an example that specifies the server URL and port,
  726. username, and password, and fetches a Revision based on a Label:
  727. <literallayout class='monospaced'>
  728. P4PORT = "tcp:p4server.example.net:1666"
  729. SRC_URI = "p4://user:passwd@example-depot/main/source/..."
  730. SRCREV = "release-1.0"
  731. PV = "p4-${SRCPV}"
  732. S = "${WORKDIR}/p4"
  733. </literallayout>
  734. <note>
  735. You should always set <filename>S</filename>
  736. to <filename>"${WORKDIR}/p4"</filename> in your recipe.
  737. </note>
  738. </para>
  739. <para>
  740. By default, the fetcher strips the depot location from the
  741. local file paths. In the above example, the content of
  742. <filename>example-depot/main/source/</filename>
  743. will be placed in <filename>${WORKDIR}/p4</filename>.
  744. For situations where preserving parts of the remote depot paths
  745. locally is desirable, the fetcher supports two parameters:
  746. <itemizedlist>
  747. <listitem><para>
  748. <emphasis>"module":</emphasis>
  749. The top-level depot location or directory to fetch. The
  750. value of this parameter can also point to a single file
  751. within the depot, in which case the local file path will
  752. include the module path.
  753. </para></listitem>
  754. <listitem><para>
  755. <emphasis>"remotepath":</emphasis>
  756. When used with the value "<filename>keep</filename>",
  757. the fetcher will mirror the full depot paths locally
  758. for the specified location, even in combination with
  759. the <filename>module</filename> parameter.
  760. </para></listitem>
  761. </itemizedlist>
  762. </para>
  763. <para>
  764. Here is an example use of the the <filename>module</filename>
  765. parameter:
  766. <literallayout class='monospaced'>
  767. SRC_URI = "p4://user:passwd@example-depot/main;module=source/..."
  768. </literallayout>
  769. In this case, the content of the top-level directory
  770. <filename>source/</filename> will be fetched to
  771. <filename>${P4DIR}</filename>, including the directory itself.
  772. The top-level directory will be accesible at
  773. <filename>${P4DIR}/source/</filename>.
  774. </para>
  775. <para>
  776. Here is an example use of the the <filename>remotepath</filename>
  777. parameter:
  778. <literallayout class='monospaced'>
  779. SRC_URI = "p4://user:passwd@example-depot/main;module=source/...;remotepath=keep"
  780. </literallayout>
  781. In this case, the content of the top-level directory
  782. <filename>source/</filename> will be fetched to
  783. <filename>${P4DIR}</filename>, but the complete depot paths will
  784. be mirrored locally. The top-level directory will be accessible
  785. at <filename>${P4DIR}/example-depot/main/source/</filename>.
  786. </para>
  787. </section>
  788. <section id='repo-fetcher'>
  789. <title>Repo Fetcher (<filename>repo://</filename>)</title>
  790. <para>
  791. This fetcher submodule fetches code from
  792. <filename>google-repo</filename> source control system.
  793. The fetcher works by initiating and syncing sources of the
  794. repository into
  795. <link linkend='var-bb-REPODIR'><filename>REPODIR</filename></link>,
  796. which is usually
  797. <link linkend='var-bb-DL_DIR'><filename>DL_DIR</filename></link><filename>/repo</filename>.
  798. </para>
  799. <para>
  800. This fetcher supports the following parameters:
  801. <itemizedlist>
  802. <listitem><para>
  803. <emphasis>"protocol":</emphasis>
  804. Protocol to fetch the repository manifest (default: git).
  805. </para></listitem>
  806. <listitem><para>
  807. <emphasis>"branch":</emphasis>
  808. Branch or tag of repository to get (default: master).
  809. </para></listitem>
  810. <listitem><para>
  811. <emphasis>"manifest":</emphasis>
  812. Name of the manifest file (default: <filename>default.xml</filename>).
  813. </para></listitem>
  814. </itemizedlist>
  815. Here are some example URLs:
  816. <literallayout class='monospaced'>
  817. SRC_URI = "repo://REPOROOT;protocol=git;branch=some_branch;manifest=my_manifest.xml"
  818. SRC_URI = "repo://REPOROOT;protocol=file;branch=some_branch;manifest=my_manifest.xml"
  819. </literallayout>
  820. </para>
  821. </section>
  822. <section id='other-fetchers'>
  823. <title>Other Fetchers</title>
  824. <para>
  825. Fetch submodules also exist for the following:
  826. <itemizedlist>
  827. <listitem><para>
  828. Bazaar (<filename>bzr://</filename>)
  829. </para></listitem>
  830. <listitem><para>
  831. Mercurial (<filename>hg://</filename>)
  832. </para></listitem>
  833. <listitem><para>
  834. npm (<filename>npm://</filename>)
  835. </para></listitem>
  836. <listitem><para>
  837. OSC (<filename>osc://</filename>)
  838. </para></listitem>
  839. <listitem><para>
  840. Secure FTP (<filename>sftp://</filename>)
  841. </para></listitem>
  842. <listitem><para>
  843. Secure Shell (<filename>ssh://</filename>)
  844. </para></listitem>
  845. <listitem><para>
  846. Trees using Git Annex (<filename>gitannex://</filename>)
  847. </para></listitem>
  848. </itemizedlist>
  849. No documentation currently exists for these lesser used
  850. fetcher submodules.
  851. However, you might find the code helpful and readable.
  852. </para>
  853. </section>
  854. </section>
  855. <section id='auto-revisions'>
  856. <title>Auto Revisions</title>
  857. <para>
  858. We need to document <filename>AUTOREV</filename> and
  859. <filename>SRCREV_FORMAT</filename> here.
  860. </para>
  861. </section>
  862. </chapter>