Merge branch 'org.openembedded.dev' of git://git.openembedded.net/openembedded into...
[vuplus_openembedded] / classes / package.bbclass
index e014796..bcd9c98 100644 (file)
@@ -21,7 +21,7 @@ def legitimize_package_name(s):
        # Remaining package name validity fixes
        return s.lower().replace('_', '-').replace('@', '+').replace(',', '+').replace('/', '-')
 
-def do_split_packages(d, root, file_regex, output_pattern, description, postinst=None, recursive=False, hook=None, extra_depends=None, aux_files_pattern=None, postrm=None, allow_dirs=False, prepend=False, match_path=False, aux_files_pattern_verbatim=None):
+def do_split_packages(d, root, file_regex, output_pattern, description, postinst=None, recursive=False, hook=None, extra_depends=None, aux_files_pattern=None, postrm=None, allow_dirs=False, prepend=False, match_path=False, aux_files_pattern_verbatim=None, allow_links=False):
        """
        Used in .bb files to split up dynamically generated subpackages of a 
        given package, usually plugins or modules.
@@ -70,7 +70,7 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
                        continue
                f = os.path.join(dvar + root, o)
                mode = os.lstat(f).st_mode
-               if not (stat.S_ISREG(mode) or (allow_dirs and stat.S_ISDIR(mode))):
+               if not (stat.S_ISREG(mode) or (allow_links and stat.S_ISLNK(mode)) or (allow_dirs and stat.S_ISDIR(mode))):
                        continue
                on = legitimize_package_name(m.group(1))
                pkg = output_pattern % on
@@ -166,7 +166,7 @@ def runstrip(file, d):
     # If the file is in a .debug directory it was already stripped,
     # don't do it again...
     if os.path.dirname(file).endswith(".debug"):
-        bb.note("Already ran strip")
+        bb.debug(2, "Already ran strip on %s" % file)
         return 0
 
     strip = bb.data.getVar("STRIP", d, 1)
@@ -293,16 +293,6 @@ python package_do_split_locales() {
                bb.data.setVar('DESCRIPTION_' + pkg, '%s translation for %s' % (l, pn), d)
 
        bb.data.setVar('PACKAGES', ' '.join(packages), d)
-
-       # Disabled by RP 18/06/07
-       # Wildcards aren't supported in debian
-       # They break with ipkg since glibc-locale* will mean that 
-       # glibc-localedata-translit* won't install as a dependency
-       # for some other package which breaks meta-toolchain
-       # Probably breaks since virtual-locale- isn't provided anywhere
-       #rdep = (bb.data.getVar('RDEPENDS_%s' % mainpkg, d, 1) or bb.data.getVar('RDEPENDS', d, 1) or "").split()
-       #rdep.append('%s-locale*' % pn)
-       #bb.data.setVar('RDEPENDS_%s' % mainpkg, ' '.join(rdep), d)
 }
 
 python populate_packages () {
@@ -365,6 +355,8 @@ python populate_packages () {
        os.system('rm -rf %s' % pkgdest)
 
        seen = []
+       main_is_empty = 1
+       main_pkg = bb.data.getVar('PN', d, 1)
 
        for pkg in package_list:
                localdata = bb.data.createCopy(d)
@@ -392,10 +384,16 @@ python populate_packages () {
                        globbed = glob.glob(file)
                        if globbed:
                                if [ file ] != globbed:
-                                       files += globbed
-                                       continue
+                                       if not file in globbed:
+                                               files += globbed
+                                               continue
+                                       else:
+                                               globbed.remove(file)
+                                               files += globbed
                        if (not os.path.islink(file)) and (not os.path.exists(file)):
                                continue
+                       if file[-4:] == '.pyc':
+                               continue
                        if file in seen:
                                continue
                        seen.append(file)
@@ -409,6 +407,8 @@ python populate_packages () {
                        ret = bb.copyfile(file, fpath)
                        if ret is False or ret == 0:
                                raise bb.build.FuncFailed("File population failed")
+                       if pkg == main_pkg and main_is_empty:
+                               main_is_empty = 0
                del localdata
        os.chdir(workdir)
 
@@ -453,7 +453,11 @@ python populate_packages () {
                                        dangling_links[pkg].append(os.path.normpath(target))
 
        for pkg in package_list:
-               rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 1) or bb.data.getVar('RDEPENDS', d, 1) or "")
+               rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "")
+
+               remstr = "${PN} (= ${EXTENDPV})"
+               if main_is_empty and remstr in rdepends:
+                       rdepends.remove(remstr)
                for l in dangling_links[pkg]:
                        found = False
                        bb.debug(1, "%s contains dangling link %s" % (pkg, l))
@@ -485,6 +489,11 @@ python emit_pkgdata() {
                val = bb.data.getVar('%s_%s' % (var, pkg), d, 1)
                if val:
                        f.write('%s_%s: %s\n' % (var, pkg, encode(val)))
+                       return
+               val = bb.data.getVar('%s' % (var), d, 1)
+               if val:
+                       f.write('%s: %s\n' % (var, encode(val)))
+               return
 
        packages = bb.data.getVar('PACKAGES', d, True)
        pkgdatadir = bb.data.getVar('PKGDATA_DIR', d, True)
@@ -505,6 +514,7 @@ python emit_pkgdata() {
                subdata_file = pkgdatadir + "/runtime/%s" % pkg
                sf = open(subdata_file, 'w')
                write_if_exists(sf, pkg, 'PN')
+               write_if_exists(sf, pkg, 'PV')
                write_if_exists(sf, pkg, 'PR')
                write_if_exists(sf, pkg, 'DESCRIPTION')
                write_if_exists(sf, pkg, 'RDEPENDS')
@@ -543,7 +553,9 @@ emit_pkgdata[dirs] = "${PKGDATA_DIR}/runtime"
 
 ldconfig_postinst_fragment() {
 if [ x"$D" = "x" ]; then
-       [ -x /sbin/ldconfig ] && /sbin/ldconfig
+       if [ -e /etc/ld.so.conf ] ; then
+               [ -x /sbin/ldconfig ] && /sbin/ldconfig
+       fi
 fi
 }
 
@@ -554,7 +566,7 @@ python package_do_shlibs() {
 
        exclude_shlibs = bb.data.getVar('EXCLUDE_FROM_SHLIBS', d, 0)
        if exclude_shlibs:
-               bb.note("not generating shlibs")
+               bb.debug(1, "not generating shlibs")
                return
                
        lib_re = re.compile("^lib.*\.so")
@@ -581,6 +593,16 @@ python package_do_shlibs() {
        if pstageactive == "1":
                lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d))
 
+       if bb.data.getVar('PACKAGE_SNAP_LIB_SYMLINKS', d, True) == "1":
+               snap_symlinks = True
+       else:
+               snap_symlinks = False
+
+       if (bb.data.getVar('USE_LDCONFIG', d, True) or "1") == "1":
+               use_ldconfig = True
+       else:
+               use_ldconfig = False
+
        needed = {}
        private_libs = bb.data.getVar('PRIVATE_LIBS', d, 1)
        for pkg in packages.split():
@@ -590,11 +612,12 @@ python package_do_shlibs() {
                needed[pkg] = []
                sonames = list()
                top = os.path.join(pkgdest, pkg)
+               renames = []
                for root, dirs, files in os.walk(top):
                        for file in files:
                                soname = None
                                path = os.path.join(root, file)
-                               if os.access(path, os.X_OK) or lib_re.match(file):
+                               if (os.access(path, os.X_OK) or lib_re.match(file)) and not os.path.islink(path):
                                        cmd = bb.data.getVar('OBJDUMP', d, 1) + " -p " + path + " 2>/dev/null"
                                        cmd = "PATH=\"%s\" %s" % (bb.data.getVar('PATH', d, 1), cmd)
                                        fd = os.popen(cmd)
@@ -605,12 +628,18 @@ python package_do_shlibs() {
                                                if m:
                                                        needed[pkg].append(m.group(1))
                                                m = re.match("\s+SONAME\s+([^\s]*)", l)
-                                               if m and not m.group(1) in sonames:
-                                                       # if library is private (only used by package) then do not build shlib for it
-                                                       if not private_libs or -1 == private_libs.find(m.group(1)):
-                                                               sonames.append(m.group(1))
-                                               if m and libdir_re.match(root):
-                                                       needs_ldconfig = True
+                                               if m:
+                                                       this_soname = m.group(1)
+                                                       if not this_soname in sonames:
+                                                               # if library is private (only used by package) then do not build shlib for it
+                                                               if not private_libs or -1 == private_libs.find(this_soname):
+                                                                       sonames.append(this_soname)
+                                                       if libdir_re.match(root):
+                                                               needs_ldconfig = True
+                                                       if snap_symlinks and (file != soname):
+                                                               renames.append((path, os.path.join(root, this_soname)))
+               for (old, new) in renames:
+                       os.rename(old, new)
                shlibs_file = os.path.join(shlibs_dir, pkg + ".list")
                if os.path.exists(shlibs_file):
                        os.remove(shlibs_file)
@@ -627,7 +656,7 @@ python package_do_shlibs() {
                        fd.write(ver + '\n')
                        fd.close()
                        package_stagefile(shver_file, d)
-               if needs_ldconfig:
+               if needs_ldconfig and use_ldconfig:
                        bb.debug(1, 'adding ldconfig call to postinst for %s' % pkg)
                        postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1) or bb.data.getVar('pkg_postinst', d, 1)
                        if not postinst: