nm-applet: fix some buildproblems
[openembedded.git] / classes / base.bbclass
blobd29ba4bfcfd757c7eeb5213aec3e192bcb4cd487
1 BB_DEFAULT_TASK ?= "build"
3 # like os.path.join but doesn't treat absolute RHS specially
4 def base_path_join(a, *p):
5     path = a
6     for b in p:
7         if path == '' or path.endswith('/'):
8             path +=  b
9         else:
10             path += '/' + b
11     return path
13 def base_path_relative(src, dest):
14     """ Return a relative path from src to dest.
16     >>> base_path_relative("/usr/bin", "/tmp/foo/bar")
17     ../../tmp/foo/bar
19     >>> base_path_relative("/usr/bin", "/usr/lib")
20     ../lib
22     >>> base_path_relative("/tmp", "/tmp/foo/bar")
23     foo/bar
24     """
25     from os.path import sep, pardir, normpath, commonprefix
27     destlist = normpath(dest).split(sep)
28     srclist = normpath(src).split(sep)
30     # Find common section of the path
31     common = commonprefix([destlist, srclist])
32     commonlen = len(common)
34     # Climb back to the point where they differentiate
35     relpath = [ pardir ] * (len(srclist) - commonlen)
36     if commonlen < len(destlist):
37         # Add remaining portion
38         relpath += destlist[commonlen:]
40     return sep.join(relpath)
42 def base_path_out(path, d):
43     """ Prepare a path for display to the user. """
44     rel = base_path_relative(d.getVar("TOPDIR", 1), path)
45     if len(rel) > len(path):
46         return path
47     else:
48         return rel
50 # for MD5/SHA handling
51 def base_chk_load_parser(config_paths):
52     import ConfigParser, os, bb
53     parser = ConfigParser.ConfigParser()
54     if len(parser.read(config_paths)) < 1:
55         raise ValueError("no ini files could be found")
57     return parser
59 def base_chk_file(parser, pn, pv, src_uri, localpath, data):
60     import os, bb
61     no_checksum = False
62     # Try PN-PV-SRC_URI first and then try PN-SRC_URI
63     # we rely on the get method to create errors
64     pn_pv_src = "%s-%s-%s" % (pn,pv,src_uri)
65     pn_src    = "%s-%s" % (pn,src_uri)
66     if parser.has_section(pn_pv_src):
67         md5    = parser.get(pn_pv_src, "md5")
68         sha256 = parser.get(pn_pv_src, "sha256")
69     elif parser.has_section(pn_src):
70         md5    = parser.get(pn_src, "md5")
71         sha256 = parser.get(pn_src, "sha256")
72     elif parser.has_section(src_uri):
73         md5    = parser.get(src_uri, "md5")
74         sha256 = parser.get(src_uri, "sha256")
75     else:
76         no_checksum = True
78     # md5 and sha256 should be valid now
79     if not os.path.exists(localpath):
80         localpath = base_path_out(localpath, data)
81         bb.note("The localpath does not exist '%s'" % localpath)
82         raise Exception("The path does not exist '%s'" % localpath)
85     # call md5(sum) and shasum
86     try:
87         md5pipe = os.popen('PATH=%s md5sum %s' % (bb.data.getVar('PATH', data, True), localpath))
88         md5data = (md5pipe.readline().split() or [ "" ])[0]
89         md5pipe.close()
90     except OSError:
91         raise Exception("Executing md5sum failed")
93     try:
94         shapipe = os.popen('PATH=%s oe_sha256sum %s' % (bb.data.getVar('PATH', data, True), localpath))
95         shadata = (shapipe.readline().split() or [ "" ])[0]
96         shapipe.close()
97     except OSError:
98         raise Exception("Executing shasum failed")
100     if no_checksum == True:     # we do not have conf/checksums.ini entry
101         try:
102             file = open("%s/checksums.ini" % bb.data.getVar("TMPDIR", data, 1), "a")
103         except:
104             return False
106         if not file:
107             raise Exception("Creating checksums.ini failed")
108         
109         file.write("[%s]\nmd5=%s\nsha256=%s\n\n" % (src_uri, md5data, shadata))
110         file.close()
111         if not bb.data.getVar("OE_STRICT_CHECKSUMS",data, True):
112             bb.note("This package has no entry in checksums.ini, please add one")
113             bb.note("\n[%s]\nmd5=%s\nsha256=%s" % (src_uri, md5data, shadata))
114             return True
115         else:
116             bb.note("Missing checksum")
117             return False
119     if not md5 == md5data:
120         bb.note("The MD5Sums did not match. Wanted: '%s' and Got: '%s'" % (md5,md5data))
121         raise Exception("MD5 Sums do not match. Wanted: '%s' Got: '%s'" % (md5, md5data))
123     if not sha256 == shadata:
124         bb.note("The SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256,shadata))
125         raise Exception("SHA256 Sums do not match. Wanted: '%s' Got: '%s'" % (sha256, shadata))
127     return True
130 def base_dep_prepend(d):
131         import bb
132         #
133         # Ideally this will check a flag so we will operate properly in
134         # the case where host == build == target, for now we don't work in
135         # that case though.
136         #
137         deps = "shasum-native coreutils-native"
138         if bb.data.getVar('PN', d, True) == "shasum-native" or bb.data.getVar('PN', d, True) == "stagemanager-native":
139                 deps = ""
140         if bb.data.getVar('PN', d, True) == "coreutils-native":
141                 deps = "shasum-native"
143         # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command.  Whether or  not
144         # we need that built is the responsibility of the patch function / class, not
145         # the application.
146         if not bb.data.getVar('INHIBIT_DEFAULT_DEPS', d):
147                 if (bb.data.getVar('HOST_SYS', d, 1) !=
148                     bb.data.getVar('BUILD_SYS', d, 1)):
149                         deps += " virtual/${TARGET_PREFIX}gcc virtual/libc "
150         return deps
152 def base_read_file(filename):
153         import bb
154         try:
155                 f = file( filename, "r" )
156         except IOError, reason:
157                 return "" # WARNING: can't raise an error now because of the new RDEPENDS handling. This is a bit ugly. :M:
158         else:
159                 return f.read().strip()
160         return None
162 def base_ifelse(condition, iftrue = True, iffalse = False):
163     if condition:
164         return iftrue
165     else:
166         return iffalse
168 def base_conditional(variable, checkvalue, truevalue, falsevalue, d):
169         import bb
170         if bb.data.getVar(variable,d,1) == checkvalue:
171                 return truevalue
172         else:
173                 return falsevalue
175 def base_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
176         import bb
177         if float(bb.data.getVar(variable,d,1)) <= float(checkvalue):
178                 return truevalue
179         else:
180                 return falsevalue
182 def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
183     import bb
184     result = bb.vercmp(bb.data.getVar(variable,d,True), checkvalue)
185     if result <= 0:
186         return truevalue
187     else:
188         return falsevalue
190 def base_contains(variable, checkvalues, truevalue, falsevalue, d):
191         import bb
192         matches = 0
193         if type(checkvalues).__name__ == "str":
194                 checkvalues = [checkvalues]
195         for value in checkvalues:
196                 if bb.data.getVar(variable,d,1).find(value) != -1:      
197                         matches = matches + 1
198         if matches == len(checkvalues):
199                 return truevalue                
200         return falsevalue
202 def base_both_contain(variable1, variable2, checkvalue, d):
203        import bb
204        if bb.data.getVar(variable1,d,1).find(checkvalue) != -1 and bb.data.getVar(variable2,d,1).find(checkvalue) != -1:
205                return checkvalue
206        else:
207                return ""
209 DEPENDS_prepend="${@base_dep_prepend(d)} "
211 # Returns PN with various suffixes removed
212 # or PN if no matching suffix was found.
213 def base_package_name(d):
214   import bb;
216   pn = bb.data.getVar('PN', d, 1)
217   if pn.endswith("-native"):
218                 pn = pn[0:-7]
219   elif pn.endswith("-cross"):
220                 pn = pn[0:-6]
221   elif pn.endswith("-initial"):
222                 pn = pn[0:-8]
223   elif pn.endswith("-intermediate"):
224                 pn = pn[0:-13]
225   elif pn.endswith("-sdk"):
226                 pn = pn[0:-4]
229   return pn
231 def base_set_filespath(path, d):
232         import os, bb
233         bb.note("base_set_filespath usage is deprecated, %s should be fixed" % d.getVar("P", 1))
234         filespath = []
235         # The ":" ensures we have an 'empty' override
236         overrides = (bb.data.getVar("OVERRIDES", d, 1) or "") + ":"
237         for p in path:
238                 for o in overrides.split(":"):
239                         filespath.append(os.path.join(p, o))
240         return ":".join(filespath)
242 def oe_filter(f, str, d):
243         from re import match
244         return " ".join(filter(lambda x: match(f, x, 0), str.split()))
246 def oe_filter_out(f, str, d):
247         from re import match
248         return " ".join(filter(lambda x: not match(f, x, 0), str.split()))
250 die() {
251         oefatal "$*"
254 oenote() {
255         echo "NOTE:" "$*"
258 oewarn() {
259         echo "WARNING:" "$*"
262 oefatal() {
263         echo "FATAL:" "$*"
264         exit 1
267 oedebug() {
268         test $# -ge 2 || {
269                 echo "Usage: oedebug level \"message\""
270                 exit 1
271         }
273         test ${OEDEBUG:-0} -ge $1 && {
274                 shift
275                 echo "DEBUG:" $*
276         }
279 oe_runmake() {
280         if [ x"$MAKE" = x ]; then MAKE=make; fi
281         oenote ${MAKE} ${EXTRA_OEMAKE} "$@"
282         ${MAKE} ${EXTRA_OEMAKE} "$@" || die "oe_runmake failed"
285 oe_soinstall() {
286         # Purpose: Install shared library file and
287         #          create the necessary links
288         # Example:
289         #
290         # oe_
291         #
292         #oenote installing shared library $1 to $2
293         #
294         libname=`basename $1`
295         install -m 755 $1 $2/$libname
296         sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
297         solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
298         ln -sf $libname $2/$sonamelink
299         ln -sf $libname $2/$solink
302 oe_libinstall() {
303         # Purpose: Install a library, in all its forms
304         # Example
305         #
306         # oe_libinstall libltdl ${STAGING_LIBDIR}/
307         # oe_libinstall -C src/libblah libblah ${D}/${libdir}/
308         dir=""
309         libtool=""
310         silent=""
311         require_static=""
312         require_shared=""
313         staging_install=""
314         while [ "$#" -gt 0 ]; do
315                 case "$1" in
316                 -C)
317                         shift
318                         dir="$1"
319                         ;;
320                 -s)
321                         silent=1
322                         ;;
323                 -a)
324                         require_static=1
325                         ;;
326                 -so)
327                         require_shared=1
328                         ;;
329                 -*)
330                         oefatal "oe_libinstall: unknown option: $1"
331                         ;;
332                 *)
333                         break;
334                         ;;
335                 esac
336                 shift
337         done
339         libname="$1"
340         shift
341         destpath="$1"
342         if [ -z "$destpath" ]; then
343                 oefatal "oe_libinstall: no destination path specified"
344         fi
345         if echo "$destpath/" | egrep '^${STAGING_LIBDIR}/' >/dev/null
346         then
347                 staging_install=1
348         fi
350         __runcmd () {
351                 if [ -z "$silent" ]; then
352                         echo >&2 "oe_libinstall: $*"
353                 fi
354                 $*
355         }
357         if [ -z "$dir" ]; then
358                 dir=`pwd`
359         fi
361         dotlai=$libname.lai
363         # Sanity check that the libname.lai is unique
364         number_of_files=`(cd $dir; find . -name "$dotlai") | wc -l`
365         if [ $number_of_files -gt 1 ]; then
366                 oefatal "oe_libinstall: $dotlai is not unique in $dir"
367         fi
370         dir=$dir`(cd $dir;find . -name "$dotlai") | sed "s/^\.//;s/\/$dotlai\$//;q"`
371         olddir=`pwd`
372         __runcmd cd $dir
374         lafile=$libname.la
376         # If such file doesn't exist, try to cut version suffix
377         if [ ! -f "$lafile" ]; then
378                 libname1=`echo "$libname" | sed 's/-[0-9.]*$//'`
379                 lafile1=$libname.la
380                 if [ -f "$lafile1" ]; then
381                         libname=$libname1
382                         lafile=$lafile1
383                 fi
384         fi
386         if [ -f "$lafile" ]; then
387                 # libtool archive
388                 eval `cat $lafile|grep "^library_names="`
389                 libtool=1
390         else
391                 library_names="$libname.so* $libname.dll.a"
392         fi
394         __runcmd install -d $destpath/
395         dota=$libname.a
396         if [ -f "$dota" -o -n "$require_static" ]; then
397                 __runcmd install -m 0644 $dota $destpath/
398         fi
399         if [ -f "$dotlai" -a -n "$libtool" ]; then
400                 if test -n "$staging_install"
401                 then
402                         # stop libtool using the final directory name for libraries
403                         # in staging:
404                         __runcmd rm -f $destpath/$libname.la
405                         __runcmd sed -e 's/^installed=yes$/installed=no/' \
406                                      -e '/^dependency_libs=/s,${WORKDIR}[[:alnum:]/\._+-]*/\([[:alnum:]\._+-]*\),${STAGING_LIBDIR}/\1,g' \
407                                      -e "/^dependency_libs=/s,\([[:space:]']\)${libdir},\1${STAGING_LIBDIR},g" \
408                                      $dotlai >$destpath/$libname.la
409                 else
410                         __runcmd install -m 0644 $dotlai $destpath/$libname.la
411                 fi
412         fi
414         for name in $library_names; do
415                 files=`eval echo $name`
416                 for f in $files; do
417                         if [ ! -e "$f" ]; then
418                                 if [ -n "$libtool" ]; then
419                                         oefatal "oe_libinstall: $dir/$f not found."
420                                 fi
421                         elif [ -L "$f" ]; then
422                                 __runcmd cp -P "$f" $destpath/
423                         elif [ ! -L "$f" ]; then
424                                 libfile="$f"
425                                 __runcmd install -m 0755 $libfile $destpath/
426                         fi
427                 done
428         done
430         if [ -z "$libfile" ]; then
431                 if  [ -n "$require_shared" ]; then
432                         oefatal "oe_libinstall: unable to locate shared library"
433                 fi
434         elif [ -z "$libtool" ]; then
435                 # special case hack for non-libtool .so.#.#.# links
436                 baselibfile=`basename "$libfile"`
437                 if (echo $baselibfile | grep -qE '^lib.*\.so\.[0-9.]*$'); then
438                         sonamelink=`${HOST_PREFIX}readelf -d $libfile |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
439                         solink=`echo $baselibfile | sed -e 's/\.so\..*/.so/'`
440                         if [ -n "$sonamelink" -a x"$baselibfile" != x"$sonamelink" ]; then
441                                 __runcmd ln -sf $baselibfile $destpath/$sonamelink
442                         fi
443                         __runcmd ln -sf $baselibfile $destpath/$solink
444                 fi
445         fi
447         __runcmd cd "$olddir"
450 def package_stagefile(file, d):
451     import bb, os
453     if bb.data.getVar('PSTAGING_ACTIVE', d, True) == "1":
454         destfile = file.replace(bb.data.getVar("TMPDIR", d, 1), bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1))
455         bb.mkdirhier(os.path.dirname(destfile))
456         #print "%s to %s" % (file, destfile)
457         bb.copyfile(file, destfile)
459 package_stagefile_shell() {
460         if [ "$PSTAGING_ACTIVE" = "1" ]; then
461                 srcfile=$1
462                 destfile=`echo $srcfile | sed s#${TMPDIR}#${PSTAGE_TMPDIR_STAGE}#`
463                 destdir=`dirname $destfile`
464                 mkdir -p $destdir
465                 cp -dp $srcfile $destfile
466         fi
469 oe_machinstall() {
470         # Purpose: Install machine dependent files, if available
471         #          If not available, check if there is a default
472         #          If no default, just touch the destination
473         # Example:
474         #                $1  $2   $3         $4
475         # oe_machinstall -m 0644 fstab ${D}/etc/fstab
476         #
477         # TODO: Check argument number?
478         #
479         filename=`basename $3`
480         dirname=`dirname $3`
482         for o in `echo ${OVERRIDES} | tr ':' ' '`; do
483                 if [ -e $dirname/$o/$filename ]; then
484                         oenote $dirname/$o/$filename present, installing to $4
485                         install $1 $2 $dirname/$o/$filename $4
486                         return
487                 fi
488         done
489 #       oenote overrides specific file NOT present, trying default=$3...
490         if [ -e $3 ]; then
491                 oenote $3 present, installing to $4
492                 install $1 $2 $3 $4
493         else
494                 oenote $3 NOT present, touching empty $4
495                 touch $4
496         fi
499 addtask listtasks
500 do_listtasks[nostamp] = "1"
501 python do_listtasks() {
502         import sys
503         # emit variables and shell functions
504         #bb.data.emit_env(sys.__stdout__, d)
505         # emit the metadata which isnt valid shell
506         for e in d.keys():
507                 if bb.data.getVarFlag(e, 'task', d):
508                         sys.__stdout__.write("%s\n" % e)
511 addtask clean
512 do_clean[dirs] = "${TOPDIR}"
513 do_clean[nostamp] = "1"
514 python base_do_clean() {
515         """clear the build and temp directories"""
516         dir = bb.data.expand("${WORKDIR}", d)
517         if dir == '//': raise bb.build.FuncFailed("wrong DATADIR")
518         bb.note("removing " + base_path_out(dir, d))
519         os.system('rm -rf ' + dir)
521         dir = "%s.*" % bb.data.expand(bb.data.getVar('STAMP', d), d)
522         bb.note("removing " + base_path_out(dir, d))
523         os.system('rm -f '+ dir)
526 python do_cleanall() {
527     pass
529 do_cleanall[recrdeptask] = "do_clean"
530 addtask cleanall after do_clean
532 #Uncomment this for bitbake 1.8.12
533 #addtask rebuild after do_${BB_DEFAULT_TASK}
534 addtask rebuild
535 do_rebuild[dirs] = "${TOPDIR}"
536 do_rebuild[nostamp] = "1"
537 python base_do_rebuild() {
538         """rebuild a package"""
539         from bb import __version__
540         try:
541                 from distutils.version import LooseVersion
542         except ImportError:
543                 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
544         if (LooseVersion(__version__) < LooseVersion('1.8.11')):
545                 bb.build.exec_func('do_clean', d)
546                 bb.build.exec_task('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1), d)
549 addtask mrproper
550 do_mrproper[dirs] = "${TOPDIR}"
551 do_mrproper[nostamp] = "1"
552 python base_do_mrproper() {
553         """clear downloaded sources, build and temp directories"""
554         dir = bb.data.expand("${DL_DIR}", d)
555         if dir == '/': bb.build.FuncFailed("wrong DATADIR")
556         bb.debug(2, "removing " + dir)
557         os.system('rm -rf ' + dir)
558         bb.build.exec_func('do_clean', d)
561 addtask distclean
562 do_distclean[dirs] = "${TOPDIR}"
563 do_distclean[nostamp] = "1"
564 python base_do_distclean() {
565         """clear downloaded sources, build and temp directories"""
566         import os
568         bb.build.exec_func('do_clean', d)
570         src_uri = bb.data.getVar('SRC_URI', d, 1)
571         if not src_uri:
572                 return
574         for uri in src_uri.split():
575                 if bb.decodeurl(uri)[0] == "file":
576                         continue
578                 try:
579                         local = bb.data.expand(bb.fetch.localpath(uri, d), d)
580                 except bb.MalformedUrl, e:
581                         bb.debug(1, 'Unable to generate local path for malformed uri: %s' % e)
582                 else:
583                         bb.note("removing %s" % base_path_out(local, d))
584                         try:
585                                 if os.path.exists(local + ".md5"):
586                                         os.remove(local + ".md5")
587                                 if os.path.exists(local):
588                                         os.remove(local)
589                         except OSError, e:
590                                 bb.note("Error in removal: %s" % e)
593 SCENEFUNCS += "base_scenefunction"
594                                                                                         
595 python base_do_setscene () {
596         for f in (bb.data.getVar('SCENEFUNCS', d, 1) or '').split():
597                 bb.build.exec_func(f, d)
598         if not os.path.exists(bb.data.getVar('STAMP', d, 1) + ".do_setscene"):
599                 bb.build.make_stamp("do_setscene", d)
601 do_setscene[selfstamp] = "1"
602 addtask setscene before do_fetch
604 python base_scenefunction () {
605         stamp = bb.data.getVar('STAMP', d, 1) + ".needclean"
606         if os.path.exists(stamp):
607                 bb.build.exec_func("do_clean", d)
611 addtask fetch
612 do_fetch[dirs] = "${DL_DIR}"
613 do_fetch[depends] = "shasum-native:do_populate_staging"
614 python base_do_fetch() {
615         import sys
617         localdata = bb.data.createCopy(d)
618         bb.data.update_data(localdata)
620         src_uri = bb.data.getVar('SRC_URI', localdata, 1)
621         if not src_uri:
622                 return 1
624         try:
625                 bb.fetch.init(src_uri.split(),d)
626         except bb.fetch.NoMethodError:
627                 (type, value, traceback) = sys.exc_info()
628                 raise bb.build.FuncFailed("No method: %s" % value)
629         except bb.MalformedUrl:
630                 (type, value, traceback) = sys.exc_info()
631                 raise bb.build.FuncFailed("Malformed URL: %s" % value)
633         try:
634                 bb.fetch.go(localdata)
635         except bb.fetch.MissingParameterError:
636                 (type, value, traceback) = sys.exc_info()
637                 raise bb.build.FuncFailed("Missing parameters: %s" % value)
638         except bb.fetch.FetchError:
639                 (type, value, traceback) = sys.exc_info()
640                 raise bb.build.FuncFailed("Fetch failed: %s" % value)
641         except bb.fetch.MD5SumError:
642                 (type, value, traceback) = sys.exc_info()
643                 raise bb.build.FuncFailed("MD5  failed: %s" % value)
644         except:
645                 (type, value, traceback) = sys.exc_info()
646                 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
649         # Verify the SHA and MD5 sums we have in OE and check what do
650         # in
651         checksum_paths = bb.data.getVar('BBPATH', d, True).split(":")
653         # reverse the list to give precedence to directories that
654         # appear first in BBPATH
655         checksum_paths.reverse()
657         checksum_files = ["%s/conf/checksums.ini" % path for path in checksum_paths]
658         try:
659                 parser = base_chk_load_parser(checksum_files)
660         except ValueError:
661                 bb.note("No conf/checksums.ini found, not checking checksums")
662                 return
663         except:
664                 bb.note("Creating the CheckSum parser failed")
665                 return
667         pv = bb.data.getVar('PV', d, True)
668         pn = bb.data.getVar('PN', d, True)
670         # Check each URI
671         for url in src_uri.split():
672                 localpath = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
673                 (type,host,path,_,_,_) = bb.decodeurl(url)
674                 uri = "%s://%s%s" % (type,host,path)
675                 try:
676                         if type == "http" or type == "https" or type == "ftp" or type == "ftps":
677                                 if not base_chk_file(parser, pn, pv,uri, localpath, d):
678                                         if not bb.data.getVar("OE_ALLOW_INSECURE_DOWNLOADS",d, True):
679                                                 bb.fatal("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
680                                         else:
681                                                 bb.note("%s-%s: %s has no entry in conf/checksums.ini, not checking URI" % (pn,pv,uri))
682                 except Exception:
683                         raise bb.build.FuncFailed("Checksum of '%s' failed" % uri)
686 addtask fetchall after do_fetch
687 do_fetchall[recrdeptask] = "do_fetch"
688 base_do_fetchall() {
689         :
692 addtask checkuri
693 do_checkuri[nostamp] = "1"
694 python do_checkuri() {
695         import sys
697         localdata = bb.data.createCopy(d)
698         bb.data.update_data(localdata)
700         src_uri = bb.data.getVar('SRC_URI', localdata, 1)
702         try:
703                 bb.fetch.init(src_uri.split(),d)
704         except bb.fetch.NoMethodError:
705                 (type, value, traceback) = sys.exc_info()
706                 raise bb.build.FuncFailed("No method: %s" % value)
708         try:
709                 bb.fetch.checkstatus(localdata)
710         except bb.fetch.MissingParameterError:
711                 (type, value, traceback) = sys.exc_info()
712                 raise bb.build.FuncFailed("Missing parameters: %s" % value)
713         except bb.fetch.FetchError:
714                 (type, value, traceback) = sys.exc_info()
715                 raise bb.build.FuncFailed("Fetch failed: %s" % value)
716         except bb.fetch.MD5SumError:
717                 (type, value, traceback) = sys.exc_info()
718                 raise bb.build.FuncFailed("MD5  failed: %s" % value)
719         except:
720                 (type, value, traceback) = sys.exc_info()
721                 raise bb.build.FuncFailed("Unknown fetch Error: %s" % value)
724 addtask checkuriall after do_checkuri
725 do_checkuriall[recrdeptask] = "do_checkuri"
726 do_checkuriall[nostamp] = "1"
727 base_do_checkuriall() {
728         :
731 addtask buildall after do_build
732 do_buildall[recrdeptask] = "do_build"
733 base_do_buildall() {
734         :
737 def subprocess_setup():
738         import signal
739         # Python installs a SIGPIPE handler by default. This is usually not what
740         # non-Python subprocesses expect.
741         signal.signal(signal.SIGPIPE, signal.SIG_DFL)
743 def oe_unpack_file(file, data, url = None):
744         import bb, os, subprocess
745         if not url:
746                 url = "file://%s" % file
747         dots = file.split(".")
748         if dots[-1] in ['gz', 'bz2', 'Z']:
749                 efile = os.path.join(bb.data.getVar('WORKDIR', data, 1),os.path.basename('.'.join(dots[0:-1])))
750         else:
751                 efile = file
752         cmd = None
753         if file.endswith('.tar'):
754                 cmd = 'tar x --no-same-owner -f %s' % file
755         elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
756                 cmd = 'tar xz --no-same-owner -f %s' % file
757         elif file.endswith('.tbz') or file.endswith('.tbz2') or file.endswith('.tar.bz2'):
758                 cmd = 'bzip2 -dc %s | tar x --no-same-owner -f -' % file
759         elif file.endswith('.gz') or file.endswith('.Z') or file.endswith('.z'):
760                 cmd = 'gzip -dc %s > %s' % (file, efile)
761         elif file.endswith('.bz2'):
762                 cmd = 'bzip2 -dc %s > %s' % (file, efile)
763         elif file.endswith('.zip') or file.endswith('.jar'):
764                 cmd = 'unzip -q -o'
765                 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
766                 if 'dos' in parm:
767                         cmd = '%s -a' % cmd
768                 cmd = '%s %s' % (cmd, file)
769         elif os.path.isdir(file):
770                 destdir = "."
771                 filespath = bb.data.getVar("FILESPATH", data, 1).split(":")
772                 for fp in filespath:
773                         if file[0:len(fp)] == fp:
774                                 destdir = file[len(fp):file.rfind('/')]
775                                 destdir = destdir.strip('/')
776                                 if len(destdir) < 1:
777                                         destdir = "."
778                                 elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK):
779                                         os.makedirs("%s/%s" % (os.getcwd(), destdir))
780                                 break
782                 cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir)
783         else:
784                 (type, host, path, user, pswd, parm) = bb.decodeurl(url)
785                 if not 'patch' in parm:
786                         # The "destdir" handling was specifically done for FILESPATH
787                         # items.  So, only do so for file:// entries.
788                         if type == "file":
789                                 destdir = bb.decodeurl(url)[1] or "."
790                         else:
791                                 destdir = "."
792                         bb.mkdirhier("%s/%s" % (os.getcwd(), destdir))
793                         cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir)
795         if not cmd:
796                 return True
798         dest = os.path.join(os.getcwd(), os.path.basename(file))
799         if os.path.exists(dest):
800                 if os.path.samefile(file, dest):
801                         return True
803         # Change to subdir before executing command
804         save_cwd = os.getcwd();
805         parm = bb.decodeurl(url)[5]
806         if 'subdir' in parm:
807                 newdir = ("%s/%s" % (os.getcwd(), parm['subdir']))
808                 bb.mkdirhier(newdir)
809                 os.chdir(newdir)
811         cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', data, 1), cmd)
812         bb.note("Unpacking %s to %s/" % (base_path_out(file, data), base_path_out(os.getcwd(), data)))
813         ret = subprocess.call(cmd, preexec_fn=subprocess_setup, shell=True)
815         os.chdir(save_cwd)
817         return ret == 0
819 addtask unpack after do_fetch
820 do_unpack[dirs] = "${WORKDIR}"
821 python base_do_unpack() {
822         import re, os
824         localdata = bb.data.createCopy(d)
825         bb.data.update_data(localdata)
827         src_uri = bb.data.getVar('SRC_URI', localdata)
828         if not src_uri:
829                 return
830         src_uri = bb.data.expand(src_uri, localdata)
831         for url in src_uri.split():
832                 try:
833                         local = bb.data.expand(bb.fetch.localpath(url, localdata), localdata)
834                 except bb.MalformedUrl, e:
835                         raise bb.build.FuncFailed('Unable to generate local path for malformed uri: %s' % e)
836                 if not local:
837                         raise bb.build.FuncFailed('Unable to locate local file for %s' % url)
838                 local = os.path.realpath(local)
839                 ret = oe_unpack_file(local, localdata, url)
840                 if not ret:
841                         raise bb.build.FuncFailed()
844 METADATA_SCM = "${@base_get_scm(d)}"
845 METADATA_REVISION = "${@base_get_scm_revision(d)}"
846 METADATA_BRANCH = "${@base_get_scm_branch(d)}"
848 def base_get_scm(d):
849         import os
850         from bb import which
851         baserepo = os.path.dirname(os.path.dirname(which(d.getVar("BBPATH", 1), "classes/base.bbclass")))
852         for (scm, scmpath) in {"svn": ".svn",
853                                "git": ".git",
854                                "monotone": "_MTN"}.iteritems():
855                 if os.path.exists(os.path.join(baserepo, scmpath)):
856                         return "%s %s" % (scm, baserepo)
857         return "<unknown> %s" % baserepo
859 def base_get_scm_revision(d):
860         (scm, path) = d.getVar("METADATA_SCM", 1).split()
861         try:
862                 if scm != "<unknown>":
863                         return globals()["base_get_metadata_%s_revision" % scm](path, d)
864                 else:
865                         return scm
866         except KeyError:
867                 return "<unknown>"
869 def base_get_scm_branch(d):
870         (scm, path) = d.getVar("METADATA_SCM", 1).split()
871         try:
872                 if scm != "<unknown>":
873                         return globals()["base_get_metadata_%s_branch" % scm](path, d)
874                 else:
875                         return scm
876         except KeyError:
877                 return "<unknown>"
879 def base_get_metadata_monotone_branch(path, d):
880         monotone_branch = "<unknown>"
881         try:
882                 monotone_branch = file( "%s/_MTN/options" % path ).read().strip()
883                 if monotone_branch.startswith( "database" ):
884                         monotone_branch_words = monotone_branch.split()
885                         monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
886         except:
887                 pass
888         return monotone_branch
890 def base_get_metadata_monotone_revision(path, d):
891         monotone_revision = "<unknown>"
892         try:
893                 monotone_revision = file( "%s/_MTN/revision" % path ).read().strip()
894                 if monotone_revision.startswith( "format_version" ):
895                         monotone_revision_words = monotone_revision.split()
896                         monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
897         except IOError:
898                 pass
899         return monotone_revision
901 def base_get_metadata_svn_revision(path, d):
902         revision = "<unknown>"
903         try:
904                 revision = file( "%s/.svn/entries" % path ).readlines()[3].strip()
905         except IOError:
906                 pass
907         return revision
909 def base_get_metadata_git_branch(path, d):
910         import os
911         branch = os.popen('cd %s; PATH=%s git symbolic-ref HEAD 2>/dev/null' % (path, d.getVar("PATH", 1))).read().rstrip()
913         if len(branch) != 0:
914                 return branch.replace("refs/heads/", "")
915         return "<unknown>"
917 def base_get_metadata_git_revision(path, d):
918         import os
919         rev = os.popen("cd %s; PATH=%s git show-ref HEAD 2>/dev/null" % (path, d.getVar("PATH", 1))).read().split(" ")[0].rstrip()
920         if len(rev) != 0:
921                 return rev
922         return "<unknown>"
925 addhandler base_eventhandler
926 python base_eventhandler() {
927         from bb import note, error, data
928         from bb.event import Handled, NotHandled, getName
929         import os
931         name = getName(e)
932         if name == "TaskCompleted":
933                 msg = "package %s: task %s is complete." % (data.getVar("PF", e.data, 1), e.task)
934         elif name == "UnsatisfiedDep":
935                 msg = "package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower())
936         else:
937                 return NotHandled
939         # Only need to output when using 1.8 or lower, the UI code handles it
940         # otherwise
941         if (int(bb.__version__.split(".")[0]) <= 1 and int(bb.__version__.split(".")[1]) <= 8):
942                 if msg:
943                         note(msg)
945         if name.startswith("BuildStarted"):
946                 bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
947                 statusvars = bb.data.getVar("BUILDCFG_VARS", e.data, 1).split()
948                 statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
949                 statusmsg = "\n%s\n%s\n" % (bb.data.getVar("BUILDCFG_HEADER", e.data, 1), "\n".join(statuslines))
950                 print statusmsg
952                 needed_vars = bb.data.getVar("BUILDCFG_NEEDEDVARS", e.data, 1).split()
953                 pesteruser = []
954                 for v in needed_vars:
955                         val = bb.data.getVar(v, e.data, 1)
956                         if not val or val == 'INVALID':
957                                 pesteruser.append(v)
958                 if pesteruser:
959                         bb.fatal('The following variable(s) were not set: %s\nPlease set them directly, or choose a MACHINE or DISTRO that sets them.' % ', '.join(pesteruser))
961         #
962         # Handle removing stamps for 'rebuild' task
963         #
964         if name.startswith("StampUpdate"):
965                 for (fn, task) in e.targets:
966                         #print "%s %s" % (task, fn)         
967                         if task == "do_rebuild":
968                                 dir = "%s.*" % e.stampPrefix[fn]
969                                 bb.note("Removing stamps: " + dir)
970                                 os.system('rm -f '+ dir)
971                                 os.system('touch ' + e.stampPrefix[fn] + '.needclean')
973         if not data in e.__dict__:
974                 return NotHandled
976         log = data.getVar("EVENTLOG", e.data, 1)
977         if log:
978                 logfile = file(log, "a")
979                 logfile.write("%s\n" % msg)
980                 logfile.close()
982         return NotHandled
985 addtask configure after do_unpack do_patch
986 do_configure[dirs] = "${S} ${B}"
987 do_configure[deptask] = "do_populate_staging"
988 base_do_configure() {
989         :
992 addtask compile after do_configure
993 do_compile[dirs] = "${S} ${B}"
994 base_do_compile() {
995         if [ -e Makefile -o -e makefile ]; then
996                 oe_runmake || die "make failed"
997         else
998                 oenote "nothing to compile"
999         fi
1002 base_do_stage () {
1003         :
1006 do_populate_staging[dirs] = "${STAGING_DIR_TARGET}/${layout_bindir} ${STAGING_DIR_TARGET}/${layout_libdir} \
1007                              ${STAGING_DIR_TARGET}/${layout_includedir} \
1008                              ${STAGING_BINDIR_NATIVE} ${STAGING_LIBDIR_NATIVE} \
1009                              ${STAGING_INCDIR_NATIVE} \
1010                              ${STAGING_DATADIR} \
1011                              ${S} ${B}"
1013 # Could be compile but populate_staging and do_install shouldn't run at the same time
1014 addtask populate_staging after do_install
1016 python do_populate_staging () {
1017     bb.build.exec_func('do_stage', d)
1020 addtask install after do_compile
1021 do_install[dirs] = "${D} ${S} ${B}"
1022 # Remove and re-create ${D} so that is it guaranteed to be empty
1023 do_install[cleandirs] = "${D}"
1025 base_do_install() {
1026         :
1029 base_do_package() {
1030         :
1033 addtask build after do_populate_staging
1034 do_build = ""
1035 do_build[func] = "1"
1037 # Functions that update metadata based on files outputted
1038 # during the build process.
1040 def explode_deps(s):
1041         r = []
1042         l = s.split()
1043         flag = False
1044         for i in l:
1045                 if i[0] == '(':
1046                         flag = True
1047                         j = []
1048                 if flag:
1049                         j.append(i)
1050                         if i.endswith(')'):
1051                                 flag = False
1052                                 r[-1] += ' ' + ' '.join(j)
1053                 else:
1054                         r.append(i)
1055         return r
1057 def packaged(pkg, d):
1058         import os, bb
1059         return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK)
1061 def read_pkgdatafile(fn):
1062         pkgdata = {}
1064         def decode(str):
1065                 import codecs
1066                 c = codecs.getdecoder("string_escape")
1067                 return c(str)[0]
1069         import os
1070         if os.access(fn, os.R_OK):
1071                 import re
1072                 f = file(fn, 'r')
1073                 lines = f.readlines()
1074                 f.close()
1075                 r = re.compile("([^:]+):\s*(.*)")
1076                 for l in lines:
1077                         m = r.match(l)
1078                         if m:
1079                                 pkgdata[m.group(1)] = decode(m.group(2))
1081         return pkgdata
1083 def get_subpkgedata_fn(pkg, d):
1084         import bb, os
1085         archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ")
1086         archs.reverse()
1087         pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d)
1088         targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d)
1089         for arch in archs:
1090                 fn = pkgdata + arch + targetdir + pkg
1091                 if os.path.exists(fn):
1092                         return fn
1093         return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d)
1095 def has_subpkgdata(pkg, d):
1096         import bb, os
1097         return os.access(get_subpkgedata_fn(pkg, d), os.R_OK)
1099 def read_subpkgdata(pkg, d):
1100         import bb
1101         return read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1103 def has_pkgdata(pn, d):
1104         import bb, os
1105         fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1106         return os.access(fn, os.R_OK)
1108 def read_pkgdata(pn, d):
1109         import bb
1110         fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d)
1111         return read_pkgdatafile(fn)
1113 python read_subpackage_metadata () {
1114         import bb
1115         data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
1117         for key in data.keys():
1118                 bb.data.setVar(key, data[key], d)
1120         for pkg in bb.data.getVar('PACKAGES', d, 1).split():
1121                 sdata = read_subpkgdata(pkg, d)
1122                 for key in sdata.keys():
1123                         bb.data.setVar(key, sdata[key], d)
1128 # Collapse FOO_pkg variables into FOO
1130 def read_subpkgdata_dict(pkg, d):
1131         import bb
1132         ret = {}
1133         subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d))
1134         for var in subd:
1135                 newvar = var.replace("_" + pkg, "")
1136                 ret[newvar] = subd[var]
1137         return ret
1139 # Make sure MACHINE isn't exported
1140 # (breaks binutils at least)
1141 MACHINE[unexport] = "1"
1143 # Make sure TARGET_ARCH isn't exported
1144 # (breaks Makefiles using implicit rules, e.g. quilt, as GNU make has this 
1145 # in them, undocumented)
1146 TARGET_ARCH[unexport] = "1"
1148 # Make sure DISTRO isn't exported
1149 # (breaks sysvinit at least)
1150 DISTRO[unexport] = "1"
1153 def base_after_parse(d):
1154     import bb, os, exceptions
1156     source_mirror_fetch = bb.data.getVar('SOURCE_MIRROR_FETCH', d, 0)
1157     if not source_mirror_fetch:
1158         need_host = bb.data.getVar('COMPATIBLE_HOST', d, 1)
1159         if need_host:
1160             import re
1161             this_host = bb.data.getVar('HOST_SYS', d, 1)
1162             if not re.match(need_host, this_host):
1163                 raise bb.parse.SkipPackage("incompatible with host %s" % this_host)
1165         need_machine = bb.data.getVar('COMPATIBLE_MACHINE', d, 1)
1166         if need_machine:
1167             import re
1168             this_machine = bb.data.getVar('MACHINE', d, 1)
1169             if this_machine and not re.match(need_machine, this_machine):
1170                 raise bb.parse.SkipPackage("incompatible with machine %s" % this_machine)
1172     pn = bb.data.getVar('PN', d, 1)
1174     # OBSOLETE in bitbake 1.7.4
1175     srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1)
1176     if srcdate != None:
1177         bb.data.setVar('SRCDATE', srcdate, d)
1179     use_nls = bb.data.getVar('USE_NLS_%s' % pn, d, 1)
1180     if use_nls != None:
1181         bb.data.setVar('USE_NLS', use_nls, d)
1183     # Git packages should DEPEND on git-native
1184     srcuri = bb.data.getVar('SRC_URI', d, 1)
1185     if "git://" in srcuri:
1186         depends = bb.data.getVarFlag('do_fetch', 'depends', d) or ""
1187         depends = depends + " git-native:do_populate_staging"
1188         bb.data.setVarFlag('do_fetch', 'depends', depends, d)
1190     # 'multimachine' handling
1191     mach_arch = bb.data.getVar('MACHINE_ARCH', d, 1)
1192     pkg_arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
1194     if (pkg_arch == mach_arch):
1195         # Already machine specific - nothing further to do
1196         return
1198     #
1199     # We always try to scan SRC_URI for urls with machine overrides
1200     # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
1201     #
1202     override = bb.data.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', d, 1)
1203     if override != '0':
1204         paths = []
1205         for p in [ "${PF}", "${P}", "${PN}", "files", "" ]:
1206             path = bb.data.expand(os.path.join("${FILE_DIRNAME}", p, "${MACHINE}"), d)
1207             if os.path.isdir(path):
1208                 paths.append(path)
1209         if len(paths) != 0:
1210             for s in srcuri.split():
1211                 if not s.startswith("file://"):
1212                     continue
1213                 local = bb.data.expand(bb.fetch.localpath(s, d), d)
1214                 for mp in paths:
1215                     if local.startswith(mp):
1216                         #bb.note("overriding PACKAGE_ARCH from %s to %s" % (pkg_arch, mach_arch))
1217                         bb.data.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}", d)
1218                         bb.data.setVar('MULTIMACH_ARCH', mach_arch, d)
1219                         return
1221     multiarch = pkg_arch
1223     packages = bb.data.getVar('PACKAGES', d, 1).split()
1224     for pkg in packages:
1225         pkgarch = bb.data.getVar("PACKAGE_ARCH_%s" % pkg, d, 1)
1227         # We could look for != PACKAGE_ARCH here but how to choose 
1228         # if multiple differences are present?
1229         # Look through PACKAGE_ARCHS for the priority order?
1230         if pkgarch and pkgarch == mach_arch:
1231             multiarch = mach_arch
1232             break
1234     bb.data.setVar('MULTIMACH_ARCH', multiarch, d)
1236 python () {
1237     import bb
1238     from bb import __version__
1239     base_after_parse(d)
1241     # Remove this for bitbake 1.8.12
1242     try:
1243         from distutils.version import LooseVersion
1244     except ImportError:
1245         def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
1246     if (LooseVersion(__version__) >= LooseVersion('1.8.11')):
1247         deps = bb.data.getVarFlag('do_rebuild', 'deps', d) or []
1248         deps.append('do_' + bb.data.getVar('BB_DEFAULT_TASK', d, 1))
1249         bb.data.setVarFlag('do_rebuild', 'deps', deps, d)
1252 def check_app_exists(app, d):
1253         from bb import which, data
1255         app = data.expand(app, d)
1256         path = data.getVar('PATH', d, 1)
1257         return len(which(path, app)) != 0
1259 def check_gcc3(data):
1260         # Primarly used by qemu to make sure we have a workable gcc-3.4.x.
1261         # Start by checking for the program name as we build it, was not
1262         # all host-provided gcc-3.4's will work.
1264         gcc3_versions = 'gcc-3.4.6 gcc-3.4.4 gcc34 gcc-3.4 gcc-3.4.7 gcc-3.3 gcc33 gcc-3.3.6 gcc-3.2 gcc32'
1266         for gcc3 in gcc3_versions.split():
1267                 if check_app_exists(gcc3, data):
1268                         return gcc3
1269         
1270         return False
1272 # Patch handling
1273 inherit patch
1275 # Configuration data from site files
1276 # Move to autotools.bbclass?
1277 inherit siteinfo
1279 EXPORT_FUNCTIONS do_setscene do_clean do_mrproper do_distclean do_fetch do_unpack do_configure do_compile do_install do_package do_populate_pkgs do_stage do_rebuild do_fetchall
1281 MIRRORS[func] = "0"
1282 MIRRORS () {
1283 ${DEBIAN_MIRROR}/main   http://snapshot.debian.net/archive/pool
1284 ${DEBIAN_MIRROR}        ftp://ftp.de.debian.org/debian/pool
1285 ${DEBIAN_MIRROR}        ftp://ftp.au.debian.org/debian/pool
1286 ${DEBIAN_MIRROR}        ftp://ftp.cl.debian.org/debian/pool
1287 ${DEBIAN_MIRROR}        ftp://ftp.hr.debian.org/debian/pool
1288 ${DEBIAN_MIRROR}        ftp://ftp.fi.debian.org/debian/pool
1289 ${DEBIAN_MIRROR}        ftp://ftp.hk.debian.org/debian/pool
1290 ${DEBIAN_MIRROR}        ftp://ftp.hu.debian.org/debian/pool
1291 ${DEBIAN_MIRROR}        ftp://ftp.ie.debian.org/debian/pool
1292 ${DEBIAN_MIRROR}        ftp://ftp.it.debian.org/debian/pool
1293 ${DEBIAN_MIRROR}        ftp://ftp.jp.debian.org/debian/pool
1294 ${DEBIAN_MIRROR}        ftp://ftp.no.debian.org/debian/pool
1295 ${DEBIAN_MIRROR}        ftp://ftp.pl.debian.org/debian/pool
1296 ${DEBIAN_MIRROR}        ftp://ftp.ro.debian.org/debian/pool
1297 ${DEBIAN_MIRROR}        ftp://ftp.si.debian.org/debian/pool
1298 ${DEBIAN_MIRROR}        ftp://ftp.es.debian.org/debian/pool
1299 ${DEBIAN_MIRROR}        ftp://ftp.se.debian.org/debian/pool
1300 ${DEBIAN_MIRROR}        ftp://ftp.tr.debian.org/debian/pool
1301 ${GNU_MIRROR}   ftp://mirrors.kernel.org/gnu
1302 ${GNU_MIRROR}   ftp://ftp.cs.ubc.ca/mirror2/gnu
1303 ${GNU_MIRROR}   ftp://sunsite.ust.hk/pub/gnu
1304 ${GNU_MIRROR}   ftp://ftp.ayamura.org/pub/gnu
1305 ${KERNELORG_MIRROR}     http://www.kernel.org/pub
1306 ${KERNELORG_MIRROR}     ftp://ftp.us.kernel.org/pub
1307 ${KERNELORG_MIRROR}     ftp://ftp.uk.kernel.org/pub
1308 ${KERNELORG_MIRROR}     ftp://ftp.hk.kernel.org/pub
1309 ${KERNELORG_MIRROR}     ftp://ftp.au.kernel.org/pub
1310 ${KERNELORG_MIRROR}     ftp://ftp.jp.kernel.org/pub
1311 ftp://ftp.gnupg.org/gcrypt/     ftp://ftp.franken.de/pub/crypt/mirror/ftp.gnupg.org/gcrypt/
1312 ftp://ftp.gnupg.org/gcrypt/     ftp://ftp.surfnet.nl/pub/security/gnupg/
1313 ftp://ftp.gnupg.org/gcrypt/     http://gulus.USherbrooke.ca/pub/appl/GnuPG/
1314 ftp://dante.ctan.org/tex-archive ftp://ftp.fu-berlin.de/tex/CTAN
1315 ftp://dante.ctan.org/tex-archive http://sunsite.sut.ac.jp/pub/archives/ctan/
1316 ftp://dante.ctan.org/tex-archive http://ctan.unsw.edu.au/
1317 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnutls.org/pub/gnutls/
1318 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.gnupg.org/gcrypt/gnutls/
1319 ftp://ftp.gnutls.org/pub/gnutls http://www.mirrors.wiretapped.net/security/network-security/gnutls/
1320 ftp://ftp.gnutls.org/pub/gnutls ftp://ftp.mirrors.wiretapped.net/pub/security/network-security/gnutls/
1321 ftp://ftp.gnutls.org/pub/gnutls http://josefsson.org/gnutls/releases/
1322 http://ftp.info-zip.org/pub/infozip/src/ http://mirror.switch.ch/ftp/mirror/infozip/src/
1323 http://ftp.info-zip.org/pub/infozip/src/ ftp://sunsite.icm.edu.pl/pub/unix/archiving/info-zip/src/
1324 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/
1325 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.tau.ac.il/pub/unix/admin/
1326 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.cert.dfn.de/pub/tools/admin/lsof/
1327 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/
1328 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.kaizo.org/pub/lsof/
1329 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.tu-darmstadt.de/pub/sysadmin/lsof/
1330 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://ftp.tux.org/pub/sites/vic.cc.purdue.edu/tools/unix/lsof/
1331 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://gd.tuwien.ac.at/utils/admin-tools/lsof/
1332 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://sunsite.ualberta.ca/pub/Mirror/lsof/
1333 ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/  ftp://the.wiretapped.net/pub/security/host-security/lsof/
1334 http://www.apache.org/dist  http://archive.apache.org/dist
1335 ftp://.*/.*     http://mirrors.openembedded.org/
1336 https?$://.*/.* http://mirrors.openembedded.org/
1337 ftp://.*/.*     http://sources.openembedded.org/
1338 https?$://.*/.* http://sources.openembedded.org/