2 DEPENDS_prepend="${@["ipkg-utils-native ", ""][(oe.data.getVar('PACKAGES', d, 1) == '')]}"
3 BOOTSTRAP_EXTRA_RDEPENDS += "ipkg-collateral ipkg ipkg-link"
4 BOOTSTRAP_EXTRA_DEPENDS += "ipkg-collateral ipkg ipkg-link"
6 python package_ipk_fn () {
8 oe.data.setVar('PKGFN', oe.data.getVar('PKG',d), d)
11 python package_ipk_install () {
13 pkg = oe.data.getVar('PKG', d, 1)
14 pkgfn = oe.data.getVar('PKGFN', d, 1)
15 rootfs = oe.data.getVar('IMAGE_ROOTFS', d, 1)
16 ipkdir = oe.data.getVar('DEPLOY_DIR_IPK', d, 1)
17 stagingdir = oe.data.getVar('STAGING_DIR', d, 1)
18 tmpdir = oe.data.getVar('TMPDIR', d, 1)
20 if None in (pkg,pkgfn,rootfs):
21 raise oe.build.FuncFailed("missing variables (one or more of PKG, PKGFN, IMAGEROOTFS)")
26 (type, value, traceback) = sys.exc_info()
28 raise oe.build.FuncFailed
30 # Generate ipk.conf if it or the stamp doesnt exist
31 conffile = os.path.join(stagingdir,"ipkg.conf")
32 if not os.access(conffile, os.R_OK):
33 ipkg_archs = oe.data.getVar('IPKG_ARCHS',d)
34 if ipkg_archs is None:
35 oe.error("IPKG_ARCHS missing")
37 ipkg_archs = ipkg_archs.split()
40 f = open(conffile,"w")
41 for arch in ipkg_archs:
42 f.write("arch %s %s\n" % ( arch, arch_priority ))
44 f.write("src local file:%s" % ipkdir)
48 if (not os.access(os.path.join(ipkdir,"Packages"), os.R_OK) or
49 not os.access(os.path.join(os.path.join(tmpdir, "stamps"),"do_packages"),os.R_OK)):
50 ret = os.system('ipkg-make-index -p %s %s ' % (os.path.join(ipkdir, "Packages"), ipkdir))
52 raise oe.build.FuncFailed
53 f=open(os.path.join(os.path.join(tmpdir, "stamps"),"do_packages"),"w")
56 ret = os.system('ipkg-cl -o %s -f %s update' % (rootfs, conffile))
57 ret = os.system('ipkg-cl -o %s -f %s install %s' % (rootfs, conffile, pkgfn))
59 raise oe.build.FuncFailed
62 python package_ipk_do_package_ipk () {
63 import copy # to back up env data
66 workdir = oe.data.getVar('WORKDIR', d, 1)
68 oe.error("WORKDIR not defined, unable to package")
71 import os # path manipulations
72 outdir = oe.data.getVar('DEPLOY_DIR_IPK', d, 1)
74 oe.error("DEPLOY_DIR_IPK not defined, unable to package")
78 dvar = oe.data.getVar('D', d, 1)
80 oe.error("D not defined, unable to package")
84 packages = oe.data.getVar('PACKAGES', d, 1)
86 oe.debug(1, "PACKAGES not defined, nothing to package")
89 tmpdir = oe.data.getVar('TMPDIR', d, 1)
90 # Invalidate the packages file
91 if os.access(os.path.join(os.path.join(tmpdir, "stamps"),"do_packages"),os.R_OK):
92 os.unlink(os.path.join(os.path.join(tmpdir, "stamps"),"do_packages"))
95 oe.debug(1, "No packages; nothing to do")
98 for pkg in packages.split():
99 from copy import deepcopy
100 localdata = deepcopy(d)
101 root = "%s/install/%s" % (workdir, pkg)
103 oe.data.setVar('ROOT', '', localdata)
104 oe.data.setVar('ROOT_%s' % pkg, root, localdata)
105 pkgname = oe.data.getVar('PKG_%s' % pkg, localdata, 1)
108 oe.data.setVar('PKG', pkgname, localdata)
110 overrides = oe.data.getVar('OVERRIDES', localdata)
112 raise oe.build.FuncFailed('OVERRIDES not defined')
113 overrides = oe.data.expand(overrides, localdata)
114 oe.data.setVar('OVERRIDES', overrides + ':' + pkg, localdata)
116 oe.data.update_data(localdata)
117 basedir = os.path.join(os.path.dirname(root))
119 oe.mkdirhier(pkgoutdir)
121 from glob import glob
124 del g[g.index('CONTROL')]
125 del g[g.index('./CONTROL')]
128 if not g and not oe.data.getVar('ALLOW_EMPTY', localdata):
130 note("Not creating empty archive for %s-%s-%s" % (pkg, oe.data.getVar('PV', localdata, 1), oe.data.getVar('PR', localdata, 1)))
132 controldir = os.path.join(root, 'CONTROL')
133 oe.mkdirhier(controldir)
135 ctrlfile = file(os.path.join(controldir, 'control'), 'w')
137 raise oe.build.FuncFailed("unable to open control file for writing.")
140 fields.append(["Version: %s-%s\n", ['PV', 'PR']])
141 fields.append(["Description: %s\n", ['DESCRIPTION']])
142 fields.append(["Section: %s\n", ['SECTION']])
143 fields.append(["Priority: %s\n", ['PRIORITY']])
144 fields.append(["Maintainer: %s\n", ['MAINTAINER']])
145 fields.append(["Architecture: %s\n", ['PACKAGE_ARCH']])
146 fields.append(["Source: %s\n", ['SRC_URI']])
151 l2.append(oe.data.getVar(i, d, 1))
154 ctrlfile.write("Package: %s\n" % pkgname)
155 # check for required fields
157 for (c, fs) in fields:
159 if oe.data.getVar(f, localdata) is None:
161 ctrlfile.write(c % tuple(pullData(fs, localdata)))
163 (type, value, traceback) = sys.exc_info()
165 raise oe.build.FuncFailed("Missing field for ipk generation: %s" % value)
167 rdepends = explode_deps(oe.data.getVar("RDEPENDS", localdata, 1) or "")
168 rsuggests = (oe.data.getVar("RSUGGESTS", localdata, 1) or "").split()
169 rrecommends = (oe.data.getVar("RRECOMMENDS", localdata, 1) or "").split()
170 rprovides = (oe.data.getVar("RPROVIDES", localdata, 1) or "").split()
172 ctrlfile.write("Depends: " + ", ".join(rdepends) + "\n")
174 ctrlfile.write("Suggests: " + ", ".join(rsuggests) + "\n")
176 ctrlfile.write("Recommends: " + ", ".join(rrecommends) + "\n")
178 ctrlfile.write("Provides: " + ", ".join(rprovides) + "\n")
181 for script in ["preinst", "postinst", "prerm", "postrm"]:
182 scriptvar = oe.data.getVar('pkg_%s' % script, localdata, 1)
186 scriptfile = file(os.path.join(controldir, script), 'w')
188 raise oe.build.FuncFailed("unable to open %s script file for writing." % script)
189 scriptfile.write(scriptvar)
191 os.chmod(os.path.join(controldir, script), 0755)
193 conffiles_str = oe.data.getVar("CONFFILES", localdata, 1)
196 conffiles = file(os.path.join(controldir, 'conffiles'), 'w')
198 raise oe.build.FuncFailed("unable to open conffiles for writing.")
199 for f in conffiles_str.split():
200 conffiles.write('%s\n' % f)
204 ret = os.system("PATH=\"%s\" ipkg-build -o 0 -g 0 %s %s" % (oe.data.getVar("PATH", localdata, 1), pkg, pkgoutdir))
206 raise oe.build.FuncFailed("ipkg-build execution failed")
208 for script in ["preinst", "postinst", "prerm", "postrm", "control" ]:
209 scriptfile = os.path.join(controldir, script)
211 os.remove(scriptfile)
221 EXPORT_FUNCTIONS do_package_ipk
223 addtask package_ipk after do_package before do_build