Control: forcemerge 813454 -1

Hi!

On Thu, 2017-04-13 at 12:02:07 +0200, Bastien ROUCARIÈS wrote:
> Package: dpkg
> Version: 1.18.23
> Severity: important
> affects: piuparts.debian.org
> affects: src:imagemagick
> control: tags -1 + patch

> I know it is late on release but it will really help to add this patch.
> 
> Could you consider for release ?

When you first filed this, I took a quick look, but producing a proper
fix seemed involved, given the contstrains I set for myself:

Thanks for the patch, although I think this is not enough.

> diff --git a/scripts/dpkg-maintscript-helper.sh 
> b/scripts/dpkg-maintscript-helper.sh
> index b4b3ac1b3..0b867d805 100755
> --- a/scripts/dpkg-maintscript-helper.sh
> +++ b/scripts/dpkg-maintscript-helper.sh
> @@ -412,14 +412,8 @@ prepare_dir_to_symlink()
>  
>       # If there are locally created files or files owned by another package
>       # we should not perform the switch.
> -     find "$PATHNAME" -print0 | xargs -0 -n1 sh -c '
> -             package="$1"
> -             file="$2"
> -             if ! dpkg-query -L "$package" | grep -F -q -x "$file"; then
> -                     exit 1
> -             fi
> -             exit 0
> -     ' check-files-ownership "$PACKAGE" || \
> +     find "$PATHNAME" -print0 | xargs -0 -n1 \
> +             dpkg-maintscript-helper package_owns_file_or_error $PACKAGE || \

The problem with this is that it aborts on first error, so any other
remaining problematic files are missed, which might make debugging
difficult, miss files, or require several iterations.

I also considered using a command like this, but it seemed wrong, as
that is exposing a private implementation detail as part of the
interface, so I'd rather not do this.

>               error "directory '$PATHNAME' contains files not owned by" \
>                     "package $PACKAGE, cannot switch to symlink"
>  
> @@ -515,6 +509,18 @@ ensure_package_owns_file() {
>       return 0
>  }
>  
> +
> +package_owns_file_or_error() {
> +       local PACKAGE="$1"
> +       local FILE="$2"
> +       if ! ensure_package_owns_file $PACKAGE $FILE ; then
> +        error "File '$FILE' not owned by package " \
> +              "'$PACKAGE'"
> +        return 1

error() already «exits 1». :)

> +       fi
> +       return 0
> +}

Thanks,
Guillem

Reply via email to