summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-02-03 14:22:32 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-02-03 14:22:32 +0100
commit3eb9e257855d83d0486d7a5fa7cc5e2edebb6aaa (patch)
tree4739355d87bcbf8f49fa634b692e48e4aee6746d /methods
parent7c748f4aa1bd47089672353fd1a401d1c5c94723 (diff)
parent875bcb3670c43bd4450e27934ba105611e534df0 (diff)
merge 'after squeeze release'-stuff
[ David Kalnischkies ] * apt-pkg/depcache.cc: - add SetCandidateRelease() to set a candidate version and the candidates of dependencies if needed to a specified release (Closes: #572709) * cmdline/apt-get.cc: - if --print-uris is used don't setup downloader as we don't need progress, lock nor the directories it would create otherwise - show dependencies of essential packages which are going to remove only if they cause the remove of this essential (Closes: #601961) - keep not installed garbage packages uninstalled instead of showing in the autoremove section and installing those (Closes: #604222) - change pkg/release behavior to use the new SetCandidateRelease so installing packages from experimental or backports is easier - really do not show packages in the extra section if they were requested on the commandline, e.g. with a modifier (Closes: #184730) * debian/control: - add Vcs-Browser now that loggerhead works again (Closes: #511168) - depend on debhelper 7 to raise compat level - depend on dpkg-dev (>= 1.15.8) to have c++ symbol mangling * apt-pkg/contrib/fileutl.cc: - add a RealFileExists method and check that your configuration files are real files to avoid endless loops if not (Closes: #604401) - ignore non-regular files in GetListOfFilesInDir (Closes: #594694) * apt-pkg/contrib/weakptr.h: - include stddefs.h to fix compile error (undefined NULL) with gcc-4.6 * methods/https.cc: - fix CURLOPT_SSL_VERIFYHOST by really passing 2 to it if enabled * deb/dpkgpm.cc: - fix popen/fclose mismatch reported by cppcheck. Thanks to Petter Reinholdtsen for report and patch! (Closes: #607803) * doc/apt.conf.5.xml: - fix multipl{y,e} spelling error reported by Jakub Wilk (Closes: #607636) * apt-inst/contrib/extracttar.cc: - let apt-utils work with encoded tar headers if uid/gid are large. Thanks to Nobuhiro Hayashi for the patch! (Closes: #330162) * apt-pkg/cacheiterator.h: - do not segfault if cache is not build (Closes: #254770) * doc/apt-get.8.xml: - remove duplicated mentioning of --install-recommends * doc/sources.list.5.xml: - remove obsolete references to non-us (Closes: #594495) * debian/rules: - use -- instead of deprecated -u for dh_gencontrol - remove shlibs.local creation and usage - show differences in the symbol files, but never fail * pre-build.sh: - remove as it is not needed for a working 'bzr bd' * debian/{apt,apt-utils}.symbols: - ship experimental unmangled c++ symbol files * methods/rred.cc: - operate optional on gzip compressed pdiffs * apt-pkg/acquire-item.cc: - don't uncompress downloaded pdiff files before feeding it to rred - try downloading clearsigned InRelease before trying Release.gpg - change the internal handling of Extensions in pkgAcqIndex - add a special uncompressed compression type to prefer those files - download and use i18n/Index to choose which Translations to download * cmdline/apt-key: - don't set trustdb-name as non-root so 'list' and 'finger' can be used without being root (Closes: #393005, #592107) * apt-pkg/deb/deblistparser.cc: - rewrite LoadReleaseInfo to cope with clearsigned Releasefiles * ftparchive/writer.cc: - add config option to search for more patterns in release command - include Index files by default in the Release file * methods/{gzip,bzip}.cc: - print a good error message if FileSize() is zero * apt-pkg/aptconfiguration.cc: - remove the inbuilt Translation files whitelist
Diffstat (limited to 'methods')
-rw-r--r--methods/bzip2.cc3
-rw-r--r--methods/gzip.cc3
-rw-r--r--methods/https.cc6
-rw-r--r--methods/makefile2
-rw-r--r--methods/rred.cc49
5 files changed, 45 insertions, 18 deletions
diff --git a/methods/bzip2.cc b/methods/bzip2.cc
index ccc3669a2..42932dded 100644
--- a/methods/bzip2.cc
+++ b/methods/bzip2.cc
@@ -56,9 +56,8 @@ bool Bzip2Method::Fetch(FetchItem *Itm)
// Open the source and destination files
FileFd From(Path,FileFd::ReadOnly);
- // FIXME add an error message saying that empty files can't be valid archives
if(From.FileSize() == 0)
- return false;
+ return _error->Error(_("Empty files can't be valid archives"));
int GzOut[2];
if (pipe(GzOut) < 0)
diff --git a/methods/gzip.cc b/methods/gzip.cc
index f1c76066e..fc4e1ecfd 100644
--- a/methods/gzip.cc
+++ b/methods/gzip.cc
@@ -48,9 +48,8 @@ bool GzipMethod::Fetch(FetchItem *Itm)
// Open the source and destination files
FileFd From(Path,FileFd::ReadOnlyGzip);
- // FIXME add an error message saying that empty files can't be valid archives
if(From.FileSize() == 0)
- return false;
+ return _error->Error(_("Empty files can't be valid archives"));
FileFd To(Itm->DestFile,FileFd::WriteAtomic);
To.EraseOnFailure();
diff --git a/methods/https.cc b/methods/https.cc
index aa6786aa8..fc649d6c2 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -143,13 +143,11 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, peer_verify);
// ... and hostname against cert CN or subjectAltName
- int default_verify = 2;
bool verify = _config->FindB("Acquire::https::Verify-Host",true);
knob = "Acquire::https::"+remotehost+"::Verify-Host";
verify = _config->FindB(knob.c_str(),verify);
- if (!verify)
- default_verify = 0;
- curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, verify);
+ int const default_verify = (verify == true) ? 2 : 0;
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, default_verify);
// Also enforce issuer of server certificate using its cert
string issuercert = _config->Find("Acquire::https::IssuerCert","");
diff --git a/methods/makefile b/methods/makefile
index d94a85340..4ee356cec 100644
--- a/methods/makefile
+++ b/methods/makefile
@@ -67,7 +67,7 @@ include $(PROGRAM_H)
# The rred method
PROGRAM=rred
-SLIBS = -lapt-pkg $(SOCKETLIBS) $(INTLLIBS)
+SLIBS = -lapt-pkg -lz $(SOCKETLIBS) $(INTLLIBS)
LIB_MAKES = apt-pkg/makefile
SOURCE = rred.cc
include $(PROGRAM_H)
diff --git a/methods/rred.cc b/methods/rred.cc
index d51c45c85..1a18a381c 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -12,6 +12,7 @@
#include <utime.h>
#include <stdio.h>
#include <errno.h>
+#include <zlib.h>
#include <apti18n.h>
/*}}}*/
/** \brief RredMethod - ed-style incremential patch method {{{
@@ -33,11 +34,14 @@ class RredMethod : public pkgAcqMethod {
// return values
enum State {ED_OK, ED_ORDERING, ED_PARSER, ED_FAILURE, MMAP_FAILED};
- State applyFile(FILE *ed_cmds, FILE *in_file, FILE *out_file,
+ State applyFile(gzFile &ed_cmds, FILE *in_file, FILE *out_file,
unsigned long &line, char *buffer, Hashes *hash) const;
void ignoreLineInFile(FILE *fin, char *buffer) const;
+ void ignoreLineInFile(gzFile &fin, char *buffer) const;
void copyLinesFromFileToFile(FILE *fin, FILE *fout, unsigned int lines,
Hashes *hash, char *buffer) const;
+ void copyLinesFromFileToFile(gzFile &fin, FILE *fout, unsigned int lines,
+ Hashes *hash, char *buffer) const;
State patchFile(FileFd &Patch, FileFd &From, FileFd &out_file, Hashes *hash) const;
State patchMMap(FileFd &Patch, FileFd &From, FileFd &out_file, Hashes *hash) const;
@@ -65,10 +69,10 @@ public:
* \param hash the created file for correctness
* \return the success State of the ed command executor
*/
-RredMethod::State RredMethod::applyFile(FILE *ed_cmds, FILE *in_file, FILE *out_file,
+RredMethod::State RredMethod::applyFile(gzFile &ed_cmds, FILE *in_file, FILE *out_file,
unsigned long &line, char *buffer, Hashes *hash) const {
// get the current command and parse it
- if (fgets(buffer, BUF_SIZE, ed_cmds) == NULL) {
+ if (gzgets(ed_cmds, buffer, BUF_SIZE) == NULL) {
if (Debug == true)
std::clog << "rred: encounter end of file - we can start patching now." << std::endl;
line = 0;
@@ -123,7 +127,7 @@ RredMethod::State RredMethod::applyFile(FILE *ed_cmds, FILE *in_file, FILE *out_
unsigned char mode = *idx;
// save the current position
- unsigned const long pos = ftell(ed_cmds);
+ unsigned const long pos = gztell(ed_cmds);
// if this is add or change then go to the next full stop
unsigned int data_length = 0;
@@ -157,7 +161,7 @@ RredMethod::State RredMethod::applyFile(FILE *ed_cmds, FILE *in_file, FILE *out_
// include data from ed script
if (mode == MODE_CHANGED || mode == MODE_ADDED) {
- fseek(ed_cmds, pos, SEEK_SET);
+ gzseek(ed_cmds, pos, SEEK_SET);
copyLinesFromFileToFile(ed_cmds, out_file, data_length, hash, buffer);
}
@@ -183,6 +187,18 @@ void RredMethod::copyLinesFromFileToFile(FILE *fin, FILE *fout, unsigned int lin
}
}
/*}}}*/
+void RredMethod::copyLinesFromFileToFile(gzFile &fin, FILE *fout, unsigned int lines,/*{{{*/
+ Hashes *hash, char *buffer) const {
+ while (0 < lines--) {
+ do {
+ gzgets(fin, buffer, BUF_SIZE);
+ size_t const written = fwrite(buffer, 1, strlen(buffer), fout);
+ hash->Add((unsigned char*)buffer, written);
+ } while (strlen(buffer) == (BUF_SIZE - 1) &&
+ buffer[BUF_SIZE - 2] != '\n');
+ }
+}
+ /*}}}*/
void RredMethod::ignoreLineInFile(FILE *fin, char *buffer) const { /*{{{*/
fgets(buffer, BUF_SIZE, fin);
while (strlen(buffer) == (BUF_SIZE - 1) &&
@@ -192,11 +208,20 @@ void RredMethod::ignoreLineInFile(FILE *fin, char *buffer) const { /*{{{*/
}
}
/*}}}*/
+void RredMethod::ignoreLineInFile(gzFile &fin, char *buffer) const { /*{{{*/
+ gzgets(fin, buffer, BUF_SIZE);
+ while (strlen(buffer) == (BUF_SIZE - 1) &&
+ buffer[BUF_SIZE - 2] != '\n') {
+ gzgets(fin, buffer, BUF_SIZE);
+ buffer[0] = ' ';
+ }
+}
+ /*}}}*/
RredMethod::State RredMethod::patchFile(FileFd &Patch, FileFd &From, /*{{{*/
FileFd &out_file, Hashes *hash) const {
char buffer[BUF_SIZE];
FILE* fFrom = fdopen(From.Fd(), "r");
- FILE* fPatch = fdopen(Patch.Fd(), "r");
+ gzFile fPatch = Patch.gzFd();
FILE* fTo = fdopen(out_file.Fd(), "w");
/* we do a tail recursion to read the commands in the right order */
@@ -228,6 +253,12 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/
FileFd &out_file, Hashes *hash) const {
#ifdef _POSIX_MAPPED_FILES
MMap ed_cmds(Patch, MMap::ReadOnly);
+ if (Patch.gzFd() != NULL) {
+ unsigned long mapSize = Patch.Size();
+ DynamicMMap dyn(0, mapSize, 0);
+ gzread(Patch.gzFd(), dyn.Data(), mapSize);
+ ed_cmds = dyn;
+ }
MMap in_file(From, MMap::ReadOnly);
if (ed_cmds.Size() == 0 || in_file.Size() == 0)
@@ -445,7 +476,7 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/
// Open the source and destination files (the d'tor of FileFd will do
// the cleanup/closing of the fds)
FileFd From(Path,FileFd::ReadOnly);
- FileFd Patch(Path+".ed",FileFd::ReadOnly);
+ FileFd Patch(Path+".ed",FileFd::ReadOnlyGzip);
FileFd To(Itm->DestFile,FileFd::WriteAtomic);
To.EraseOnFailure();
if (_error->PendingError() == true)
@@ -456,8 +487,8 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/
State const result = patchMMap(Patch, From, To, &Hash);
if (result == MMAP_FAILED) {
// retry with patchFile
- lseek(Patch.Fd(), 0, SEEK_SET);
- lseek(From.Fd(), 0, SEEK_SET);
+ Patch.Seek(0);
+ From.Seek(0);
To.Open(Itm->DestFile,FileFd::WriteAtomic);
if (_error->PendingError() == true)
return false;