From 5c0caae4c1a433aa02be455fd1aa247a48f47273 Mon Sep 17 00:00:00 2001
From: Lukas Bulwahn <lukas.bulwahn@bmw-carit.de>
Date: Wed, 12 Dec 2012 13:04:45 +0100
Subject: [PATCH] setting the hosts file through the image recipe

---
 README.af_yocto                            | 10 +++++++++-
 install.sh                                 |  2 --
 meta/recipes-core/images/core-image-bmw.bb |  8 +++++++-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/README.af_yocto b/README.af_yocto
index f042f9f..3c911ad 100644
--- a/README.af_yocto
+++ b/README.af_yocto
@@ -62,4 +62,12 @@ OPEN ISSUES for M1:
     SHOULD BE RESOLVED by creating an appropriate patch for python-setuptools and contributing to openembedded-core
   - rospkg modules are not found when runnning python.
     TEMPORARILY RESOLVED by installing natively in the virtual machine
-    SOLUTION UNCLEAR. Cannot be solved by adding rospkg-dev.
+    CAUSE of PROBLEM: must add /usr/lib/python2.7/site-packages/rospkg-1.0.15-py2.7.egg to PYTHON_PATH (sys.path)
+    In the usual setting, this is done by adding rospkg-1.0.15-py2.7.egg to the easy-install.pth
+    However, the distutils class removes the created easy-install.pth before packaging.
+    Modifying the class, to not remove the easy-install.pth does not solve the issue, because
+    also the python-setuptools must add an entry to easy-install.pth
+    This can be only solved by providing a general merge mechanism for the easy-install.pth file.
+    Implementing this should not be difficult because the format of this file is very easy, and
+    the pathes can be simply accumulated.
+    TEMPORARY SOLUTION NOW: we simply write the easy-install.pth file in the rootfs task of the image generation.
diff --git a/install.sh b/install.sh
index 74468c3..79958a4 100644
--- a/install.sh
+++ b/install.sh
@@ -42,8 +42,6 @@ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/ros/fuerte -DSETUPTOOLS_DEB_LAYOUT=OFF
 # compile and install
 make
 make install
-# add own name to hosts
-echo -e '127.0.0.1\tqemux86-64.localdomain\t\tqemux86-64' >> /etc/hosts
 # start roscore
 . /opt/ros/fuerte/setup.sh
 roscore
diff --git a/meta/recipes-core/images/core-image-bmw.bb b/meta/recipes-core/images/core-image-bmw.bb
index 949e076..d3d19ed 100644
--- a/meta/recipes-core/images/core-image-bmw.bb
+++ b/meta/recipes-core/images/core-image-bmw.bb
@@ -10,7 +10,13 @@ inherit core-image
 
 IMAGE_ROOTFS_EXTRA_SPACE = "524288"
 
+# add own name to hosts
+augment_hosts_setting_file () {
+	echo '127.0.0.1\tqemux86-64.localdomain\t\tqemux86-64' >> ${IMAGE_ROOTFS}/etc/hosts
+}
+
 # remove not needed ipkg informations
-ROOTFS_POSTPROCESS_COMMAND += "remove_packaging_data_files ; "
+# create a custom hosts file
+ROOTFS_POSTPROCESS_COMMAND += "remove_packaging_data_files ; augment_hosts_setting_file ; "
 
 IMAGE_INSTALL += "boost boost-dev packagegroup-core-ssh-openssh dhcp-client file ldd python-modules python-rospkg python-rosinstall git cmake python-empy python-pyyaml python-nose log4cxx log4cxx-dev libbz2-dev python-setuptools"
-- 
GitLab