]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
changelog: Respect Dir setting for local changelog getting
[apt.git] / test / integration / framework
index 39c9fcde2e3fdfcf5a7c1d1eeead9b52da9fd556..ec57a23c34b7e0fbc194793b373ed161cceadb49 100644 (file)
@@ -195,6 +195,9 @@ aptinternalplanner() { runapt "${APTINTERNALPLANNER}" "$@"; }
 dpkg() {
        "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "$@"
 }
 dpkg() {
        "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "$@"
 }
+dpkg_version() {
+       command perl -MDpkg -E 'say $Dpkg::PROGVERSION'
+}
 dpkgcheckbuilddeps() {
        command dpkg-checkbuilddeps --admindir="${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg" "$@"
 }
 dpkgcheckbuilddeps() {
        command dpkg-checkbuilddeps --admindir="${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg" "$@"
 }
@@ -407,11 +410,13 @@ EOF
        cp "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg"
        cat >> "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" <<EOF
 exec fakeroot '${DPKG:-dpkg}' --root='${TMPWORKINGDIRECTORY}/rootdir' \\
        cp "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg"
        cat >> "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" <<EOF
 exec fakeroot '${DPKG:-dpkg}' --root='${TMPWORKINGDIRECTORY}/rootdir' \\
+       --admindir="${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg" \\
        --log='${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log' \\
        --force-not-root --force-bad-path "\$@"
 EOF
        cat >> "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg" <<EOF
 exec fakeroot gdb --quiet -ex run '${DPKG:-dpkg}' --args '${DPKG:-dpkg}' --root='${TMPWORKINGDIRECTORY}/rootdir' \\
        --log='${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log' \\
        --force-not-root --force-bad-path "\$@"
 EOF
        cat >> "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg" <<EOF
 exec fakeroot gdb --quiet -ex run '${DPKG:-dpkg}' --args '${DPKG:-dpkg}' --root='${TMPWORKINGDIRECTORY}/rootdir' \\
+       --admindir="${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg" \\
        --log='${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log' \\
        --force-not-root --force-bad-path "\$@"
 EOF
        --log='${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log' \\
        --force-not-root --force-bad-path "\$@"
 EOF
@@ -449,11 +454,8 @@ EOF
 
        # create some files in /tmp and look at user/group to get what this means
        TEST_DEFAULT_USER="$(id -un)"
 
        # create some files in /tmp and look at user/group to get what this means
        TEST_DEFAULT_USER="$(id -un)"
-       if [ "$(uname)" = 'GNU/kFreeBSD' ]; then
-               TEST_DEFAULT_GROUP='root'
-       else
-               TEST_DEFAULT_GROUP="$(id -gn)"
-       fi
+       touch "${TMPWORKINGDIRECTORY}/test-file"
+       TEST_DEFAULT_GROUP=$(stat --format '%G'  "${TMPWORKINGDIRECTORY}/test-file")
 
        # cleanup the environment a bit
        # prefer our apt binaries over the system apt binaries
 
        # cleanup the environment a bit
        # prefer our apt binaries over the system apt binaries
@@ -521,6 +523,14 @@ configdpkg() {
                fi
        fi
        rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
                fi
        fi
        rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
+       # if multi-arch make sure dpkg can detect itself as capable of it
+       if getarchitectures | grep -E -q '[^ ]+ [^ ]+'; then
+               if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
+                       # dpkg doesn't really check the version as long as it is fully installed,
+                       # but just to be sure we choose one above the required version
+                       insertinstalledpackage 'dpkg' "all" '1.16.2+fake'
+               fi
+       fi
        if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
                local ARCHS="$(getarchitectures)"
                local DPKGARCH="$(dpkg --print-architecture)"
        if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
                local ARCHS="$(getarchitectures)"
                local DPKGARCH="$(dpkg --print-architecture)"
@@ -536,14 +546,6 @@ configdpkg() {
                                fi
                        fi
                done
                                fi
                        fi
                done
-               # if multi-arch make sure dpkg can detect itself as capable of it
-               if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
-                       if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
-                               # dpkg doesn't really check the version as long as it is fully installed,
-                               # but just to be sure we choose one above the required version
-                               insertinstalledpackage 'dpkg' "all" '1.16.2+fake'
-                       fi
-               fi
        fi
 }
 
        fi
 }
 
@@ -589,7 +591,11 @@ int execvp(const char *file, char *const argv[]) {
        return func_execvp(newfile, argv);
 }
 EOF
        return func_execvp(newfile, argv);
 }
 EOF
-       testempty --nomsg gcc -Wall -Wextra -fPIC -shared -o noopchroot.so noopchroot.c -ldl
+       if cc -ldl 2>&1 | grep -q dl; then
+               testempty --nomsg cc -Wall -Wextra -fPIC -shared -o noopchroot.so noopchroot.c
+       else
+               testempty --nomsg cc -Wall -Wextra -fPIC -shared -o noopchroot.so noopchroot.c -ldl
+       fi
 }
 configcompression() {
        if [ "$1" = 'ALL' ]; then
 }
 configcompression() {
        if [ "$1" = 'ALL' ]; then
@@ -647,10 +653,10 @@ _setupsimplenativepackage() {
        local VERSION="$3"
        local RELEASE="${4:-unstable}"
        local DEPENDENCIES="$5"
        local VERSION="$3"
        local RELEASE="${4:-unstable}"
        local DEPENDENCIES="$5"
-       local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+       local DESCRIPTION="${6:-an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
- und used only by testcases and serve no other purpose…"}"
+ und used only by testcases and serve no other purpose…}"
 
        local SECTION="${7:-others}"
        local PRIORITY="${8:-optional}"
 
        local SECTION="${7:-others}"
        local PRIORITY="${8:-optional}"
@@ -683,7 +689,7 @@ Standards-Version: 3.9.3"
                if [ "$SECTION" != '<none>' ]; then
                        echo "Section: $SECTION"
                fi
                if [ "$SECTION" != '<none>' ]; then
                        echo "Section: $SECTION"
                fi
-               local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
+               local BUILDDEPS="$(printf "%b\n" "$DEPENDENCIES" | grep '^Build-')"
                test -z "$BUILDDEPS" || echo "$BUILDDEPS"
                echo "
 Package: $NAME"
                test -z "$BUILDDEPS" || echo "$BUILDDEPS"
                echo "
 Package: $NAME"
@@ -693,9 +699,9 @@ Package: $NAME"
                else
                        echo "Architecture: any"
                fi
                else
                        echo "Architecture: any"
                fi
-               local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
+               local DEPS="$(printf "%b\n" "$DEPENDENCIES" | grep -v '^Build-')"
                test -z "$DEPS" || echo "$DEPS"
                test -z "$DEPS" || echo "$DEPS"
-               echo "Description: $DESCRIPTION"
+               printf "%b\n" "Description: $DESCRIPTION"
        } > "${BUILDDIR}/debian/control"
 
        echo '3.0 (native)' > "${BUILDDIR}/debian/source/format"
        } > "${BUILDDIR}/debian/control"
 
        echo '3.0 (native)' > "${BUILDDIR}/debian/source/format"
@@ -877,10 +883,10 @@ insertpackage() {
        local VERSION="$4"
        local DEPENDENCIES="$5"
        local PRIORITY="${6:-optional}"
        local VERSION="$4"
        local DEPENDENCIES="$5"
        local PRIORITY="${6:-optional}"
-       local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASES}
+       local DESCRIPTION="${7:-an autogenerated dummy ${NAME}=${VERSION}/${RELEASES}
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
- und used only by testcases and serve no other purpose…"}"
+ und used only by testcases and serve no other purpose…}"
        local ARCHS=""
        for RELEASE in $(printf '%s' "$RELEASES" | tr ',' '\n'); do
                if [ "$RELEASE" = 'installed' ]; then
        local ARCHS=""
        for RELEASE in $(printf '%s' "$RELEASES" | tr ',' '\n'); do
                if [ "$RELEASE" = 'installed' ]; then
@@ -905,7 +911,7 @@ Maintainer: Joe Sixpack <joe@example.org>"
                                        test "$arch" = 'none' || echo "Architecture: $arch"
                                        echo "Version: $VERSION
 Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb"
                                        test "$arch" = 'none' || echo "Architecture: $arch"
                                        echo "Version: $VERSION
 Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb"
-                                       test -z "$DEPENDENCIES" || echo "$DEPENDENCIES"
+                                       test -z "$DEPENDENCIES" || printf "%b\n" "$DEPENDENCIES"
                                        echo "Description: $(printf '%s' "$DESCRIPTION" | head -n 1)"
                                        echo "Description-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)"
                                        echo
                                        echo "Description: $(printf '%s' "$DESCRIPTION" | head -n 1)"
                                        echo "Description-md5: $(printf '%s' "$DESCRIPTION" | md5sum | cut -d' ' -f 1)"
                                        echo
@@ -940,7 +946,7 @@ Binary: $BINARY
 Version: $VERSION
 Maintainer: Joe Sixpack <joe@example.org>
 Architecture: $ARCH" >> $FILE
 Version: $VERSION
 Maintainer: Joe Sixpack <joe@example.org>
 Architecture: $ARCH" >> $FILE
-               test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> "$FILE"
+               test -z "$DEPENDENCIES" || printf "%b\n" "$DEPENDENCIES" >> "$FILE"
                echo "Files:
  $(echo -n "$DSCFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) "$DSCFILE"
  $(echo -n "$TARFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) "$TARFILE"
                echo "Files:
  $(echo -n "$DSCFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$DSCFILE" | wc -c) "$DSCFILE"
  $(echo -n "$TARFILE" | md5sum | cut -d' ' -f 1) $(echo -n "$TARFILE" | wc -c) "$TARFILE"
@@ -958,10 +964,10 @@ insertinstalledpackage() {
        local DEPENDENCIES="$4"
        local PRIORITY="${5:-optional}"
        local STATUS="${6:-install ok installed}"
        local DEPENDENCIES="$4"
        local PRIORITY="${5:-optional}"
        local STATUS="${6:-install ok installed}"
-       local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
+       local DESCRIPTION="${7:-an autogenerated dummy ${NAME}=${VERSION}/installed
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
  If you find such a package installed on your system,
  something went horribly wrong! They are autogenerated
- und used only by testcases and serve no other purpose…"}"
+ und used only by testcases and serve no other purpose…}"
 
        local FILE='rootdir/var/lib/dpkg/status'
        local INFO='rootdir/var/lib/dpkg/info'
 
        local FILE='rootdir/var/lib/dpkg/status'
        local INFO='rootdir/var/lib/dpkg/info'
@@ -974,8 +980,8 @@ Installed-Size: 42
 Maintainer: Joe Sixpack <joe@example.org>
 Version: $VERSION" >> "$FILE"
                test "$arch" = 'none' || echo "Architecture: $arch" >> "$FILE"
 Maintainer: Joe Sixpack <joe@example.org>
 Version: $VERSION" >> "$FILE"
                test "$arch" = 'none' || echo "Architecture: $arch" >> "$FILE"
-               test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> "$FILE"
-               echo "Description: $DESCRIPTION" >> "$FILE"
+               test -z "$DEPENDENCIES" || printf "%b\n" "$DEPENDENCIES" >> "$FILE"
+               printf "%b\n" "Description: $DESCRIPTION" >> "$FILE"
                echo >> "$FILE"
                if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
                        echo -n > "${INFO}/${NAME}:${arch}.list"
                echo >> "$FILE"
                if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
                        echo -n > "${INFO}/${NAME}:${arch}.list"