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