Patchwork gtk-icon-cache.bbclass: Fix multiple rebuilds of the icon cache on first boot

login
register
mail settings
Submitter Andreas Müller
Date March 22, 2012, 7:15 p.m.
Message ID <1332443701-24282-1-git-send-email-schnitzeltony@googlemail.com>
Download mbox | patch
Permalink /patch/24179/
State New
Headers show

Comments

Andreas Müller - March 22, 2012, 7:15 p.m.
* Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
* With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
* This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
* Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
* Run-tested with systemd and opkg

Signed-off-by: Samuel Stirtzel <s.stirtzel@googlemail.com>
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
---
 meta/classes/gtk-icon-cache.bbclass                |   19 +++++++++-------
 .../gtk+/gtk-update-icon-cache-runonce.bb          |   23 ++++++++++++++++++++
 .../gtk-update-icon-cache-runonce.in               |   16 +++++++++++++
 3 files changed, 50 insertions(+), 8 deletions(-)
 create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb
 create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in
Koen Kooi - March 22, 2012, 7:34 p.m.
Op 22 mrt. 2012, om 20:15 heeft Andreas Müller het volgende geschreven:

> * Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
> * With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
> * This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
> * Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
> * Run-tested with systemd and opkg

Wouldn't adding it to the opkg intercept code (and likely rpm as well) be a better idea?

regards,

Koen
Andreas Müller - March 22, 2012, 7:51 p.m.
On Thu, Mar 22, 2012 at 8:34 PM, Koen Kooi <koen@dominion.thruhere.net> wrote:
>
> Op 22 mrt. 2012, om 20:15 heeft Andreas Müller het volgende geschreven:
>
>> * Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
>> * With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
>> * This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
>> * Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
>> * Run-tested with systemd and opkg
>
> Wouldn't adding it to the opkg intercept code (and likely rpm as well) be a better idea?
>
We wanted to be independent of package manager selected and decided to
follow the systemd-compat-units approach. Ehm opkg intercept code -
teach me :)

Andreas
Koen Kooi - March 22, 2012, 8:06 p.m.
Op 22 mrt. 2012, om 20:51 heeft Andreas Müller het volgende geschreven:

> On Thu, Mar 22, 2012 at 8:34 PM, Koen Kooi <koen@dominion.thruhere.net> wrote:
>> 
>> Op 22 mrt. 2012, om 20:15 heeft Andreas Müller het volgende geschreven:
>> 
>>> * Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
>>> * With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
>>> * This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
>>> * Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
>>> * Run-tested with systemd and opkg
>> 
>> Wouldn't adding it to the opkg intercept code (and likely rpm as well) be a better idea?
>> 
> We wanted to be independent of package manager selected and decided to
> follow the systemd-compat-units approach. Ehm opkg intercept code -
> teach me :)

Have a look at http://code.google.com/p/opkg/source/browse/#svn%2Ftrunk%2Fintercept

It is a bit iffy to encode knowledge of postinsts into the package manager, but you show that something like that is needed. Another thought: can the icon updates be done at do_rootfs time and mark the postinsts as done?

regards,

Koen
Richard Purdie - March 23, 2012, 12:12 p.m.
On Thu, 2012-03-22 at 20:15 +0100, Andreas Müller wrote:
> * Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
> * With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
> * This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
> * Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
> * Run-tested with systemd and opkg
> 
> Signed-off-by: Samuel Stirtzel <s.stirtzel@googlemail.com>
> Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
> ---
>  meta/classes/gtk-icon-cache.bbclass                |   19 +++++++++-------
>  .../gtk+/gtk-update-icon-cache-runonce.bb          |   23 ++++++++++++++++++++
>  .../gtk-update-icon-cache-runonce.in               |   16 +++++++++++++
>  3 files changed, 50 insertions(+), 8 deletions(-)
>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb
>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in
> 
> diff --git a/meta/classes/gtk-icon-cache.bbclass b/meta/classes/gtk-icon-cache.bbclass
> index 60e3401..b48aabe 100644
> --- a/meta/classes/gtk-icon-cache.bbclass
> +++ b/meta/classes/gtk-icon-cache.bbclass
> @@ -9,14 +9,16 @@ if [ "x$D" != "x" ]; then
>          exit 1
>  fi
>  
> -# Update the pixbuf loaders in case they haven't been registered yet
> -GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
> -
> -for icondir in /usr/share/icons/* ; do
> -    if [ -d $icondir ] ; then
> -        gtk-update-icon-cache -fqt  $icondir
> -    fi
> -done
> +# do not execute in case a final run-once is waiting
> +if [ ! -e ${sysconfdir}/init.d/gtk-update-icon-cache-runonce ]; then
> +    # Update the pixbuf loaders in case they haven't been registered yet
> +    GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
> +    for icondir in /usr/share/icons/* ; do
> +        if [ -d $icondir ] ; then
> +            gtk-update-icon-cache -fqt  $icondir
> +        fi
> +    done
> +fi


Can't we just reduce this to adding a "touch
${sysconfdir}/init.d/gtk-update-icon-cache-runonce" to the above code
and then clear that file at boot time?

Cheers,

Richard
Andreas Müller - March 23, 2012, 10:46 p.m.
On Fri, Mar 23, 2012 at 1:12 PM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> On Thu, 2012-03-22 at 20:15 +0100, Andreas Müller wrote:
>> * Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
>> * With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
>> * This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
>> * Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
>> * Run-tested with systemd and opkg
>>
>> Signed-off-by: Samuel Stirtzel <s.stirtzel@googlemail.com>
>> Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
>> ---
>>  meta/classes/gtk-icon-cache.bbclass                |   19 +++++++++-------
>>  .../gtk+/gtk-update-icon-cache-runonce.bb          |   23 ++++++++++++++++++++
>>  .../gtk-update-icon-cache-runonce.in               |   16 +++++++++++++
>>  3 files changed, 50 insertions(+), 8 deletions(-)
>>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb
>>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in
>>
>> diff --git a/meta/classes/gtk-icon-cache.bbclass b/meta/classes/gtk-icon-cache.bbclass
>> index 60e3401..b48aabe 100644
>> --- a/meta/classes/gtk-icon-cache.bbclass
>> +++ b/meta/classes/gtk-icon-cache.bbclass
>> @@ -9,14 +9,16 @@ if [ "x$D" != "x" ]; then
>>          exit 1
>>  fi
>>
>> -# Update the pixbuf loaders in case they haven't been registered yet
>> -GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
>> -
>> -for icondir in /usr/share/icons/* ; do
>> -    if [ -d $icondir ] ; then
>> -        gtk-update-icon-cache -fqt  $icondir
>> -    fi
>> -done
>> +# do not execute in case a final run-once is waiting
>> +if [ ! -e ${sysconfdir}/init.d/gtk-update-icon-cache-runonce ]; then
>> +    # Update the pixbuf loaders in case they haven't been registered yet
>> +    GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
>> +    for icondir in /usr/share/icons/* ; do
>> +        if [ -d $icondir ] ; then
>> +            gtk-update-icon-cache -fqt  $icondir
>> +        fi
>> +    done
>> +fi
>
>
> Can't we just reduce this to adding a "touch
> ${sysconfdir}/init.d/gtk-update-icon-cache-runonce" to the above code
> and then clear that file at boot time?
>
Maybe it's a misunderstanding on my side but how shall an empty file
cover the three tasks during 1st boot:

1. Preventing all postints of running gtk-update-icon-cache by existing
2. Running gtk-update-icon-cache ( after postinsts )
3. Deleting itself and thereby avoid running during subsequent boots
and ensuring that packages which are installed later do run
gtk-update-icon-cache.

Andreas
Richard Purdie - March 23, 2012, 11:37 p.m.
On Fri, 2012-03-23 at 23:46 +0100, Andreas Müller wrote:
> On Fri, Mar 23, 2012 at 1:12 PM, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > On Thu, 2012-03-22 at 20:15 +0100, Andreas Müller wrote:
> >> * Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
> >> * With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
> >> * This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
> >> * Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
> >> * Run-tested with systemd and opkg
> >>
> >> Signed-off-by: Samuel Stirtzel <s.stirtzel@googlemail.com>
> >> Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
> >> ---
> >>  meta/classes/gtk-icon-cache.bbclass                |   19 +++++++++-------
> >>  .../gtk+/gtk-update-icon-cache-runonce.bb          |   23 ++++++++++++++++++++
> >>  .../gtk-update-icon-cache-runonce.in               |   16 +++++++++++++
> >>  3 files changed, 50 insertions(+), 8 deletions(-)
> >>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb
> >>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in
> >>
> >> diff --git a/meta/classes/gtk-icon-cache.bbclass b/meta/classes/gtk-icon-cache.bbclass
> >> index 60e3401..b48aabe 100644
> >> --- a/meta/classes/gtk-icon-cache.bbclass
> >> +++ b/meta/classes/gtk-icon-cache.bbclass
> >> @@ -9,14 +9,16 @@ if [ "x$D" != "x" ]; then
> >>          exit 1
> >>  fi
> >>
> >> -# Update the pixbuf loaders in case they haven't been registered yet
> >> -GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
> >> -
> >> -for icondir in /usr/share/icons/* ; do
> >> -    if [ -d $icondir ] ; then
> >> -        gtk-update-icon-cache -fqt  $icondir
> >> -    fi
> >> -done
> >> +# do not execute in case a final run-once is waiting
> >> +if [ ! -e ${sysconfdir}/init.d/gtk-update-icon-cache-runonce ]; then
> >> +    # Update the pixbuf loaders in case they haven't been registered yet
> >> +    GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
> >> +    for icondir in /usr/share/icons/* ; do
> >> +        if [ -d $icondir ] ; then
> >> +            gtk-update-icon-cache -fqt  $icondir
> >> +        fi
> >> +    done
> >> +fi
> >
> >
> > Can't we just reduce this to adding a "touch
> > ${sysconfdir}/init.d/gtk-update-icon-cache-runonce" to the above code
> > and then clear that file at boot time?
> >
> Maybe it's a misunderstanding on my side but how shall an empty file
> cover the three tasks during 1st boot:
> 
> 1. Preventing all postints of running gtk-update-icon-cache by existing
> 2. Running gtk-update-icon-cache ( after postinsts )
> 3. Deleting itself and thereby avoid running during subsequent boots
> and ensuring that packages which are installed later do run
> gtk-update-icon-cache.

The first time something tries this it creates the "lock".
Any subsequent postinstall sees the "lock" and knows not to run.

There are two problems:

a) Knowing these are postinstalls at first boot and not package installs
b) Deleting the unused "lock" files afterwards

You'd therefore probably have to add something to the postinstalls core
which:

a) Creates some file during final rootfs postinstalls on first boot
b) Clears some set of files after first boot.

I don't see a major issue with doing either of these two things though
and it would simplify your patch whilst also allowing other similar
cases to work in a similar way.

Cheers,

Richard
Andreas Müller - March 26, 2012, 7:39 a.m.
On Sat, Mar 24, 2012 at 12:37 AM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> On Fri, 2012-03-23 at 23:46 +0100, Andreas Müller wrote:
>> On Fri, Mar 23, 2012 at 1:12 PM, Richard Purdie
>> <richard.purdie@linuxfoundation.org> wrote:
>> > On Thu, 2012-03-22 at 20:15 +0100, Andreas Müller wrote:
>> >> * Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
>> >> * With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
>> >> * This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
>> >> * Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
>> >> * Run-tested with systemd and opkg
>> >>
>> >> Signed-off-by: Samuel Stirtzel <s.stirtzel@googlemail.com>
>> >> Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
>> >> ---
>> >>  meta/classes/gtk-icon-cache.bbclass                |   19 +++++++++-------
>> >>  .../gtk+/gtk-update-icon-cache-runonce.bb          |   23 ++++++++++++++++++++
>> >>  .../gtk-update-icon-cache-runonce.in               |   16 +++++++++++++
>> >>  3 files changed, 50 insertions(+), 8 deletions(-)
>> >>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb
>> >>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in
>> >>
>> >> diff --git a/meta/classes/gtk-icon-cache.bbclass b/meta/classes/gtk-icon-cache.bbclass
>> >> index 60e3401..b48aabe 100644
>> >> --- a/meta/classes/gtk-icon-cache.bbclass
>> >> +++ b/meta/classes/gtk-icon-cache.bbclass
>> >> @@ -9,14 +9,16 @@ if [ "x$D" != "x" ]; then
>> >>          exit 1
>> >>  fi
>> >>
>> >> -# Update the pixbuf loaders in case they haven't been registered yet
>> >> -GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
>> >> -
>> >> -for icondir in /usr/share/icons/* ; do
>> >> -    if [ -d $icondir ] ; then
>> >> -        gtk-update-icon-cache -fqt  $icondir
>> >> -    fi
>> >> -done
>> >> +# do not execute in case a final run-once is waiting
>> >> +if [ ! -e ${sysconfdir}/init.d/gtk-update-icon-cache-runonce ]; then
>> >> +    # Update the pixbuf loaders in case they haven't been registered yet
>> >> +    GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
>> >> +    for icondir in /usr/share/icons/* ; do
>> >> +        if [ -d $icondir ] ; then
>> >> +            gtk-update-icon-cache -fqt  $icondir
>> >> +        fi
>> >> +    done
>> >> +fi
>> >
>> >
>> > Can't we just reduce this to adding a "touch
>> > ${sysconfdir}/init.d/gtk-update-icon-cache-runonce" to the above code
>> > and then clear that file at boot time?
>> >
>> Maybe it's a misunderstanding on my side but how shall an empty file
>> cover the three tasks during 1st boot:
>>
>> 1. Preventing all postints of running gtk-update-icon-cache by existing
>> 2. Running gtk-update-icon-cache ( after postinsts )
>> 3. Deleting itself and thereby avoid running during subsequent boots
>> and ensuring that packages which are installed later do run
>> gtk-update-icon-cache.
>
> The first time something tries this it creates the "lock".
> Any subsequent postinstall sees the "lock" and knows not to run.
>
> There are two problems:
>
> a) Knowing these are postinstalls at first boot and not package installs
> b) Deleting the unused "lock" files afterwards
>
> You'd therefore probably have to add something to the postinstalls core
> which:
>
> a) Creates some file during final rootfs postinstalls on first boot
> b) Clears some set of files after first boot.
Isn't this exactly what we are doing?
>
> I don't see a major issue with doing either of these two things though
> and it would simplify your patch whilst also allowing other similar
> cases to work in a similar way.
>
We presented a working solution fixing an issue existing for long time
and don't see that this suggestion gives major enhancements. Feel free
to present a different solution.

Andreas
Richard Purdie - March 26, 2012, 9:19 a.m.
On Mon, 2012-03-26 at 09:39 +0200, Andreas Müller wrote:
> On Sat, Mar 24, 2012 at 12:37 AM, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > On Fri, 2012-03-23 at 23:46 +0100, Andreas Müller wrote:
> >> On Fri, Mar 23, 2012 at 1:12 PM, Richard Purdie
> >> <richard.purdie@linuxfoundation.org> wrote:
> >> > On Thu, 2012-03-22 at 20:15 +0100, Andreas Müller wrote:
> >> >> * Before this patch every inheritance of this class rebuilt the full icon cache at the first boot.
> >> >> * With this patch the icon cache will only be build once at the first boot and on pkg installations that require it.
> >> >> * This patch reduces the time needed for the first boot from 96 minutes to 5 minutes on the test machine.
> >> >> * Build-tested incremental (BB_SIGNATURE_HANDLER = "OEBasicHash") & from scratch
> >> >> * Run-tested with systemd and opkg
> >> >>
> >> >> Signed-off-by: Samuel Stirtzel <s.stirtzel@googlemail.com>
> >> >> Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
> >> >> ---
> >> >>  meta/classes/gtk-icon-cache.bbclass                |   19 +++++++++-------
> >> >>  .../gtk+/gtk-update-icon-cache-runonce.bb          |   23 ++++++++++++++++++++
> >> >>  .../gtk-update-icon-cache-runonce.in               |   16 +++++++++++++
> >> >>  3 files changed, 50 insertions(+), 8 deletions(-)
> >> >>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb
> >> >>  create mode 100644 meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in
> >> >>
> >> >> diff --git a/meta/classes/gtk-icon-cache.bbclass b/meta/classes/gtk-icon-cache.bbclass
> >> >> index 60e3401..b48aabe 100644
> >> >> --- a/meta/classes/gtk-icon-cache.bbclass
> >> >> +++ b/meta/classes/gtk-icon-cache.bbclass
> >> >> @@ -9,14 +9,16 @@ if [ "x$D" != "x" ]; then
> >> >>          exit 1
> >> >>  fi
> >> >>
> >> >> -# Update the pixbuf loaders in case they haven't been registered yet
> >> >> -GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
> >> >> -
> >> >> -for icondir in /usr/share/icons/* ; do
> >> >> -    if [ -d $icondir ] ; then
> >> >> -        gtk-update-icon-cache -fqt  $icondir
> >> >> -    fi
> >> >> -done
> >> >> +# do not execute in case a final run-once is waiting
> >> >> +if [ ! -e ${sysconfdir}/init.d/gtk-update-icon-cache-runonce ]; then
> >> >> +    # Update the pixbuf loaders in case they haven't been registered yet
> >> >> +    GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
> >> >> +    for icondir in /usr/share/icons/* ; do
> >> >> +        if [ -d $icondir ] ; then
> >> >> +            gtk-update-icon-cache -fqt  $icondir
> >> >> +        fi
> >> >> +    done
> >> >> +fi
> >> >
> >> >
> >> > Can't we just reduce this to adding a "touch
> >> > ${sysconfdir}/init.d/gtk-update-icon-cache-runonce" to the above code
> >> > and then clear that file at boot time?
> >> >
> >> Maybe it's a misunderstanding on my side but how shall an empty file
> >> cover the three tasks during 1st boot:
> >>
> >> 1. Preventing all postints of running gtk-update-icon-cache by existing
> >> 2. Running gtk-update-icon-cache ( after postinsts )
> >> 3. Deleting itself and thereby avoid running during subsequent boots
> >> and ensuring that packages which are installed later do run
> >> gtk-update-icon-cache.
> >
> > The first time something tries this it creates the "lock".
> > Any subsequent postinstall sees the "lock" and knows not to run.
> >
> > There are two problems:
> >
> > a) Knowing these are postinstalls at first boot and not package installs
> > b) Deleting the unused "lock" files afterwards
> >
> > You'd therefore probably have to add something to the postinstalls core
> > which:
> >
> > a) Creates some file during final rootfs postinstalls on first boot
> > b) Clears some set of files after first boot.
> Isn't this exactly what we are doing?
> >
> > I don't see a major issue with doing either of these two things though
> > and it would simplify your patch whilst also allowing other similar
> > cases to work in a similar way.
> >
> We presented a working solution fixing an issue existing for long time
> and don't see that this suggestion gives major enhancements. Feel free
> to present a different solution.

Right, what I'm trying to figure out is whether we can simplify that
implementation a little so we don't need a new recipe, dependencies and
a new init script. There is nothing wrong with that solution but I think
its possible to simplify things a little.

My worry is whether the simplifications I have in mind will work in the
systemd world :/.

Cheers,

Richard
Andreas Müller - March 26, 2012, 11:43 a.m.
On Mon, Mar 26, 2012 at 11:19 AM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>> > There are two problems:
>> >
>> > a) Knowing these are postinstalls at first boot and not package installs
>> > b) Deleting the unused "lock" files afterwards
>> >
>> > You'd therefore probably have to add something to the postinstalls core
>> > which:
>> >
>> > a) Creates some file during final rootfs postinstalls on first boot
>> > b) Clears some set of files after first boot.
>> Isn't this exactly what we are doing?
>> >
>> > I don't see a major issue with doing either of these two things though
>> > and it would simplify your patch whilst also allowing other similar
>> > cases to work in a similar way.
>> >
>> We presented a working solution fixing an issue existing for long time
>> and don't see that this suggestion gives major enhancements. Feel free
>> to present a different solution.
>
> Right, what I'm trying to figure out is whether we can simplify that
> implementation a little so we don't need a new recipe, dependencies and
> a new init script. There is nothing wrong with that solution but I think
> its possible to simplify things a little.
OK - you are looking for a more generic approach (next candidate might
be mime.bbclass/update-mime-database). Without taking care of how /
where / by whom a framework for runonce-functionalty is going to be
implemented - how about:

 * Each class/recipe requiring runonce functionality adds code
snippets by appending into a global variable. For
gtk-icon-cache.bbclass something like

<snip>
gtk-update-icon-cache-runonce = " \
gtk-update-icon-cache-runonce() {
    for icondir in @datadir@/icons/* ; do \
        if [ -d $icondir ] ; then \
            gtk-update-icon-cache -fqt $icondir
        fi
    done
}
"

# online
RUNONCE_TASKS += "gtk-update-icon-cache-runonce"
# offline - requires gtk+-native
# RUNONCE_TASKS_OFFLINE += "gtk-update-icon-cache-runonce"

gtk_icon_cache_postinst() {
if [ "x$D" != "x" ]; then
        exit 1
fi

# after 1st boot
if [ ! -e ${sysconfdir}/init.d/runonce ]; then
    ${gtk-update-icon-cache-runonce}
fi
}
<\snip>

* In case the global variable RUNONCE_TASKS is not empty, the
framework creates one systemwide initscript (
${sysconfdir}/init.d/runonce ) + systemd-service ( we sent systemd
implementation for gtk-icon-update approach in meta-oe [1] ). The
contents of this script are the snippets and code to delete itself and
systemd-stuff. Since the code snippets are identified by a name ( here
gtk-update-icon-cache-runonce ), it is no problem to ensure that each
snippet is added only once.
* In case RUNONCE_TASK_OFFLINE  is not empty,  the framework creates
one script with similar contents. This is called after
offline-postinst. If we decide to have gtk+-native in oe-core, we
could do gtk-icon-update offline ( as Koen suggested ).

> My worry is whether the simplifications I have in mind will work in the
> systemd world :/.
See above

Andreas

[1] http://patches.openembedded.org/patch/24181/

Patch

diff --git a/meta/classes/gtk-icon-cache.bbclass b/meta/classes/gtk-icon-cache.bbclass
index 60e3401..b48aabe 100644
--- a/meta/classes/gtk-icon-cache.bbclass
+++ b/meta/classes/gtk-icon-cache.bbclass
@@ -9,14 +9,16 @@  if [ "x$D" != "x" ]; then
         exit 1
 fi
 
-# Update the pixbuf loaders in case they haven't been registered yet
-GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
-
-for icondir in /usr/share/icons/* ; do
-    if [ -d $icondir ] ; then
-        gtk-update-icon-cache -fqt  $icondir
-    fi
-done
+# do not execute in case a final run-once is waiting
+if [ ! -e ${sysconfdir}/init.d/gtk-update-icon-cache-runonce ]; then
+    # Update the pixbuf loaders in case they haven't been registered yet
+    GDK_PIXBUF_MODULEDIR=${libdir}/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
+    for icondir in /usr/share/icons/* ; do
+        if [ -d $icondir ] ; then
+            gtk-update-icon-cache -fqt  $icondir
+        fi
+    done
+fi
 }
 
 gtk_icon_cache_postrm() {
@@ -56,3 +58,4 @@  python populate_packages_append () {
 		d.setVar('pkg_postrm_%s' % pkg, postrm)
 }
 
+RDEPENDS += "gtk-update-icon-cache-runonce"
diff --git a/meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb b/meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb
new file mode 100644
index 0000000..55bec67
--- /dev/null
+++ b/meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce.bb
@@ -0,0 +1,23 @@ 
+DESCRIPTION = "Init script calling gtk-update-icon-cache once"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58"
+
+SRC_URI = "file://gtk-update-icon-cache-runonce.in"
+
+INIT_SEQ_NUM = "99"
+
+inherit update-rc.d
+
+do_install() {
+	install -d ${D}${sysconfdir}/init.d
+	sed -e 's,@libdir@,${libdir},g' \
+            -e 's,@datadir@,${datadir},g' \
+            -e 's,@sysconfdir@,${sysconfdir},g' \
+            -e 's,@INIT_SEQ_NUM@,${INIT_SEQ_NUM},g' \
+             < ${WORKDIR}/gtk-update-icon-cache-runonce.in \
+             > ${D}${sysconfdir}/init.d/gtk-update-icon-cache-runonce
+	chmod 755 ${D}${sysconfdir}/init.d/gtk-update-icon-cache-runonce
+}
+
+INITSCRIPT_NAME = "gtk-update-icon-cache-runonce"
+INITSCRIPT_PARAMS = "start ${INIT_SEQ_NUM} S ."
diff --git a/meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in b/meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in
new file mode 100644
index 0000000..8952e1a
--- /dev/null
+++ b/meta/recipes-gnome/gtk+/gtk-update-icon-cache-runonce/gtk-update-icon-cache-runonce.in
@@ -0,0 +1,16 @@ 
+#!/bin/sh
+
+echo 'Updating the GTK icon cache...'
+
+# Update the pixbuf loaders in case they haven't been registered yet
+GDK_PIXBUF_MODULEDIR=@libdir@/gdk-pixbuf-2.0/2.10.0/loaders gdk-pixbuf-query-loaders --update-cache
+
+for icondir in @datadir@/icons/* ; do
+    if [ -d $icondir ] ; then
+        gtk-update-icon-cache -fqt $icondir
+    fi
+done
+
+# This script should only run once at the first boot of the machine
+rm -f @sysconfdir@/rcS.d/S@INIT_SEQ_NUM@gtk-update-icon-cache-runonce
+rm -f @sysconfdir@/init.d/gtk-update-icon-cache-runonce