From d7003ba6961f404aa5ffa35231650b3ee83b78d7 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Wed, 3 Aug 2005 09:47:13 +0000 Subject: Add sourcepkg.bbclass, a crude way to tar up the patched sources into DL_DIR/sourcepkg and md5sums the result. do INHERIT += "sourcepkg" to get all of this goodness. Now I need to find out how to override the Source: field to make it point to said tarballs on your distro's source mirror --- classes/sourcepkg.bbclass | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 classes/sourcepkg.bbclass (limited to 'classes/sourcepkg.bbclass') diff --git a/classes/sourcepkg.bbclass b/classes/sourcepkg.bbclass new file mode 100644 index 0000000000..52cf2647b6 --- /dev/null +++ b/classes/sourcepkg.bbclass @@ -0,0 +1,13 @@ + +do_tarballing(){ + + mkdir -p ${DL_DIR}/sourcepkg/ + cd ${WORKDIR} + echo '.pc' > tar-exclude + tar cjvf ${DL_DIR}/sourcepkg/${P}.tar.bz2 `basename ${S}` -X tar-exclude + md5sum ${DL_DIR}/sourcepkg/${P}.tar.bz2 > ${DL_DIR}/sourcepkg/${P}.tar.bz2.md5 +} + +addtask tarballing after do_patch before do_configure + + -- cgit v1.2.3 From 8a4adf77cb17f20506911ff94e7683936a7f575c Mon Sep 17 00:00:00 2001 From: Rene Wagner Date: Wed, 3 Aug 2005 19:40:58 +0000 Subject: sourcepkg.bbclass: generate .orig.tar.gz and .diff.tar.gz. the latter also contains all extra files, the .bb and a showdata dump. output goes to $DEPLOY_DIR/source now. --- classes/sourcepkg.bbclass | 106 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 6 deletions(-) (limited to 'classes/sourcepkg.bbclass') diff --git a/classes/sourcepkg.bbclass b/classes/sourcepkg.bbclass index 52cf2647b6..dd9a1e2e25 100644 --- a/classes/sourcepkg.bbclass +++ b/classes/sourcepkg.bbclass @@ -1,13 +1,107 @@ +DEPLOY_DIR_SRC ?= "${DEPLOY_DIR}/source" +EXCLUDE_FROM ?= ".pc" -do_tarballing(){ +# used as part of a path. make sure it's set +DISTRO ?= "openembedded" + +def get_src_tree(d): + import bb + import os, os.path + + workdir = bb.data.getVar('WORKDIR', d, 1) + if not workdir: + bb.error("WORKDIR not defined, unable to find source tree.") + return + + s = bb.data.getVar('S', d, 0) + if not s: + bb.error("S not defined, unable to find source tree.") + return + + s_tree_raw = s.split('/')[1] + s_tree = bb.data.expand(s_tree_raw, d) + + src_tree_path = os.path.join(workdir, s_tree) + try: + os.listdir(src_tree_path) + except OSError: + bb.fatal("Expected to find source tree in '%s' which doesn't exist." % src_tree_path) + bb.debug("Assuming source tree is '%s'" % src_tree_path) + + return s_tree + +sourcepkg_do_create_orig_tgz(){ + + mkdir -p ${DEPLOY_DIR_SRC} + cd ${WORKDIR} + for i in ${EXCLUDE_FROM}; do + echo $i > temp/exclude-from-file + done + + src_tree=${@get_src_tree(d)} + + echo $src_tree + oenote "Creating .orig.tar.gz in ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz" + tar cvzf ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz $src_tree --exclude-from temp/exclude-from-file + cp -a $src_tree $src_tree.orig +} + +sourcepkg_do_archive_bb() { + + src_tree=${@get_src_tree(d)} + dest=${WORKDIR}/$src_tree/${DISTRO} + mkdir -p $dest + + cp ${FILE} $dest +} + +python sourcepkg_do_dumpdata() { + import os + import os.path + + workdir = bb.data.getVar('WORKDIR', d, 1) + distro = bb.data.getVar('DISTRO', d, 1) + s_tree = get_src_tree(d) + openembeddeddir = os.path.join(workdir, s_tree, distro) + dumpfile = os.path.join(openembeddeddir, bb.data.expand("${P}-${PR}.showdata.dump",d)) + + try: + os.mkdir(openembeddeddir) + except OSError: + # dir exists + pass + + bb.note("Dumping metadata into '%s'" % dumpfile) + f = open(dumpfile, "w") + # emit variables and shell functions + bb.data.emit_env(f, d, True) + # emit the metadata which isnt valid shell + for e in d.keys(): + if bb.data.getVarFlag(e, 'python', d): + f.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1))) + f.close() +} + +sourcepkg_do_create_diff_gz(){ - mkdir -p ${DL_DIR}/sourcepkg/ cd ${WORKDIR} - echo '.pc' > tar-exclude - tar cjvf ${DL_DIR}/sourcepkg/${P}.tar.bz2 `basename ${S}` -X tar-exclude - md5sum ${DL_DIR}/sourcepkg/${P}.tar.bz2 > ${DL_DIR}/sourcepkg/${P}.tar.bz2.md5 + + src_tree=${@get_src_tree(d)} + + for i in `find . -maxdepth 1 -type f`; do + mkdir -p $src_tree/${DISTRO}/files + cp $i $src_tree/${DISTRO}/files + done + + oenote "Creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.gz" + 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 + rm -rf $src_tree.orig } -addtask tarballing after do_patch before do_configure +EXPORT_FUNCTIONS do_create_orig_tgz do_archive_bb do_dumpdata do_create_diff_gz +addtask create_orig_tgz after do_unpack before do_patch +addtask archive_bb after do_patch before do_dumpdata +addtask dumpdata after archive_bb before do_create_diff_gz +addtask create_diff_gz after do_dump_data before do_configure -- cgit v1.2.3 From 92917970baea2b818611e3a7e8fffc9d27acb2b1 Mon Sep 17 00:00:00 2001 From: Rene Wagner Date: Wed, 3 Aug 2005 19:48:43 +0000 Subject: sourcepkg.bbclass: fix handling of EXCLUDE_FROM. thanks to koen for spotting. --- classes/sourcepkg.bbclass | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'classes/sourcepkg.bbclass') diff --git a/classes/sourcepkg.bbclass b/classes/sourcepkg.bbclass index dd9a1e2e25..ee022c99d2 100644 --- a/classes/sourcepkg.bbclass +++ b/classes/sourcepkg.bbclass @@ -35,7 +35,7 @@ sourcepkg_do_create_orig_tgz(){ mkdir -p ${DEPLOY_DIR_SRC} cd ${WORKDIR} for i in ${EXCLUDE_FROM}; do - echo $i > temp/exclude-from-file + echo $i >> temp/exclude-from-file done src_tree=${@get_src_tree(d)} @@ -85,6 +85,10 @@ python sourcepkg_do_dumpdata() { sourcepkg_do_create_diff_gz(){ cd ${WORKDIR} + for i in ${EXCLUDE_FROM}; do + echo $i >> temp/exclude-from-file + done + src_tree=${@get_src_tree(d)} -- cgit v1.2.3 From 57c3acf775eeb9f8a2613c3752688d7816f2b0a4 Mon Sep 17 00:00:00 2001 From: Holger Freyther Date: Mon, 19 Sep 2005 12:29:59 +0000 Subject: GNU cp has a nice -a switch, sadly the BSD tools lack it update our descriptions to work with any version of cp. Patches that include cp -a are not changed. They seem to work and I'm too scared busybox cp is more like GNU cp than BSD cp. (e.g do not know about P) --- classes/sourcepkg.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/sourcepkg.bbclass') diff --git a/classes/sourcepkg.bbclass b/classes/sourcepkg.bbclass index ee022c99d2..3eeff91333 100644 --- a/classes/sourcepkg.bbclass +++ b/classes/sourcepkg.bbclass @@ -43,7 +43,7 @@ sourcepkg_do_create_orig_tgz(){ echo $src_tree oenote "Creating .orig.tar.gz in ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz" tar cvzf ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz $src_tree --exclude-from temp/exclude-from-file - cp -a $src_tree $src_tree.orig + cp -pPR $src_tree $src_tree.orig } sourcepkg_do_archive_bb() { -- cgit v1.2.3 From e39e9a50ba61d155179b9a6f413d4f7a8bc58012 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Wed, 5 Oct 2005 13:36:42 +0000 Subject: Two changes to sourcepkg.class: - added "autom4te.cache" to default EXCLUDE_FROM to not have configure tests in resulted diff - changed order of tar arguments to get it working with GNU tar 1.15.1 --- classes/sourcepkg.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/sourcepkg.bbclass') diff --git a/classes/sourcepkg.bbclass b/classes/sourcepkg.bbclass index 3eeff91333..390d3684d4 100644 --- a/classes/sourcepkg.bbclass +++ b/classes/sourcepkg.bbclass @@ -1,5 +1,5 @@ DEPLOY_DIR_SRC ?= "${DEPLOY_DIR}/source" -EXCLUDE_FROM ?= ".pc" +EXCLUDE_FROM ?= ".pc autom4te.cache" # used as part of a path. make sure it's set DISTRO ?= "openembedded" @@ -42,7 +42,7 @@ sourcepkg_do_create_orig_tgz(){ echo $src_tree oenote "Creating .orig.tar.gz in ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz" - tar cvzf ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz $src_tree --exclude-from temp/exclude-from-file + tar cvzf ${DEPLOY_DIR_SRC}/${P}.orig.tar.gz --exclude-from temp/exclude-from-file $src_tree cp -pPR $src_tree $src_tree.orig } -- cgit v1.2.3