Remove ${D} from post/pre scripts
authorKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Wed, 4 Jun 2014 14:42:37 +0000 (16:42 +0200)
committerKévin THIERRY <kevin.thierry@open.eurogiciel.org>
Wed, 4 Jun 2014 14:42:37 +0000 (16:42 +0200)
The correct path is generated in the recipe when macros are used in the
spec file. Correcting the spec files is the way to go so we remove the
addition of the "${D}" prefix.

Also clean code.

Signed-off-by: Kévin THIERRY <kevin.thierry@open.eurogiciel.org>
tools/spec2yocto.py

index ba384e3..65f5c79 100755 (executable)
@@ -1184,13 +1184,7 @@ Group: devel
                 res_file_list.append( section_key )
         return res_file_list
 
-        #pkg_preinst, pkg_postinst, pkg_prerm, and pkg_postrm
-        #self.__post_flag = "%post"
-        #self.__preun_flag = "%preun"
-        #self.__postun_flag = "%postun"
-        #self.__pre_flag = "%pre"
-
-    def get_script_section_key( self, __flag ):
+    def get_script_section_key(self, __flag):
         '''
         return the list of file section of the spec file.
         '''
@@ -1657,20 +1651,14 @@ class MetaSpec:
     def __create_script_file_section( self, spec_section):
         '''
         Returns the command executed in one of the %pre, %post, %preun
-        or %postun section of a spec file with the necessary Yocto
-        prefix "${D}".
+        or %postun section of a spec file.
         '''
-
         code = self.__spec_parser.get_script_section_key(spec_section)
         command_list = code.split("\n")
         formated_code = ""
         for line in command_list:
             if line != "":
                 formated_code += "    " + line + "\n"
-        formated_code = formated_code.replace(" /usr", " ${D}/usr")
-        formated_code = formated_code.replace(" /bin", " ${D}/bin")
-        formated_code = formated_code.replace(" /lib", " ${D}/lib")
-        formated_code = formated_code.replace(" /sbin", " ${D}/sbin")
 
         return formated_code
 
@@ -1678,7 +1666,6 @@ class MetaSpec:
         '''
         Writes the pre/post (un)install sections of the recipe.
         '''
-
         file_d.write("%s() {\n" % recipe_section)
         file_d.write("    #!/bin/sh -e\n")
         file_d.write("%s\n" % code)
@@ -1690,9 +1677,6 @@ class MetaSpec:
         Add the pre/post install/uninstall sections of a spec file to
         the recipe.
         '''
-
-        #pkg_preinst, pkg_postinst, pkg_prerm, and pkg_postrm
-
         code = self.__create_script_file_section("%pre")
         if code != "":
             self.__create_script_file_write(file_d, code, "pkg_preinst_${PN}")