summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-inst/deb/debfile.cc42
-rw-r--r--apt-pkg/aptconfiguration.cc87
-rw-r--r--apt-pkg/aptconfiguration.h29
-rw-r--r--apt-pkg/contrib/configuration.h2
-rw-r--r--apt-pkg/deb/debsrcrecords.cc8
-rw-r--r--cmdline/apt-get.cc2
-rw-r--r--debian/changelog25
-rw-r--r--doc/apt-ftparchive.1.xml11
-rw-r--r--ftparchive/apt-ftparchive.cc2
-rw-r--r--ftparchive/contents.cc27
-rw-r--r--ftparchive/multicompress.cc58
-rw-r--r--ftparchive/multicompress.h21
-rw-r--r--ftparchive/writer.cc151
-rw-r--r--ftparchive/writer.h6
-rw-r--r--methods/makefile10
-rw-r--r--test/integration/framework9
-rwxr-xr-xtest/integration/test-bug-595691-empty-and-broken-archive-files8
17 files changed, 335 insertions, 163 deletions
diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc
index cd7a88808..a40cd1ae8 100644
--- a/apt-inst/deb/debfile.cc
+++ b/apt-inst/deb/debfile.cc
@@ -20,6 +20,7 @@
#include <apt-pkg/extracttar.h>
#include <apt-pkg/error.h>
#include <apt-pkg/deblistparser.h>
+#include <apt-pkg/aptconfiguration.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -46,7 +47,9 @@ debDebFile::debDebFile(FileFd &File) : File(File), AR(File)
if (!CheckMember("data.tar.gz") &&
!CheckMember("data.tar.bz2") &&
- !CheckMember("data.tar.lzma")) {
+ !CheckMember("data.tar.lzma") &&
+ !CheckMember("data.tar.xz")) {
+ // FIXME: add data.tar.xz here - adding it now would require a Translation round for a very small gain
_error->Error(_("This is not a valid DEB archive, it has no '%s', '%s' or '%s' member"), "data.tar.gz", "data.tar.bz2", "data.tar.lzma");
return;
}
@@ -125,22 +128,35 @@ bool debDebFile::ExtractControl(pkgDataBase &DB)
/* Simple wrapper around tar.. */
bool debDebFile::ExtractArchive(pkgDirStream &Stream)
{
- // Get the archive member and positition the file
- const ARArchive::Member *Member = AR.FindMember("data.tar.gz");
- const char *Compressor = "gzip";
- if (Member == 0) {
- Member = AR.FindMember("data.tar.bz2");
- Compressor = "bzip2";
+ // Get the archive member
+ const ARArchive::Member *Member = NULL;
+ std::string Compressor;
+
+ std::string const data = "data.tar";
+ std::vector<APT::Configuration::Compressor> compressor = APT::Configuration::getCompressors();
+ for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
+ c != compressor.end(); ++c)
+ {
+ Member = AR.FindMember(std::string(data).append(c->Extension).c_str());
+ if (Member == NULL)
+ continue;
+ Compressor = c->Binary;
+ break;
}
- if (Member == 0) {
- Member = AR.FindMember("data.tar.lzma");
- Compressor = "lzma";
+
+ if (Member == NULL)
+ {
+ std::string ext = "data.tar.{";
+ for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
+ c != compressor.end(); ++c)
+ ext.append(c->Extension.substr(1));
+ ext.append("}");
+ return _error->Error(_("Internal error, could not locate member %s"), ext.c_str());
}
- if (Member == 0)
- return _error->Error(_("Internal error, could not locate member"));
+
if (File.Seek(Member->Start) == false)
return false;
-
+
// Prepare Tar
ExtractTar Tar(File,Member->Size,Compressor);
if (_error->PendingError() == true)
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 3cf4d2429..b23e12acb 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -38,12 +38,11 @@ const Configuration::getCompressionTypes(bool const &Cached) {
// setup the defaults for the compressiontypes => method mapping
_config->CndSet("Acquire::CompressionTypes::bz2","bzip2");
+ _config->CndSet("Acquire::CompressionTypes::xz","xz");
_config->CndSet("Acquire::CompressionTypes::lzma","lzma");
_config->CndSet("Acquire::CompressionTypes::gz","gzip");
- // Set default application paths to check for optional compression types
- _config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
- _config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
+ setDefaultConfigurationForCompressors();
// accept non-list order as override setting for config settings on commandline
std::string const overrideOrder = _config->Find("Acquire::CompressionTypes::Order","");
@@ -344,4 +343,86 @@ bool const Configuration::checkArchitecture(std::string const &Arch) {
return (std::find(archs.begin(), archs.end(), Arch) != archs.end());
}
/*}}}*/
+// setDefaultConfigurationForCompressors /*{{{*/
+void Configuration::setDefaultConfigurationForCompressors() {
+ // Set default application paths to check for optional compression types
+ _config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
+ _config->CndSet("Dir::Bin::xz", "/usr/bin/xz");
+ _config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
+}
+ /*}}}*/
+// getCompressors - Return Vector of usbale compressors /*{{{*/
+// ---------------------------------------------------------------------
+/* return a vector of compressors used by apt-ftparchive in the
+ multicompress functionality or to detect data.tar files */
+std::vector<APT::Configuration::Compressor>
+const Configuration::getCompressors(bool const Cached) {
+ static std::vector<APT::Configuration::Compressor> compressors;
+ if (compressors.empty() == false) {
+ if (Cached == true)
+ return compressors;
+ else
+ compressors.clear();
+ }
+
+ setDefaultConfigurationForCompressors();
+
+ compressors.push_back(Compressor(".", "", "", "", "", 1));
+ if (_config->Exists("Dir::Bin::gzip") == false || FileExists(_config->FindFile("Dir::Bin::gzip")) == true)
+ compressors.push_back(Compressor("gzip",".gz","gzip","-9n","-d",2));
+ if (_config->Exists("Dir::Bin::bzip2") == false || FileExists(_config->FindFile("Dir::Bin::bzip2")) == true)
+ compressors.push_back(Compressor("bzip2",".bz2","bzip2","-9","-d",3));
+ if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true)
+ compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",4));
+ if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
+ compressors.push_back(Compressor("xz",".xz","xz","-6","-d",5));
+
+ std::vector<std::string> const comp = _config->FindVector("APT::Compressor");
+ for (std::vector<std::string>::const_iterator c = comp.begin();
+ c != comp.end(); ++c) {
+ if (*c == "." || *c == "gzip" || *c == "bzip2" || *c == "lzma" || *c == "xz")
+ continue;
+ compressors.push_back(Compressor(c->c_str(), std::string(".").append(*c).c_str(), c->c_str(), "-9", "-d", 100));
+ }
+
+ return compressors;
+}
+ /*}}}*/
+// getCompressorExtensions - supported data.tar extensions /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+std::vector<std::string> const Configuration::getCompressorExtensions() {
+ std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
+ std::vector<std::string> ext;
+ for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
+ c != compressors.end(); ++c)
+ if (c->Extension.empty() == false && c->Extension != ".")
+ ext.push_back(c->Extension);
+ return ext;
+}
+ /*}}}*/
+// Compressor constructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+Configuration::Compressor::Compressor(char const *name, char const *extension,
+ char const *binary,
+ char const *compressArg, char const *uncompressArg,
+ unsigned short const cost) {
+ std::string const config = string("APT:Compressor::").append(name).append("::");
+ Name = _config->Find(std::string(config).append("Name"), name);
+ Extension = _config->Find(std::string(config).append("Extension"), extension);
+ Binary = _config->Find(std::string(config).append("Binary"), binary);
+ Cost = _config->FindI(std::string(config).append("Cost"), cost);
+ std::string const compConf = std::string(config).append("CompressArg");
+ if (_config->Exists(compConf) == true)
+ CompressArgs = _config->FindVector(compConf);
+ else if (compressArg != NULL)
+ CompressArgs.push_back(compressArg);
+ std::string const uncompConf = std::string(config).append("UncompressArg");
+ if (_config->Exists(uncompConf) == true)
+ UncompressArgs = _config->FindVector(uncompConf);
+ else if (uncompressArg != NULL)
+ UncompressArgs.push_back(uncompressArg);
+}
+ /*}}}*/
}
diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h
index dd339d841..815db6cae 100644
--- a/apt-pkg/aptconfiguration.h
+++ b/apt-pkg/aptconfiguration.h
@@ -82,6 +82,35 @@ public: /*{{{*/
*/
bool static const checkArchitecture(std::string const &Arch);
+ /** \brief Representation of supported compressors */
+ struct Compressor {
+ std::string Name;
+ std::string Extension;
+ std::string Binary;
+ std::vector<std::string> CompressArgs;
+ std::vector<std::string> UncompressArgs;
+ unsigned short Cost;
+
+ Compressor(char const *name, char const *extension, char const *binary,
+ char const *compressArg, char const *uncompressArg,
+ unsigned short const cost);
+ Compressor() {};
+ };
+
+ /** \brief Return a vector of Compressors supported for data.tar's
+ *
+ * \param Cached saves the result so we need to calculated it only once
+ * this parameter should ony be used for testing purposes.
+ *
+ * \return a vector of Compressors
+ */
+ std::vector<Compressor> static const getCompressors(bool const Cached = true);
+
+ /** \brief Return a vector of extensions supported for data.tar's */
+ std::vector<std::string> static const getCompressorExtensions();
+ /*}}}*/
+ private: /*{{{*/
+ void static setDefaultConfigurationForCompressors();
/*}}}*/
};
/*}}}*/
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 175c1bef3..71e5a0e47 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -72,8 +72,8 @@ class Configuration
string Find(string const &Name, string const &Default) const {return Find(Name.c_str(),Default.c_str());};
string FindFile(const char *Name,const char *Default = 0) const;
string FindDir(const char *Name,const char *Default = 0) const;
- std::vector<string> FindVector(string const &Name) const;
std::vector<string> FindVector(const char *Name) const;
+ std::vector<string> FindVector(string const &Name) const { return FindVector(Name.c_str()); };
int FindI(const char *Name,int const &Default = 0) const;
int FindI(string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);};
bool FindB(const char *Name,bool const &Default = false) const;
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index 21336e1af..749305005 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -14,6 +14,7 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
using std::max;
/*}}}*/
@@ -111,7 +112,9 @@ bool debSrcRecordParser::Files(vector<pkgSrcRecords::File> &List)
string Base = Sect.FindS("Directory");
if (Base.empty() == false && Base[Base.length()-1] != '/')
Base += '/';
-
+
+ std::vector<std::string> const compExts = APT::Configuration::getCompressorExtensions();
+
// Iterate over the entire list grabbing each triplet
const char *C = Files.c_str();
while (*C != 0)
@@ -144,7 +147,8 @@ bool debSrcRecordParser::Files(vector<pkgSrcRecords::File> &List)
}
F.Type = string(F.Path,Tmp+1,Pos-Tmp);
- if (F.Type == "gz" || F.Type == "bz2" || F.Type == "lzma" || F.Type == "tar")
+ if (std::find(compExts.begin(), compExts.end(), std::string(".").append(F.Type)) != compExts.end() ||
+ F.Type == "tar")
{
Pos = Tmp-1;
continue;
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index bc2f71c18..c0983b06d 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1718,7 +1718,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
R->Type != pkgCache::Dep::PreDepends)
continue;
pkgCache::PkgIterator N = R.ParentPkg();
- if (N.end() == true || N->CurrentVer == 0)
+ if (N.end() == true || (N->CurrentVer == 0 && (*Cache)[N].Install() == false))
continue;
if (Debug == true)
std::clog << "Save " << P << " as another installed garbage package depends on it" << std::endl;
diff --git a/debian/changelog b/debian/changelog
index 779bcad18..971e967a4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,11 +1,34 @@
apt (0.8.11.6) UNRELEASED; urgency=low
+ [ Christian Perrier ]
* Fix error in French translation of manpages (apt_preferences(5)).
Merci, RĂ©mi Vanicat. Closes: #613689
* Complete French manpage translation
* Italian translation update (Milo Casagrande). Closes: #614395
- -- Christian Perrier <bubulle@debian.org> Fri, 18 Feb 2011 05:53:49 +0100
+ [ David Kalnischkies ]
+ * ftparchive/multicompress.cc, apt-inst/deb/debfile.cc:
+ - support xz compressor to create xz-compressed Indexes and be able
+ to open data.tar.xz files
+ - load the supported compressors from configuration
+ * ftparchive/writer.cc:
+ - ensure that Date and Valid-Until time strings are not localised
+ - add options to disable specific checksums for Indexes
+ - include xz-compressed Packages and Sources files in Release file
+ * apt-pkg/aptconfiguration.cc:
+ - support download of xz-compressed indexes files
+ - support adding new compressors by configuration
+ * apt-pkg/deb/debsrcrecords.cc:
+ - support xz-compressed source v3 debian.tar files
+ - support every compression we have a compressor configured
+ * ftparchive/contents.cc:
+ - remove ExtractArchive codecopy from apt-inst/deb/debfile.cc
+ * apt-inst/deb/debfile.cc:
+ - support data.tar's compressed with any configured compressor
+ * cmdline/apt-get.cc:
+ - reinstall dependencies of reinstalled "garbage" (Closes: #617257)
+
+ -- David Kalnischkies <kalnischkies@gmail.com> Mon, 07 Mar 2011 22:43:15 +0100
apt (0.8.11.5) unstable; urgency=low
diff --git a/doc/apt-ftparchive.1.xml b/doc/apt-ftparchive.1.xml
index 0090d21d9..8e5df1f36 100644
--- a/doc/apt-ftparchive.1.xml
+++ b/doc/apt-ftparchive.1.xml
@@ -526,11 +526,14 @@ for i in Sections do
&apt-cmdblurb;
<variablelist>
- <varlistentry><term><option>--md5</option></term>
+ <varlistentry><term><option>--md5</option>, <option>--sha1</option>, <option>--sha256</option></term>
<listitem><para>
- Generate MD5 sums. This defaults to on, when turned off the generated
- index files will not have MD5Sum fields where possible.
- Configuration Item: <literal>APT::FTPArchive::MD5</literal></para></listitem>
+ Generate the given checksum. These options default to on, when turned off the generated
+ index files will not have the checksum fields where possible.
+ Configuration Items: <literal>APT::FTPArchive::<replaceable>Checksum</replaceable></literal> and
+ <literal>APT::FTPArchive::<replaceable>Index</replaceable>::<replaceable>Checksum</replaceable></literal> where
+ <literal>Index</literal> can be <literal>Packages</literal>, <literal>Sources</literal> or <literal>Release</literal> and
+ <literal>Checksum</literal> can be <literal>MD5</literal>, <literal>SHA1</literal> or <literal>SHA256</literal>.</para></listitem>
</varlistentry>
<varlistentry><term><option>-d</option></term><term><option>--db</option></term>
diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc
index 0c29002e6..0762a2b28 100644
--- a/ftparchive/apt-ftparchive.cc
+++ b/ftparchive/apt-ftparchive.cc
@@ -949,6 +949,8 @@ int main(int argc, const char *argv[])
CommandLine::Args Args[] = {
{'h',"help","help",0},
{0,"md5","APT::FTPArchive::MD5",0},
+ {0,"sha1","APT::FTPArchive::SHA1",0},
+ {0,"sha256","APT::FTPArchive::SHA256",0},
{'v',"version","version",0},
{'d',"db","APT::FTPArchive::DB",CommandLine::HasArg},
{'s',"source-override","APT::FTPArchive::SourceOverride",CommandLine::HasArg},
diff --git a/ftparchive/contents.cc b/ftparchive/contents.cc
index b761d9204..eadced626 100644
--- a/ftparchive/contents.cc
+++ b/ftparchive/contents.cc
@@ -36,12 +36,13 @@
#include "contents.h"
#include <apti18n.h>
+#include <apt-pkg/debfile.h>
#include <apt-pkg/extracttar.h>
#include <apt-pkg/error.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <malloc.h>
+#include <malloc.h>
/*}}}*/
// GenContents::~GenContents - Free allocated memory /*{{{*/
@@ -305,29 +306,7 @@ void GenContents::DoPrint(FILE *Out,GenContents::Node *Top, char *Buf)
bool ContentsExtract::Read(debDebFile &Deb)
{
Reset();
-
- // Get the archive member and positition the file
- const ARArchive::Member *Member = Deb.GotoMember("data.tar.gz");
- const char *Compressor = "gzip";
- if (Member == 0) {
- Member = Deb.GotoMember("data.tar.bz2");
- Compressor = "bzip2";
- }
- if (Member == 0) {
- Member = Deb.GotoMember("data.tar.lzma");
- Compressor = "lzma";
- }
- if (Member == 0) {
- _error->Error(_("Internal error, could not locate member %s"),
- "data.tar.{gz,bz2,lzma}");
- return false;
- }
-
- // Extract it.
- ExtractTar Tar(Deb.GetFile(),Member->Size,Compressor);
- if (Tar.Go(*this) == false)
- return false;
- return true;
+ return Deb.ExtractArchive(*this);
}
/*}}}*/
// ContentsExtract::DoItem - Extract an item /*{{{*/
diff --git a/ftparchive/multicompress.cc b/ftparchive/multicompress.cc
index bb4beedf9..f82879015 100644
--- a/ftparchive/multicompress.cc
+++ b/ftparchive/multicompress.cc
@@ -30,12 +30,6 @@
using namespace std;
-const MultiCompress::CompType MultiCompress::Compressors[] =
- {{".","",0,0,0,1},
- {"gzip",".gz","gzip","-9n","-d",2},
- {"bzip2",".bz2","bzip2","-9","-d",3},
- {"lzma",".lzma","lzma","-9","-d",4},
- {}};
// MultiCompress::MultiCompress - Constructor /*{{{*/
// ---------------------------------------------------------------------
@@ -48,7 +42,7 @@ MultiCompress::MultiCompress(string const &Output,string const &Compress,
Outputter = -1;
Input = 0;
UpdateMTime = 0;
-
+
/* Parse the compression string, a space separated lists of compresison
types */
string::const_iterator I = Compress.begin();
@@ -61,13 +55,14 @@ MultiCompress::MultiCompress(string const &Output,string const &Compress,
for (; I != Compress.end() && !isspace(*I); I++);
// Find the matching compressor
- const CompType *Comp = Compressors;
- for (; Comp->Name != 0; Comp++)
- if (stringcmp(Start,I,Comp->Name) == 0)
+ std::vector<APT::Configuration::Compressor> Compressors = APT::Configuration::getCompressors();
+ std::vector<APT::Configuration::Compressor>::const_iterator Comp = Compressors.begin();
+ for (; Comp != Compressors.end(); ++Comp)
+ if (stringcmp(Start,I,Comp->Name.c_str()) == 0)
break;
// Hmm.. unknown.
- if (Comp->Name == 0)
+ if (Comp == Compressors.end())
{
_error->Warning(_("Unknown compression algorithm '%s'"),string(Start,I).c_str());
continue;
@@ -77,7 +72,7 @@ MultiCompress::MultiCompress(string const &Output,string const &Compress,
Files *NewOut = new Files;
NewOut->Next = Outputs;
Outputs = NewOut;
- NewOut->CompressProg = Comp;
+ NewOut->CompressProg = *Comp;
NewOut->Output = Output+Comp->Extension;
struct stat St;
@@ -141,13 +136,14 @@ bool MultiCompress::GetStat(string const &Output,string const &Compress,struct s
for (; I != Compress.end() && !isspace(*I); I++);
// Find the matching compressor
- const CompType *Comp = Compressors;
- for (; Comp->Name != 0; Comp++)
- if (stringcmp(Start,I,Comp->Name) == 0)
+ std::vector<APT::Configuration::Compressor> Compressors = APT::Configuration::getCompressors();
+ std::vector<APT::Configuration::Compressor>::const_iterator Comp = Compressors.begin();
+ for (; Comp != Compressors.end(); ++Comp)
+ if (stringcmp(Start,I,Comp->Name.c_str()) == 0)
break;
// Hmm.. unknown.
- if (Comp->Name == 0)
+ if (Comp == Compressors.end())
continue;
string Name = Output+Comp->Extension;
@@ -268,13 +264,13 @@ bool MultiCompress::Finalize(unsigned long &OutSize)
/* This opens the compressor, either in compress mode or decompress
mode. FileFd is always the compressor input/output file,
OutFd is the created pipe, Input for Compress, Output for Decompress. */
-bool MultiCompress::OpenCompress(const CompType *Prog,pid_t &Pid,int const &FileFd,
- int &OutFd,bool const &Comp)
+bool MultiCompress::OpenCompress(APT::Configuration::Compressor const &Prog,
+ pid_t &Pid,int const &FileFd,int &OutFd,bool const &Comp)
{
Pid = -1;
// No compression
- if (Prog->Binary == 0)
+ if (Prog.Binary.empty() == true)
{
OutFd = dup(FileFd);
return true;
@@ -309,15 +305,17 @@ bool MultiCompress::OpenCompress(const CompType *Prog,pid_t &Pid,int const &File
SetCloseExec(STDOUT_FILENO,false);
SetCloseExec(STDIN_FILENO,false);
-
- const char *Args[3];
- Args[0] = Prog->Binary;
- if (Comp == true)
- Args[1] = Prog->CompArgs;
- else
- Args[1] = Prog->UnCompArgs;
- Args[2] = 0;
- execvp(Args[0],(char **)Args);
+
+ std::vector<char const*> Args;
+ Args.push_back(Prog.Binary.c_str());
+ std::vector<std::string> const * const addArgs =
+ (Comp == true) ? &(Prog.CompressArgs) : &(Prog.UncompressArgs);
+ for (std::vector<std::string>::const_iterator a = addArgs->begin();
+ a != addArgs->end(); ++a)
+ Args.push_back(a->c_str());
+ Args.push_back(NULL);
+
+ execvp(Args[0],(char **)&Args[0]);
cerr << _("Failed to exec compressor ") << Args[0] << endl;
_exit(100);
};
@@ -335,7 +333,7 @@ bool MultiCompress::OpenOld(int &Fd,pid_t &Proc)
{
Files *Best = Outputs;
for (Files *I = Outputs; I != 0; I = I->Next)
- if (Best->CompressProg->Cost > I->CompressProg->Cost)
+ if (Best->CompressProg.Cost > I->CompressProg.Cost)
Best = I;
// Open the file
@@ -414,7 +412,7 @@ bool MultiCompress::Child(int const &FD)
for (Files *I = Outputs; I != 0; I = I->Next)
{
if (I->CompressProc != -1)
- ExecWait(I->CompressProc,I->CompressProg->Binary,false);
+ ExecWait(I->CompressProc, I->CompressProg.Binary.c_str(), false);
}
if (_error->PendingError() == true)
diff --git a/ftparchive/multicompress.h b/ftparchive/multicompress.h
index 3ac3b8fb2..19dede174 100644
--- a/ftparchive/multicompress.h
+++ b/ftparchive/multicompress.h
@@ -20,28 +20,18 @@
#include <string>
#include <apt-pkg/fileutl.h>
+#include <apt-pkg/aptconfiguration.h>
#include <stdio.h>
#include <sys/types.h>
class MultiCompress
{
- // Enumeration of all supported compressors
- struct CompType
- {
- const char *Name;
- const char *Extension;
- const char *Binary;
- const char *CompArgs;
- const char *UnCompArgs;
- unsigned char Cost;
- };
-
// An output file
struct Files
{
string Output;
- const CompType *CompressProg;
- Files *Next;
+ APT::Configuration::Compressor CompressProg;
+ Files *Next;
FileFd TmpFile;
pid_t CompressProc;
time_t OldMTime;
@@ -51,10 +41,9 @@ class MultiCompress
Files *Outputs;
pid_t Outputter;
mode_t Permissions;
- static const CompType Compressors[];
- bool OpenCompress(const CompType *Prog,pid_t &Pid,int const &FileFd,
- int &OutFd,bool const &Comp);
+ bool OpenCompress(APT::Configuration::Compressor const &Prog,
+ pid_t &Pid,int const &FileFd, int &OutFd,bool const &Comp);
bool Child(int const &Fd);
bool Start();
bool Die();
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index 9cdca8d3e..9f12cbf3d 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -17,6 +17,7 @@
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
#include <apt-pkg/sha256.h>
@@ -59,6 +60,10 @@ FTWScanner::FTWScanner(string const &Arch): Arch(Arch)
{
ErrorPrinted = false;
NoLinkAct = !_config->FindB("APT::FTPArchive::DeLinkAct",true);
+
+ DoMD5 = _config->FindB("APT::FTPArchive::MD5",true);
+ DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true);
+ DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
}
/*}}}*/
// FTWScanner::Scanner - FTW Scanner /*{{{*/
@@ -308,9 +313,9 @@ PackagesWriter::PackagesWriter(string const &DB,string const &Overrides,string c
DeLinkLimit = 0;
// Process the command line options
- DoMD5 = _config->FindB("APT::FTPArchive::MD5",true);
- DoSHA1 = _config->FindB("APT::FTPArchive::SHA1",true);
- DoSHA256 = _config->FindB("APT::FTPArchive::SHA256",true);
+ DoMD5 = _config->FindB("APT::FTPArchive::Packages::MD5",DoMD5);
+ DoSHA1 = _config->FindB("APT::FTPArchive::Packages::SHA1",DoSHA1);
+ DoSHA256 = _config->FindB("APT::FTPArchive::Packages::SHA256",DoSHA256);
DoAlwaysStat = _config->FindB("APT::FTPArchive::AlwaysStat", false);
DoContents = _config->FindB("APT::FTPArchive::Contents",true);
NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false);
@@ -435,9 +440,12 @@ bool PackagesWriter::DoPackage(string FileName)
unsigned int End = 0;
SetTFRewriteData(Changes[End++], "Size", Size);
- SetTFRewriteData(Changes[End++], "MD5sum", Db.MD5Res.c_str());
- SetTFRewriteData(Changes[End++], "SHA1", Db.SHA1Res.c_str());
- SetTFRewriteData(Changes[End++], "SHA256", Db.SHA256Res.c_str());
+ if (DoMD5 == true)
+ SetTFRewriteData(Changes[End++], "MD5sum", Db.MD5Res.c_str());
+ if (DoSHA1 == true)
+ SetTFRewriteData(Changes[End++], "SHA1", Db.SHA1Res.c_str());
+ if (DoSHA256 == true)
+ SetTFRewriteData(Changes[End++], "SHA256", Db.SHA256Res.c_str());
SetTFRewriteData(Changes[End++], "Filename", NewFileName.c_str());
SetTFRewriteData(Changes[End++], "Priority", OverItem->Priority.c_str());
SetTFRewriteData(Changes[End++], "Status", 0);
@@ -559,6 +567,9 @@ SourcesWriter::SourcesWriter(string const &BOverrides,string const &SOverrides,
BufSize = 0;
// Process the command line options
+ DoMD5 = _config->FindB("APT::FTPArchive::Sources::MD5",DoMD5);
+ DoSHA1 = _config->FindB("APT::FTPArchive::Sources::SHA1",DoSHA1);
+ DoSHA256 = _config->FindB("APT::FTPArchive::Sources::SHA256",DoSHA256);
NoOverride = _config->FindB("APT::FTPArchive::NoOverrideMsg",false);
// Read the override file
@@ -608,13 +619,17 @@ bool SourcesWriter::DoPackage(string FileName)
// Hash the file
char *Start = Buffer;
char *BlkEnd = Buffer + St.st_size;
- MD5Summation MD5;
- MD5.Add((unsigned char *)Start,BlkEnd - Start);
+ MD5Summation MD5;
SHA1Summation SHA1;
SHA256Summation SHA256;
- SHA1.Add((unsigned char *)Start,BlkEnd - Start);
- SHA256.Add((unsigned char *)Start,BlkEnd - Start);
+
+ if (DoMD5 == true)
+ MD5.Add((unsigned char *)Start,BlkEnd - Start);
+ if (DoSHA1 == true)
+ SHA1.Add((unsigned char *)Start,BlkEnd - Start);
+ if (DoSHA256 == true)
+ SHA256.Add((unsigned char *)Start,BlkEnd - Start);
// Add an extra \n to the end, just in case
*BlkEnd++ = '\n';
@@ -708,19 +723,19 @@ bool SourcesWriter::DoPackage(string FileName)
// Add the dsc to the files hash list
string const strippedName = flNotDir(FileName);
std::ostringstream ostreamFiles;
- if (Tags.Exists("Files"))
+ if (DoMD5 == true && Tags.Exists("Files"))
ostreamFiles << "\n " << string(MD5.Result()) << " " << St.st_size << " "
<< strippedName << "\n " << Tags.FindS("Files");
string const Files = ostreamFiles.str();
std::ostringstream ostreamSha1;
- if (Tags.Exists("Checksums-Sha1"))
+ if (DoSHA1 == true && Tags.Exists("Checksums-Sha1"))
ostreamSha1 << "\n " << string(SHA1.Result()) << " " << St.st_size << " "
<< strippedName << "\n " << Tags.FindS("Checksums-Sha1");
string const ChecksumsSha1 = ostreamSha1.str();
std::ostringstream ostreamSha256;
- if (Tags.Exists("Checksums-Sha256"))
+ if (DoSHA256 == true && Tags.Exists("Checksums-Sha256"))
ostreamSha256 << "\n " << string(SHA256.Result()) << " " << St.st_size << " "
<< strippedName << "\n " << Tags.FindS("Checksums-Sha256");
string const ChecksumsSha256 = ostreamSha256.str();
@@ -774,9 +789,12 @@ bool SourcesWriter::DoPackage(string FileName)
unsigned int End = 0;
SetTFRewriteData(Changes[End++],"Source",Package.c_str(),"Package");
- SetTFRewriteData(Changes[End++],"Files",Files.c_str());
- SetTFRewriteData(Changes[End++],"Checksums-Sha1",ChecksumsSha1.c_str());
- SetTFRewriteData(Changes[End++],"Checksums-Sha256",ChecksumsSha256.c_str());
+ if (Files.empty() == false)
+ SetTFRewriteData(Changes[End++],"Files",Files.c_str());
+ if (ChecksumsSha1.empty() == false)
+ SetTFRewriteData(Changes[End++],"Checksums-Sha1",ChecksumsSha1.c_str());
+ if (ChecksumsSha256.empty() == false)
+ SetTFRewriteData(Changes[End++],"Checksums-Sha256",ChecksumsSha256.c_str());
if (Directory != "./")
SetTFRewriteData(Changes[End++],"Directory",Directory.c_str());
SetTFRewriteData(Changes[End++],"Priority",BestPrio.c_str());
@@ -913,10 +931,12 @@ ReleaseWriter::ReleaseWriter(string const &DB)
AddPattern("Packages.gz");
AddPattern("Packages.bz2");
AddPattern("Packages.lzma");
+ AddPattern("Packages.xz");
AddPattern("Sources");
AddPattern("Sources.gz");
AddPattern("Sources.bz2");
AddPattern("Sources.lzma");
+ AddPattern("Sources.xz");
AddPattern("Release");
AddPattern("Index");
AddPattern("md5sum.txt");
@@ -925,6 +945,9 @@ ReleaseWriter::ReleaseWriter(string const &DB)
Output = stdout;
time_t const now = time(NULL);
+
+ setlocale(LC_TIME, "C");
+
char datestr[128];
if (strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S UTC",
gmtime(&now)) == 0)
@@ -941,6 +964,8 @@ ReleaseWriter::ReleaseWriter(string const &DB)
validstr[0] = '\0';
}
+ setlocale(LC_TIME, "");
+
map<string,string> Fields;
Fields["Origin"] = "";
Fields["Label"] = "";
@@ -964,6 +989,10 @@ ReleaseWriter::ReleaseWriter(string const &DB)
fprintf(Output, "%s: %s\n", (*I).first.c_str(), Value.c_str());
}
+
+ DoMD5 = _config->FindB("APT::FTPArchive::Release::MD5",DoMD5);
+ DoSHA1 = _config->FindB("APT::FTPArchive::Release::SHA1",DoSHA1);
+ DoSHA256 = _config->FindB("APT::FTPArchive::Release::SHA256",DoSHA256);
}
/*}}}*/
// ReleaseWriter::DoPackage - Process a single package /*{{{*/
@@ -996,19 +1025,26 @@ bool ReleaseWriter::DoPackage(string FileName)
CheckSums[NewFileName].size = fd.Size();
- MD5Summation MD5;
- MD5.AddFD(fd.Fd(), fd.Size());
- CheckSums[NewFileName].MD5 = MD5.Result();
-
- fd.Seek(0);
- SHA1Summation SHA1;
- SHA1.AddFD(fd.Fd(), fd.Size());
- CheckSums[NewFileName].SHA1 = SHA1.Result();
-
- fd.Seek(0);
- SHA256Summation SHA256;
- SHA256.AddFD(fd.Fd(), fd.Size());
- CheckSums[NewFileName].SHA256 = SHA256.Result();
+ if (DoMD5 == true)
+ {
+ MD5Summation MD5;
+ MD5.AddFD(fd.Fd(), fd.Size());
+ CheckSums[NewFileName].MD5 = MD5.Result();
+ fd.Seek(0);
+ }
+ if (DoSHA1 == true)
+ {
+ SHA1Summation SHA1;
+ SHA1.AddFD(fd.Fd(), fd.Size());
+ CheckSums[NewFileName].SHA1 = SHA1.Result();
+ fd.Seek(0);
+ }
+ if (DoSHA256 == true)
+ {
+ SHA256Summation SHA256;
+ SHA256.AddFD(fd.Fd(), fd.Size());
+ CheckSums[NewFileName].SHA256 = SHA256.Result();
+ }
fd.Close();
@@ -1020,37 +1056,40 @@ bool ReleaseWriter::DoPackage(string FileName)
// ---------------------------------------------------------------------
void ReleaseWriter::Finish()
{
- fprintf(Output, "MD5Sum:\n");
- for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
- I != CheckSums.end();
- ++I)
+ if (DoMD5 == true)
{
- fprintf(Output, " %s %16ld %s\n",
- (*I).second.MD5.c_str(),
- (*I).second.size,
- (*I).first.c_str());
+ fprintf(Output, "MD5Sum:\n");
+ for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
+ I != CheckSums.end(); ++I)
+ {
+ fprintf(Output, " %s %16ld %s\n",
+ (*I).second.MD5.c_str(),
+ (*I).second.size,
+ (*I).first.c_str());
+ }
}
-
- fprintf(Output, "SHA1:\n");
- for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
- I != CheckSums.end();
- ++I)
+ if (DoSHA1 == true)
{
- fprintf(Output, " %s %16ld %s\n",
- (*I).second.SHA1.c_str(),
- (*I).second.size,
- (*I).first.c_str());
+ fprintf(Output, "SHA1:\n");
+ for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
+ I != CheckSums.end(); ++I)
+ {
+ fprintf(Output, " %s %16ld %s\n",
+ (*I).second.SHA1.c_str(),
+ (*I).second.size,
+ (*I).first.c_str());
+ }
}
-
- fprintf(Output, "SHA256:\n");
- for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
- I != CheckSums.end();
- ++I)
+ if (DoSHA256 == true)
{
- fprintf(Output, " %s %16ld %s\n",
- (*I).second.SHA256.c_str(),
- (*I).second.size,
- (*I).first.c_str());
+ fprintf(Output, "SHA256:\n");
+ for(map<string,struct CheckSum>::const_iterator I = CheckSums.begin();
+ I != CheckSums.end(); ++I)
+ {
+ fprintf(Output, " %s %16ld %s\n",
+ (*I).second.SHA256.c_str(),
+ (*I).second.size,
+ (*I).first.c_str());
+ }
}
}
-
diff --git a/ftparchive/writer.h b/ftparchive/writer.h
index 3796f79f6..ce0eab7af 100644
--- a/ftparchive/writer.h
+++ b/ftparchive/writer.h
@@ -60,6 +60,9 @@ class FTWScanner
}
public:
+ bool DoMD5;
+ bool DoSHA1;
+ bool DoSHA256;
unsigned long DeLinkLimit;
string InternalPrefix;
@@ -103,9 +106,6 @@ class PackagesWriter : public FTWScanner
public:
// Some flags
- bool DoMD5;
- bool DoSHA1;
- bool DoSHA256;
bool DoAlwaysStat;
bool NoOverride;
bool DoContents;
diff --git a/methods/makefile b/methods/makefile
index 4ee356cec..6ba51058e 100644
--- a/methods/makefile
+++ b/methods/makefile
@@ -94,8 +94,8 @@ SOURCE = bzip2.cc
include $(PROGRAM_H)
# SSH and lzma method symlink
-binary: $(BIN)/ssh $(BIN)/lzma
-veryclean: clean-$(BIN)/ssh clean-$(BIN)/lzma
+binary: $(BIN)/ssh $(BIN)/lzma $(BIN)/xz
+veryclean: clean-$(BIN)/ssh clean-$(BIN)/lzma clean-$(BIN)/xz
$(BIN)/ssh:
echo "Installing ssh method link"
@@ -108,3 +108,9 @@ $(BIN)/lzma:
ln -fs bzip2 $(BIN)/lzma
clean-$(BIN)/lzma:
-rm $(BIN)/lzma
+
+$(BIN)/xz:
+ echo "Installing xz method link"
+ ln -fs bzip2 $(BIN)/xz
+clean-$(BIN)/xz:
+ -rm $(BIN)/xz
diff --git a/test/integration/framework b/test/integration/framework
index 7e1d25e61..71e7e476c 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -328,10 +328,10 @@ createaptftparchiveconfig() {
echo -n '";
};
Default {
- Packages::Compress ". gzip bzip2 lzma";
- Sources::Compress ". gzip bzip2 lzma";
- Contents::Compress ". gzip bzip2 lzma";
- Translation::Compress ". gzip bzip2 lzma";
+ Packages::Compress ". gzip bzip2 lzma xz";
+ Sources::Compress ". gzip bzip2 lzma xz";
+ Contents::Compress ". gzip bzip2 lzma xz";
+ Translation::Compress ". gzip bzip2 lzma xz";
LongDescription "false";
};
TreeDefault {
@@ -438,6 +438,7 @@ buildaptarchivefromfiles() {
cat ${line} | gzip > ${line}.gz
cat ${line} | bzip2 > ${line}.bz2
cat ${line} | lzma > ${line}.lzma
+ cat ${line} | xz > ${line}.xz
msgdone "info"
done
generatereleasefiles
diff --git a/test/integration/test-bug-595691-empty-and-broken-archive-files b/test/integration/test-bug-595691-empty-and-broken-archive-files
index 2179ba03b..11dee0628 100755
--- a/test/integration/test-bug-595691-empty-and-broken-archive-files
+++ b/test/integration/test-bug-595691-empty-and-broken-archive-files
@@ -54,12 +54,14 @@ setupcompressor() {
gzip) COMPRESS="gz";;
bzip2) COMPRESS="bz2";;
lzma) COMPRESS="lzma";;
+ xz) COMPRESS="xz";;
esac
echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
Dir::Bin::uncompressed \"/does/not/exist\";
Dir::Bin::gzip \"/does/not/exist\";
Dir::Bin::bzip2 \"/does/not/exist\";
-Dir::Bin::lzma \"/does/not/exist\";" > rootdir/etc/apt/apt.conf.d/00compressor
+Dir::Bin::lzma \"/does/not/exist\";
+Dir::Bin::xz \"/does/not/exist\";" > rootdir/etc/apt/apt.conf.d/00compressor
if [ -e "/bin/${COMPRESSOR}" ]; then
echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor
elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
@@ -134,9 +136,9 @@ W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial
E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
}
-for COMPRESSOR in 'gzip' 'bzip2' 'lzma'; do testoverfile $COMPRESSOR; done
+for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverfile $COMPRESSOR; done
# do the same again with http instead of file
changetowebserver
-for COMPRESSOR in 'gzip' 'bzip2' 'lzma'; do testoverhttp $COMPRESSOR; done
+for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testoverhttp $COMPRESSOR; done