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

Re: Enquiry about building a new root file system



Le 22. 08. 14 07:44, Bas Wijnen a écrit :
On Thu, Aug 21, 2014 at 09:43:13PM -0500, David Lechner wrote:
The .preinst files is something that I have not yet taken the time
to understand as well as I should yet, so you should not trust me as
absolute expert on this. It is my understanding, though, that when
multistrap runs, there is nothing in the chroot, so preinst scripts
can't run before we unpack because there is no /bin/sh or any of the
commands or programs that the scripts will use.
Preinst scripts may expect all Essential:yes packages (and their
dependencies) to be installed and configured on the system.  The
exception is obviously preinst scripts of Essential packages; they may
expect all those packages to be unpacked.

So the proper order of events would be:
- unpack essential packages
- run preinst of essential packages
- run postinst of essential packages
- run preinst of other packages
- unpack other packages
- run postinst of other packages

I'm not surprised if during bootstrap all Priority:standard and higher
packages are treated the same, even if not all of them are Essential

Thanks Bas,

I tried this to mimic the suggested proper order according with this script called from sudo chroot target:

export LC_ALL=C
export LANG=C
export LANGUAGE=C
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
debconf-set-selections /tmp/debconfseed.txt
essentials_yes=$(dpkg-query -Wf '${Package;-40} ${Essential}\n' | grep " yes$" | cut -f1 -d' ')
for package in $essentials_yes; do
    script=/var/lib/dpkg/info/$package.preinst
    if [ -x $script ]; then
        echo "Preinstall essential $package"
        $script install
    fi
done
for package in $essentials_yes; do
    script=/var/lib/dpkg/info/$package.postinst
    if [ -x $script ]; then
        version=$(dpkg-query -Wf '${Version}' $package)
        echo "Postinstall essential $package $version"
        $script configure $version
    fi
done
essentials_no=$(dpkg-query -Wf '${Package;-40} ${Essential}\n' | grep " no$" | cut -f1 -d' ')
for package in $essentials_no; do
    script=/var/lib/dpkg/info/$package.preinst
    if [ -x $script ]; then
        echo "Preinstall $package"
        $script install
    fi
done
for package in $essentials_no; do
    script=/var/lib/dpkg/info/$package.postinst
    if [ -x $script ]; then
        version=$(dpkg-query -Wf '${Version}' $package)
        echo "Postinstall $package $version"
        $script configure $version
    fi
done
dpkg --configure -a

My observations so fare:

1) Postinstall essential util-linux raise a insserv error that I don't understand at all. 2) Preinstall initscripts systematically raise "dpkg-maintscript-helper: error: environment variable DPKG_MAINTSCRIPT_NAME is required" no matter his order. 3) Calling the postinst script seem to be somewhat the same effect as calling the dpkg --configure -a, but raise more error. Part of the problem is maybe related to the fact that the order of the scripts don't respect the dependencies order.

After some test, I have found that only preinst of essential packages is required before dpkg --configure -a, and that this last command already do the rest of the work just well. Running preinst of non-essential package don't seem to bring any advantage but raise more error.

Below is my actual script:

export LC_ALL=C
export LANG=C
export LANGUAGE=C
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
debconf-set-selections /tmp/debconfseed.txt
essentials_yes=$(dpkg-query -Wf '${Package;-40} ${Essential}\n' | grep " yes$" | cut -f1 -d' ')
for package in $essentials_yes; do
    script=/var/lib/dpkg/info/$package.preinst
    if [ -x $script ]; then
        echo "Preinstall essential $package"
        $script install
    fi
done
dpkg --configure -a

Best Regards,

Jean-Christian


Reply to: