summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/base.bbclass1
-rw-r--r--classes/package.bbclass11
-rw-r--r--classes/package_ipk.bbclass9
-rw-r--r--classes/package_rpm.bbclass134
-rw-r--r--classes/package_tar.bbclass100
5 files changed, 241 insertions, 14 deletions
diff --git a/classes/base.bbclass b/classes/base.bbclass
index f09968e612..d80ce3010b 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -686,7 +686,6 @@ python __anonymous () {
try:
bb.build.exec_func('read_manifest', d)
bb.build.exec_func('parse_manifest', d)
- bb.build.exec_func('read_shlibdeps', d)
except exceptions.KeyboardInterrupt:
raise
except Exception, e:
diff --git a/classes/package.bbclass b/classes/package.bbclass
index ca2d90c697..53ec3b8e28 100644
--- a/classes/package.bbclass
+++ b/classes/package.bbclass
@@ -560,13 +560,12 @@ python package_do_split_locales() {
bb.data.setVar('RDEPENDS_%s' % mainpkg, ' '.join(rdep), d)
}
+PACKAGEFUNCS = "do_install package_do_split_locales \
+ populate_packages package_do_shlibs \
+ package_do_pkgconfig read_shlibdeps"
python package_do_package () {
- bb.build.exec_func('do_install', d)
- bb.build.exec_func('package_do_split_locales', d)
- bb.build.exec_func('populate_packages', d)
- bb.build.exec_func('package_do_shlibs', d)
- bb.build.exec_func('package_do_pkgconfig', d)
- bb.build.exec_func('read_shlibdeps', d)
+ for f in (bb.data.getVar('PACKAGEFUNCS', d, 1) or '').split():
+ bb.build.exec_func(f, d)
}
do_package[dirs] = "${D}"
diff --git a/classes/package_ipk.bbclass b/classes/package_ipk.bbclass
index f4d816adad..1119502bc8 100644
--- a/classes/package_ipk.bbclass
+++ b/classes/package_ipk.bbclass
@@ -2,6 +2,7 @@ inherit package
DEPENDS_prepend="${@["ipkg-utils-native ", ""][(bb.data.getVar('PACKAGES', d, 1) == '')]}"
BOOTSTRAP_EXTRA_RDEPENDS += "ipkg-collateral ipkg ipkg-link"
BOOTSTRAP_EXTRA_DEPENDS += "ipkg-collateral ipkg ipkg-link"
+PACKAGEFUNCS += "do_package_ipk"
python package_ipk_fn () {
from bb import data
@@ -59,12 +60,10 @@ python package_ipk_install () {
raise bb.build.FuncFailed
}
-python package_ipk_do_package_ipk () {
+python do_package_ipk () {
import copy # to back up env data
import sys
- bb.build.exec_func('read_subpackage_metadata', d)
-
workdir = bb.data.getVar('WORKDIR', d, 1)
if not workdir:
bb.error("WORKDIR not defined, unable to package")
@@ -226,7 +225,3 @@ python package_ipk_do_package_ipk () {
pass
del localdata
}
-
-EXPORT_FUNCTIONS do_package_ipk
-
-addtask package_ipk after do_package before do_build
diff --git a/classes/package_rpm.bbclass b/classes/package_rpm.bbclass
index e69de29bb2..ff5e4ee3a8 100644
--- a/classes/package_rpm.bbclass
+++ b/classes/package_rpm.bbclass
@@ -0,0 +1,134 @@
+inherit package
+inherit rpm_core
+
+RPMBUILD="rpmbuild --short-circuit ${RPMOPTS}"
+PACKAGEFUNCS += "do_package_rpm"
+
+python write_specfile() {
+ from bb import data, build
+ import sys
+ out_vartranslate = {
+ "PKG": "Name",
+ "PV": "Version",
+ "PR": "Release",
+ "DESCRIPTION": "%description",
+ "ROOT": "BuildRoot",
+ "LICENSE": "License",
+ "SECTION": "Group",
+ }
+
+ root = bb.data.getVar('ROOT', d)
+
+ # get %files
+ filesvar = bb.data.expand(bb.data.getVar('FILES', d), d) or ""
+ from glob import glob
+ files = filesvar.split()
+ todelete = []
+ for file in files:
+ if file[0] == '.':
+ newfile = file[1:]
+ files[files.index(file)] = newfile
+ file = newfile
+ else:
+ newfile = file
+ realfile = os.path.join(root, './'+file)
+ if not glob(realfile):
+ todelete.append(files[files.index(newfile)])
+ for r in todelete:
+ try:
+ del files[files.index(r)]
+ except ValueError:
+ pass
+ if not files:
+ from bb import note
+ note("Not creating empty archive for %s-%s-%s" % (bb.data.getVar('PKG',d, 1), bb.data.getVar('PV', d, 1), bb.data.getVar('PR', d, 1)))
+ return
+
+ # output .spec using this metadata store
+ try:
+ from __builtin__ import file
+ if not bb.data.getVar('OUTSPECFILE', d):
+ raise OSError('eek!')
+ specfile = file(bb.data.getVar('OUTSPECFILE', d), 'w')
+ except OSError:
+ raise bb.build.FuncFailed("unable to open spec file for writing.")
+
+# fd = sys.__stdout__
+ fd = specfile
+ for var in out_vartranslate.keys():
+ if out_vartranslate[var][0] == "%":
+ continue
+ fd.write("%s\t: %s\n" % (out_vartranslate[var], bb.data.getVar(var, d)))
+ fd.write("Summary\t: .\n")
+
+ for var in out_vartranslate.keys():
+ if out_vartranslate[var][0] != "%":
+ continue
+ fd.write(out_vartranslate[var] + "\n")
+ fd.write(bb.data.getVar(var, d) + "\n\n")
+
+ fd.write("%files\n")
+ for file in files:
+ fd.write("%s\n" % file)
+
+ fd.close()
+
+ # call out rpm -bb on the .spec, thereby creating an rpm
+
+ bb.data.setVar('BUILDSPEC', "${RPMBUILD} -bb ${OUTSPECFILE}\n", d)
+ bb.data.setVarFlag('BUILDSPEC', 'func', '1', d)
+ bb.build.exec_func('BUILDSPEC', d)
+
+ # move the rpm into the pkgoutdir
+ rpm = bb.data.expand('${RPMBUILDPATH}/RPMS/${TARGET_ARCH}/${PKG}-${PV}-${PR}.${TARGET_ARCH}.rpm', d)
+ outrpm = bb.data.expand('${DEPLOY_DIR_RPM}/${PKG}-${PV}-${PR}.${TARGET_ARCH}.rpm', d)
+ bb.movefile(rpm, outrpm)
+}
+
+python do_package_rpm () {
+ workdir = bb.data.getVar('WORKDIR', d)
+ if not workdir:
+ raise bb.build.FuncFailed("WORKDIR not defined")
+ workdir = bb.data.expand(workdir, d)
+
+ import os # path manipulations
+ outdir = bb.data.getVar('DEPLOY_DIR_RPM', d)
+ if not outdir:
+ raise bb.build.FuncFailed("DEPLOY_DIR_RPM not defined")
+ outdir = bb.data.expand(outdir, d)
+ bb.mkdirhier(outdir)
+
+ packages = bb.data.getVar('PACKAGES', d)
+ if not packages:
+ packages = "${PN}"
+ bb.data.setVar('FILES', '', d)
+ ddir = bb.data.expand(bb.data.getVar('D', d), d)
+ bb.mkdirhier(ddir)
+ bb.data.setVar(bb.data.expand('FILES_${PN}', d), ''.join([ "./%s" % x for x in os.listdir(ddir)]), d)
+ packages = bb.data.expand(packages, d)
+
+ for pkg in packages.split():
+ from copy import copy, deepcopy
+ localdata = deepcopy(d)
+ root = "%s/install/%s" % (workdir, pkg)
+
+ bb.data.setVar('ROOT', '', localdata)
+ bb.data.setVar('ROOT_%s' % pkg, root, localdata)
+ bb.data.setVar('PKG', pkg, localdata)
+
+ overrides = bb.data.getVar('OVERRIDES', localdata)
+ if not overrides:
+ raise bb.build.FuncFailed('OVERRIDES not defined')
+ overrides = bb.data.expand(overrides, localdata)
+ bb.data.setVar('OVERRIDES', '%s:%s' % (overrides, pkg), localdata)
+
+ bb.data.update_data(localdata)
+# stuff
+ root = bb.data.getVar('ROOT', localdata)
+ basedir = os.path.dirname(root)
+ pkgoutdir = outdir
+ bb.mkdirhier(pkgoutdir)
+ bb.data.setVar('OUTSPECFILE', os.path.join(workdir, "%s.spec" % pkg), localdata)
+ bb.build.exec_func('write_specfile', localdata)
+ del localdata
+}
diff --git a/classes/package_tar.bbclass b/classes/package_tar.bbclass
index e69de29bb2..2d169c7491 100644
--- a/classes/package_tar.bbclass
+++ b/classes/package_tar.bbclass
@@ -0,0 +1,100 @@
+inherit package
+
+PACKAGEFUNCS += "do_package_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)
+ 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)
+
+ if None in (pkg,pkgfn,rootfs):
+ bb.error("missing variables (one or more of PKG, PKGFN, IMAGEROOTFS)")
+ raise bb.build.FuncFailed
+ try:
+ bb.mkdirhier(rootfs)
+ os.chdir(rootfs)
+ except OSError:
+ (type, value, traceback) = sys.exc_info()
+ print value
+ raise bb.build.FuncFailed
+
+ if not os.access(pkgfn, os.R_OK):
+ bb.debug(1, "%s does not exist, skipping" % pkgfn)
+ raise bb.build.FuncFailed
+
+ ret = os.system('zcat %s | tar -xf -' % pkgfn)
+ if ret != 0:
+ raise bb.build.FuncFailed
+}
+
+python do_package_tar () {
+ workdir = bb.data.getVar('WORKDIR', d, 1)
+ if not workdir:
+ 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")
+ return
+ bb.mkdirhier(outdir)
+
+ dvar = bb.data.getVar('D', d, 1)
+ if not dvar:
+ bb.error("D not defined, unable to package")
+ return
+ bb.mkdirhier(dvar)
+
+ packages = bb.data.getVar('PACKAGES', d, 1)
+ if not packages:
+ bb.debug(1, "PACKAGES not defined, nothing to package")
+ return
+
+ for pkg in packages.split():
+ from copy import copy, deepcopy
+ localdata = deepcopy(d)
+ root = "%s/install/%s" % (workdir, pkg)
+
+ bb.data.setVar('ROOT', '', localdata)
+ bb.data.setVar('ROOT_%s' % pkg, root, localdata)
+ bb.data.setVar('PKG', pkg, localdata)
+
+ overrides = bb.data.getVar('OVERRIDES', localdata)
+ if not overrides:
+ raise bb.build.FuncFailed('OVERRIDES not defined')
+ overrides = bb.data.expand(overrides, localdata)
+ 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)
+ pkgoutdir = outdir
+ 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)))
+ continue
+ ret = os.system("tar -czvf %s %s" % (tarfn, '.'))
+ if ret != 0:
+ bb.error("Creation of tar %s failed." % tarfn)
+# end stuff
+ del localdata
+}