file_d.write( "}\n" )
file_d.write( "\n" )
- def __create_script_file( self ,file_d):
+ def __create_script_file_section( self, spec_section):
'''
- generate script file.
+ Returns the command executed in one of the %pre, %post, %preun
+ or %postun section of a spec file with the necessary Yocto
+ prefix "${D}".
'''
- #pkg_preinst, pkg_postinst, pkg_prerm, and pkg_postrm
- code = self.__spec_parser.get_script_section_key("%post")
+ code = self.__spec_parser.get_script_section_key(spec_section)
command_list = code.split("\n")
formated_code = ""
for line in command_list:
formated_code = formated_code.replace(" /lib", " ${D}/lib")
formated_code = formated_code.replace(" /sbin", " ${D}/sbin")
- file_d.write("pkg_postinst_${PN}() {\n")
- file_d.write("%s\n" % formated_code)
+ return formated_code
+
+ def __create_script_file_write( self, file_d, code, recipe_section):
+ '''
+ 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)
file_d.write("}\n")
file_d.write("\n")
+ def __create_script_file( self, file_d):
+ '''
+ 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}")
+
+ code = self.__create_script_file_section("%post")
+ if code != "":
+ self.__create_script_file_write(file_d, code, "pkg_postinst_${PN}")
+
+ code = self.__create_script_file_section("%preun")
+ if code != "":
+ self.__create_script_file_write(file_d, code, "pkg_prerm_${PN}")
+
+ code = self.__create_script_file_section("%postun")
+ if code != "":
+ self.__create_script_file_write(file_d, code, "pkg_postrm_${PN}")
+
def __create_provides_file( self ,file_d):
'''
generate provide file.