1 <?xml version="1.0" encoding="UTF-8"?>
2 <section id="src_uri_variable" xreflabel="SRC_URI variable">
3 <title>SRC_URI variable: Source code and patches</title>
5 <para>All recipies need to contain a definition of
6 <command>SRC_URI</command>. It determines what files and source code is
7 needed and where that source code should be obtained from. This includes
8 patches to be applied and basic files that are shipped as part of the
9 meta-data for the package.</para>
11 <para>A typical <command>SRC_URI</command> contains a list of URL's, patches
12 and files as shown in this example from quagga:<screen>SRC_URI = "http://www.quagga.net/download/quagga-${PV}.tar.gz \
13 file://ospfd-no-opaque-lsa-fix.patch;patch=1 \
14 file://fix-for-lib-inpath.patch;patch=1 \
16 file://quagga.default \
17 file://watchquagga.init \
18 file://watchquagga.default"</screen>All source code and files will
19 be placed into the work directory, <command>${WORKDIR}</command>, for the
20 package. All patches will be placed into a <command>patches</command>
21 subdirectory of the package source directory, <command>${S}</command>, and
22 then automatically applied to the source.</para>
24 <para>Before downloading from a remote URI a check will be made to see if
25 what is to be retrieved is already present in the download source directory,
26 <command>${DL_DIR}</command>, along with an associated md5 sum. If the
27 source is present in the downloaded sources directory and the md5 sum
28 matches that listed in the associated md5 sum file, then that version will
29 be used in preference to retrieving a new version . Any source that is
30 retrieved from a remote URI will be stored in the download source directory
31 and an appropriate md5 sum generated and stored alongside it.</para>
33 <para>Each URI supports a set of additional options. These options are
34 tag/value pairs of the form <command>"a=b"</command> and are semi-colon
35 separated from each other and from the URI. The follow examples shows two
36 options being included, the patch and pnum options:<screen>file://ospfd-no-opaque-lsa-fix.patch;patch=1;pnum=2</screen>The
37 supported methods for fetching source and files are:</para>
41 <term>http, https, ftps</term>
44 <para>Used to download files and source code via the specified URL.
45 These are fetched from the specified location using wget.</para>
53 <para>Used for files that are included locally in the meta-data. These
54 may be plain files, such as init scripts to be added to the final
55 package, or they may be patch files to be applied to other
64 <para>Used to download from a CVS repository.</para>
72 <para>Used to download from a subversion repository.</para>
80 <para>Used to download from a git repository.</para>
85 <para>When source code is specified as a part of <command>SRC_URI</command>
86 it is unpacked into the work directory, <command>${WORKDIR}</command>. The
87 unpacker recognises several archive and compression types and for these it
88 will decompress any compressed files and extract all of the files from
89 archives into the work directory. The supported types are:</para>
96 <para>Tar archives which will be extracted with <command>"tar x
97 --no-same-owner -f <srcfile>"</command>.</para>
102 <term>.tgz, .tar.gz, tar.Z</term>
105 <para>Gzip compressed tar archives which will be extracted with
106 <command>"tar xz --no-same-owner -f <srcfile>"</command>.</para>
111 <term>.tbz, .tar.bz2</term>
114 <para>Bzip2 compressed tar archives which will be extracted with
115 <command>"bzip2 -dc <srcfile> | tar x --no-same-owner -f
121 <term>.gz, .Z, .z</term>
124 <para>Gzip compressed files which will be decompressed with
125 <command>"gzip -dc <srcfile> >
126 <dstfile>"</command>.</para>
134 <para>Bzip2 compressed files which will be decompressed with
135 <command>"bzip2 -dc <srcfile> >
136 <dstfile>"</command>.</para>
144 <para>Zip archives which will be extracted with <command>"unzip -q
145 <srcfile>"</command>.</para>
150 <para>The downloading of the source files occurs in the
151 <emphasis>fetch</emphasis> task, the unpacking and copying to the work
152 directory occurs in the <emphasis>unpack</emphasis> task and the applying of
153 patches occurs in the <emphasis>patch</emphasis> task.</para>
156 <title>http/https/ftp (wget)</title>
158 <para>The wget fetcher handles http, https and ftp URLs.<screen>http://www.quagga.net/download/quagga-${PV}.tar.gz</screen></para>
160 <para>Supported options:</para>
167 <para>If an md5sum is provided then the downloaded files will only
168 be considered valid if the md5sum of the downloaded file matches the
169 md5sum option provided.</para>
174 <para>Related variables:</para>
181 <para>Mirrors define alternative locations to download source files
182 from. See the mirror section below for more information.</para>
190 <para>The downloaded files will be placed in this directory with the
191 name exactly as supplied via the URI.</para>
198 <title>file: for patches and additional files</title>
200 <para>The file URI's are used to copy files, included as part of the
201 package meta data, into the work directory to be used when building the
202 package. Typical use of the file URI's is to specify patches that be
203 applied to the source and to provide additional files, such as init
204 scripts, to be included in the final package.</para>
206 <para>The following example shows the specification of a patch
207 file:<screen>file://ospfd-no-opaque-lsa-fix.patch;patch=1</screen></para>
209 <para>Patch files are be copied to the patches subdirectory of the source
210 directory, <command>${S}/patches</command>, and then applied from the
211 source directory. The patches are searched for along the path specified
212 via the file path variable, <command>${FILESPATH},</command> and if not
213 found the directory specified by the file directory variable,
214 <command>${FILEDIR}</command>, is also checked.</para>
216 <para>The following example shows the specification of a non-patch file.
217 In this case it's an init script:<screen>file://quagga.init</screen>Non-patch
218 files are copied to the work directory, <command>${WORKDIR}</command>. You
219 can access these files from within a recipe by referring to them relative
220 to the work directory. The following example, from the quagga recipe,
221 shows the above init script being included in the package by copying it
222 during the <emphasis>install</emphasis> task:<screen>do_install () {
223 # Install init script and default settings
224 install -m 0755 -d ${D}${sysconfdir}/default ${D}${sysconfdir}/init.d ${D}${sysconfdir}/quagga
225 install -m 0644 <emphasis role="bold">${WORKDIR}/quagga.init</emphasis> ${D}${sysconfdir}/init.d/quagga
228 <para>Supported options:</para>
235 <para>Used as <command>"patch=1"</command> to define this file as a
236 patch file. Patch files will be copied to
237 <command>${S}/patches</command> and then applied to source from
238 within the source directory, <command>${S}</command>.</para>
246 <para>By default patches are applied with the <command>"-p
247 1"</command> parameter, which strips off the first directory of the
248 pathname in the patches. This option is used to explicitly control
249 the value passed to <command>"-p"</command>. The most typical use is
250 when the patches are relative to the source directory already and
251 need to be applied using <command>"-p 0"</command>, in which case
252 the <command>"pnum=0"</command> option is supplied.</para>
261 <para>The cvs fetcher is used to retrieve files from a CVS repository.
262 <screen> cvs://anonymous@cvs.sourceforge.net/cvsroot/linuxsh;module=linux;date=20051111</screen>A
263 cvs URI will retrieve the source from a cvs repository. Note that use of
264 the <emphasis>date=</emphasis> to specify a checkout for specified date.
265 It is preferable to use either a <emphasis>date=</emphasis> or a
266 <emphasis>tag=</emphasis> option to select a specific date and/or tag from
267 cvs rather than leave the checkout floating at the head revision.</para>
269 <para>Supported options:</para>
276 <para>The name of a module to retrieve. This is a required parameter
277 and there is no default value.</para>
285 <para>The name of a cvs tag to retrieve. Releases are often tagged
286 with a specific name to allow easy access. Either a tag or a date
287 can be specified, but not both.</para>
295 <para>The date to retrieve. This requests that files as of the
296 specified date, rather then the current code or a tagged release. If
297 no date or tag options are specified, then the date is set to the
298 current date. The date is of any form accepted by cvs with the most
299 common format being <command>"YYYYMMDD"</command>.</para>
307 <para>The method used to access the repository. Common options are
308 <command>"pserver"</command> and <command>"ext"</command> (for cvs
309 over rsh or ssh). The default is
310 <command>"pserver"</command>.</para>
318 <para>The rsh command to use with the <command>"ext"</command>
319 method. Common options are <command>"rsh"</command> or
320 <command>"ssh"</command>. The default is
321 <command>"rsh"</command>.</para>
326 <para>Related variables:<variablelist>
328 <term>CVS_TARBALL_STASH</term>
331 <para>Used to specifies a location to search for pre-generated tar
332 archives to use instead of accessing cvs directly.</para>
340 <para>The directory in which the cvs checkouts will be performed.
341 The default is <command>${DL_DIR}/cvs</command>.</para>
349 <para>A compressed tar archive of the retrieved files will be
350 placed in this directory. The archive name will be of the form:
351 <command>"<module>_<host>_<tag>_<date>.tar.gz"</command>.
352 Path separators in <command>module</command> will be replaced with
356 </variablelist></para>
362 <para>The svn fetcher is used to retrieve files from a subversion
365 <para><screen> svn://svn.xiph.org/trunk;module=Tremor;rev=4573;proto=http</screen></para>
367 <para>Supported options:</para>
374 <para>The name of a module to retrieve. This is a required parameter
375 and there is no default value.</para>
383 <para>The revision to retrieve. Revisions in subversion are integer
392 <para>The method to use to access the repository. Common options are
393 <command>"svn"</command>, <command>"svn+ssh"</command>,
394 <command>"http"</command> and <command>"https"</command>. The
395 default is <command>"svn"</command>.</para>
403 <para>The rsh command to use with using the
404 <command>"svn+ssh"</command> method. Common options are
405 <command>"rsh"</command> or <command>"ssh"</command>. The default is
406 <command>"ssh"</command>.</para>
411 <para>Related variables:<variablelist>
416 <para>The directory in which the svn checkouts will be performed..
417 The default is <command>${DL_DIR}/svn</command>.</para>
425 <para>A compressed tar archive of the retrieved files will be
426 placed in this directory. The archive name will be of the form:
427 <command>"<module>_<host>_<path>_<revn>_<date>.tar.gz"</command>.
428 Path separators in <command>path</command> and
429 <command>module</command> will be replaced with full stops.</para>
432 </variablelist></para>
438 <para>The git fetcher is used to retrieve files from a git repository.
439 <screen> SRC_URI = "git://www.denx.de/git/u-boot.git;protocol=git;tag=${TAG}"</screen></para>
441 <para>Supported options:</para>
448 <para>The tag to retrieve. The default is
449 <command>"master"</command>.</para>
454 <term>protocol</term>
457 <para>The method to use to access the repository. Common options are
458 <command>"git"</command> and <command>"rsync"</command>. The default
459 is <command>"rsync"</command>.</para>
464 <para>Related variables</para>
471 <para>The directory in which the git checkouts will be performed.
472 The default is <command>${DL_DIR}/git</command>.</para>
480 <para>A compressed tar archive of the retrieved files will be
481 placed in this directory. The archive name will be of the form:
482 <command>"git_<host><mpath>_<tag>.tar.gz"</command>.
483 Path separators in <command>host</command> will be replaced with
487 </variablelist></para>
491 <title>Mirrors</title>
493 <para>The support for mirror sites enables spreading the load over sites
494 and allows for downloads to occur even when one of the mirror sites are
497 <para>Default mirrors, along with their primary URL, include:</para>
501 <term>GNU_MIRROR</term>
504 <para>ftp://ftp.gnu.org/gnu</para>
509 <term>DEBIAN_MIRROR</term>
512 <para>ftp://ftp.debian.org/debian/pool</para>
517 <term>SOURCEFORGE_MIRROR</term>
520 <para>http://heanet.dl.sourceforge.net/sourceforge</para>
525 <term>GPE_MIRROR</term>
528 <para>http://handhelds.org/pub/projects/gpe/source</para>
533 <term>XLIBS_MIRROR</term>
536 <para>http://xlibs.freedesktop.org/release</para>
541 <term>XORG_MIRROR</term>
544 <para>http://xorg.freedesktop.org/releases</para>
549 <term>GNOME_MIRROR</term>
552 <para>http://ftp.gnome.org/pub/GNOME/sources</para>
557 <term>FREEBSD_MIRROR</term>
560 <para>ftp://ftp.freebsd.org/pub/FreeBSD</para>
565 <term>GENTOO_MIRROR</term>
568 <para>http://distfiles.gentoo.org/distfiles</para>
573 <term>APACHE_MIRROR</term>
576 <para>http://www.apache.org/dist</para>
581 <para>When creating new recipes this mirrors should be used when you wish
582 to use one of the above sites by referring to the name of the mirror in
583 the URI, as show in this example from flex:<screen>SRC_URI = "${SOURCEFORGE_MIRROR}/lex/flex-2.5.31.tar.bz2</screen></para>
585 <para>You can manually define your mirrors if you wish to force the use of
586 a specific mirror by exporting the appropriate mirrors in
587 <command>local.conf</command> with them set to the local mirror:<screen>export GNU_MIRROR = "http://www.planetmirror.com/pub/gnu"
588 export DEBIAN_MIRROR = "http://mirror.optusnet.com.au/debian/pool"
589 export SOURCEFORGE_MIRROR = "http://optusnet.dl.sourceforge.net/sourceforge"</screen></para>
591 <para>Mirrors can be extended in individual recipes via the use of
592 <command>MIRRORS_prepend</command> or <command>MIRRORS_append</command>.
593 Each entry in the list contains the mirror name on the left-hand side and
594 the URI of the mirror on the right-hand side. The following example from
595 libffi shows the addition of two URI for the
596 <command>"${GNU_MIRROR}/gcc/"</command> URI:<screen>MIRRORS_prepend () {
597 ${GNU_MIRROR}/gcc/ http://gcc.get-software.com/releases/
598 ${GNU_MIRROR}/gcc/ http://mirrors.rcn.net/pub/sourceware/gcc/releases/
603 <title>Manipulating SRC_URI</title>
605 <para>Sometimes it is desirable to only include patches for a specific
606 architecture and/or to include different files based on the architecture.
607 This can be done via the <command>SRC_URI_append</command> and/or
608 <command>SRC_URI_prepend</command> methods for adding additional URI's
609 based on the architecture or machine name.</para>
611 <para>In this example from glibc, the patch creates a configuration file
612 for glibc, which should only be used or the sh4 architecture. Therefore
613 this patch is appended to the <command>SRC_URI</command>, but only for the
614 sh4 architecture. For other architectures it is ignored:<screen># Build fails on sh4 unless no-z-defs is defined
615 SRC_URI_append_sh4 = " file://no-z-defs.patch;patch=1"</screen></para>
619 <title>Source distribution (src_distribute_local)</title>
621 <para>In order to obtain a set of source files for a build you can use the
622 <emphasis>src_distribute_local</emphasis> class. This will result in all
623 the files that were actually used during a build being made available in a
624 seperate directory and therefore they can be distributed with the
627 <para>Enabling this option is as simple as activating the functionality by
628 including the required class in one of your configuration files:<screen>SRC_DIST_LOCAL = "copy"
629 INHERIT += "src_distribute_local"</screen></para>
631 <para>Now during a build each recipe which has a LICENSE that mandates
632 source availability, like the GPL, will be placed into the source
633 distribution directory, <command>${SRC_DISTRIBUTEDIR}</command>, after
636 <para>There are some options available to effect the option</para>
640 <term>SRC_DIST_LOCAL</term>
643 <para>Specifies if the source files should be copied, symlinked or
644 moved and symlinked back. The default is
645 <command>"move+symlink"</command>.</para>
650 <term>SRC_DISTRIBUTEDIR</term>
653 <para>Specifies the source distribution directory - this is why the
654 source files that was used for the build are placed. The default is
655 <command>"${DEPLOY_DIR}/sources"</command>.</para>
660 <para>The valid values for <command>SRC_DIST_LOCAL</command> are:</para>
667 <para>Copies the files to the downloaded sources directory into the
668 distribution directory.</para>
676 <para>Symlinks the files from the downloaded sources directory into
677 the distribution directory.</para>
682 <term>move+symlink</term>
685 <para>Moves the files from the downloaded sources directory into the
686 distribution directory. Then creates a symlink in the download
687 sources directory to the moved files.</para>