1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
inherit package
python package_tar_fn () {
import os
from oe import data
fn = os.path.join(oe.data.getVar('DEPLOY_DIR_TAR', d), "%s-%s-%s.tar.gz" % (oe.data.getVar('PKG', d), oe.data.getVar('PV', d), oe.data.getVar('PR', d)))
fn = oe.data.expand(fn, d)
oe.data.setVar('PKGFN', fn, d)
}
python package_tar_install () {
import os, sys
pkg = oe.data.getVar('PKG', d, 1)
pkgfn = oe.data.getVar('PKGFN', d, 1)
rootfs = oe.data.getVar('IMAGE_ROOTFS', d, 1)
if None in (pkg,pkgfn,rootfs):
oe.error("missing variables (one or more of PKG, PKGFN, IMAGEROOTFS)")
raise oe.build.FuncFailed
try:
oe.mkdirhier(rootfs)
os.chdir(rootfs)
except OSError:
(type, value, traceback) = sys.exc_info()
print value
raise oe.build.FuncFailed
if not os.access(pkgfn, os.R_OK):
oe.debug(1, "%s does not exist, skipping" % pkgfn)
raise oe.build.FuncFailed
ret = os.system('zcat %s | tar -xf -' % pkgfn)
if ret != 0:
raise oe.build.FuncFailed
}
python do_package_tar () {
workdir = oe.data.getVar('WORKDIR', d, 1)
if not workdir:
oe.error("WORKDIR not defined, unable to package")
return
import os # path manipulations
outdir = oe.data.getVar('DEPLOY_DIR_TAR', d, 1)
if not outdir:
oe.error("DEPLOY_DIR_TAR not defined, unable to package")
return
oe.mkdirhier(outdir)
dvar = oe.data.getVar('D', d, 1)
if not dvar:
oe.error("D not defined, unable to package")
return
oe.mkdirhier(dvar)
packages = oe.data.getVar('PACKAGES', d, 1)
if not packages:
oe.debug(1, "PACKAGES not defined, nothing to package")
return
for pkg in packages.split():
localdata = {}
oe.data.linkDataSet(localdata,d)
root = "%s/install/%s" % (workdir, pkg)
oe.data.setVar('ROOT', '', localdata)
oe.data.setVar('ROOT_%s' % pkg, root, localdata)
oe.data.setVar('PKG', pkg, localdata)
overrides = oe.data.getVar('OVERRIDES', localdata)
if not overrides:
raise oe.build.FuncFailed('OVERRIDES not defined')
overrides = oe.data.expand(overrides, localdata)
oe.data.setVar('OVERRIDES', '%s:%s' % (overrides, pkg), localdata)
oe.data.update_data(localdata)
# stuff
root = oe.data.getVar('ROOT', localdata)
oe.mkdirhier(root)
basedir = os.path.dirname(root)
pkgoutdir = outdir
oe.mkdirhier(pkgoutdir)
oe.build.exec_func('package_tar_fn', localdata)
tarfn = oe.data.getVar('PKGFN', localdata, 1)
# if os.path.exists(tarfn):
# del localdata
# continue
os.chdir(root)
from glob import glob
if not glob('*'):
oe.note("Not creating empty archive for %s-%s-%s" % (pkg, oe.data.getVar('PV', localdata, 1), oe.data.getVar('PR', localdata, 1)))
continue
ret = os.system("tar -czvf %s %s" % (tarfn, '.'))
if ret != 0:
oe.error("Creation of tar %s failed." % tarfn)
# end stuff
del localdata
}
addtask package_tar after do_package before do_build
|