gnome-terminal: add 2.26.2
[openembedded.git] / classes / sourcepkg.bbclass
blob200ff8c2288ca0f73986e48984be9017e33bf6cb
1 DEPLOY_DIR_SRC ?= "${DEPLOY_DIR}/sources"
2 EXCLUDE_FROM ?= ".pc autom4te.cache"
4 # used as part of a path. make sure it's set
5 DISTRO ?= "openembedded"
7 def get_src_tree(d):
8         import bb
9         import os, os.path
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
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
21         s_tree_raw = s.split('/')[1]
22         s_tree = bb.data.expand(s_tree_raw, d)
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)
31         return s_tree
33 sourcepkg_do_create_orig_tgz(){
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
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
49 sourcepkg_do_archive_bb() {
51         src_tree=${@get_src_tree(d)}
52         dest=${WORKDIR}/$src_tree/${DISTRO}
53         mkdir -p $dest
55         cp ${FILE} $dest
58 python sourcepkg_do_dumpdata() {
59         import os
60         import os.path
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
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()
85 sourcepkg_do_create_diff_gz(){
87         cd ${WORKDIR}
88         for i in ${EXCLUDE_FROM}; do
89                 echo $i >> temp/exclude-from-file
90         done
93         src_tree=${@get_src_tree(d)}
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
105 EXPORT_FUNCTIONS do_create_orig_tgz do_archive_bb do_dumpdata do_create_diff_gz
107 do_create_orig_tgz[deptask] = "do_unpack"
108 do_create_diff_gz[deptask] = "do_patch"
109 do_archive_bb[deptask] = "do_patch"
110 do_dumpdata[deptask] = "do_unpack"
112 addtask create_orig_tgz after do_unpack before do_patch
113 addtask archive_bb after do_patch before do_dumpdata
114 addtask dumpdata after do_archive_bb before do_create_diff_gz
115 addtask create_diff_gz after do_dumpdata before do_configure