summaryrefslogtreecommitdiffstats
path: root/meta/classes/sourcepkg.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
committerRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
commitb2f192faabe412adce79534e22efe9fb69ee40e2 (patch)
tree7076c49d4286f8a1733650bd8fbc7161af200d57 /meta/classes/sourcepkg.bbclass
parent2cf0eadf9f730027833af802d7e6c90b44248f80 (diff)
downloadpoky-b2f192faabe412adce79534e22efe9fb69ee40e2.tar.gz
Rename /openembedded/ -> /meta/
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@530 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes/sourcepkg.bbclass')
-rw-r--r--meta/classes/sourcepkg.bbclass111
1 files changed, 111 insertions, 0 deletions
diff --git a/meta/classes/sourcepkg.bbclass b/meta/classes/sourcepkg.bbclass
new file mode 100644
index 0000000000..390d3684d4
--- /dev/null
+++ b/meta/classes/sourcepkg.bbclass
@@ -0,0 +1,111 @@
1DEPLOY_DIR_SRC ?= "${DEPLOY_DIR}/source"
2EXCLUDE_FROM ?= ".pc autom4te.cache"
3
4# used as part of a path. make sure it's set
5DISTRO ?= "openembedded"
6
7def get_src_tree(d):
8 import bb
9 import os, os.path
10
11 workdir = bb.data.getVar('WORKDIR', d, 1)
12 if not workdir:
13 bb.error("WORKDIR not defined, unable to find source tree.")
14 return
15
16 s = bb.data.getVar('S', d, 0)
17 if not s:
18 bb.error("S not defined, unable to find source tree.")
19 return
20
21 s_tree_raw = s.split('/')[1]
22 s_tree = bb.data.expand(s_tree_raw, d)
23
24 src_tree_path = os.path.join(workdir, s_tree)
25 try:
26 os.listdir(src_tree_path)
27 except OSError:
28 bb.fatal("Expected to find source tree in '%s' which doesn't exist." % src_tree_path)
29 bb.debug("Assuming source tree is '%s'" % src_tree_path)
30
31 return s_tree
32
33sourcepkg_do_create_orig_tgz(){
34
35 mkdir -p ${DEPLOY_DIR_SRC}
36 cd ${WORKDIR}
37 for i in ${EXCLUDE_FROM}; do
38 echo $i >> temp/exclude-from-file
39 done
40
41 src_tree=${@get_src_tree(d)}
42
43 echo $src_tree
44 oenote "Creating .orig.tar.gz in ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz"
45 tar cvzf ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz --exclude-from temp/exclude-from-file $src_tree
46 cp -pPR $src_tree $src_tree.orig
47}
48
49sourcepkg_do_archive_bb() {
50
51 src_tree=${@get_src_tree(d)}
52 dest=${WORKDIR}/$src_tree/${DISTRO}
53 mkdir -p $dest
54
55 cp ${FILE} $dest
56}
57
58python sourcepkg_do_dumpdata() {
59 import os
60 import os.path
61
62 workdir = bb.data.getVar('WORKDIR', d, 1)
63 distro = bb.data.getVar('DISTRO', d, 1)
64 s_tree = get_src_tree(d)
65 openembeddeddir = os.path.join(workdir, s_tree, distro)
66 dumpfile = os.path.join(openembeddeddir, bb.data.expand("${P}-${PR}.showdata.dump",d))
67
68 try:
69 os.mkdir(openembeddeddir)
70 except OSError:
71 # dir exists
72 pass
73
74 bb.note("Dumping metadata into '%s'" % dumpfile)
75 f = open(dumpfile, "w")
76 # emit variables and shell functions
77 bb.data.emit_env(f, d, True)
78 # emit the metadata which isnt valid shell
79 for e in d.keys():
80 if bb.data.getVarFlag(e, 'python', d):
81 f.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
82 f.close()
83}
84
85sourcepkg_do_create_diff_gz(){
86
87 cd ${WORKDIR}
88 for i in ${EXCLUDE_FROM}; do
89 echo $i >> temp/exclude-from-file
90 done
91
92
93 src_tree=${@get_src_tree(d)}
94
95 for i in `find . -maxdepth 1 -type f`; do
96 mkdir -p $src_tree/${DISTRO}/files
97 cp $i $src_tree/${DISTRO}/files
98 done
99
100 oenote "Creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.gz"
101 LC_ALL=C TZ=UTC0 diff --exclude-from=temp/exclude-from-file -Naur $src_tree.orig $src_tree | gzip -c > ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.gz
102 rm -rf $src_tree.orig
103}
104
105EXPORT_FUNCTIONS do_create_orig_tgz do_archive_bb do_dumpdata do_create_diff_gz
106
107addtask create_orig_tgz after do_unpack before do_patch
108addtask archive_bb after do_patch before do_dumpdata
109addtask dumpdata after archive_bb before do_create_diff_gz
110addtask create_diff_gz after do_dump_data before do_configure
111