Package: dpkg
Version: 1.17.6
Severity: important
Tags: patch

Dear Maintainer,

This is a problem that I encountered when trying to upgrade php-aws-sdk from
1.5.6.2-1 to 2.5.2-1, I would get these messages (the first repeats a large
number of times):

    Preparing to unpack .../php-aws-sdk_2.5.2-1_all.deb ...
    check-files-ownership: line 6: return: can only `return' from a function or
sourced script
    [ ... the previous line repeats over 30 times ... ]
    dpkg-maintscript-helper: error: directory '/usr/share/php/AWSSDKforPHP'
contains files not owned by package php-aws-sdk:all, cannot switch to symlink
    dpkg: error processing archive /var/cache/apt/archives/php-aws-
sdk_2.5.2-1_all.deb (--unpack):
     subprocess new pre-installation script returned error exit status 1
    Errors were encountered while processing:
     /var/cache/apt/archives/php-aws-sdk_2.5.2-1_all.deb

I went looking in /usr/bin/dpkg-maintscript-helper, and found this snippet of
code in prepare_dir_to_symlink:

        find "$PATHNAME" -print0 | xargs -0 -n1 sh -c '
                package="$1"
                file="$2"
                if ! dpkg-query -L "$package" | grep -q -x "$file"; then
                        return 1
                fi
                return 0
        ' check-files-ownership "$PACKAGE" || \
                error "directory '$PATHNAME' contains files not owned by" \
                      "package $PACKAGE, cannot switch to symlink"

The code performed with sh -c will never be able to succeed, easily
demonstrated as follows:

    : ; sh -c 'return 0'
    sh: line 0: return: can only `return' from a function or sourced script
    : ; echo $?
    1

However, using exit works, as expected:

    : ; sh -c 'exit 0'
    : ; echo $?
    0

After changing /usr/bin/dpkg-maintscript-helper to use exit instead of return
in the code shown above, php-aws-sdk upgraded with no problems.

Patch included



-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=sv_SE.utf8, LC_CTYPE=sv_SE.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages dpkg depends on:
ii  libbz2-1.0   1.0.6-5
ii  libc6        2.17-97
ii  liblzma5     5.1.1alpha+20120614-2
ii  libselinux1  2.2.2-1
ii  tar          1.27.1-1
ii  zlib1g       1:1.2.8.dfsg-1

dpkg recommends no packages.

Versions of packages dpkg suggests:
ii  apt  0.9.15.2

-- no debconf information
--- /usr/bin/dpkg-maintscript-helper.orig	2014-02-14 09:49:53.000000000 +0100
+++ /usr/bin/dpkg-maintscript-helper	2014-02-14 09:51:47.000000000 +0100
@@ -394,9 +394,9 @@
 		package="$1"
 		file="$2"
 		if ! dpkg-query -L "$package" | grep -q -x "$file"; then
-			return 1
+			exit 1
 		fi
-		return 0
+		exit 0
 	' check-files-ownership "$PACKAGE" || \
 		error "directory '$PATHNAME' contains files not owned by" \
 		      "package $PACKAGE, cannot switch to symlink"

Reply via email to