* what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? @ 2021-08-25 20:35 Robert P. J. Day 2021-08-25 20:56 ` [OE-core] " Alexander Kanavin 0 siblings, 1 reply; 11+ messages in thread From: Robert P. J. Day @ 2021-08-25 20:35 UTC (permalink / raw) To: openembedded-core there will be many more questions about pkg_postinst (and related) routines shortly, but digging into these for the first time, i thought that that test checked whether the routine was being run at image creation time, or at first-time boot. now i'm not quite sure what to think after seeing several examples. what does the test for null or non-null variable "D" mean in a pkg_postinst routine? and once i figure all this out, i may very well contribute some enhanced docs for the next confused person. rday ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 20:35 what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? Robert P. J. Day @ 2021-08-25 20:56 ` Alexander Kanavin 2021-08-25 21:12 ` Robert P. J. Day 0 siblings, 1 reply; 11+ messages in thread From: Alexander Kanavin @ 2021-08-25 20:56 UTC (permalink / raw) To: Robert P. J. Day; +Cc: OE-core [-- Attachment #1: Type: text/plain, Size: 723 bytes --] If you show the confusing examples, we could try to figure it out. Alex On Wed, 25 Aug 2021 at 22:35, Robert P. J. Day <rpjday@crashcourse.ca> wrote: > > there will be many more questions about pkg_postinst (and related) > routines shortly, but digging into these for the first time, i > thought that that test checked whether the routine was being run > at image creation time, or at first-time boot. now i'm not quite > sure what to think after seeing several examples. > > what does the test for null or non-null variable "D" mean in > a pkg_postinst routine? and once i figure all this out, i may > very well contribute some enhanced docs for the next confused > person. > > rday > > > > > [-- Attachment #2: Type: text/html, Size: 1087 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 20:56 ` [OE-core] " Alexander Kanavin @ 2021-08-25 21:12 ` Robert P. J. Day 2021-08-25 21:18 ` Phil Blundell 0 siblings, 1 reply; 11+ messages in thread From: Robert P. J. Day @ 2021-08-25 21:12 UTC (permalink / raw) To: openembedded-core Quoting Alexander Kanavin <alex.kanavin@gmail.com>: > If you show the confusing examples, we could try to figure it out. > > Alex > > On Wed, 25 Aug 2021 at 22:35, Robert P. J. Day <rpjday@crashcourse.ca> > wrote: > >> >> there will be many more questions about pkg_postinst (and related) >> routines shortly, but digging into these for the first time, i >> thought that that test checked whether the routine was being run >> at image creation time, or at first-time boot. now i'm not quite >> sure what to think after seeing several examples. >> >> what does the test for null or non-null variable "D" mean in >> a pkg_postinst routine? and once i figure all this out, i may >> very well contribute some enhanced docs for the next confused >> person. there's no shortage of examples ... here's just one from recipes-bsp/alsa-state/alsa-state.bb: pkg_postinst:${PN}() { if test -z "$D" <======== then if test -x ${sbindir}/alsactl then ${sbindir}/alsactl -g -f ${localstatedir}/lib/alsa/asound.state restore fi fi } there's plenty more ... recipes-bsp/keymaps/keymaps_1.0.bb: pkg_postinst:${PN} () { if ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','true','false',d)}; then if [ -n "$D" ]; then <======== OPTS="--root=$D" fi systemctl $OPTS mask keymap.service fi } rday ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 21:12 ` Robert P. J. Day @ 2021-08-25 21:18 ` Phil Blundell 2021-08-25 21:27 ` Robert P. J. Day 2021-08-25 21:51 ` Robert P. J. Day 0 siblings, 2 replies; 11+ messages in thread From: Phil Blundell @ 2021-08-25 21:18 UTC (permalink / raw) To: openembedded-core, Robert P. J. Day [-- Attachment #1: Type: text/plain, Size: 1878 bytes --] That's testing for offline installation. If $D is not set, it's running on the target. p. On 25 August 2021 22:12:22 BST, "Robert P. J. Day" <rpjday@crashcourse.ca> wrote: > >Quoting Alexander Kanavin <alex.kanavin@gmail.com>: > >> If you show the confusing examples, we could try to figure it out. >> >> Alex >> >> On Wed, 25 Aug 2021 at 22:35, Robert P. J. Day <rpjday@crashcourse.ca> >> wrote: >> >>> >>> there will be many more questions about pkg_postinst (and related) >>> routines shortly, but digging into these for the first time, i >>> thought that that test checked whether the routine was being run >>> at image creation time, or at first-time boot. now i'm not quite >>> sure what to think after seeing several examples. >>> >>> what does the test for null or non-null variable "D" mean in >>> a pkg_postinst routine? and once i figure all this out, i may >>> very well contribute some enhanced docs for the next confused >>> person. > > there's no shortage of examples ... here's just one from >recipes-bsp/alsa-state/alsa-state.bb: > > >pkg_postinst:${PN}() { > if test -z "$D" <======== > then > if test -x ${sbindir}/alsactl > then > ${sbindir}/alsactl -g -f >${localstatedir}/lib/alsa/asound.state restore > fi > fi >} > > >there's plenty more ... recipes-bsp/keymaps/keymaps_1.0.bb: > > >pkg_postinst:${PN} () { > if ${@bb.utils.contains('DISTRO_FEATURES','systemd >sysvinit','true','false',d)}; then > if [ -n "$D" ]; then <======== > OPTS="--root=$D" > fi > systemctl $OPTS mask keymap.service > fi >} > > >rday > -- Sent from my Android device with K-9 Mail. Please excuse my brevity. [-- Attachment #2: Type: text/html, Size: 2525 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 21:18 ` Phil Blundell @ 2021-08-25 21:27 ` Robert P. J. Day 2021-08-25 21:40 ` Alexander Kanavin 2021-08-25 21:51 ` Robert P. J. Day 1 sibling, 1 reply; 11+ messages in thread From: Robert P. J. Day @ 2021-08-25 21:27 UTC (permalink / raw) To: Phil Blundell; +Cc: openembedded-core Quoting Phil Blundell <pb@pbcl.net>: > That's testing for offline installation. If $D is not set, it's > running on the target. > > p. right, that's exactly what i suspected in my original posting, i just wanted to make sure, which raises a couple issues. first, that distinction doesn't seem to be mentioned in the docs, so i'll ponder writing something. second, is that simply an old form that would be superseded by using "pkg_postinst_ontarget()" instead? anyway, more questions later as i work on some lengthier docs on this. rday ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 21:27 ` Robert P. J. Day @ 2021-08-25 21:40 ` Alexander Kanavin 0 siblings, 0 replies; 11+ messages in thread From: Alexander Kanavin @ 2021-08-25 21:40 UTC (permalink / raw) To: Robert P. J. Day; +Cc: Phil Blundell, OE-core [-- Attachment #1: Type: text/plain, Size: 872 bytes --] _ontarget() is basically syntactic sugar for $D test, but yes it's the new preferred form. If you see $D, that means the recipe hasn't been converted. Alex On Wed, 25 Aug 2021 at 23:27, Robert P. J. Day <rpjday@crashcourse.ca> wrote: > > Quoting Phil Blundell <pb@pbcl.net>: > > > That's testing for offline installation. If $D is not set, it's > > running on the target. > > > > p. > > right, that's exactly what i suspected in my original posting, > i just wanted to make sure, which raises a couple issues. > > first, that distinction doesn't seem to be mentioned in the > docs, so i'll ponder writing something. > > second, is that simply an old form that would be superseded > by using "pkg_postinst_ontarget()" instead? > > anyway, more questions later as i work on some lengthier docs > on this. > > rday > > > > > [-- Attachment #2: Type: text/html, Size: 1361 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 21:18 ` Phil Blundell 2021-08-25 21:27 ` Robert P. J. Day @ 2021-08-25 21:51 ` Robert P. J. Day 2021-08-25 22:02 ` Alexander Kanavin 1 sibling, 1 reply; 11+ messages in thread From: Robert P. J. Day @ 2021-08-25 21:51 UTC (permalink / raw) To: Phil Blundell; +Cc: openembedded-core Quoting Phil Blundell <pb@pbcl.net>: > That's testing for offline installation. If $D is not set, it's > running on the target. > > p. one last query before i head off for dinner ... so what about pkg_postinst() routines that do double duty, like this one from dbus_1.12.20.bb: PACKAGE_WRITE_DEPS += "${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','systemd-systemctl-native','',d)}" pkg_postinst:dbus() { # If both systemd and sysvinit are enabled, mask the dbus-1 init script if ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','true','false',d)}; then if [ -n "$D" ]; then OPTS="--root=$D" fi systemctl $OPTS mask dbus-1.service fi if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then /etc/init.d/populate-volatile.sh update fi } note how that routine checks its context and, as i recall (but it's not documented in the docs i'm looking at), i'd swear that i read somewhere that if a pkg_postinst() routine fails at image creation time, it was deferred until boot time, which would explain the above routine checking its runtime context. anyway, off for food. rday ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 21:51 ` Robert P. J. Day @ 2021-08-25 22:02 ` Alexander Kanavin 2021-08-26 8:41 ` Robert P. J. Day 2021-08-26 9:23 ` Robert P. J. Day 0 siblings, 2 replies; 11+ messages in thread From: Alexander Kanavin @ 2021-08-25 22:02 UTC (permalink / raw) To: Robert P. J. Day; +Cc: Phil Blundell, OE-core [-- Attachment #1: Type: text/plain, Size: 1835 bytes --] It used to be that 'exit 1' was the way to defer to boot time, but that was changed long time ago to not be ambiguous like that and cause a real failure at build time. Deferring to first boot needs to be explicitly requested with _ontarget() (you can read the definition for it to see what really happens, how $D is used and how request to defer is made). Alex On Wed, 25 Aug 2021 at 23:51, Robert P. J. Day <rpjday@crashcourse.ca> wrote: > > Quoting Phil Blundell <pb@pbcl.net>: > > > That's testing for offline installation. If $D is not set, it's > > running on the target. > > > > p. > > one last query before i head off for dinner ... so what about > pkg_postinst() routines that do double duty, like this one from > dbus_1.12.20.bb: > > > PACKAGE_WRITE_DEPS += "${@bb.utils.contains('DISTRO_FEATURES','systemd > sysvinit','systemd-systemctl-native','',d)}" > pkg_postinst:dbus() { > # If both systemd and sysvinit are enabled, mask the dbus-1 > init script > if ${@bb.utils.contains('DISTRO_FEATURES','systemd > sysvinit','true','false',d)}; then > if [ -n "$D" ]; then > OPTS="--root=$D" > fi > systemctl $OPTS mask dbus-1.service > fi > > if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then > /etc/init.d/populate-volatile.sh update > fi > } > > > note how that routine checks its context and, as i recall (but > it's not documented in the docs i'm looking at), i'd swear that > i read somewhere that if a pkg_postinst() routine fails at image > creation time, it was deferred until boot time, which would > explain the above routine checking its runtime context. > > anyway, off for food. > > rday > > > > > [-- Attachment #2: Type: text/html, Size: 2631 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 22:02 ` Alexander Kanavin @ 2021-08-26 8:41 ` Robert P. J. Day 2021-08-26 9:23 ` Robert P. J. Day 1 sibling, 0 replies; 11+ messages in thread From: Robert P. J. Day @ 2021-08-26 8:41 UTC (permalink / raw) To: Alexander Kanavin; +Cc: Phil Blundell, OE-core On Thu, 26 Aug 2021, Alexander Kanavin wrote: > It used to be that 'exit 1' was the way to defer to boot time, but > that was changed long time ago to not be ambiguous like that and > cause a real failure at build time. Deferring to first boot needs to > be explicitly requested with _ontarget() (you can read the > definition for it to see what really happens, how $D is used and how > request to defer is made). > > Alex and that's sort of what i thought, despite what the docs currently say: https://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html#new-recipe-post-installation-scripts "If you do not use this variable, the tools might be missing and execution of the post-installation script is deferred until first boot." i'll put together some enhanced docs that clear this up, and submit to docs list. rday ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-25 22:02 ` Alexander Kanavin 2021-08-26 8:41 ` Robert P. J. Day @ 2021-08-26 9:23 ` Robert P. J. Day 2021-08-26 11:51 ` Alexander Kanavin 1 sibling, 1 reply; 11+ messages in thread From: Robert P. J. Day @ 2021-08-26 9:23 UTC (permalink / raw) To: Alexander Kanavin; +Cc: Phil Blundell, OE-core [-- Attachment #1: Type: text/plain, Size: 2777 bytes --] On Thu, 26 Aug 2021, Alexander Kanavin wrote: > It used to be that 'exit 1' was the way to defer to boot time, but > that was changed long time ago to not be ambiguous like that and > cause a real failure at build time. Deferring to first boot needs to > be explicitly requested with _ontarget() (you can read the > definition for it to see what really happens, how $D is used and how > request to defer is made). > > Alex > > On Wed, 25 Aug 2021 at 23:51, Robert P. J. Day <rpjday@crashcourse.ca> wrote: > > Quoting Phil Blundell <pb@pbcl.net>: > > > That's testing for offline installation. If $D is not set, it's > > running on the target. > > > > p. > > one last query before i head off for dinner ... so what about > pkg_postinst() routines that do double duty, like this one from > dbus_1.12.20.bb: > > > PACKAGE_WRITE_DEPS += "${@bb.utils.contains('DISTRO_FEATURES','systemd > sysvinit','systemd-systemctl-native','',d)}" > pkg_postinst:dbus() { > # If both systemd and sysvinit are enabled, mask the dbus-1 > init script > if ${@bb.utils.contains('DISTRO_FEATURES','systemd > sysvinit','true','false',d)}; then > if [ -n "$D" ]; then > OPTS="--root=$D" > fi > systemctl $OPTS mask dbus-1.service > fi > > if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then > /etc/init.d/populate-volatile.sh update > fi > } so, just to confirm the previous tidbits of information (thank you for your patience), here's my current understanding so i can submit updated docs: * pkg_postinst:${PN} is run at image creation time and *only* at image creation time; it is no longer deferred to boot time under any circumstances(?) * pkg_postinst_ontarget:${PN} is run at boot time and *only* at boot time * because of the above, there is no value to the numerous legacy checks of: if [ -z "$D" ] if [ -n "$D" ] or any of its variations (even though, in a lot of cases, they don't hurt) * from within pkg_postinst:${PN}, you can still defer some work to boot time with "postinst_intercept delay_to_first_boot", although isn't this precisely what pkg_postinst_ontarget:${PN} is for, so is this postinst_intercept construct still useful? * PACKAGE_WRITE_DEPS is still necessary to identify non-standard native tools you might need for any pkg_postinst:${PN} processing does all that look about right? rday ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [OE-core] what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? 2021-08-26 9:23 ` Robert P. J. Day @ 2021-08-26 11:51 ` Alexander Kanavin 0 siblings, 0 replies; 11+ messages in thread From: Alexander Kanavin @ 2021-08-26 11:51 UTC (permalink / raw) To: Robert P. J. Day; +Cc: Phil Blundell, OE-core [-- Attachment #1: Type: text/plain, Size: 1915 bytes --] On Thu, 26 Aug 2021 at 11:23, Robert P. J. Day <rpjday@crashcourse.ca> wrote: > so, just to confirm the previous tidbits of information (thank you > for your patience), here's my current understanding so i can submit > updated docs: > > * pkg_postinst:${PN} is run at image creation time and *only* at image > creation time; it is no longer deferred to boot time under any > circumstances(?) > If a package is installed on directly target using a package management system, this will run there. Also, if the snippet does contain an explicit call to the defer to first boot hook as a part of its logic, then that will happen, and the same code will run again on first boot. > * pkg_postinst_ontarget:${PN} is run at boot time and *only* at boot > time > First boot, or package installation on target. > * because of the above, there is no value to the numerous legacy > checks of: > > if [ -z "$D" ] > if [ -n "$D" ] > > or any of its variations (even though, in a lot of cases, they don't > hurt) > There might be use cases for doing explicit manual logic where you want full control over a) checking what environment you're in b) doing first boot deferral. In that case, you want to use $D and the hook directly. But most are legacy scriptlets that need converting for readability. > * from within pkg_postinst:${PN}, you can still defer some work to > boot time with "postinst_intercept delay_to_first_boot", although > isn't this precisely what pkg_postinst_ontarget:${PN} is for, so is > this postinst_intercept construct still useful? > _ontarget is basically a wrapper for the delay to first boot hook. It might be useful for manual control, as explained above. > * PACKAGE_WRITE_DEPS is still necessary to identify non-standard > native tools you might need for any pkg_postinst:${PN} processing > Yes. Alex [-- Attachment #2: Type: text/html, Size: 3185 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-08-26 11:51 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-08-25 20:35 what means the test 'if [ -z "$D" ]' in a pkg_postinst routine? Robert P. J. Day 2021-08-25 20:56 ` [OE-core] " Alexander Kanavin 2021-08-25 21:12 ` Robert P. J. Day 2021-08-25 21:18 ` Phil Blundell 2021-08-25 21:27 ` Robert P. J. Day 2021-08-25 21:40 ` Alexander Kanavin 2021-08-25 21:51 ` Robert P. J. Day 2021-08-25 22:02 ` Alexander Kanavin 2021-08-26 8:41 ` Robert P. J. Day 2021-08-26 9:23 ` Robert P. J. Day 2021-08-26 11:51 ` Alexander Kanavin
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.