From 7d44c85a06361a676ac144e8d0e3051fa570beed Mon Sep 17 00:00:00 2001 From: Ronan Le Martret Date: Tue, 2 Dec 2014 16:51:18 +0100 Subject: [PATCH] generate cleaner code Change-Id: I98d098e51a0c2c1d8f3aef4c360c0aaf9640ea64 --- tools/spec2yocto.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/spec2yocto.py b/tools/spec2yocto.py index 2f8303f..c52927e 100755 --- a/tools/spec2yocto.py +++ b/tools/spec2yocto.py @@ -905,7 +905,8 @@ class SpecParser: else: setup_id = splited_line[i + 1] res_prep_section += "#extracte source %s\n" % setup_id - res_prep_section += "pushd ${S}\n" + res_prep_section += "CURDIR=$(pwd)\n" + res_prep_section += "cd ${S}\n" source = os.path.basename( pattern_source_dico[setup_id] ) # not a good way to do this if source.endswith( "rpmlintrc" ): @@ -913,7 +914,7 @@ class SpecParser: else: file_name = os.path.basename( pattern_source_dico[setup_id] ) res_prep_section += "tar -zxf ${S}/packaging/%s\n" % file_name - res_prep_section += "popd \n" + res_prep_section += "cd ${CURDIR}\n" elif splited_line[i].startswith( "-b" ): if len( splited_line[i] ) > len( "-b" ): @@ -922,13 +923,14 @@ class SpecParser: setup_id = splited_line[i + 1] if setup_id != "0": res_prep_section += "#extracte source %s\n" % ( setup_id ) - res_prep_section += "pushd ${S}/../\n" + res_prep_section += "CURDIR=$(pwd)\n" + res_prep_section += "cd ${S}/../\n" source = os.path.basename( pattern_source_dico[setup_id] ) if source.endswith( "rpmlintrc" ): res_prep_section += "cp ${S}/packaging/%s .\n" % source else: res_prep_section += "tar -zxf ${S}/packaging/%s\n" % source - res_prep_section += "popd\n" + res_prep_section += "cd ${CURDIR}\n" res_prep_section += "chmod -Rf a+rX,u+w,g-w,o-w ${S}\n" @@ -1650,9 +1652,19 @@ class MetaSpec: file_d.write( "PKG_%s= \"%s\"\n" % (pkg_yocto_name,pkg_yocto_name) ) file_d.write( "\n" ) + def __cleanCode( self ,code): + code=code.replace("\n","\n ") + code=code.replace("\n EOF","\nEOF") + code=code.replace("///lib","/lib") + code=code.replace("//lib","/lib") + code=code.replace("//usr","/usr") + + code=code.replace("${D}/${prefix}","${D}${prefix}") + return code + def __create_patch( self ,file_d): code=self.__spec_parser.get_prep_section() - code=code.replace("\n","\n ") + code=self.__cleanCode(code) file_d.write( "do_prep() {\n" ) file_d.write( " %s\n" % code ) file_d.write( "}\n" ) @@ -1669,7 +1681,7 @@ class MetaSpec: def __create_compile( self ,file_d): EXTRA_OECONF = None code=self.__spec_parser.get_build_section() - code=code.replace("\n","\n ") + code=self.__cleanCode(code) file_d.write( "do_compile() {\n" ) if code.count("autotools_do_configure") == 1 : @@ -1700,8 +1712,10 @@ class MetaSpec: def __create_install( self ,file_d): code=self.__spec_parser.get_install_section() - code=code.replace("\n","\n ") - code=code.replace("\n EOF","\nEOF") + code=self.__cleanCode(code) + + + file_d.write( "do_install() {\n" ) file_d.write( " export RPM_BUILD_ROOT=${D}\n" ) file_d.write( " %s\n" % code ) -- 2.7.4