"Fossies" - the Fresh Open Source Software Archive

Member "apt-2.2.4/test/integration/test-apt-get-install-deb" (10 Jun 2021, 10512 Bytes) of package /linux/misc/apt-2.2.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "test-apt-get-install-deb": 2.2.3_vs_2.2.4.

    1 #!/bin/sh
    2 set -e
    3 
    4 TESTDIR="$(readlink -f "$(dirname "$0")")"
    5 . "$TESTDIR/framework"
    6 
    7 setupenvironment
    8 configarchitecture 'amd64' 'i386'
    9 
   10 # regression test for #754904
   11 cat > foo.rpm <<EOF
   12 I'm not a deb, I'm a teapot.
   13 EOF
   14 for exe in apt aptget; do
   15     for cmd in install remove purge upgrade full-upgrade; do
   16         testfailureequal 'E: Unsupported file /dev/null given on commandline' $exe $cmd -qq /dev/null
   17         testfailureequal 'E: Unsupported file ./foo.rpm given on commandline' $exe $cmd -qq ./foo.rpm
   18     done
   19 done
   20 
   21 # and ensure we fail for invalid debs
   22 mv foo.rpm foo.deb
   23 for exe in apt aptget; do
   24     for cmd in install remove purge upgrade full-upgrade; do
   25         testfailuremsg "E: Invalid archive signature
   26 E: Internal error, could not locate member control.tar{.zst,.lz4,.gz,.xz,.bz2,.lzma,}
   27 E: Could not read meta data from ${TMPWORKINGDIRECTORY}/foo.deb
   28 E: The package lists or status file could not be parsed or opened." $exe $cmd ./foo.deb
   29     done
   30 done
   31 
   32 buildsimplenativepackage 'foo' 'i386,amd64' '1.0'
   33 
   34 testfailureequal "Reading package lists...
   35 Building dependency tree...
   36 Note, selecting 'foo:i386' instead of './incoming/foo_1.0_i386.deb'
   37 Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
   38 Some packages could not be installed. This may mean that you have
   39 requested an impossible situation or if you are using the unstable
   40 distribution that some required packages have not yet been created
   41 or been moved out of Incoming.
   42 The following information may help to resolve the situation:
   43 
   44 The following packages have unmet dependencies:
   45  foo:i386 : Conflicts: foo but 1.0 is to be installed
   46  foo : Conflicts: foo:i386 but 1.0 is to be installed
   47 E: Unable to correct problems, you have held broken packages." aptget install ./incoming/foo_1.0_i386.deb ./incoming/foo_1.0_amd64.deb -s
   48 
   49 testsuccess apt show foo --with-source ./incoming/foo_1.0_amd64.deb
   50 testequal 'Package: foo
   51 Version: 1.0' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
   52 testsuccess apt show ./incoming/foo_1.0_amd64.deb
   53 testequal 'Package: foo
   54 Version: 1.0' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
   55 testsuccess apt show foo:i386 ./incoming/foo_1.0_amd64.deb --with-source ./incoming/foo_1.0_i386.deb
   56 testequal 'Package: foo:i386
   57 Version: 1.0
   58 Package: foo
   59 Version: 1.0' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
   60 
   61 testsuccess aptcache show foo --with-source ./incoming/foo_1.0_amd64.deb
   62 testequal 'Package: foo
   63 Version: 1.0
   64 Architecture: amd64' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
   65 testsuccess aptcache show ./incoming/foo_1.0_amd64.deb
   66 testequal 'Package: foo
   67 Version: 1.0
   68 Architecture: amd64' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
   69 testsuccess aptcache show foo:i386 ./incoming/foo_1.0_amd64.deb --with-source ./incoming/foo_1.0_i386.deb
   70 testequal 'Package: foo
   71 Version: 1.0
   72 Architecture: i386
   73 Package: foo
   74 Version: 1.0
   75 Architecture: amd64' grep -e '^Package:' -e '^Version:' -e '^Architecture:' rootdir/tmp/testsuccess.output
   76 
   77 testsuccessequal 'Sorting...
   78 Full Text Search...
   79 foo/local-deb 1.0 amd64
   80   an autogenerated dummy foo=1.0/unstable
   81 ' apt search foo --with-source ./incoming/foo_1.0_amd64.deb
   82 testsuccessequal 'foo - an autogenerated dummy foo=1.0/unstable' aptcache search foo --with-source ./incoming/foo_1.0_amd64.deb
   83 
   84 testdpkgnotinstalled 'foo' 'foo:i386'
   85 testsuccess aptget install ./incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
   86 testdpkginstalled 'foo:i386'
   87 testfailure aptget install incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
   88 cd downloaded
   89 testsuccess aptget install "$(readlink -f ../incoming/foo_1.0_i386.deb)" -o Debug::pkgCacheGen=1 -y --reinstall
   90 testfailure grep 'is already the newest version' ../rootdir/tmp/testsuccess.output
   91 testsuccess aptget install ../incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1 -y --reinstall
   92 testfailure grep 'is already the newest version' ../rootdir/tmp/testsuccess.output
   93 cd ..
   94 
   95 testsuccessequal "Reading package lists...
   96 Building dependency tree...
   97 Reading state information...
   98 Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
   99 The following packages will be REMOVED:
  100   foo:i386
  101 The following NEW packages will be installed:
  102   foo
  103 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  104 Remv foo:i386 [1.0]
  105 Inst foo (1.0 local-deb [amd64])
  106 Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
  107 
  108 testsuccessequal 'Reading package lists...
  109 Building dependency tree...
  110 Reading state information...
  111 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget install --with-source ./incoming/foo_1.0_amd64.deb -s
  112 
  113 testsuccessequal 'Reading package lists...
  114 Building dependency tree...
  115 Reading state information...
  116 The following packages will be REMOVED:
  117   foo:i386
  118 The following NEW packages will be installed:
  119   foo
  120 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  121 Remv foo:i386 [1.0]
  122 Inst foo (1.0 local-deb [amd64])
  123 Conf foo (1.0 local-deb [amd64])' aptget install --with-source ./incoming/foo_1.0_amd64.deb foo -s
  124 
  125 # Check that installing the local deb works if it is not the candidate
  126 echo "Package: foo
  127 Pin: version 1.0
  128 Pin-Priority: -1" > rootdir/etc/apt/preferences
  129 
  130 testsuccessequal "Reading package lists...
  131 Building dependency tree...
  132 Reading state information...
  133 Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
  134 The following packages will be REMOVED:
  135   foo:i386
  136 The following NEW packages will be installed:
  137   foo
  138 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
  139 Remv foo:i386 [1.0]
  140 Inst foo (1.0 local-deb [amd64])
  141 Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
  142 
  143 createpkg() {
  144     local PKG="pkg-$1"
  145     mkdir -p ./incoming/$PKG/DEBIAN
  146     if [ -n "$2" ]; then
  147         echo -n "$2" >> ./incoming/$PKG/DEBIAN/control
  148     fi
  149     echo "Package: $PKG
  150 Version: 0
  151 Priority: extra
  152 Maintainer: No Body <no@example.org>
  153 Architecture: all
  154 Depends: foo:i386
  155 Description: test package" >> ./incoming/$PKG/DEBIAN/control
  156     if [ -n "$3" ]; then
  157         echo -n "$3" >> ./incoming/$PKG/DEBIAN/control
  158     fi
  159     testsuccess dpkg-deb --build ./incoming/$PKG/ ./incoming
  160     #dpkg-deb -I ./incoming/${PKG}_0_all.deb control
  161 }
  162 createpkg 'as-it-should-be'
  163 createpkg 'leading-newline' '
  164 
  165 '
  166 createpkg 'trailing-newline' '' '
  167 '
  168 createpkg 'double-trailing-newline' '' '
  169 
  170 '
  171 createpkg 'last-line-parse' '' 'Pre-Depends: pkg-as-it-should-be
  172 '
  173 
  174 echo 'Package: /pkg-/
  175 Pin: release a=experimental
  176 Pin-Priority: 501' > rootdir/etc/apt/preferences.d/pinit
  177 
  178 testfailuremsg 'E: Unable to correct problems, you have held broken packages.' aptget install -q=0 ./incoming/pkg-last-line-parse_0_all.deb
  179 testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
  180 testsuccess aptget install ./incoming/pkg-last-line-parse_0_all.deb
  181 testsuccess aptget install "$(readlink -f ./incoming/pkg-leading-newline_0_all.deb)"
  182 testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
  183 testsuccess aptget install ./incoming/pkg-double-trailing-newline_0_all.deb
  184 
  185 testempty apt clean
  186 if [ "$(id -u)" = '0' ]; then
  187     # see if permission dropping is checked before usage
  188     chmod 711 ./incoming
  189     testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  190     testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  191     chmod 710 ./incoming
  192     testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  193     testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
  194     chmod 700 ./incoming
  195     testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  196     testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
  197     chmod 711 ./incoming
  198 else
  199     testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
  200     testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  201 fi
  202 
  203 sed -i -e '/^Depends: foo/ d' rootdir/var/lib/dpkg/status
  204 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb
  205 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  206 testsuccess apt purge -y pkg-as-it-should-be
  207 
  208 echo "Package: pkg-as-it-should-be
  209 Architecture: all
  210 Version: 0
  211 Installed-Size: 2903
  212 Filename: incoming/pkg-as-it-should-be_0%3a0+0_all.deb
  213 Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.deb)
  214 SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.deb | cut -d' ' -f 1)
  215 " > Packages
  216 ln -s pkg-as-it-should-be_0_all.deb incoming/pkg-as-it-should-be_0%3a0+0_all.deb
  217 testdpkgnotinstalled 'pkg-as-it-should-be'
  218 testnopackage pkg-as-it-should-be
  219 testsuccess apt install --with-source ./Packages pkg-as-it-should-be -s
  220 testsuccess apt install --with-source ./Packages pkg-as-it-should-be --print-uris
  221 testsuccess apt show --with-source ./Packages pkg-as-it-should-be
  222 testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
  223 testsuccess apt install -y --with-source ./Packages pkg-as-it-should-be -o Debug::pkgAcquire::Worker=1
  224 testdpkginstalled 'pkg-as-it-should-be'
  225 rm -f ./Packages
  226 
  227 echo 'dpkg::install::recursive "true";
  228 dpkg::install::recursive::force "true";
  229 dpkg::install::recursive::minimum "0";' > rootdir/etc/apt/apt.conf.d/lowerminimum.conf
  230 mv ./incoming/pkg-as-it-should-be_0_all.deb ./incoming/pkg-as-it-should-be_0%3a0+0_all.ddeb
  231 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0%3a0+0_all.ddeb --reinstall
  232 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
  233 testsuccess apt purge -y pkg-as-it-should-be
  234 testdpkgnotinstalled 'pkg-as-it-should-be'
  235 
  236 mv ./incoming/pkg-as-it-should-be_0%3a0+0_all.ddeb ./incoming/pkg-as-it-should-be_0_all.foobar
  237 echo "Package: pkg-as-it-should-be
  238 Architecture: all
  239 Version: 0
  240 Installed-Size: 2903
  241 Filename: incoming/pkg-as-it-should-be_0_all.foobar
  242 Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.foobar)
  243 SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.foobar | cut -d' ' -f 1)
  244 " | gzip > Packages.gz
  245 testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be -s
  246 testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be --print-uris
  247 testsuccess apt show --with-source ./Packages.gz pkg-as-it-should-be
  248 testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
  249 testsuccess apt install -y --with-source ./Packages.gz pkg-as-it-should-be
  250 testdpkginstalled 'pkg-as-it-should-be'