initial commit

This commit is contained in:
josch 2015-04-18 22:07:36 +02:00
commit a3b40ed41e

319
run.sh Executable file
View file

@ -0,0 +1,319 @@
#!/bin/sh
PATH=/usr/sbin:/sbin:$PATH
export PATH
setupapt() {
APTROOT=`pwd`/aptroot
rm -rf "$APTROOT"
mkdir -p "$APTROOT"
mkdir -p "$APTROOT/etc/apt/"
# instead of setting options via -o, use a configuration file because
# otherwise the values set for "Dir::" will not be respected.
# See apt.conf(5) for the order in which configuration values get
# read
# Commandline options are read last so they cannot be used for this
cat << END > "$APTROOT/etc/apt/apt.conf"
Dir "$APTROOT/";
END
}
testdpkg() {
pkgtype="$1"
provides="$2"
pkgaarch="$3"
pkgbarch="$4"
pkgama="$5"
pkgbma="$6"
debrel="$7"
debvpkg="$8"
if [ "$pkgtype" != "binary" ]; then
echo "cannot handle source yet"
exit 1
fi
case $debrel in
depends)
debrel="Depends: $debvpkg"
;;
conflicts)
debrel="Conflicts: $debvpkg"
;;
*)
echo "unexpected value for t7 $debrel"
exit 1
esac
if [ "$provides" != "none" ]; then
provides="Provides: $provides"
else
provides=""
fi
# reset dpkgdb
rm -rf dpkgdb
mkdir dpkgdb
mkdir dpkgdb/info
mkdir dpkgdb/triggers
mkdir dpkgdb/updates
touch dpkgdb/available
touch dpkgdb/diversions
touch dpkgdb/lock
touch dpkgdb/statoverride
touch dpkgdb/status
touch dpkgdb/status-old
touch dpkgdb/triggers/Lock
touch dpkgdb/triggers/Unincorp
echo 1 > dpkgdb/info/format
# create packages
rm -rf pkga
mkdir -p pkga/DEBIAN
cat << END > pkga/DEBIAN/control
Package: pkga
Version: 1
Architecture: $pkgaarch
Multi-Arch: $pkgama
Description: pkga
Maintainer: pkga maintainers
$debrel
END
rm -rf pkgb
mkdir -p pkgb/DEBIAN
cat << END > pkgb/DEBIAN/control
Package: pkgb
Version: 1
Architecture: $pkgbarch
Multi-Arch: $pkgbma
Description: pkgb
Maintainer: pkgb maintainers
$provides
END
dpkg-deb --build pkga pkga.deb >/dev/null || exit 1
dpkg-deb --build pkgb pkgb.deb >/dev/null || exit 1
dpkg --admindir=./dpkgdb --add-architecture i386
dpkg --admindir=./dpkgdb --add-architecture amd64
# it is important that pkgb comes before pkga in the commandline because of #377860
dpkg --log=/dev/null --force-unsafe-io --force-not-root --admindir=./dpkgdb -i pkgb.deb pkga.deb >/dev/null 2>&1
exitcode=$?
case $exitcode in
0)
echo "sat"
;;
1)
echo "unsat"
;;
*)
echo "unexpected exit code $exitcode"
exit 1
esac
}
testapt() {
pkgtype="$1"
provides="$2"
pkgaarch="$3"
pkgbarch="$4"
pkgama="$5"
pkgbma="$6"
debrel="$7"
debvpkg="$8"
if [ "$pkgtype" != "binary" ]; then
echo "cannot handle source yet"
exit 1
fi
case $debrel in
depends)
debrel="Depends: $debvpkg"
;;
conflicts)
debrel="Conflicts: $debvpkg"
;;
*)
echo "unexpected value for t7 $debrel"
exit 1
esac
if [ "$provides" != "none" ]; then
provides="Provides: $provides"
else
provides=""
fi
cat << END > request.edsp
Request: EDSP 0.5
Architecture: amd64
Architectures: amd64 i386
Install: pkga pkgb
Package: pkga
Version: 1
Architecture: $pkgaarch
Multi-Arch: $pkgama
$debrel
Package: pkgb
Version: 1
Architecture: $pkgbarch
Multi-Arch: $pkgbma
$provides
END
if APT_CONFIG="`pwd`/aptroot/etc/apt/apt.conf" /usr/lib/apt/solvers/apt < request.edsp 2>/dev/null | grep "^Install:" > /dev/null; then
echo "sat"
else
echo "unsat"
fi
}
testdose() {
pkgtype="$1"
provides="$2"
pkgaarch="$3"
pkgbarch="$4"
pkgama="$5"
pkgbma="$6"
debrel="$7"
debvpkg="$8"
if [ "$pkgtype" != "binary" ]; then
echo "cannot handle source yet"
exit 1
fi
case $debrel in
depends)
debrel="Depends: $debvpkg"
;;
conflicts)
debrel="Conflicts: $debvpkg"
;;
*)
echo "unexpected value for t7 $debrel"
exit 1
esac
if [ "$provides" != "none" ]; then
provides="Provides: $provides"
else
provides=""
fi
cat << END | dose-deb-coinstall --deb-native-arch=amd64 --deb-foreign-archs=i386 > /dev/null
Package: pkga
Version: 1
Architecture: $pkgaarch
Multi-Arch: $pkgama
$debrel
Package: pkgb
Version: 1
Architecture: $pkgbarch
Multi-Arch: $pkgbma
$provides
END
exitcode=$?
case $exitcode in
0)
echo "sat"
;;
1)
echo "unsat"
;;
*)
echo "unexpected exit code $exitcode"
exit 1
esac
}
setupapt
pkgArel="depends conflicts"
pkgAvpkg="pkgb pkgb:amd64 pkgb:i386 pkgb:any pkgc pkgc:amd64 pkgc:i386 pkgc:any"
pkgAsrcvpkg="pkgb:native pkgc:native"
# deactivate pkgA being a source package for now
#pkgAtype="binary source"
pkgAtype="binary"
pkgBprovides="none pkgc pkgc:amd64 pkgc:i386"
binpkgarch="amd64 i386 all"
# possible Multi-Arch values
maprop="no foreign allowed same"
# list for Arch:all packages without "same"
allmaprop="no foreign allowed"
# all testcases are a 8-tuple with the following content:
#
# 1. pkgAtype
# 2. pkgBprovides
# 3. pkgAarch (if pkgA is a binary package)
# 4. pkgBarch
# 5. pkgAmaprop (if pkgA is a binary package)
# 6. pkgBmaprop
# 7. relationship (depends or conflicts)
# 8. vpkg value
#
# then, in case pkgAtype is "binary" both packages are tried to be installed
# at the same time
# in case pkgAtype is "source", the source package is checked for its
# build depends/conflict satisfiability with the second package installed
#
# the :any qualifier will also be used to depend on packages which are not
# m-a:allowed. This is to test situations in which either:
# 1. :any was added wrongly or
# 2. a m-a:allowed package was changed to something else without changing
# all reverse dependencies or
# 3. different package repositories are mixed where a package which
# is m-a:allowed in one repository and depended upon with :any is not
# m-a:allowed in another repository but of higher version or otherwise
# preferred
i=1
for t1 in $pkgAtype; do
for t2 in $pkgBprovides; do
if [ "$t1" = "binary" ]; then
pkgAarches="$binpkgarch"
else
pkgAarches="none"
fi
for t3 in $pkgAarches; do
for t4 in $binpkgarch; do
if [ "$t1" = "binary" ]; then
if [ "$t3" = "all" ]; then
pkgAma="$allmaprop"
else
pkgAma="$maprop"
fi
else
pkgAma="none"
fi
for t5 in $pkgAma; do
if [ "$t4" = "all" ]; then
pkgBma="$allmaprop"
else
pkgBma="$maprop"
fi
for t6 in $pkgBma; do
for t7 in $pkgArel; do
if [ "$t1" = "binary" ]; then
props="$pkgAvpkg"
else
props="$pkgAvpkg $pkgAsrcvpkg"
fi
for t8 in $props; do
echo "$t1 $t2 $t3 $t4 $t5 $t6 $t7 $t8"
done
done
done
done
done
done
done
done | while read pkgtype provides pkgaarch pkgbarch pkgama pkgbma debrel debvpkg; do
echo "$i" >&2
i=$((i+1))
dpkgres=`testdpkg $pkgtype $provides $pkgaarch $pkgbarch $pkgama $pkgbma $debrel $debvpkg`
aptres=`testapt $pkgtype $provides $pkgaarch $pkgbarch $pkgama $pkgbma $debrel $debvpkg`
doseres=`testdose $pkgtype $provides $pkgaarch $pkgbarch $pkgama $pkgbma $debrel $debvpkg`
if [ "$dpkgres" != "$aptres" -o "$dpkgres" != "$doseres" ]; then
echo "$pkgtype $provides $pkgaarch $pkgbarch $pkgama $pkgbma $debrel $debvpkg $dpkgres $aptres $doseres"
fi
done