summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-containers/criu/files/protobuf-allow-running-python-scripts-from-anywhere.patch38
-rwxr-xr-xrecipes-containers/criu/files/run-ptest32
-rw-r--r--recipes-containers/criu/protobuf_2.5.0.bb62
3 files changed, 128 insertions, 4 deletions
diff --git a/recipes-containers/criu/files/protobuf-allow-running-python-scripts-from-anywhere.patch b/recipes-containers/criu/files/protobuf-allow-running-python-scripts-from-anywhere.patch
new file mode 100644
index 00000000..13d4e848
--- /dev/null
+++ b/recipes-containers/criu/files/protobuf-allow-running-python-scripts-from-anywhere.patch
@@ -0,0 +1,38 @@
1From 46e331263eb92e47510e88478b255f226d30245c Mon Sep 17 00:00:00 2001
2From: Keith Holman <Keith.Holman@windriver.com>
3Date: Mon, 18 Aug 2014 15:19:35 -0400
4Subject: [PATCH] protobuf: allow running python scripts from anywhere
5
6The Makefile to generate the examples with Google Protocol Buffers
7generates some scripts for python. However, these generated scripts
8only work if they are ran in the same directory as the source files.
9This fix generates scripts to execute from anywhere on the system.
10
11Signed-off-by: Keith Holman <Keith.Holman@windriver.com>
12---
13 examples/Makefile | 6 ++++--
14 1 file changed, 4 insertions(+), 2 deletions(-)
15
16diff --git a/examples/Makefile b/examples/Makefile
17index 8dc9083..a993d63 100644
18--- a/examples/Makefile
19+++ b/examples/Makefile
20@@ -48,11 +48,13 @@ list_people_java: javac_middleman
21 add_person_python: add_person.py protoc_middleman
22 @echo "Writing shortcut script add_person_python..."
23 @echo '#! /bin/sh' > add_person_python
24- @echo './add_person.py "$$@"' >> add_person_python
25+ @echo 'SCRIPT_DIR=$$(dirname $$0)' >> add_person_python
26+ @echo '$$SCRIPT_DIR/add_person.py "$$@"' >> add_person_python
27 @chmod +x add_person_python
28
29 list_people_python: list_people.py protoc_middleman
30 @echo "Writing shortcut script list_people_python..."
31 @echo '#! /bin/sh' > list_people_python
32- @echo './list_people.py "$$@"' >> list_people_python
33+ @echo 'SCRIPT_DIR=$$(dirname $$0)' >> list_people_python
34+ @echo '$$SCRIPT_DIR/list_people.py "$$@"' >> list_people_python
35 @chmod +x list_people_python
36--
371.9.3
38
diff --git a/recipes-containers/criu/files/run-ptest b/recipes-containers/criu/files/run-ptest
new file mode 100755
index 00000000..a5a7b0f9
--- /dev/null
+++ b/recipes-containers/criu/files/run-ptest
@@ -0,0 +1,32 @@
1#!/bin/bash
2DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3TEST_FILE="/tmp/test.data"
4
5RETVAL=0
6# Test every writing test application
7for write_exe_full_path in ${DIR}/add_person_*; do
8 if [ -x "${write_exe_full_path}" ]; then
9 write_exe=`basename ${write_exe_full_path}`
10 echo "Generating new test file using ${write_exe}..."
11 ${write_exe_full_path} "${TEST_FILE}"
12 RETVAL=$?
13
14 # Test every reading test application
15 for read_exe_full_path in ${DIR}/list_people_*; do
16 read_exe=`basename ${read_exe_full_path}`
17 echo "Test: Write with ${write_exe}; Read with ${read_exe}..."
18 if [ -x "${read_exe_full_path}" ]; then
19 ${read_exe_full_path} "${TEST_FILE}"
20 RETVAL=$?
21 fi
22 done
23
24 # Cleanup...
25 if [ -e "${TEST_FILE}" ]; then
26 rm "${TEST_FILE}"
27 fi
28 fi
29done
30
31exit $RETVAL
32
diff --git a/recipes-containers/criu/protobuf_2.5.0.bb b/recipes-containers/criu/protobuf_2.5.0.bb
index 5cf6cc92..851fbf06 100644
--- a/recipes-containers/criu/protobuf_2.5.0.bb
+++ b/recipes-containers/criu/protobuf_2.5.0.bb
@@ -12,23 +12,77 @@ PR = "r0"
12 12
13SRC_URI[md5sum] = "b751f772bdeb2812a2a8e7202bf1dae8" 13SRC_URI[md5sum] = "b751f772bdeb2812a2a8e7202bf1dae8"
14SRC_URI[sha256sum] = "c55aa3dc538e6fd5eaf732f4eb6b98bdcb7cedb5b91d3b5bdcf29c98c293f58e" 14SRC_URI[sha256sum] = "c55aa3dc538e6fd5eaf732f4eb6b98bdcb7cedb5b91d3b5bdcf29c98c293f58e"
15SRC_URI = "http://protobuf.googlecode.com/files/protobuf-${PV}.tar.gz" 15SRC_URI = "http://protobuf.googlecode.com/files/protobuf-${PV}.tar.gz \
16PYTHON_SRC_DIR="python" 16 file://protobuf-allow-running-python-scripts-from-anywhere.patch \
17 file://run-ptest"
17 18
18EXTRA_OECONF += " --with-protoc=echo" 19EXTRA_OECONF += " --with-protoc=echo"
19inherit autotools setuptools 20inherit autotools setuptools ptest
21
22RDEPENDS_${PN}-ptest += "make"
23
24PYTHON_SRC_DIR="python"
25TEST_SRC_DIR="examples"
26LANG_SUPPORT="cpp python"
20 27
21do_compile() { 28do_compile() {
22 # Compile protoc compiler 29 # Compile protoc compiler
23 base_do_compile 30 base_do_compile
24} 31}
25 32
33do_compile_ptest() {
34 # Modify makefile to use the cross-compiler
35 sed -e "s|c++|${CXX}|g" -i "${S}/${TEST_SRC_DIR}/Makefile"
36
37 # Add the location of the cross-compiled header and library files
38 # which haven't been installed yet.
39 cp "${S}/protobuf.pc" "${S}/${TEST_SRC_DIR}/protobuf.pc"
40 sed -e 's|Cflags:|Cflags: -I${S}/src|' -i "${S}/${TEST_SRC_DIR}/protobuf.pc"
41 sed -e 's|Libs:|Libs: -L${S}/src/.libs|' -i "${S}/${TEST_SRC_DIR}/protobuf.pc"
42 export PKG_CONFIG_PATH="${S}/${TEST_SRC_DIR}"
43
44 # Save the pkgcfg sysroot variable, and update it to nothing so
45 # that it doesn't append the sysroot to the beginning of paths.
46 # The header and library files aren't installed to the target
47 # system yet. So the absolute paths were specified above.
48 save_pkg_config_sysroot_dir=$PKG_CONFIG_SYSROOT_DIR
49 export PKG_CONFIG_SYSROOT_DIR=
50
51 # Compile the tests
52 for lang in ${LANG_SUPPORT}; do
53 oe_runmake -C "${S}/${TEST_SRC_DIR}" ${lang}
54 done
55
56 # Restore the pkgconfig sysroot variable
57 export PKG_CONFIG_SYSROOT_DIR=$save_pkg_config_sysroot_dir
58}
59
26do_install() { 60do_install() {
61 local olddir=`pwd`
62
27 # Install protoc compiler 63 # Install protoc compiler
28 autotools_do_install 64 autotools_do_install
65
29 # Install header files 66 # Install header files
30 cd "${PYTHON_SRC_DIR}" 67 cd "${S}/${PYTHON_SRC_DIR}"
31 distutils_do_install 68 distutils_do_install
69
70 cd "$olddir"
71}
72
73do_install_ptest() {
74 local olddir=`pwd`
75
76 cd "${S}/${TEST_SRC_DIR}"
77 install -d "${D}/${PTEST_PATH}"
78 for i in add_person* list_people*; do
79 if [ -x "$i" ]; then
80 install "$i" "${D}/${PTEST_PATH}"
81 fi
82 done
83 cp "${S}/${TEST_SRC_DIR}/addressbook_pb2.py" "${D}/${PTEST_PATH}"
84
85 cd "$olddir"
32} 86}
33 87
34BBCLASSEXTEND = "native nativesdk" 88BBCLASSEXTEND = "native nativesdk"