base.bbclass: fix quoting for md5/sha256 checksums checking
[openembedded.git] / classes / package_tar.bbclass
index e94e763..b905e17 100644 (file)
@@ -1,20 +1,11 @@
 inherit package
 
-PACKAGE_EXTRA_DEPENDS += "tar-native"
-
-PACKAGE_WRITE_FUNCS += "do_package_tar"
-IMAGE_PKGTYPE ?= "tar"
-
 python package_tar_fn () {
-       import os
-       from bb import data
-       fn = os.path.join(bb.data.getVar('DEPLOY_DIR_TAR', d), "%s-%s-%s.tar.gz" % (bb.data.getVar('PKG', d), bb.data.getVar('PV', d), bb.data.getVar('PR', d)))
-       fn = bb.data.expand(fn, d)
+       fn = os.path.join(bb.data.getVar('DEPLOY_DIR_TAR', d, True), bb.data.expand('${PKG}-${PV}-${PR}${DISTRO_PR}.tar.gz', d, True))
        bb.data.setVar('PKGFN', fn, d)
 }
 
 python package_tar_install () {
-       import os, sys
        pkg = bb.data.getVar('PKG', d, 1)
        pkgfn = bb.data.getVar('PKGFN', d, 1)
        rootfs = bb.data.getVar('IMAGE_ROOTFS', d, 1)
@@ -26,6 +17,7 @@ python package_tar_install () {
                bb.mkdirhier(rootfs)
                os.chdir(rootfs)
        except OSError:
+               import sys
                (type, value, traceback) = sys.exc_info()
                print value
                raise bb.build.FuncFailed
@@ -45,7 +37,6 @@ python do_package_tar () {
                bb.error("WORKDIR not defined, unable to package")
                return
 
-       import os # path manipulations
        outdir = bb.data.getVar('DEPLOY_DIR_TAR', d, 1)
        if not outdir:
                bb.error("DEPLOY_DIR_TAR not defined, unable to package")
@@ -65,7 +56,8 @@ python do_package_tar () {
 
        for pkg in packages.split():
                localdata = bb.data.createCopy(d)
-               root = "%s/install/%s" % (workdir, pkg)
+               pkgdest = bb.data.getVar('PKGDEST', d, 1)
+               root = "%s/%s" % (pkgdest, pkg)
 
                bb.data.setVar('ROOT', '', localdata)
                bb.data.setVar('ROOT_%s' % pkg, root, localdata)
@@ -78,7 +70,7 @@ python do_package_tar () {
                bb.data.setVar('OVERRIDES', '%s:%s' % (overrides, pkg), localdata)
 
                bb.data.update_data(localdata)
-# stuff
+
                root = bb.data.getVar('ROOT', localdata)
                bb.mkdirhier(root)
                basedir = os.path.dirname(root)
@@ -86,20 +78,28 @@ python do_package_tar () {
                bb.mkdirhier(pkgoutdir)
                bb.build.exec_func('package_tar_fn', localdata)
                tarfn = bb.data.getVar('PKGFN', localdata, 1)
-#              if os.path.exists(tarfn):
-#                      del localdata
-#                      continue
                os.chdir(root)
                from glob import glob
-               if not glob('*'):
-                       bb.note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1)))
+               if not glob('*') + glob('.[!.]*'):
+                       bb.note("Not creating empty archive for %s-%s" % (pkg, bb.data.expand('${PV}-${PR}${DISTRO_PR}', d, True)))
                        continue
-               ret = os.system("tar -czvf %s %s" % (tarfn, '.'))
+               ret = os.system("tar -czf %s %s" % (tarfn, '.'))
                if ret != 0:
                        bb.error("Creation of tar %s failed." % tarfn)
+}
+
+python () {
+    if bb.data.getVar('PACKAGES', d, True) != '':
+        deps = (bb.data.getVarFlag('do_package_write_tar', 'depends', d) or "").split()
+        deps.append('tar-native:do_populate_staging')
+        deps.append('fakeroot-native:do_populate_staging')
+        bb.data.setVarFlag('do_package_write_tar', 'depends', " ".join(deps), d)
+}
 
-               file(bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s.packaged' % pkg, d), 'w').close()
 
-# end stuff
-               del localdata
+python do_package_write_tar () {
+       bb.build.exec_func("read_subpackage_metadata", d)
+       bb.build.exec_func("do_package_tar", d)
 }
+do_package_write_tar[dirs] = "${D}"
+addtask package_write_tar before do_build after do_package