Fix install_lite to make RO installation from source works; new Makefile rules for building and cleaning both packages

Change-Id: I8810c7ef7433d1a3c8ba701cd70ab591f6676904
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/Makefile b/Makefile
index 189cb21..8a16ee1 100644
--- a/Makefile
+++ b/Makefile
@@ -4,13 +4,15 @@
 all: clean build pip install
 lite: clean build_lite pip_lite install_lite
 
+clean_deb:
+	rm -rf .build
 clean:
 	rm -rf build
 	find osm_openvim -name '*.pyc' -delete
 	find osm_openvim -name '*.pyo' -delete
 
 prepare_lite:
-	pip install setuptools
+	pip install --upgrade setuptools
 	mkdir -p build
 	VER1=$(shell git describe | sed -e 's/^v//' |cut -d- -f1); \
 	VER2=$(shell git describe | cut -d- -f2); \
@@ -18,10 +20,10 @@
 	echo "$$VER1.dev$$VER2+$$VER3" > build/OVIM_VERSION
 	cp MANIFEST.in build/
 	sed -i "s/include OPENVIM_VERSION/include OVIM_VERSION/g" build/MANIFEST.in
-	sed -i "s/recursive-include osm_openvim */recursive-include lib_osm_openvim */g" build/MANIFEST.in
+	sed -i "s/recursive-include osm_openvim/recursive-include lib_osm_openvim/g" build/MANIFEST.in
 	sed -i "s/include openflow/include openflow-lib/g" build/MANIFEST.in
-	sed '/include openvimd/d' build/MANIFEST.in
-	sed '/include openvim/d' build/MANIFEST.in
+	sed -i '/include openvimd/d' build/MANIFEST.in
+	sed -i '/include openvim/d' build/MANIFEST.in
 	cp README_lite.rst build/README.rst
 	cp setup_lite.py build/setup.py
 	cp stdeb_lite.cfg build/stdeb.cfg
@@ -33,10 +35,10 @@
 	cp openflow build/openflow-lib
 	sed -i "s/from osm_openvim/from lib_osm_openvim/g" build/openflow-lib
 	sed -i "s/import osm_openvim/import lib_osm_openvim/g" build/openflow-lib
-	sed -i "s/import osm_openvim; print osm_openvim.__path__[0]/import lib_osm_openvim; print lib_osm_openvim.__path__[0]/g" build/lib_osm_openvim/database_utils/migrate_vim_db.sh
+	sed -i "s/import osm_openvim; print osm_openvim\.__path__\[0\]/import lib_osm_openvim; print lib_osm_openvim\.__path__\[0\]/g" build/lib_osm_openvim/database_utils/migrate_vim_db.sh
 
 prepare:
-	pip install setuptools
+	pip install --upgrade setuptools
 	mkdir -p build
 	VER1=$(shell git describe | sed -e 's/^v//' |cut -d- -f1); \
 	VER2=$(shell git describe | cut -d- -f2); \
@@ -63,30 +65,36 @@
 	python -m py_compile build/lib_osm_openvim/*.py
 
 pip: clean build
-	cd build; ./setup.py sdist
+	cd build && ./setup.py sdist
 
 pip_lite: clean build_lite
-	cd build; ./setup.py sdist
+	cd build && ./setup.py sdist
 
-package: clean prepare
+package_openvim: clean prepare
 	#apt-get install -y python-stdeb
 	cd build && python setup.py --command-packages=stdeb.command sdist_dsc --with-python2=True
 	cd build && cp osm_openvim/scripts/python-osm-openvim.postinst deb_dist/osm-openvim*/debian/
 	cd build/deb_dist/osm-openvim* && dpkg-buildpackage -rfakeroot -uc -us
+	mkdir -p .build
+	cp build/deb_dist/python-*.deb ./build/
 
-package_lite: clean prepare_lite
+package_lib: clean prepare_lite
 	#apt-get install -y python-stdeb
 	cd build && python setup.py --command-packages=stdeb.command sdist_dsc --with-python2=True
 	cd build/deb_dist/lib-osm-openvim* && dpkg-buildpackage -rfakeroot -uc -us
+	mkdir -p .build
+	cp build/deb_dist/python-*.deb ./build/
+
+package: clean_deb package_openvim package_lib
 
 snap:
 	echo "Nothing to be done yet"
 
 install: clean build
-	cd build/dist; pip  install osm_openvim*
+	cd build/dist; pip install osm_openvim*
 
 install_lite: clean build_lite
-	cd build/dist; pip  install  lib_osm_openvim-*
+	cd build/dist; pip install lib_osm_openvim-*