How to add postinst and prerm scripts to a recipe?
I have a package that has postinst and prerm scripts that are embedded when packaging as a DEB file. Now I want to write a recipe for that package, but I cannot figure out how to add the postinst and prerm scripts in the final packaging.
You need to install and package the scripts as 'regular' scripts on target, and then write postinst() recipe snippets that call the scripts.
Alex
Quoted 11 lines · hchanuy via lists.yoctoproject.org
I have a package that has postinst and prerm scripts that are embedded when packaging as a DEB file. Now I want to write a recipe for that package, but I cannot figure out how to add the postinst and prerm scripts in the final packaging.
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#64118): https://lists.yoctoproject.org/g/yocto/message/64118
Mute This Topic: https://lists.yoctoproject.org/mt/109204322/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Could you give me an example? I can install the scripts as regular scripts but since DEB and RPM have different naming for these scripts, do i have to write package manager dependant code?
You can rename the scripts when you install them into something generic:
do_install() {}
install ${S}/debian/rules/postinst ${D}/${bindir}/my-package-postinst.sh
}then in
pkg_postinst:${PN} () {
sh my-package-postinst.sh
}
Alex
Quoted 11 lines · Uy Ha via lists.yoctoproject.org
Could you give me an example? I can install the scripts as regular scripts but since DEB and RPM have different naming for these scripts, do i have to write package manager dependant code?
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#64121): https://lists.yoctoproject.org/g/yocto/message/64121
Mute This Topic: https://lists.yoctoproject.org/mt/109204322/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
That works for postinst, but what about prerm? It is run only when the package is removed in future so it cannot be done at bitbake build time
Why? prerm would work just the same and there are examples in meta/:
pkg_prerm:${PN} () {
sh run-my-prerm-script.sh
}
Alex
Quoted 2 lines · Uy Ha via Lists.Yoctoproject.Org
That works for postinst, but what about prerm? It is run only when the package is removed in future so it cannot be done at bitbake build time
I'm just not really sure what pkg_prerm does. Does it create a script that will be run when the package is removed? or does it run entirely during bitbake build step?
Quoted 2 lines · Uy Ha via Lists.Yoctoproject.Org
I'm just not really sure what
pkg_prermdoes. Does it create a script that will be run when the package is removed? or does it run entirely during bitbake build step?
It creates a 'scriptlet' embedded into rpm package (for the sake of example). rpm will write the scriptlet into the target package database when you install the package, and take the 'scriptlet' from that database whenever the package is removed, and then give it to shell interpreter. Then you can put the actual script in that scriptlet.
I'd suggest you run experiments with for example poky and toy recipes and sample images that have package management, it's not difficult to do.
Alex