Просмотр исходного кода

merged from lp:~donkult/apt/sid

Michael Vogt лет назад: 16
Родитель
Сommit
ea479d9490

+ 3 - 3
apt-pkg/acquire-item.cc

@@ -280,7 +280,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)		/*{{{*/
       ss >> ServerSha1 >> size;
       unsigned long const ServerSize = atol(size.c_str());
 
-      FileFd fd(CurrentPackagesFile, FileFd::ReadOnlyGzip);
+      FileFd fd(CurrentPackagesFile, FileFd::ReadOnly);
       SHA1Summation SHA1;
       SHA1.AddFD(fd.Fd(), fd.Size());
       string const local_sha1 = SHA1.Result();
@@ -297,7 +297,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)		/*{{{*/
       else 
       {
 	 if(Debug)
-	    std::clog << "SHA1-Current: " << ServerSha1 << std::endl;
+	    std::clog << "SHA1-Current: " << ServerSha1 << " and we start at "<< fd.Name() << " " << fd.Size() << " " << local_sha1 << std::endl;
 
 	 // check the historie and see what patches we need
 	 string const history = Tags.FindS("SHA1-History");
@@ -511,7 +511,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
    string FinalFile = _config->FindDir("Dir::State::lists");
    FinalFile += URItoFileName(RealURI);
 
-   FileFd fd(FinalFile, FileFd::ReadOnlyGzip);
+   FileFd fd(FinalFile, FileFd::ReadOnly);
    SHA1Summation SHA1;
    SHA1.AddFD(fd.Fd(), fd.Size());
    string local_sha1 = string(SHA1.Result());

+ 2 - 1
apt-pkg/algorithms.cc

@@ -1052,7 +1052,8 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 			      solving this dependency. This helps every time a previous solver
 			      is removed by the resolver because of a conflict or alike but it is
 			      dangerous as it could trigger new breaks/conflicts… */
-			   std::cout << "  Try Installing " << Start.TargetPkg() << " before changing " << I.FullName(false) << std::endl;
+			   if (Debug == true)
+			      clog << "  Try Installing " << Start.TargetPkg() << " before changing " << I.FullName(false) << std::endl;
 			   unsigned long const OldBroken = Cache.BrokenCount();
 			   Cache.MarkInstall(Start.TargetPkg(), true, 1, false);
 			   // FIXME: we should undo the complete MarkInstall process here

+ 1 - 1
apt-pkg/contrib/strutl.cc

@@ -1161,7 +1161,7 @@ void strprintf(string &out,const char *format,...)
 char *safe_snprintf(char *Buffer,char *End,const char *Format,...)
 {
    va_list args;
-   unsigned long Did;
+   int Did;
 
    va_start(args,Format);
 

+ 1 - 1
apt-pkg/deb/debsystem.cc

@@ -165,7 +165,7 @@ bool debSystem::Initialize(Configuration &Cnf)
       which is yet to be determined. The functions in pkgcachegen should
       be the only users of these */
    Cnf.CndSet("Dir::State::extended_states", Cnf.FindDir("Dir::State").append("extended_states"));
-   Cnf.CndSet("Dir::State::status","/var/lib/dpkg/status");
+   Cnf.CndSet("Dir::State::status", Cnf.FindDir("Dir", "/").append("var/lib/dpkg/status"));
    Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg");
 
    if (StatusFile) {

+ 4 - 2
apt-pkg/deb/dpkgpm.cc

@@ -554,7 +554,7 @@ void pkgDPkgPM::handleDisappearAction(string const &pkgname)
    // the disappeared package was auto-installed - nothing to do
    if ((Cache[Pkg].Flags & pkgCache::Flag::Auto) == pkgCache::Flag::Auto)
       return;
-   pkgCache::VerIterator PkgVer = Pkg.CurrentVer();
+   pkgCache::VerIterator PkgVer = Cache[Pkg].InstVerIter(Cache);
    if (unlikely(PkgVer.end() == true))
       return;
    /* search in the list of dependencies for (Pre)Depends,
@@ -571,7 +571,9 @@ void pkgDPkgPM::handleDisappearAction(string const &pkgname)
       // the package is already marked as manual
       if ((Cache[Tar].Flags & pkgCache::Flag::Auto) != pkgCache::Flag::Auto)
 	 continue;
-      pkgCache::VerIterator TarVer = Tar.CurrentVer();
+      pkgCache::VerIterator TarVer =  Cache[Tar].InstVerIter(Cache);
+      if (TarVer.end() == true)
+	 continue;
       for (pkgCache::DepIterator Rep = TarVer.DependsList(); Rep.end() != true; ++Rep)
       {
 	 if (Rep->Type != pkgCache::Dep::Replaces)

+ 2 - 3
apt-pkg/indexcopy.cc

@@ -661,9 +661,8 @@ bool SigVerify::RunGPGV(std::string const &File, std::string const &FileGPG,
 {
    string const gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
    // FIXME: remove support for deprecated APT::GPGV setting
-   string const trustedFile = _config->FindFile("Dir::Etc::Trusted",
-		_config->Find("APT::GPGV::TrustedKeyring", "/etc/apt/trusted.gpg").c_str());
-   string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts", "/etc/apt/trusted.gpg.d");
+   string const trustedFile = _config->FindFile("Dir::Etc::Trusted");
+   string const trustedPath = _config->FindDir("Dir::Etc::TrustedParts");
 
    bool const Debug = _config->FindB("Debug::Acquire::gpgv", false);
 

+ 3 - 0
apt-pkg/init.cc

@@ -70,6 +70,9 @@ bool pkgInitConfig(Configuration &Cnf)
    Cnf.Set("Dir::Etc::parts","apt.conf.d");
    Cnf.Set("Dir::Etc::preferences","preferences");
    Cnf.Set("Dir::Etc::preferencesparts","preferences.d");
+   string const deprecated = _config->Find("APT::GPGV::TrustedKeyring");
+   Cnf.Set("Dir::Etc::trusted", deprecated.empty() ? "trusted.gpg" : deprecated);
+   Cnf.Set("Dir::Etc::trustedparts","trusted.gpg.d");
    Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
    Cnf.Set("Dir::Media::MountPath","/media/apt");
 

+ 9 - 0
debian/apt.cron.daily

@@ -320,6 +320,15 @@ debug_echo()
 
 # ------------------------ main ----------------------------
 
+# Backup the 7 last versions of APT's extended_states file
+# shameless copy from dpkg cron
+if cd /var/backups ; then
+    if ! cmp -s apt.extended_states.0 /var/lib/apt/extended_states; then
+	cp -p /var/lib/apt/extended_states apt.extended_states
+	savelog -c 7 apt.extended_states >/dev/null
+    fi
+fi
+
 # check apt-config exstance
 if ! which apt-config >/dev/null ; then
 	exit 0

+ 27 - 0
debian/changelog

@@ -1,3 +1,30 @@
+apt (0.8.0~pre2) UNRELEASED; urgency=low
+
+  [ David Kalnischkies ]
+  * apt-pkg/contrib/strutl.cc:
+    - fix error checking for vsnprintf in its safe variant
+  * methods/bzip2.cc:
+    - fix error checking for read in case of failing bzip2/lzma/whatever
+  * debian/apt.cron.daily:
+    - create backups for our extended_states file (Closes: #593430)
+  * apt-pkg/init.cc:
+    - set the default values for dir::etc::trusted options correctly
+  * ftparchive/writer.cc:
+    - init valid-until correctly to prevent garbage entering Release file
+  * apt-pkg/deb/debsystem.cc:
+    - set dir::state::status based at least on dir
+  * apt-pkg/deb/dpkgpm.cc:
+    - use the InstVer instead of the CurrentVer for the autobit transfer
+  * methods/http.cc:
+    - some http servers violate HTTP1.1 by not issuing a Reason-Phrase
+      (or at least a space after the code) especially for 200, but lets
+      be nice and ignore it as we don't need the reason in general
+  * apt-pkg/acquire-item.cc:
+    - don't use ReadOnlyGzip mode for PDiffs as this mode doesn't work
+      in combination with the AddFd methods of our hashclasses
+
+ -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 21 Aug 2010 22:18:41 +0200
+
 apt (0.8.0~pre1) experimental; urgency=low
 
   [ Programs translations ]

+ 1 - 1
ftparchive/writer.cc

@@ -925,7 +925,7 @@ ReleaseWriter::ReleaseWriter(string const &DB)
    }
 
    time_t const validuntil = now + _config->FindI("APT::FTPArchive::Release::ValidTime", 0);
-   char validstr[128];
+   char validstr[128] = "";
    if (now == validuntil ||
        strftime(validstr, sizeof(validstr), "%a, %d %b %Y %H:%M:%S UTC",
                 gmtime(&validuntil)) == 0)

+ 1 - 2
methods/bzip2.cc

@@ -102,9 +102,8 @@ bool Bzip2Method::Fetch(FetchItem *Itm)
    while (1) 
    {
       unsigned char Buffer[4*1024];
-      unsigned long Count;
       
-      Count = read(GzOut[0],Buffer,sizeof(Buffer));
+      ssize_t Count = read(GzOut[0],Buffer,sizeof(Buffer));
       if (Count < 0 && errno == EINTR)
 	 continue;
       

+ 1 - 1
methods/gpgv.cc

@@ -69,7 +69,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
       {
 	 // TRANSLATOR: %s is the trusted keyring parts directory
 	 ioprintf(ret, _("No keyring installed in %s."),
-		  _config->FindDir("Dir::Etc::TrustedParts", "/etc/apt/trusted.gpg.d").c_str());
+		  _config->FindDir("Dir::Etc::TrustedParts").c_str());
 	 return ret.str();
       }
       exit(111);

+ 8 - 2
methods/http.cc

@@ -553,8 +553,14 @@ bool ServerState::HeaderLine(string Line)
       // Evil servers return no version
       if (Line[4] == '/')
       {
-	 if (sscanf(Line.c_str(),"HTTP/%u.%u %u%[^\n]",&Major,&Minor,
-		    &Result,Code) != 4)
+	 int const elements = sscanf(Line.c_str(),"HTTP/%u.%u %u%[^\n]",&Major,&Minor,&Result,Code);
+	 if (elements == 3)
+	 {
+	    Code[0] = '\0';
+	    if (Debug == true)
+	       clog << "HTTP server doesn't give Reason-Phrase for " << Result << std::endl;
+	 }
+	 else if (elements != 4)
 	    return _error->Error(_("The HTTP server sent an invalid reply header"));
       }
       else

Разница между файлами не показана из-за своего большого размера
+ 1787 - 0
test/integration/Packages-bug-591882-conkeror


+ 34 - 0
test/integration/Packages-pdiff-usage

@@ -0,0 +1,34 @@
+Package: apt
+Version: 0.7.25.3
+Architecture: i386
+Maintainer: APT Development Team <deity@lists.debian.org>
+Installed-Size: 5244
+Replaces: libapt-pkg-dev (<< 0.3.7), libapt-pkg-doc (<< 0.3.7)
+Provides: libapt-pkg-libc6.9-6-4.8
+Depends: libc6 (>= 2.3.4), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.4.0), debian-archive-keyring
+Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, bzip2, lzma, python-apt
+Filename: pool/main/a/apt/apt_0.7.25.3_i386.deb
+Size: 1750610
+MD5sum: 311aadc67d1b72428b54c9b4e1f76671
+SHA1: 3c695e028f74d5c55226f9ef30000bbbd881088c
+SHA256: b46fd1546151c545fe4bfa56a5cc0e7811a9f68826326a529777fd660f28f050
+Description: Advanced front-end for dpkg
+ This is Debian's next generation front-end for the dpkg package manager.
+ It provides the apt-get utility and APT dselect method that provides a
+ simpler, safer way to install and upgrade packages.
+ .
+ APT features complete installation ordering, multiple source capability
+ and several other unique features, see the Users Guide in apt-doc.
+
+Package: oldstuff
+Version: 1.0
+Architecture: i386
+Maintainer: Joe Sixpack <joe@example.org>
+Installed-Size: 100
+Filename: pool/oldstuff_1.0_i386.deb
+Size: 100000
+MD5sum: 311aeeadf78324aaff54c9b4e1f76671
+SHA1: 3c695e028f74d5c544deeddaaa1242desa81088c
+SHA256: b46fd1546151c545fe4bfa56a5cc0e7deaef23e2da3e4f129727fd660f28f050
+Description: some cool but old stuff
+ This package will disappear in the next mirror update

+ 37 - 0
test/integration/Packages-pdiff-usage-new

@@ -0,0 +1,37 @@
+Package: newstuff
+Version: 1.0
+Architecture: i386
+Maintainer: Joe Sixpack <joe@example.org>
+Installed-Size: 101
+Filename: pool/newstuff_1.0_i386.deb
+Size: 101100
+MD5sum: 311aeeadf78324aaff1ceaf3e1f76671
+SHA1: 3c695e028f7a1ae324deeddaaa1242desa81088c
+SHA256: b46fd154615edefab321cc56a5cc0e7deaef23e2da3e4f129727fd660f28f050
+Description: some cool and shiny new stuff
+ This package will appear in the next mirror update
+
+Package: apt
+Priority: important
+Section: admin
+Installed-Size: 5672
+Maintainer: APT Development Team <deity@lists.debian.org>
+Architecture: i386
+Version: 0.8.0~pre1
+Replaces: manpages-pl (<< 20060617-3~)
+Provides: libapt-pkg4.10
+Depends: libc6 (>= 2.3.4), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.4.0), zlib1g (>= 1:1.1.4), debian-archive-keyring, gnupg
+Suggests: aptitude | synaptic | wajig, dpkg-dev, apt-doc, bzip2, lzma, python-apt
+Conflicts: python-apt (<< 0.7.93.2~)
+Filename: pool/main/a/apt/apt_0.8.0~pre1_i386.deb
+Size: 2013046
+MD5sum: 6786ca6270c988f2c201716ededaedec
+SHA1: fe26559e745d4c2c977c27170938852041c9adff
+SHA256: a12f968467e1e3cec24191b72bfe84f7aeed3ce422e1a60bb4f1454f2b89b8ee
+Description: Advanced front-end for dpkg
+ This is Debian's next generation front-end for the dpkg package manager.
+ It provides the apt-get utility and APT dselect method that provides a
+ simpler, safer way to install and upgrade packages.
+ .
+ APT features complete installation ordering, multiple source capability
+ and several other unique features, see the Users Guide in apt-doc.

+ 33 - 0
test/integration/create-test-data

@@ -0,0 +1,33 @@
+#!/bin/sh
+set +e # its okay to fail in these script, most of the time the apt* stuff will generate errors
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+BUILDDIRECTORY="${TESTDIR}/../../build/bin"
+
+GENERATE=$1
+CODENAME=$2
+shift 2
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+touch $WORKDIR/status
+TMPGEN=$WORKDIR/Packages
+export LANG=C
+
+LISTOFPKGS=$(aptget install $* -t $CODENAME -so Dir::state::status=$WORKDIR/status -o Dir::Cache::archives=$WORKDIR -o pkgCacheGen::Essential=none -o APT::Immediate-Configure=0 2> /dev/null | awk '/^Inst/ {print $2}' | sed -e "s#\$#/$CODENAME#")
+aptcache show $LISTOFPKGS --no-all-versions 2> /dev/null > $TMPGEN
+sed -i $TMPGEN \
+	-e '/^ / d' \
+	-e '/^SHA1: / d' -e '/^SHA256: / d' \
+	-e '/^Homepage: / d' -e '/^Tag: / d' \
+	-e '/^Xul-Appid: / d' \
+	-e '/^Status: / d'
+
+if echo "$GENERATE" | grep '^status-' > /dev/null; then
+	sed -i $TMPGEN -e '/^Package: / a\
+Status: install ok installed' \
+		-e '/^Filename: / d' -e '/^Size: / d' -e '/^MD5sum: / d'
+fi
+
+apt-sortpkgs $TMPGEN > $GENERATE

+ 321 - 29
test/integration/framework

@@ -28,15 +28,45 @@ msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
 msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
 
 # enable / disable Debugging
-msginfo() { true; }
-msgdebug() { true; }
-msgninfo() { true; }
-msgndebug() { true; }
-msgdone() { if [ "$1" = "debug" -o "$1" = "info" ]; then true; else echo "${CDONE}DONE${CNORMAL}" >&2; fi }
+MSGLEVEL=${MSGLEVEL:-3}
+if [ $MSGLEVEL -le 0 ]; then
+	msgdie() { true; }
+fi
+if [ $MSGLEVEL -le 1 ]; then
+	msgwarn() { true; }
+	msgnwarn() { true; }
+fi
+if [ $MSGLEVEL -le 2 ]; then
+	msgmsg() { true; }
+	msgnmsg() { true; }
+fi
+if [ $MSGLEVEL -le 3 ]; then
+	msginfo() { true; }
+	msgninfo() { true; }
+fi
+if [ $MSGLEVEL -le 4 ]; then
+	msgdebug() { true; }
+	msgndebug() { true; }
+fi
+msgdone() {
+	if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
+	   [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
+	   [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
+	   [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
+	   [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
+		true;
+	else
+		echo "${CDONE}DONE${CNORMAL}" >&2;
+	fi
+}
 
 runapt() {
 	msgdebug "Executing: ${CCMD}$*${CDEBUG} "
-	APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+	if [ -f ./aptconfig.conf ]; then
+		APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+	else
+		LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+	fi
 }
 aptconfig() { runapt apt-config $*; }
 aptcache() { runapt apt-cache $*; }
@@ -44,24 +74,27 @@ aptget() { runapt apt-get $*; }
 aptftparchive() { runapt apt-ftparchive $*; }
 
 setupenvironment() {
-	local TMPWORKINGDIRECTORY=$(mktemp -d)
+	TMPWORKINGDIRECTORY=$(mktemp -d)
 	local TESTDIR=$(readlink -f $(dirname $0))
 	msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… "
 	BUILDDIRECTORY="${TESTDIR}/../../build/bin"
 	test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
 	local OLDWORKINGDIRECTORY=$(pwd)
-	trap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+	CURRENTTRAP="cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY"
+	trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
 	cd $TMPWORKINGDIRECTORY
-	mkdir rootdir aptarchive
+	mkdir rootdir aptarchive keys
 	cd rootdir
-	mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache var/lib/dpkg
-	mkdir -p var/cache/apt/archives/partial var/lib/apt/lists/partial
+	mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache
+	mkdir -p var/log/apt var/lib/apt
+	mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
 	local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/')
 	if [ -f "${TESTDIR}/${STATUSFILE}" ]; then
 		cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status
 	else
 		touch var/lib/dpkg/status
 	fi
+	touch var/lib/dpkg/available
 	mkdir -p usr/lib/apt
 	ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods
 	cd ..
@@ -69,11 +102,19 @@ setupenvironment() {
 	if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
 		cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages
 	else
-		touch var/lib/dpkg/status
+		touch aptarchive/Packages
 	fi
-	echo "RootDir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
+	cp $(find $TESTDIR -name '*.pub' -o -name '*.sec') keys/
+	ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
+	echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
 	echo "Debug::NoLocking \"true\";" >> aptconfig.conf
 	echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
+	echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
+	echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
+	echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
+	echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
+	echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
+	echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
 	export LC_ALL=C
 	msgdone "info"
 }
@@ -88,10 +129,193 @@ configarchitecture() {
 	done
 }
 
-buildflataptarchive() {
-	msginfo "Build APT archive for ${CCMD}$0${CINFO}…"
+setupsimplenativepackage() {
+	local NAME="$1"
+	local ARCH="$2"
+	local VERSION="$3"
+	local RELEASE="${4:-unstable}"
+	local DEPENDENCIES="$5"
+	local DESCRIPTION="$6"
+	local SECTION="${7:-others}"
+	local DISTSECTION
+	if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
+		DISTSECTION="main"
+	else
+		DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
+	fi
+	local BUILDDIR=incoming/${NAME}-${VERSION}
+	mkdir -p ${BUILDDIR}/debian/source
+	cd ${BUILDDIR}
+	echo "* most suckless software product ever" > FEATURES
+	test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
+	test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
+
+  * Initial release
+
+ -- Joe Sixpack <joe@example.org>  $(date -R)" > debian/changelog
+	test -e debian/control || echo "Source: $NAME
+Section: $SECTION
+Priority: optional
+Maintainer: Joe Sixpack <joe@example.org>
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.9.1
+
+Package: $NAME
+Architecture: $ARCH" > debian/control
+	test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
+	if [ -z "$DESCRIPTION" ]; then
+		echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
+ If you find such a package installed on your system,
+ YOU did something horribly wrong! They are autogenerated
+ und used only by testcases for APT and surf no other propose…" >> debian/control
+	else
+		echo "Description: $DESCRIPTION" >> debian/control
+	fi
+	test -e debian/compat || echo "7" > debian/compat
+	test -e debian/source/format || echo "3.0 (native)" > debian/source/format
+	test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
+	cd - > /dev/null
+}
+
+buildsimplenativepackage() {
+	local NAME="$1"
+	local ARCH="$2"
+	local VERSION="$3"
+	local RELEASE="${4:-unstable}"
+	local DEPENDENCIES="$5"
+	local DESCRIPTION="$6"
+	local SECTION="${7:-others}"
+	local DISTSECTION
+	if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
+		DISTSECTION="main"
+	else
+		DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
+	fi
+	setupsimplenativepackage "$NAME" "$ARCH" "$VERSION" "$RELEASE" "$DEPENDENCIES" "$DESCRIPTION" "$SECTION"
+	buildpackage "incoming/${NAME}-${VERSION}" "$RELEASE" "$DISTSECTION"
+	rm -rf "incoming/${NAME}-${VERSION}"
+}
+
+buildpackage() {
+	local BUILDDIR=$1
+	local RELEASE=$2
+	local SECTION=$3
+	msgninfo "Build package $(echo "$BUILDDIR" | grep -o '[^/]*$') for ${RELEASE} in ${SECTION}… "
+	cd $BUILDDIR
+	if [ "$ARCH" = "all" ]; then
+		ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
+	fi
+	local BUILT="$(dpkg-buildpackage -uc -us -a$ARCH 2> /dev/null)"
+	local PKGS="$( echo "$BUILT" | grep '^dpkg-deb: building package' | cut -d'/' -f 2 | sed -e "s#'\.##")"
+	local SRCS="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._-]*$')"
+	cd - > /dev/null
+	for PKG in $PKGS; do
+		echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
+	done
+	for SRC in $SRCS; do
+		echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
+	done
+	msgdone "info"
+}
+
+buildaptarchive() {
+	if [ -d incoming ]; then
+		buildaptarchivefromincoming $*
+	else
+		buildaptarchivefromfiles $*
+	fi
+}
+
+createaptftparchiveconfig() {
+	local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')"
+	echo -n 'Dir {
+	ArchiveDir "' >> ftparchive.conf
+	echo -n $(readlink -f .) >> ftparchive.conf
+	echo -n '";
+	CacheDir "' >> ftparchive.conf
+	echo -n $(readlink -f ..) >> ftparchive.conf
+	echo -n '";
+	FileListDir "' >> ftparchive.conf
+	echo -n $(readlink -f pool/) >> ftparchive.conf
+	echo -n '";
+};
+Default {
+	Packages::Compress ". gzip bzip2 lzma";
+	Sources::Compress ". gzip bzip2 lzma";
+	Contents::Compress ". gzip bzip2 lzma";
+};
+TreeDefault {
+	Directory "pool/";
+	SrcDirectory "pool/";
+};
+APT {
+	FTPArchive {
+		Release {
+			Origin "joesixpack";
+			Label "apttestcases";
+			Suite "unstable";
+			Description "repository with dummy packages";
+			Architectures "' >> ftparchive.conf
+	echo -n "$ARCHS" >> ftparchive.conf
+	echo 'source";
+		};
+	};
+};' >> ftparchive.conf
+	for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
+		echo -n 'tree "dists/' >> ftparchive.conf
+		echo -n "$DIST" >> ftparchive.conf
+		echo -n '" {
+	Architectures "' >> ftparchive.conf
+		echo -n "$ARCHS" >> ftparchive.conf
+		echo -n 'source";
+	FileList "' >> ftparchive.conf
+		echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
+		echo -n '";
+	SourceFileList "' >> ftparchive.conf
+		echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
+		echo -n '";
+	Sections "' >> ftparchive.conf
+		echo -n "$(find ./pool/ -maxdepth 1 -name "${DIST}.*.pkglist" -type f | cut -d'/' -f 3 | cut -d'.' -f 2 | sort | uniq | tr '\n' ' ')" >> ftparchive.conf
+		echo '";
+};' >> ftparchive.conf
+	done
+}
+
+buildaptftparchivedirectorystructure() {
+	local DISTS="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
+	for DIST in $DISTS; do
+		local SECTIONS="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
+		for SECTION in $SECTIONS; do
+			local ARCHS="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
+			for ARCH in $ARCHS; do
+				mkdir -p dists/${DIST}/${SECTION}/binary-${ARCH}
+			done
+			mkdir -p dists/${DIST}/${SECTION}/source
+			mkdir -p dists/${DIST}/${SECTION}/i18n
+		done
+	done
+}
+
+buildaptarchivefromincoming() {
+	msginfo "Build APT archive for ${CCMD}$0${CINFO} based on incoming packages…"
+	cd aptarchive
+	[ -e pool ] || ln -s ../incoming pool
+	[ -e ftparchive.conf ] || createaptftparchiveconfig
+	[ -e dists ] || buildaptftparchivedirectorystructure
+	msgninfo "\tGenerate Packages, Sources and Contents files… "
+	aptftparchive -qq generate ftparchive.conf
+	msgdone "info"
+	msgninfo "\tGenerate Release files… "
+	for dir in $(find ./dists -mindepth 1 -maxdepth 1 -type d); do
+		aptftparchive -qq release $dir -o APT::FTPArchive::Release::Codename="$(echo "$dir" | cut -d'/' -f 3)" | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
+	done
+	cd - > /dev/null
+	msgdone "info"
+}
+
+buildaptarchivefromfiles() {
+	msginfo "Build APT archive for ${CCMD}$0${CINFO} based on prebuild files…"
 	cd aptarchive
-	APTARCHIVE=$(readlink -f .)
 	if [ -f Packages ]; then
 		msgninfo "\tPackages file… "
 		cat Packages | gzip > Packages.gz
@@ -106,13 +330,27 @@ buildflataptarchive() {
 		cat Sources | lzma > Sources.lzma
 		msgdone "info"
 	fi
+	msgninfo "\tRelease file… "
+	aptftparchive -qq release . | sed -e '/0 Release$/ d' > Release # remove the self reference
+	msgdone "info"
 	cd ..
-	aptftparchive release . > Release
+}
+
+setupdistsaptarchive() {
+	local APTARCHIVE=$(readlink -f ./aptarchive)
+	rm -f root/etc/apt/sources.list.d/apt-test-*-deb.list
+	rm -f root/etc/apt/sources.list.d/apt-test-*-deb-src.list
+	for DISTS in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
+		SECTIONS=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
+		msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
+		echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list
+		echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list
+		msgdone "info"
+	done
 }
 
 setupflataptarchive() {
-	buildflataptarchive
-	APTARCHIVE=$(readlink -f ./aptarchive)
+	local APTARCHIVE=$(readlink -f ./aptarchive)
 	if [ -f ${APTARCHIVE}/Packages ]; then
 		msgninfo "\tadd deb sources.list line… "
 		echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
@@ -127,10 +365,53 @@ setupflataptarchive() {
 	else
 		rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
 	fi
+}
+
+setupaptarchive() {
+	buildaptarchive
+	if [ -e aptarchive/dists ]; then
+		setupdistsaptarchive
+	else
+		setupflataptarchive
+	fi
+	signreleasefiles
+	msgninfo "\tSync APT's cache with the archive… "
 	aptget update -qq
+	msgdone "info"
+}
+
+signreleasefiles() {
+	local SIGNER="${1:-Joe Sixpack}"
+	msgninfo "\tSign archive with $SIGNER key… "
+	local SECKEYS=""
+	for KEY in $(find keys/ -name '*.sec'); do
+		SECKEYS="$SECKEYS --secret-keyring $KEY"
+	done
+	local PUBKEYS=""
+	for KEY in $(find keys/ -name '*.pub'); do
+		PUBKEYS="$PUBKEYS --keyring $KEY"
+	done
+	for RELEASE in $(find aptarchive/ -name Release); do
+		gpg --yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" -abs -o ${RELEASE}.gpg ${RELEASE}
+	done
+	msgdone "info"
+}
+
+changetowebserver() {
+	if which weborf > /dev/null; then
+		weborf -xb aptarchive/ 2>&1 > /dev/null &
+		CURRENTTRAP="kill $(ps | grep weborf | sed -e 's#^[ ]*##' | cut -d' ' -f 1); $CURRENTTRAP"
+		trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+		local APTARCHIVE="file://$(readlink -f ./aptarchive)"
+		for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
+			sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
+		done
+		return 0
+	fi
+	return 1
 }
 
-diff() {
+checkdiff() {
 	local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
 	if [ -n "$DIFFTEXT" ]; then
 		echo
@@ -141,12 +422,23 @@ diff() {
 	fi
 }
 
+testfileequal() {
+	local FILE="$1"
+	shift
+	msgtest "Test for correctness of file" "$FILE"
+	if [ -z "$*" ]; then
+		echo -n "" | checkdiff $FILE - && msgpass || msgfail
+	else
+		echo "$*" | checkdiff $FILE - && msgpass || msgfail
+	fi
+}
+
 testequal() {
 	local COMPAREFILE=$(mktemp)
 	echo "$1" > $COMPAREFILE
 	shift
 	msgtest "Test for equality of" "$*"
-	$* 2>&1 | diff $COMPAREFILE - && msgpass || msgfail
+	$* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
 	rm $COMPAREFILE
 }
 
@@ -159,32 +451,32 @@ testequalor2() {
 	shift 2
 	msgtest "Test for equality OR of" "$*"
 	$* 2>&1 1> $COMPAREAGAINST
-	(diff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null ||
-		diff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass ||
-		( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(diff $COMPAREFILE1 $COMPAREAGAINST)" \
-		       "\n${CINFO}Diff against OR 2${CNORMAL}" "$(diff $COMPAREFILE2 $COMPAREAGAINST)" &&
+	(checkdiff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null ||
+		checkdiff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass ||
+		( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(checkdiff $COMPAREFILE1 $COMPAREAGAINST)" \
+		       "\n${CINFO}Diff against OR 2${CNORMAL}" "$(checkdiff $COMPAREFILE2 $COMPAREAGAINST)" &&
 		  msgfail )
 	rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST
 }
 
 testshowvirtual() {
-	local VIRTUAL="E: Can't select versions from package '$1' as it purely virtual"
+	local VIRTUAL="N: Can't select versions from package '$1' as it purely virtual"
 	local PACKAGE="$1"
 	shift
 	while [ -n "$1" ]; do
 		VIRTUAL="${VIRTUAL}
-E: Can't select versions from package '$1' as it purely virtual"
+N: Can't select versions from package '$1' as it purely virtual"
 		PACKAGE="${PACKAGE} $1"
 		shift
 	done
 	msgtest "Test for virtual packages" "apt-cache show $PACKAGE"
 	VIRTUAL="${VIRTUAL}
-E: No packages found"
+N: No packages found"
 	local COMPAREFILE=$(mktemp)
 	local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
 	eval `apt-config shell ARCH APT::Architecture`
 	echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
-	aptcache show $PACKAGE 2>&1 | diff $COMPAREFILE - && msgpass || msgfail
+	aptcache show $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
 	rm $COMPAREFILE
 }
 

BIN
test/integration/joesixpack.pub


BIN
test/integration/joesixpack.sec


Разница между файлами не показана из-за своего большого размера
+ 1357 - 0
test/integration/status-bug-591882-conkeror


+ 1 - 1
test/integration/test-bug-590041-prefer-non-virtual-packages

@@ -41,7 +41,7 @@ $pkglibc6
 $pkglibdb1
 EOF
 
-setupflataptarchive
+setupaptarchive
 
 testshowvirtual libc6:i386
 testequal "$pkglibc6" aptcache show libc6:armel

+ 1 - 1
test/integration/test-bug-590438-broken-provides-thanks-to-remove-order

@@ -6,7 +6,7 @@ local TESTDIR=$(readlink -f $(dirname $0))
 
 setupenvironment
 configarchitecture "i386"
-setupflataptarchive
+setupaptarchive
 
 pkgbasefile="Package: base-files
 Status: install ok installed

+ 75 - 0
test/integration/test-bug-591882-conkeror

@@ -0,0 +1,75 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+setupaptarchive
+
+UPGRADEFAIL="Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+  conkeror libdatrie0 libkrb53 libxcb-xlib0 xulrunner-1.9
+The following NEW packages will be installed:
+  gcc-4.4-base libavahi-client3 libavahi-common-data libavahi-common3 libc-bin
+  libdatrie1 libdb4.7 libdb4.8 libdbus-1-3 libgssapi-krb5-2 libjasper1
+  libk5crypto3 libkrb5-3 libkrb5support0 liblzma2 libpam-modules libpam0g
+  libuuid1 libxcb-atom1 libxcb-aux0 libxcb-event1 libxml2 passwd
+  sensible-utils shared-mime-info xz-utils
+The following packages will be upgraded:
+  coreutils debconf debconf-i18n debianutils defoma dpkg file fontconfig
+  fontconfig-config libacl1 libatk1.0-0 libattr1 libbz2-1.0 libc6 libcairo2
+  libcomerr2 libcups2 libexpat1 libfontconfig1 libfreetype6 libgcc1
+  libgcrypt11 libgdbm3 libglib2.0-0 libgnutls26 libgpg-error0 libgtk2.0-0
+  libgtk2.0-common libhunspell-1.2-0 libice6 libjpeg62 libkeyutils1
+  liblocale-gettext-perl libmagic1 libncurses5 libnewt0.52 libnspr4-0d
+  libnss3-1d libpango1.0-0 libpango1.0-common libpcre3 libpixman-1-0
+  libpng12-0 libpopt0 libselinux1 libslang2 libsm6 libsqlite3-0
+  libstartup-notification0 libstdc++6 libtasn1-3 libtext-charwidth-perl
+  libtext-iconv-perl libtext-wrapi18n-perl libthai-data libthai0 libtiff4
+  libx11-6 libx11-data libxau6 libxcb-render-util0 libxcb-render0 libxcb1
+  libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxft2
+  libxi6 libxinerama1 libxrandr2 libxrender1 libxt6 lsb-base ncurses-bin perl
+  perl-base perl-modules readline-common sed ttf-dejavu-core ucf whiptail
+  x11-common zlib1g
+87 upgraded, 26 newly installed, 5 to remove and 0 not upgraded.
+Need to get 0B/54.4MB of archives.
+After this operation, 12.4MB of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation."
+
+UPGRADESUCCESS="Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+  libdatrie0 libkrb53 libxcb-xlib0 xulrunner-1.9
+The following NEW packages will be installed:
+  gcc-4.4-base libasound2 libavahi-client3 libavahi-common-data
+  libavahi-common3 libc-bin libdatrie1 libdb4.7 libdb4.8 libdbus-1-3
+  libgssapi-krb5-2 libjasper1 libk5crypto3 libkrb5-3 libkrb5support0 liblzma2
+  libmozjs2d libpam-modules libpam0g libreadline6 libuuid1 libxcb-atom1
+  libxcb-aux0 libxcb-event1 libxml2 passwd sensible-utils shared-mime-info
+  xulrunner-1.9.1 xz-utils
+The following packages will be upgraded:
+  conkeror coreutils debconf debconf-i18n debianutils defoma dpkg file
+  fontconfig fontconfig-config libacl1 libatk1.0-0 libattr1 libbz2-1.0 libc6
+  libcairo2 libcomerr2 libcups2 libexpat1 libfontconfig1 libfreetype6 libgcc1
+  libgcrypt11 libgdbm3 libglib2.0-0 libgnutls26 libgpg-error0 libgtk2.0-0
+  libgtk2.0-common libhunspell-1.2-0 libice6 libjpeg62 libkeyutils1
+  liblocale-gettext-perl libmagic1 libncurses5 libnewt0.52 libnspr4-0d
+  libnss3-1d libpango1.0-0 libpango1.0-common libpcre3 libpixman-1-0
+  libpng12-0 libpopt0 libselinux1 libslang2 libsm6 libsqlite3-0
+  libstartup-notification0 libstdc++6 libtasn1-3 libtext-charwidth-perl
+  libtext-iconv-perl libtext-wrapi18n-perl libthai-data libthai0 libtiff4
+  libx11-6 libx11-data libxau6 libxcb-render-util0 libxcb-render0 libxcb1
+  libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxft2
+  libxi6 libxinerama1 libxrandr2 libxrender1 libxt6 lsb-base ncurses-bin perl
+  perl-base perl-modules readline-common sed ttf-dejavu-core ucf whiptail
+  x11-common zlib1g
+88 upgraded, 30 newly installed, 4 to remove and 0 not upgraded.
+Need to get 0B/62.9MB of archives.
+After this operation, 36.0MB of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation."
+
+# Test that the old behavior can be restored with the option
+testequal "$UPGRADEFAIL" aptget dist-upgrade --trivial-only -o pkgProblemResolver::FixByInstall=0
+testequal "$UPGRADESUCCESS" aptget dist-upgrade --trivial-only #-o pkgProblemResolver::FixByInstall=0

+ 131 - 0
test/integration/test-compressed-indexes

@@ -0,0 +1,131 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+buildsimplenativepackage "testpkg" "i386" "1.0"
+setupaptarchive
+
+local GOODSHOW="$(aptcache show testpkg)
+"
+local GOODPOLICY="$(aptcache policy testpkg)"
+local GOODSHOWSRC="$(aptcache showsrc testpkg)
+"
+
+test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3
+testequal "$GOODSHOW" aptcache show testpkg
+test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 file:/' | wc -l) -eq 4
+testequal "$GOODPOLICY" aptcache policy testpkg
+test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4
+testequal "$GOODSHOWSRC" aptcache showsrc testpkg
+
+
+testrun() {
+	local F
+	if [ -e rootdir/var/lib/apt/lists/*localhost*Release ]; then
+		msgtest "Check if all index files are" "${1:-uncompressed}"
+		if [ "$1" = "compressed" ]; then
+			! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
+			! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
+			test -e rootdir/var/lib/apt/lists/*_Packages.gz || F=1
+			test -e rootdir/var/lib/apt/lists/*_Sources.gz || F=1
+		else
+			test -e rootdir/var/lib/apt/lists/*_Packages || F=1
+			test -e rootdir/var/lib/apt/lists/*_Sources || F=1
+			! test -e rootdir/var/lib/apt/lists/*_Packages.gz || F=1
+			! test -e rootdir/var/lib/apt/lists/*_Sources.gz || F=1
+		fi
+		if [ -n "$F" ]; then
+			ls -laR rootdir/var/lib/apt/lists/
+			msgfail
+		else
+			msgpass
+		fi
+		msgtest "Check if package is downloadable"
+		aptget install -d testpkg -qq && msgpass || msgfail
+		msgtest "\tdeb file is present"; test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail
+		aptget clean
+		msgtest "\tdeb file is gone"; ! test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail
+	fi
+	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	testequal "$GOODSHOW" aptcache show testpkg
+	testequal "$GOODSHOW" aptcache show testpkg
+	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	testequal "$GOODPOLICY" aptcache policy testpkg
+	testequal "$GOODPOLICY" aptcache policy testpkg
+	rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	testequal "$GOODSHOWSRC" aptcache showsrc testpkg
+	testequal "$GOODSHOWSRC" aptcache showsrc testpkg
+	rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
+	rm -rf rootdir/var/cache/apt/archives
+	msgtest "Check if the source is aptgetable"
+	aptget source testpkg -qq 2> /dev/null > /dev/null && msgpass || msgfail
+	msgtest "\tdsc file is present"; test -f testpkg_1.0.dsc && msgpass || msgfail
+	msgtest "\tdirectory is present"; test -d testpkg-1.0 && msgpass || msgfail
+	rm -rf testpkg-1.0
+}
+
+msgmsg "File: Test with uncompressed indexes"
+testrun
+
+aptget update -qq -o Acquire::Pdiffs=1
+msgmsg "File: Test with uncompressed indexes (update unchanged with pdiffs)"
+testrun
+
+aptget update -qq -o Acquire::Pdiffs=0
+msgmsg "File: Test with uncompressed indexes (update unchanged without pdiffs)"
+testrun
+
+rm -rf rootdir/var/lib/apt/lists
+echo 'Acquire::CompressionTypes::Order:: "gz";
+Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
+
+aptget update -qq
+msgmsg "File: Test with compressed indexes"
+testrun "compressed"
+
+aptget update -qq -o Acquire::Pdiffs=1
+msgmsg "File: Test with compressed indexes (update unchanged with pdiffs)"
+testrun "compressed"
+
+aptget update -qq -o Acquire::Pdiffs=0
+msgmsg "File: Test with compressed indexes (update unchanged without pdiffs)"
+testrun "compressed"
+
+rm rootdir/etc/apt/apt.conf.d/02compressindex
+changetowebserver
+aptget update -qq
+local GOODPOLICY="$(aptcache policy testpkg)"
+test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^  Candidate:' -e '^  Installed: (none)' -e '500 http://' | wc -l) -eq 4
+testequal "$GOODPOLICY" aptcache policy testpkg
+
+msgmsg "HTTP: Test with uncompressed indexes"
+testrun
+
+aptget update -qq -o Acquire::Pdiffs=1
+msgmsg "HTTP: Test with uncompressed indexes (update unchanged with pdiffs)"
+testrun
+
+aptget update -qq -o Acquire::Pdiffs=0
+msgmsg "HTTP: Test with uncompressed indexes (update unchanged without pdiffs)"
+testrun
+
+rm -rf rootdir/var/lib/apt/lists
+echo 'Acquire::CompressionTypes::Order:: "gz";
+Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
+
+aptget update -qq
+msgmsg "HTTP: Test with compressed indexes"
+testrun "compressed"
+
+aptget update -qq -o Acquire::Pdiffs=1
+msgmsg "HTTP: Test with compressed indexes (update unchanged with pdiffs)"
+testrun "compressed"
+
+aptget update -qq -o Acquire::Pdiffs=0
+msgmsg "HTTP: Test with compressed indexes (update unchanged without pdiffs)"
+testrun "compressed"

+ 54 - 0
test/integration/test-disappearing-packages

@@ -0,0 +1,54 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture "i386"
+
+buildsimplenativepackage "old-pkg" "i386" "1.0" "stable"
+buildsimplenativepackage "unrelated" "all" "0.5" "unstable"
+
+setupsimplenativepackage "new-pkg" "i386" "2.0" "unstable" "Provides: old-pkg
+Replaces: old-pkg
+Conflicts: old-pkg (<< 2.0)"
+local BUILDDIR="incoming/new-pkg-2.0"
+echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/new-pkg.links
+buildpackage "$BUILDDIR" "unstable" "main"
+rm -rf "$BUILDDIR"
+
+setupsimplenativepackage "old-pkg" "all" "2.0" "unstable" "Depends: new-pkg"
+local BUILDDIR="incoming/old-pkg-2.0"
+echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/old-pkg.links
+echo "
+override_dh_link:
+	rm -rf debian/old-pkg/usr/share/doc/old-pkg/
+	dh_link" >> ${BUILDDIR}/debian/rules
+buildpackage "$BUILDDIR" "unstable" "main"
+rm -rf "$BUILDDIR"
+
+setupaptarchive
+
+aptget install old-pkg=1.0 --trivial-only -qq 2>&1 > /dev/null
+
+testfileequal "rootdir/var/lib/apt/extended_states" "" # old-pkg is manual installed
+
+local CMD="aptget dist-upgrade -y -q=0"
+msgtest "Test for equality of" "$CMD"
+local COMPAREFILE=$(mktemp)
+echo "The following package disappeared from your system as
+all files have been overwritten by other packages:
+  old-pkg
+Note: This is done automatic and on purpose by dpkg." > $COMPAREFILE
+$CMD 2>&1 | tail -n 4 | diff $COMPAREFILE - && msgpass || msgfail
+rm $COMPAREFILE
+
+sed -i rootdir/var/log/apt/history.log -e '/^Commandline: / d' -e '/^Start-Date: / d' -e '/^End-Date: / d'
+testfileequal "rootdir/var/log/apt/history.log" "
+Install: old-pkg:i386 (1.0)
+
+Install: new-pkg:i386 (2.0, automatic)
+Upgrade: old-pkg:i386 (1.0, 2.0)
+Disappeared: old-pkg (1.0)"
+
+testfileequal "rootdir/var/lib/apt/extended_states" "" # new-pkg should have get the manual flag from old-pkg

+ 51 - 0
test/integration/test-pdiff-usage

@@ -0,0 +1,51 @@
+#!/bin/sh
+set -e
+
+local TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+
+setupenvironment
+configarchitecture "i386"
+
+buildaptarchive
+setupflataptarchive
+changetowebserver
+signreleasefiles
+aptget update -qq
+
+testnopackage newstuff
+PKGFILE="${TESTDIR}/$(echo "$(basename $0)" | sed 's#^test-#Packages-#')"
+testequal "$(cat ${PKGFILE})
+" aptcache show apt oldstuff
+
+cp ${PKGFILE}-new aptarchive/Packages
+cat aptarchive/Packages | gzip > aptarchive/Packages.gz
+cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2
+cat aptarchive/Packages | lzma > aptarchive/Packages.lzma
+rm -rf aptarchive/Packages.diff
+aptftparchive release aptarchive/ > aptarchive/Release
+mkdir -p aptarchive/Packages.diff
+PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)"
+diff -e ${PKGFILE} ${PKGFILE}-new > ${PATCHFILE} || true
+cat $PATCHFILE | gzip > ${PATCHFILE}.gz
+PATCHINDEX="aptarchive/Packages.diff/Index"
+echo "SHA1-Current: $(sha1sum ${PKGFILE}-new | cut -d' ' -f 1) $(stat -c%s ${PKGFILE}-new)
+SHA1-History:
+ 9f4148e06d7faa37062994ff10d0c842d7017513 33053002 2010-08-18-2013.28
+ $(sha1sum $PKGFILE | cut -d' ' -f 1) $(stat -c%s $PKGFILE) $(basename $PATCHFILE)
+SHA1-Patches:
+ 7651fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
+ $(sha1sum $PATCHFILE | cut -d' ' -f 1) $(stat -c%s $PATCHFILE) $(basename $PATCHFILE)" > $PATCHINDEX
+sed -i aptarchive/Release \
+ -e "/^MD5Sum:/ a\
+ \ $(md5sum $PATCHINDEX | cut -d' ' -f 1) $(stat -c%s $PATCHINDEX) Packages.diff/Index" \
+ -e "/^SHA1:/ a\
+ \ $(sha1sum $PATCHINDEX | cut -d' ' -f 1) $(stat -c%s $PATCHINDEX) Packages.diff/Index" \
+ -e "/^SHA256:/ a\
+ \ $(sha256sum $PATCHINDEX | cut -d' ' -f 1) $(stat -c%s $PATCHINDEX) Packages.diff/Index"
+signreleasefiles
+aptget update -qq
+
+testnopackage oldstuff
+testequal "$(cat ${PKGFILE}-new)
+" aptcache show apt newstuff