Am Freitag, den 10.01.2020, 17:03 +0100 schrieb Johannes Schauer:
> Hi,
> 
> Quoting Benjamin Drung (2020-01-10 12:35:51)
> > thanks for the patch. I tried it and it failed with a dependency
> > issue.
> > Debugging it revealed the reason: I have a apt preferences file
> > that reduces
> > the pin priority for some repositories. This file is copied in in
> > an
> > essential hook. When running as dry-run, the essential hook is
> > skipped and
> > therefore apt does not use the pin priority of this preferences
> > file.
> > 
> > Then I added '--aptopts=Dir::Etc::preferencesparts "[...]"' and it
> > worked.
> 
> the reason I deactivated hooks for --dry-run is, that hooks are able
> to do
> arbitrary stuff and when specifying --dry-run one probably does not
> expect
> something meaningful to happen. With hooks you could shoot yourself
> in the
> foot. I'm not strongly against allowing users to shoots themselves in
> the foot,
> so another reason to disable them was, that it is then possible to
> just add
> --dry-run to any command line (even including --hook options) and
> have the
> result just work without errors and without the user having to adjust
> the whole
> command line. But your example is a good argument to actually leave
> hooks be
> and expect the user to handle whatever they do.

Executing the hooks in --dry-run has more drawbacks than benefits,
because simple commands in the hooks would become much more complex.
Because every invocation needs to learn the dry-run mode.

How about adding --customize-hook-dry-run (etc.) and only execute those
in dry-run mode? Then the users can decide on their own which hook
needs a dry-run equivalent.

> > Our test-package-selection script did one more thing. It checked
> > that
> > exactly one kernel package was installed. Currently mmdebstrap had
> > to
> > way to do this check, because all hooks are skipped. This is the
> > code:
> > 
> > exec 3>&1
> > KERNEL_PACKAGE=$(chroot "$1" apt-get install -s -y --no-install-
> > recommends $pkg_list | \
> >     tee /dev/fd/3 | grep '^Inst linux-image' | cut -d ' ' -f 2,3 |
> > sed 's/ (/=/')
> > exec 3>&-
> > number_kernels=$(echo "$KERNEL_PACKAGE" | wc -w)
> > if test "$number_kernels" -ne 1; then
> >     echo "Error: Found $number_kernels kernels instead of one:" >&2
> >     for kernel_package in $KERNEL_PACKAGE; do
> >         package="${kernel_package%=*}"
> >         echo "*** Kernel package $kernel_package. Direct reverse
> > dependencies:"
> >         chroot "$1" apt-cache --no-recommends --no-suggests --no-
> > conflicts \
> >             --no-breaks --no-replaces --no-enhances rdepends
> > "${kernel_package}" | \
> >             grep -v "^${package}$" | grep -v ':' | sed 's/^
> > *|\?/  /' | sort | uniq
> >         echo "  All recursive reverse dependencies:"
> >         chroot "$1" apt-cache --no-recommends --no-suggests --no-
> > conflicts \
> >             --no-breaks --no-replaces --no-enhances  --recurse
> > rdepends \
> >             "${kernel_package}" | grep -v "^${package}$" | grep -v
> > ':' | \
> >             sed 's/^ *|\?/    /' | sort | uniq
> >     done
> >     printf "Error: Found $number_kernels kernels instead of one."
> > >&2
> >     printf " Details see above (search for three asterisks).\n" >&2
> >     exit 1
> > fi
> 
> This would not work anyways with --dry-run because you cannot chroot
> as the
> directory does not contain any binaries.
> 
> In case you care: a much cleaner and robust way than the above
> fragile
> grep/cut/sed to answer questions like "what would apt install" or
> "what are
> dependency chains to this package" are to use apt's ability to rely
> on third
> party solvers. You would pass apt your own EDSP script which would
> intercept
> the communication between the apt frontend and the solver backend and
> would
> then be able to parse the EDSP easily because it is in a format
> similar to
> deb822.

Thanks for the pointer. I wasn't aware of doing that. Do you know any
example third party solver doing that? Is it possible to add this hook
to the apt call of mmdebstrap (and only to the apt call that installs
the remaining packages)? If that is possible, then I don't need the
dry-run hook support.

-- 
Benjamin Drung

DevOps Engineer and Debian & Ubuntu Developer
Platform Integration (IONOS Cloud)

1&1 IONOS SE | Greifswalder Str. 207 | 10405 Berlin | Germany
E-mail: benjamin.dr...@cloud.ionos.com | Web: www.ionos.de

Hauptsitz Montabaur, Amtsgericht Montabaur, HRB 24498

Vorstand: Dr. Christian Böing, Hüseyin Dogan, Dr. Martin Endreß, Hans-
Henning Kettler, Matthias Steinberg, Achim Weiß
Aufsichtsratsvorsitzender: Markus Kadelke


Member of United Internet

Diese E-Mail kann vertrauliche und/oder gesetzlich geschützte
Informationen enthalten. Wenn Sie nicht der bestimmungsgemäße Adressat
sind oder diese E-Mail irrtümlich erhalten haben, unterrichten Sie
bitte den Absender und vernichten Sie diese E-Mail. Anderen als dem
bestimmungsgemäßen Adressaten ist untersagt, diese E-Mail zu speichern,
weiterzuleiten oder ihren Inhalt auf welche Weise auch immer zu
verwenden.

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient of this e-mail, you are hereby
notified that saving, distribution or use of the content of this e-mail 
in any way is prohibited. If you have received this e-mail in error,
please notify the sender and delete the e-mail.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to