[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Avoid running update-initramfs more than once during installation



When installing debian-edu-artwork-usplash, the initrd is updated
twice, once in the usplash postinst, and once in the
debian-edu-artwork-usplash postinst.  This seem like a waste of time
to me.  Could it be possible to rewrite initramfs-tools to make sure
the initrd is only generated once, at the end of the install?

One idea is to make two commands, update-initramfs-intent and
update-initramfs-delayed, where the former register the packages
intent to run update-initramfs in their config script, and the last
package to call the latter will do the updating in their postinst
script.

The code of the programs will look something like this:

update-initramfs-intent

  #!/bin/sh
  package=$1
  statefile=/var/lib/initramfs-tools/intendtoupdateinitrd
  echo $package >> $statefile

update-initramfs-delayed

  #!/bin/sh
  package=$1
  statefile=/var/lib/initramfs-tools/intendtoupdateinitrd
  grep -v "^$package\$" < $statefile > $statefile.new && mv $statefile.new $statefile
  if [ -s $state ] ; then # Not empty, more packages left
      :
  else # Last package, run command
      update-initramfs
  fi

When the statefile is empty, all packages who registered their intend
have executed update-initramfs-delayed, and it is time to run
update-initramfs.  I suspect this might speed up the installation
quite a bit if there are several packages adding hooks to initramfs.

The existing packages will continue to work, while packages moving to
this new approach need to add

  update-initramfs-intent packagename

to their config script, and replace update-initramfs with

  update-initramfs-intent packagename

in their postinst script.

Is there any reason why this can't be done?

Friendly,
-- 
Petter Reinholdtsen



Reply to: