3 BOOTSTRAP_EXTRA_RDEPENDS += "ipkg-collateral ipkg"
6 IPKGCONF_TARGET = "${STAGING_ETCDIR_NATIVE}/ipkg.conf"
7 IPKGCONF_SDK = "${STAGING_ETCDIR_NATIVE}/ipkg-sdk.conf"
9 python package_ipk_fn () {
11 bb.data.setVar('PKGFN', bb.data.getVar('PKG',d), d)
14 python package_ipk_install () {
16 pkg = bb.data.getVar('PKG', d, 1)
17 pkgfn = bb.data.getVar('PKGFN', d, 1)
18 rootfs = bb.data.getVar('IMAGE_ROOTFS', d, 1)
19 ipkdir = bb.data.getVar('DEPLOY_DIR_IPK', d, 1)
20 stagingdir = bb.data.getVar('STAGING_DIR', d, 1)
21 tmpdir = bb.data.getVar('TMPDIR', d, 1)
23 if None in (pkg,pkgfn,rootfs):
24 raise bb.build.FuncFailed("missing variables (one or more of PKG, PKGFN, IMAGEROOTFS)")
29 (type, value, traceback) = sys.exc_info()
31 raise bb.build.FuncFailed
33 # Generate ipk.conf if it or the stamp doesnt exist
34 conffile = os.path.join(stagingdir,"ipkg.conf")
35 if not os.access(conffile, os.R_OK):
36 ipkg_archs = bb.data.getVar('PACKAGE_ARCHS',d)
37 if ipkg_archs is None:
38 bb.error("PACKAGE_ARCHS missing")
40 ipkg_archs = ipkg_archs.split()
43 f = open(conffile,"w")
44 for arch in ipkg_archs:
45 f.write("arch %s %s\n" % ( arch, arch_priority ))
47 f.write("src local file:%s" % ipkdir)
51 if (not os.access(os.path.join(ipkdir,"Packages"), os.R_OK) or
52 not os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"),os.R_OK):
53 ret = os.system('ipkg-make-index -p %s %s ' % (os.path.join(ipkdir, "Packages"), ipkdir))
55 raise bb.build.FuncFailed
56 f = open(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"),"w")
59 ret = os.system('ipkg-cl -o %s -f %s update' % (rootfs, conffile))
60 ret = os.system('ipkg-cl -o %s -f %s install %s' % (rootfs, conffile, pkgfn))
62 raise bb.build.FuncFailed
66 # Update the Packages index files in ${DEPLOY_DIR_IPK}
68 package_update_index_ipk () {
71 ipkgarchs="${PACKAGE_ARCHS}"
73 if [ ! -z "${DEPLOY_KEEP_PACKAGES}" ]; then
77 touch ${DEPLOY_DIR_IPK}/Packages
78 ipkg-make-index -r ${DEPLOY_DIR_IPK}/Packages -p ${DEPLOY_DIR_IPK}/Packages -l ${DEPLOY_DIR_IPK}/Packages.filelist -m ${DEPLOY_DIR_IPK}
80 for arch in $ipkgarchs; do
81 if [ -e ${DEPLOY_DIR_IPK}/$arch/ ] ; then
82 touch ${DEPLOY_DIR_IPK}/$arch/Packages
83 ipkg-make-index -r ${DEPLOY_DIR_IPK}/$arch/Packages -p ${DEPLOY_DIR_IPK}/$arch/Packages -l ${DEPLOY_DIR_IPK}/$arch/Packages.filelist -m ${DEPLOY_DIR_IPK}/$arch/
85 if [ -e ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/ ] ; then
86 touch ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages
87 ipkg-make-index -r ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages -p ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages -l ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages.filelist -m ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/
93 # Generate an ipkg conf file ${IPKGCONF_TARGET} suitable for use against
94 # the target system and an ipkg conf file ${IPKGCONF_SDK} suitable for
95 # use against the host system in sdk builds
97 package_generate_ipkg_conf () {
98 mkdir -p ${STAGING_ETCDIR_NATIVE}/
99 echo "src oe file:${DEPLOY_DIR_IPK}" > ${IPKGCONF_TARGET}
100 echo "src oe file:${DEPLOY_DIR_IPK}" > ${IPKGCONF_SDK}
101 ipkgarchs="${PACKAGE_ARCHS}"
103 for arch in $ipkgarchs; do
104 echo "arch $arch $priority" >> ${IPKGCONF_TARGET}
105 echo "arch ${BUILD_ARCH}-$arch-sdk $priority" >> ${IPKGCONF_SDK}
106 priority=$(expr $priority + 5)
107 if [ -e ${DEPLOY_DIR_IPK}/$arch/Packages ] ; then
108 echo "src oe-$arch file:${DEPLOY_DIR_IPK}/$arch" >> ${IPKGCONF_TARGET}
110 if [ -e ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages ] ; then
111 echo "src oe-${BUILD_ARCH}-$arch-sdk file:${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk" >> ${IPKGCONF_SDK}
116 python do_package_ipk () {
117 import sys, re, fcntl, copy
119 workdir = bb.data.getVar('WORKDIR', d, 1)
121 bb.error("WORKDIR not defined, unable to package")
124 import os # path manipulations
125 outdir = bb.data.getVar('DEPLOY_DIR_IPK', d, 1)
127 bb.error("DEPLOY_DIR_IPK not defined, unable to package")
130 arch = bb.data.getVar('PACKAGE_ARCH', d, 1)
131 outdir = "%s/%s" % (outdir, arch)
134 dvar = bb.data.getVar('D', d, 1)
136 bb.error("D not defined, unable to package")
140 packages = bb.data.getVar('PACKAGES', d, 1)
142 bb.debug(1, "PACKAGES not defined, nothing to package")
145 tmpdir = bb.data.getVar('TMPDIR', d, 1)
147 if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
148 os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
151 bb.debug(1, "No packages; nothing to do")
155 lf = open(name, "a+")
156 fcntl.flock(lf.fileno(), fcntl.LOCK_EX)
160 fcntl.flock(lf.fileno(), fcntl.LOCK_UN)
163 for pkg in packages.split():
164 localdata = bb.data.createCopy(d)
165 root = "%s/install/%s" % (workdir, pkg)
167 lf = lockfile(root + ".lock")
169 bb.data.setVar('ROOT', '', localdata)
170 bb.data.setVar('ROOT_%s' % pkg, root, localdata)
171 pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1)
174 bb.data.setVar('PKG', pkgname, localdata)
176 overrides = bb.data.getVar('OVERRIDES', localdata)
178 raise bb.build.FuncFailed('OVERRIDES not defined')
179 overrides = bb.data.expand(overrides, localdata)
180 bb.data.setVar('OVERRIDES', overrides + ':' + pkg, localdata)
182 bb.data.update_data(localdata)
183 basedir = os.path.join(os.path.dirname(root))
185 bb.mkdirhier(pkgoutdir)
187 from glob import glob
190 del g[g.index('CONTROL')]
191 del g[g.index('./CONTROL')]
194 if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1":
196 note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1)))
200 controldir = os.path.join(root, 'CONTROL')
201 bb.mkdirhier(controldir)
203 ctrlfile = file(os.path.join(controldir, 'control'), 'w')
205 raise bb.build.FuncFailed("unable to open control file for writing.")
208 pe = bb.data.getVar('PE', d, 1)
209 if pe and int(pe) > 0:
210 fields.append(["Version: %s:%s-%s\n", ['PE', 'PV', 'PR']])
212 fields.append(["Version: %s-%s\n", ['PV', 'PR']])
213 fields.append(["Description: %s\n", ['DESCRIPTION']])
214 fields.append(["Section: %s\n", ['SECTION']])
215 fields.append(["Priority: %s\n", ['PRIORITY']])
216 fields.append(["Maintainer: %s\n", ['MAINTAINER']])
217 fields.append(["Architecture: %s\n", ['PACKAGE_ARCH']])
218 fields.append(["OE: %s\n", ['PN']])
219 fields.append(["Homepage: %s\n", ['HOMEPAGE']])
224 l2.append(bb.data.getVar(i, d, 1))
227 ctrlfile.write("Package: %s\n" % pkgname)
228 # check for required fields
230 for (c, fs) in fields:
232 if bb.data.getVar(f, localdata) is None:
234 ctrlfile.write(c % tuple(pullData(fs, localdata)))
236 (type, value, traceback) = sys.exc_info()
238 raise bb.build.FuncFailed("Missing field for ipk generation: %s" % value)
241 bb.build.exec_func("mapping_rename_hook", localdata)
243 rdepends = explode_deps(bb.data.getVar("RDEPENDS", localdata, 1) or "")
244 rrecommends = explode_deps(bb.data.getVar("RRECOMMENDS", localdata, 1) or "")
245 rsuggests = (bb.data.getVar("RSUGGESTS", localdata, 1) or "").split()
246 rprovides = (bb.data.getVar("RPROVIDES", localdata, 1) or "").split()
247 rreplaces = (bb.data.getVar("RREPLACES", localdata, 1) or "").split()
248 rconflicts = (bb.data.getVar("RCONFLICTS", localdata, 1) or "").split()
250 ctrlfile.write("Depends: %s\n" % ", ".join(rdepends))
252 ctrlfile.write("Suggests: %s\n" % ", ".join(rsuggests))
254 ctrlfile.write("Recommends: %s\n" % ", ".join(rrecommends))
256 ctrlfile.write("Provides: %s\n" % ", ".join(rprovides))
258 ctrlfile.write("Replaces: %s\n" % ", ".join(rreplaces))
260 ctrlfile.write("Conflicts: %s\n" % ", ".join(rconflicts))
261 src_uri = bb.data.getVar("SRC_URI", localdata, 1)
263 src_uri = re.sub("\s+", " ", src_uri)
264 ctrlfile.write("Source: %s\n" % " ".join(src_uri.split()))
267 for script in ["preinst", "postinst", "prerm", "postrm"]:
268 scriptvar = bb.data.getVar('pkg_%s' % script, localdata, 1)
272 scriptfile = file(os.path.join(controldir, script), 'w')
274 raise bb.build.FuncFailed("unable to open %s script file for writing." % script)
275 scriptfile.write(scriptvar)
277 os.chmod(os.path.join(controldir, script), 0755)
279 conffiles_str = bb.data.getVar("CONFFILES", localdata, 1)
282 conffiles = file(os.path.join(controldir, 'conffiles'), 'w')
284 raise bb.build.FuncFailed("unable to open conffiles for writing.")
285 for f in conffiles_str.split():
286 conffiles.write('%s\n' % f)
290 ret = os.system("PATH=\"%s\" %s %s %s" % (bb.data.getVar("PATH", localdata, 1),
291 bb.data.getVar("IPKGBUILDCMD",d,1), pkg, pkgoutdir))
293 raise bb.build.FuncFailed("ipkg-build execution failed")
295 for script in ["preinst", "postinst", "prerm", "postrm", "control" ]:
296 scriptfile = os.path.join(controldir, script)
298 os.remove(scriptfile)
310 if bb.data.getVar('PACKAGES', d, True) != '':
311 bb.data.setVarFlag('do_package_write_ipk', 'depends', 'ipkg-utils-native:do_populate_staging fakeroot-native:do_populate_staging', d)
314 python do_package_write_ipk () {
315 bb.build.exec_func("read_subpackage_metadata", d)
316 bb.build.exec_func("do_package_ipk", d)
318 do_package_write_ipk[dirs] = "${D}"
319 addtask package_write_ipk before do_package_write after do_package