summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/contrib/configuration.cc12
-rw-r--r--apt-pkg/contrib/configuration.h1
-rw-r--r--apt-pkg/contrib/fileutl.cc31
-rw-r--r--apt-pkg/contrib/fileutl.h3
-rw-r--r--apt-pkg/deb/deblistparser.cc2
-rw-r--r--apt-pkg/deb/dpkgpm.cc20
-rw-r--r--apt-pkg/indexrecords.cc2
-rw-r--r--apt-pkg/tagfile.cc59
-rw-r--r--apt-pkg/tagfile.h1
-rw-r--r--apt-private/private-upgrade.cc6
-rw-r--r--cmdline/apt-get.cc3
-rw-r--r--debian/changelog22
-rw-r--r--doc/apt.conf.5.xml23
-rw-r--r--po/fr.po14
-rw-r--r--test/integration/framework8
-rwxr-xr-xtest/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch94
-rw-r--r--test/libapt/configuration_test.cc4
-rw-r--r--test/libapt/fileutl_test.cc42
-rw-r--r--test/libapt/makefile5
-rwxr-xr-xtest/libapt/run-tests20
20 files changed, 281 insertions, 91 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 376617401..4ef4663c0 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -422,6 +422,18 @@ void Configuration::Clear(string const &Name, string const &Value)
}
/*}}}*/
+// Configuration::Clear - Clear everything /*{{{*/
+// ---------------------------------------------------------------------
+void Configuration::Clear()
+{
+ const Configuration::Item *Top = Tree(0);
+ while( Top != 0 )
+ {
+ Clear(Top->FullTag());
+ Top = Top->Next;
+ }
+}
+ /*}}}*/
// Configuration::Clear - Clear an entire tree /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index ea94c2fe6..8e09ea0a6 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -94,6 +94,7 @@ class Configuration
// clear a whole tree
void Clear(const std::string &Name);
+ void Clear();
// remove a certain value from a list (e.g. the list of "APT::Keep-Fds")
void Clear(std::string const &List, std::string const &Value);
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index f24df65fc..dca468c63 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -41,6 +41,8 @@
#include <dirent.h>
#include <signal.h>
#include <errno.h>
+#include <glob.h>
+
#include <set>
#include <algorithm>
@@ -1766,3 +1768,32 @@ bool FileFd::FileFdError(const char *Description,...) {
/*}}}*/
gzFile FileFd::gzFd() { return (gzFile) d->gz; }
+
+
+// Glob - wrapper around "glob()" /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+std::vector<std::string> Glob(std::string const &pattern, int flags)
+{
+ std::vector<std::string> result;
+ glob_t globbuf;
+ int glob_res, i;
+
+ glob_res = glob(pattern.c_str(), flags, NULL, &globbuf);
+
+ if (glob_res != 0)
+ {
+ if(glob_res != GLOB_NOMATCH) {
+ _error->Errno("glob", "Problem with glob");
+ return result;
+ }
+ }
+
+ // append results
+ for(i=0;i<globbuf.gl_pathc;i++)
+ result.push_back(string(globbuf.gl_pathv[i]));
+
+ globfree(&globbuf);
+ return result;
+}
+ /*}}}*/
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 3ec01dd9a..decd64d9d 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -191,4 +191,7 @@ std::string flNoLink(std::string File);
std::string flExtension(std::string File);
std::string flCombine(std::string Dir,std::string File);
+// simple c++ glob
+std::vector<std::string> Glob(std::string const &pattern, int flags=0);
+
#endif
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index c2707d0a5..87aab6ee2 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -805,7 +805,7 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
map_ptrloc const storage = WriteUniqString(component);
FileI->Component = storage;
- pkgTagFile TagFile(&File);
+ pkgTagFile TagFile(&File, File.Size());
pkgTagSection Section;
if (_error->PendingError() == true || TagFile.Step(Section) == false)
return false;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 959d06455..4b5467eff 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -382,24 +382,32 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
OptSec = "DPkg::Tools::Options::" + string(Opts->Value.c_str(),Pos);
unsigned int Version = _config->FindI(OptSec+"::Version",1);
+ unsigned int InfoFD = _config->FindI(OptSec + "::InfoFD", STDIN_FILENO);
// Create the pipes
int Pipes[2];
if (pipe(Pipes) != 0)
return _error->Errno("pipe","Failed to create IPC pipe to subprocess");
- SetCloseExec(Pipes[0],true);
+ if (InfoFD != (unsigned)Pipes[0])
+ SetCloseExec(Pipes[0],true);
+ else
+ _config->Set("APT::Keep-Fds::", Pipes[0]);
SetCloseExec(Pipes[1],true);
-
+
// Purified Fork for running the script
- pid_t Process = ExecFork();
+ pid_t Process = ExecFork();
if (Process == 0)
{
// Setup the FDs
- dup2(Pipes[0],STDIN_FILENO);
+ dup2(Pipes[0], InfoFD);
SetCloseExec(STDOUT_FILENO,false);
- SetCloseExec(STDIN_FILENO,false);
+ SetCloseExec(STDIN_FILENO,false);
SetCloseExec(STDERR_FILENO,false);
+ string hookfd;
+ strprintf(hookfd, "%d", InfoFD);
+ setenv("APT_HOOK_INFO_FD", hookfd.c_str(), 1);
+
dpkgChrootDirectory();
const char *Args[4];
Args[0] = "/bin/sh";
@@ -409,6 +417,8 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
execv(Args[0],(char **)Args);
_exit(100);
}
+ if (InfoFD == (unsigned)Pipes[0])
+ _config->Clear("APT::Keep-Fds", Pipes[0]);
close(Pipes[0]);
FILE *F = fdopen(Pipes[1],"w");
if (F == 0)
diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc
index 6d89949a0..8a72ca151 100644
--- a/apt-pkg/indexrecords.cc
+++ b/apt-pkg/indexrecords.cc
@@ -62,7 +62,7 @@ bool indexRecords::Load(const string Filename) /*{{{*/
if (OpenMaybeClearSignedFile(Filename, Fd) == false)
return false;
- pkgTagFile TagFile(&Fd);
+ pkgTagFile TagFile(&Fd, Fd.Size());
if (_error->PendingError() == true)
{
strprintf(ErrorText, _("Unable to parse Release file %s"),Filename.c_str());
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 1c79ee74f..10bc08d95 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -50,21 +50,27 @@ public:
/* */
pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long long Size)
{
+ /* The size is increased by 4 because if we start with the Size of the
+ filename we need to try to read 1 char more to see an EOF faster, 1
+ char the end-pointer can be on and maybe 2 newlines need to be added
+ to the end of the file -> 4 extra chars */
+ Size += 4;
d = new pkgTagFilePrivate(pFd, Size);
if (d->Fd.IsOpen() == false)
- {
d->Start = d->End = d->Buffer = 0;
+ else
+ d->Buffer = (char*)malloc(sizeof(char) * Size);
+
+ if (d->Buffer == NULL)
d->Done = true;
- d->iOffset = 0;
- return;
- }
-
- d->Buffer = new char[Size];
+ else
+ d->Done = false;
+
d->Start = d->End = d->Buffer;
- d->Done = false;
d->iOffset = 0;
- Fill();
+ if (d->Done == false)
+ Fill();
}
/*}}}*/
// TagFile::~pkgTagFile - Destructor /*{{{*/
@@ -72,11 +78,11 @@ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long long Size)
/* */
pkgTagFile::~pkgTagFile()
{
- delete [] d->Buffer;
+ free(d->Buffer);
delete d;
}
/*}}}*/
-// TagFile::Offset - Return the current offset in the buffer /*{{{*/
+// TagFile::Offset - Return the current offset in the buffer /*{{{*/
unsigned long pkgTagFile::Offset()
{
return d->iOffset;
@@ -89,19 +95,22 @@ unsigned long pkgTagFile::Offset()
*/
bool pkgTagFile::Resize()
{
- char *tmp;
- unsigned long long EndSize = d->End - d->Start;
-
// fail is the buffer grows too big
if(d->Size > 1024*1024+1)
return false;
+ return Resize(d->Size * 2);
+}
+bool pkgTagFile::Resize(unsigned long long const newSize)
+{
+ unsigned long long const EndSize = d->End - d->Start;
+
// get new buffer and use it
- tmp = new char[2*d->Size];
- memcpy(tmp, d->Buffer, d->Size);
- d->Size = d->Size*2;
- delete [] d->Buffer;
- d->Buffer = tmp;
+ char* newBuffer = (char*)realloc(d->Buffer, sizeof(char) * newSize);
+ if (newBuffer == NULL)
+ return false;
+ d->Buffer = newBuffer;
+ d->Size = newSize;
// update the start/end pointers to the new buffer
d->Start = d->Buffer;
@@ -152,9 +161,10 @@ bool pkgTagFile::Fill()
if (d->Done == false)
{
// See if only a bit of the file is left
- if (d->Fd.Read(d->End, d->Size - (d->End - d->Buffer),&Actual) == false)
+ unsigned long long const dataSize = d->Size - ((d->End - d->Buffer) + 1);
+ if (d->Fd.Read(d->End, dataSize, &Actual) == false)
return false;
- if (Actual != d->Size - (d->End - d->Buffer))
+ if (Actual != dataSize || d->Fd.Eof() == true)
d->Done = true;
d->End += Actual;
}
@@ -171,8 +181,13 @@ bool pkgTagFile::Fill()
for (const char *E = d->End - 1; E - d->End < 6 && (*E == '\n' || *E == '\r'); E--)
if (*E == '\n')
LineCount++;
- for (; LineCount < 2; LineCount++)
- *d->End++ = '\n';
+ if (LineCount < 2)
+ {
+ if ((unsigned)(d->End - d->Buffer) >= d->Size)
+ Resize(d->Size + 3);
+ for (; LineCount < 2; LineCount++)
+ *d->End++ = '\n';
+ }
return true;
}
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index fedd72701..66c56799d 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -95,6 +95,7 @@ class pkgTagFile
bool Fill();
bool Resize();
+ bool Resize(unsigned long long const newSize);
public:
diff --git a/apt-private/private-upgrade.cc b/apt-private/private-upgrade.cc
index 85b5a492a..eb546e3e3 100644
--- a/apt-private/private-upgrade.cc
+++ b/apt-private/private-upgrade.cc
@@ -13,6 +13,9 @@
packages */
bool DoUpgradeNoNewPackages(CommandLine &CmdL)
{
+ if (CmdL.FileSize() != 1)
+ return _error->Error(_("The upgrade command takes no arguments"));
+
CacheFile Cache;
if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
@@ -31,6 +34,9 @@ bool DoUpgradeNoNewPackages(CommandLine &CmdL)
// DoSafeUpgrade - Upgrade all packages with install but not remove /*{{{*/
bool DoUpgradeWithAllowNewPackages(CommandLine &CmdL)
{
+ if (CmdL.FileSize() != 1)
+ return _error->Error(_("The upgrade command takes no arguments"));
+
CacheFile Cache;
if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 06dbbce5b..93c21651f 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -350,6 +350,9 @@ bool DoMarkAuto(CommandLine &CmdL)
/* Intelligent upgrader that will install and remove packages at will */
bool DoDistUpgrade(CommandLine &CmdL)
{
+ if (CmdL.FileSize() != 1)
+ return _error->Error(_("The dist-upgrade command takes no arguments"));
+
CacheFile Cache;
if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
diff --git a/debian/changelog b/debian/changelog
index 8e4def2b0..bd6357c62 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,22 @@
+apt (0.9.11) UNRELEASED; urgency=low
+
+ [ Daniel Hartwig ]
+ * Clarify units of Acquire::http::Dl-Limit (closes: #705445)
+ * Show a error message if {,dist-}upgrade is used with additional
+ arguments (closes: #705510)
+
+ [ Michael Vogt ]
+ * lp:~mvo/apt/config-clear:
+ - support Configuration.Clear() for a clear of the entire
+ configuration
+ * lp:~mvo/apt/add-glob-function:
+ - add Glob() to fileutl.{cc,h}
+ * feature/apt-binary2
+ - refactor large chunks of cmdline/*.cc into a new libapt-private
+ library that is shared between the internal apt cmdline tools
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 15 Aug 2013 09:27:35 +0200
+
apt (0.9.10) unstable; urgency=low
The "Hello to Debconf" upload
@@ -5,6 +24,7 @@ apt (0.9.10) unstable; urgency=low
[ Christian Perrier ]
* Vietnamese translation update. Closes: #718615
* Japanese translation update. Closes: #719279
+ * French translation update.
[ Michael Vogt ]
* work on fixing coverity scan results:
@@ -38,7 +58,7 @@ apt (0.9.10) unstable; urgency=low
* make the keyring locations in apt-key configurable
* let apt-key del work better with softlink and single key keyrings
* do not call 'apt-key update' in apt.postinst
-
+
[ Colin Watson ]
* prefer native arch over higher priority for providers (Closes: #718482)
diff --git a/doc/apt.conf.5.xml b/doc/apt.conf.5.xml
index 9973fe42b..42119baa5 100644
--- a/doc/apt.conf.5.xml
+++ b/doc/apt.conf.5.xml
@@ -386,10 +386,12 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
<para><literal>Acquire::http::AllowRedirect</literal> controls whether APT will follow
redirects, which is enabled by default.</para>
- <para>The used bandwidth can be limited with <literal>Acquire::http::Dl-Limit</literal>
- which accepts integer values in kilobytes. The default value is 0 which deactivates
- the limit and tries to use all available bandwidth (note that this option implicitly
- disables downloading from multiple servers at the same time.)</para>
+ <para>The used bandwidth can be limited with
+ <literal>Acquire::http::Dl-Limit</literal> which accepts integer
+ values in kilobytes per second. The default value is 0 which
+ deactivates the limit and tries to use all available bandwidth.
+ Note that this option implicitly disables downloading from
+ multiple servers at the same time.</para>
<para><literal>Acquire::http::User-Agent</literal> can be used to set a different
User-Agent for the http download method as some proxies allow access for clients
@@ -686,7 +688,8 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
<literal>options</literal> this must be specified in list notation. The commands
are invoked in order using <filename>/bin/sh</filename>; should any fail APT
will abort. APT will pass the filenames of all .deb files it is going to
- install to the commands, one per line on standard input.</para>
+ install to the commands, one per line on the requested file descriptor, defaulting
+ to standard input.</para>
<para>Version 2 of this protocol dumps more information, including the
protocol version, the APT configuration space and the packages, files
@@ -698,7 +701,15 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
<literal>DPkg::Tools::options::<replaceable>cmd</replaceable>::Version</literal>
accordingly, the default being version 1. If APT isn't supporting the requested
version it will send the information in the highest version it has support for instead.
- </para></listitem>
+ </para>
+
+ <para>The file descriptor to be used to send the information can be requested with
+ <literal>DPkg::Tools::options::<replaceable>cmd</replaceable>::InfoFD</literal>
+ which defaults to <literal>0</literal> for standard input and is available since
+ version 0.9.11. Support for the option can be detected by looking for the environment
+ variable <envar>APT_HOOK_INFO_FD</envar> which contains the number of the used
+ file descriptor as a confirmation.</para>
+ </listitem>
</varlistentry>
<varlistentry><term><option>Run-Directory</option></term>
diff --git a/po/fr.po b/po/fr.po
index 9b26539b0..fc6dc4300 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -9,14 +9,14 @@ msgstr ""
"Project-Id-Version: fr\n"
"Report-Msgid-Bugs-To: APT Development Team <deity@lists.debian.org>\n"
"POT-Creation-Date: 2013-07-31 16:24+0200\n"
-"PO-Revision-Date: 2013-04-09 07:58+0200\n"
+"PO-Revision-Date: 2013-08-17 07:57+0200\n"
"Last-Translator: Christian Perrier <bubulle@debian.org>\n"
"Language-Team: French <debian-l10n-french@lists.debian.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: Lokalize 1.4\n"
+"X-Generator: Lokalize 1.5\n"
"Plural-Forms: Plural-Forms: nplurals=2; plural=n > 1;\n"
#: cmdline/apt-cache.cc:158
@@ -243,6 +243,10 @@ msgid ""
"You may try the --cdrom option to set the CD-ROM mount point. See 'man apt-"
"cdrom' for more information about the CD-ROM auto-detection and mount point."
msgstr ""
+"Aucun CD n'a été détecté sur le point de montage par défaut.\n"
+"Vous pouvez utiliser l'option --cdrom pour indiquer le point de montage du "
+"CD-ROM. Voir la page de manuel d'apt-cdrom pour plus d'informations sur "
+"l'auto-détection des CD et le point de montage."
#: cmdline/apt-cdrom.cc:85
msgid "Please provide a name for this Disc, such as 'Debian 5.0.3 Disk 1'"
@@ -1606,6 +1610,8 @@ msgid ""
"Clearsigned file isn't valid, got '%s' (does the network require "
"authentication?)"
msgstr ""
+"Le fichier signé en clair n'est pas valable, ce qui a été reçu est « %s ». "
+"Peut-être le réseau nécessite-t-il une authentification."
#: methods/gpgv.cc:183
msgid "Unknown error executing gpgv"
@@ -1729,9 +1735,9 @@ msgid "Can not read mirror file '%s'"
msgstr "Impossible de lire le fichier de miroir « %s »."
#: methods/mirror.cc:315
-#, fuzzy, c-format
+#, c-format
msgid "No entry found in mirror file '%s'"
-msgstr "Impossible de lire le fichier de miroir « %s »."
+msgstr "Pas d'entrée trouvée dans le fichier de miroir « %s »."
#: methods/mirror.cc:445
#, c-format
diff --git a/test/integration/framework b/test/integration/framework
index 72c899e32..54d35fef8 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -88,11 +88,11 @@ msgdone() {
runapt() {
msgdebug "Executing: ${CCMD}$*${CDEBUG} "
if [ -f ./aptconfig.conf ]; then
- APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
- elif [ -f ../aptconfig.conf ]; then
- APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+ elif [ -f ../aptconfig.conf ]; then
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
else
- LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
+ MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
fi
}
aptconfig() { runapt apt-config $*; }
diff --git a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
index af65397ea..62355a6b5 100755
--- a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
+++ b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch
@@ -26,95 +26,111 @@ hook='pre-install-pkgs'
enablehookversion() {
echo "#!/bin/sh
-while read line; do
+FD=0
+echo -n > ${hook}-v${1}.list
+if [ -n \"${2}\" ]; then
+ FD=\$APT_HOOK_INFO_FD
+ if [ "\$FD" != \"${2}\" ]; then echo \"ERROR: Information is not on requested FD: \$FD != ${2}\" >> ${hook}-v${1}.list; fi
+fi
+while read </proc/\$\$/fd/\$FD line; do
if echo \"\$line\" | grep -Fq '**'; then
echo \"\$line\"
fi
-done > ${hook}-v${1}.list" > ${hook}-v${1}.sh
+done >> ${hook}-v${1}.list" > ${hook}-v${1}.sh
chmod +x ${hook}-v${1}.sh
echo "dpkg::${hook}:: \"./${hook}-v${1}.sh --foo -bar\";
DPkg::Tools::options::\"./${hook}-v${1}.sh\"::Version \"$1\";" > rootdir/etc/apt/apt.conf.d/hook-v$1
+ if [ -n "$2" ]; then
+ echo "DPkg::Tools::options::\"./${hook}-v${1}.sh\"::InfoFD \"${2}\";" >> rootdir/etc/apt/apt.conf.d/hook-v$1
+ fi
}
-enablehookversion 2
-enablehookversion 3
-
observehook() {
rm -f ${hook}-v2.list ${hook}-v3.list
msgtest 'Observe hooks while' "$*"
testsuccess --nomsg aptget "$@" -y --force-yes
}
-observehook install stuff -t stable
-testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE**
+testrun() {
+ observehook install stuff -t stable
+ testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE**
toolkit - < 1 **CONFIGURE**
stuff - < 1 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE**
+ testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE**
toolkit - - none < 1 all foreign **CONFIGURE**
stuff - - none < 1 amd64 none **CONFIGURE**'
-observehook install stuff -t unstable
-testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
+ observehook install stuff -t unstable
+ testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
toolkit 1 < 2 **CONFIGURE**
stuff 1 < 2 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE**
+ testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE**
toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**
stuff 1 amd64 none < 2 amd64 none **CONFIGURE**'
-observehook install stuff:i386 -t unstable
-testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE**
+ observehook install stuff:i386 -t unstable
+ testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE**
libsame - < 2 **CONFIGURE**
stuff - < 2 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE**
+ testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE**
libsame - - none < 2 i386 same **CONFIGURE**
stuff - - none < 2 i386 none **CONFIGURE**'
-observehook remove libsame
-testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**'
-testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**'
+ observehook remove libsame
+ testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**'
+ testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**'
-observehook install stuff:i386/stable libsame:i386/stable toolkit/stable
-testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE**
+ observehook install stuff:i386/stable libsame:i386/stable toolkit/stable
+ testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE**
toolkit 2 > 1 **CONFIGURE**
stuff 2 > 1 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE**
+ testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE**
toolkit 2 amd64 foreign > 1 all foreign **CONFIGURE**
stuff 2 i386 none > 1 i386 none **CONFIGURE**'
-observehook install 'libsame:*'
-testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
+ observehook install 'libsame:*'
+ testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE**
libsame - < 2 **CONFIGURE**
toolkit 1 < 2 **CONFIGURE**
stuff 1 < 2 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE**
+ testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE**
libsame - - none < 2 amd64 same **CONFIGURE**
toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**
stuff 1 i386 none < 2 i386 none **CONFIGURE**'
-observehook purge stuff:i386 'libsame:*' toolkit
-testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**
+ observehook purge stuff:i386 'libsame:*' toolkit
+ testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**
stuff 2 > - **REMOVE**
libsame 2 > - **REMOVE**
toolkit 2 > - **REMOVE**'
-testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**
+ testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**
stuff 2 i386 none > - - none **REMOVE**
libsame 2 i386 same > - - none **REMOVE**
toolkit 2 amd64 foreign > - - none **REMOVE**'
-observehook install confpkg
-testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**'
-testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**'
+ observehook install confpkg
+ testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**'
+ testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**'
+
+ observehook remove confpkg
+ testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
+ testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
-observehook remove confpkg
-testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
-testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
+ msgtest 'Conffiles of package remained after remove' 'confpkg'
+ dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail
-msgtest 'Conffiles of package remained after remove' 'confpkg'
-dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail
+ observehook purge confpkg
+ testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
+ testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
-observehook purge confpkg
-testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**'
-testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**'
+ msgtest 'Conffiles are gone after purge' 'confpkg'
+ dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass
+}
+
+enablehookversion 2
+enablehookversion 3
+testrun
-msgtest 'Conffiles are gone after purge' 'confpkg'
-dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass
+enablehookversion 2 13
+enablehookversion 3 13
+testrun
diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc
index 87d5699ef..2c974ee0a 100644
--- a/test/libapt/configuration_test.cc
+++ b/test/libapt/configuration_test.cc
@@ -98,6 +98,10 @@ int main(int argc,const char *argv[]) {
equals(Cnf.FindDir("Dir::State"), "/rootdir/dev/null");
equals(Cnf.FindDir("Dir::State::lists"), "/rootdir/dev/null");
+ Cnf.Set("Moo::Bar", "1");
+ Cnf.Clear();
+ equals(Cnf.Find("Moo::Bar"), "");
+
//FIXME: Test for configuration file parsing;
// currently only integration/ tests test them implicitly
diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc
new file mode 100644
index 000000000..b6b8ac579
--- /dev/null
+++ b/test/libapt/fileutl_test.cc
@@ -0,0 +1,42 @@
+#include <apt-pkg/error.h>
+#include <apt-pkg/fileutl.h>
+
+#include "assert.h"
+#include <string>
+#include <vector>
+
+#include <stdio.h>
+#include <iostream>
+#include <stdlib.h>
+
+
+int main(int argc,char *argv[])
+{
+ std::vector<std::string> files;
+
+ // normal match
+ files = Glob("*.lst");
+ if (files.size() != 1)
+ {
+ _error->DumpErrors();
+ return 1;
+ }
+
+ // not there
+ files = Glob("xxxyyyzzz");
+ if (files.size() != 0 || _error->PendingError())
+ {
+ _error->DumpErrors();
+ return 1;
+ }
+
+ // many matches (number is a bit random)
+ files = Glob("*.cc");
+ if (files.size() < 10)
+ {
+ _error->DumpErrors();
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
index 1b67cba9d..73403b24c 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -98,6 +98,11 @@ include $(PROGRAM_H)
PROGRAM = IndexCopyToSourceList${BASENAME}
SLIBS = -lapt-pkg
SOURCE = indexcopytosourcelist_test.cc
+
+# test fileutls
+PROGRAM = FileUtl${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = fileutl_test.cc
include $(PROGRAM_H)
# test tagfile
diff --git a/test/libapt/run-tests b/test/libapt/run-tests
index f18be6d2b..a056f31f9 100755
--- a/test/libapt/run-tests
+++ b/test/libapt/run-tests
@@ -2,9 +2,11 @@
set -e
DIR=$(readlink -f $(dirname $0))
-echo "Compiling the tests …"
-(cd $DIR && make)
-echo "Running all testcases …"
+if [ -z "$MAKELEVEL" ]; then
+ echo 'Compiling the tests …'
+ (cd $DIR && make)
+ echo 'Running all testcases …'
+fi
LDPATH="$DIR/../../build/bin"
EXT="_libapt_test"
EXIT_CODE=0
@@ -70,9 +72,11 @@ do
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tlh%5fDE"
elif [ $name = "HashSums${EXT}" ]; then
TMP="$(readlink -f "./${0}")"
- echo -n "Testing with ${NAME} "
- LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "$TESTOKAY" || echo "$TESTFAIL"
- continue
+ tmppath="$TMP"
+ tmppath="${tmppath} $(md5sum $TMP | cut -d' ' -f 1)"
+ tmppath="${tmppath} $(sha1sum $TMP | cut -d' ' -f 1)"
+ tmppath="${tmppath} $(sha256sum $TMP | cut -d' ' -f 1)"
+ tmppath="${tmppath} $(sha512sum $TMP | cut -d' ' -f 1)"
elif [ $name = "CompareVersion${EXT}" ]; then
tmppath="${DIR}/versions.lst"
elif [ $name = "CdromFindPackages${EXT}" ]; then
@@ -107,8 +111,8 @@ do
fi
echo -n "Testing with ${NAME} "
- if LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then
- echo "$TESTOKAY"
+ if MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=${LDPATH} ${testapp} ${tmppath} ; then
+ echo "$TESTOKAY"
else
echo "$TESTFAIL"
EXIT_CODE=1