These run
- at image creation time in the context of package manager (dnf/apt/opkg)
installing packages into the image rootfs directory. The code that executes
the package manager specifically exports $D into the environment before
launching it.
- at runtime when packages are installed or updated through the same
package manager. Then, $D is absent.

The scripts are written into the package files when the packages gets
created; they become 'post-install scriptlets' that every package manager
supports and executes if they are present.

Alex

On Tue, 7 Apr 2020 at 21:11, Robert P. J. Day <[email protected]> wrote:

>
>   first time looking closely at pkg_postinst_* routines, so can
> someone clarify the use of "$D" in those routines? at the moment, i'm
> *guessing* that those routines need to be able to run in two different
> contexts (but i could be wrong):
>
>   1) at image creation time
>   2) at later package installation time on a running system
>
> i'm aware that bitbake requires the use of curly braces, so always
> must use "${D}", so in something like this from xorg-font-common.inc,
> how does OE process this shell function? as in, what context do those
> routines run in?
>
>   pkg_postinst_${PN} () {
>         for fontdir in `find $D/usr/lib/X11/fonts -type d`; do
>                 mkfontdir $fontdir
>                 mkfontscale $fontdir
>         done
>         for fontdir in `find $D/usr/share/fonts/X11 -type d`; do
>                 mkfontdir $fontdir
>                 mkfontscale $fontdir
>         done
>   }
>
> it seems(?) clear that testing $D is the way to tell which of the two
> contexts one is running in, as in:
>
>   pkg_postinst_${PN}_class-target () {
>         if [ "x$D" != "x" ]; then
>           rootarg="--root $D"
>         else
>           rootarg=""
>         fi
>         ... snip ...
>
> such that if $D is the empty string, then you're in the context of a
> running system. am i close?
>
> rday
>
> p.s. i notice there are two ways that $D is used to define the
> context. in some cases, just using it (as in the first example above)
> is sufficient, while in other cases (as in the second case), the
> routine needs to actually test the value.
> 
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#137102): 
https://lists.openembedded.org/g/openembedded-core/message/137102
Mute This Topic: https://lists.openembedded.org/mt/72858070/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to