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