summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorPeter Karlsson <peterk@debian.org>2007-10-08 11:44:54 +0100
committerPeter Karlsson <peterk@debian.org>2007-10-08 11:44:54 +0100
commit21231056c2f4fb82730c0ac7e7f90456668cae38 (patch)
tree1f9ca6a27065dce5014adea7095596ec6a8cb744 /methods
parent28b68bf4207be80d4549579f34262f1248a2e528 (diff)
parent24401c09f0a826ec0074f46dfe70efe3aaf79f25 (diff)
Merge upstream.
Diffstat (limited to 'methods')
-rw-r--r--methods/copy.cc5
-rw-r--r--methods/ftp.cc2
-rw-r--r--methods/gpgv.cc6
-rw-r--r--methods/https.cc53
-rw-r--r--methods/makefile13
5 files changed, 57 insertions, 22 deletions
diff --git a/methods/copy.cc b/methods/copy.cc
index d737e3c33..72896b4c0 100644
--- a/methods/copy.cc
+++ b/methods/copy.cc
@@ -12,6 +12,7 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/hashes.h>
#include <sys/stat.h>
#include <utime.h>
@@ -79,6 +80,10 @@ bool CopyMethod::Fetch(FetchItem *Itm)
return _error->Errno("utime",_("Failed to set modification time"));
}
+ Hashes Hash;
+ FileFd Fd(Res.Filename, FileFd::ReadOnly);
+ Hash.AddFD(Fd.Fd(), Fd.Size());
+ Res.TakeHashes(Hash);
URIDone(Res);
return true;
}
diff --git a/methods/ftp.cc b/methods/ftp.cc
index 0c2aa00a7..554a24cf5 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -1101,7 +1101,7 @@ int main(int argc,const char *argv[])
char S[300];
snprintf(S,sizeof(S),"http_proxy=%s",getenv("ftp_proxy"));
putenv(S);
- putenv("no_proxy=");
+ putenv((char *)"no_proxy=");
// Run the http method
string Path = flNotFile(argv[0]) + "http";
diff --git a/methods/gpgv.cc b/methods/gpgv.cc
index 227e08d63..2b1fa5169 100644
--- a/methods/gpgv.cc
+++ b/methods/gpgv.cc
@@ -121,9 +121,9 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
// Redirect the pipe to the status fd (3)
dup2(fd[1], 3);
- putenv("LANG=");
- putenv("LC_ALL=");
- putenv("LC_MESSAGES=");
+ putenv((char *)"LANG=");
+ putenv((char *)"LC_ALL=");
+ putenv((char *)"LC_MESSAGES=");
execvp(gpgvpath.c_str(), (char **)Args);
exit(111);
diff --git a/methods/https.cc b/methods/https.cc
index d48ac97fb..b2bbbddb1 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -107,6 +107,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
struct stat SBuf;
struct curl_slist *headers=NULL;
char curl_errorstr[CURL_ERROR_SIZE];
+ long curl_responsecode;
// TODO:
// - http::Timeout
@@ -114,6 +115,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
// - error checking/reporting
// - more debug options? (CURLOPT_DEBUGFUNCTION?)
+ curl_easy_reset(curl);
SetupProxy();
// callbacks
@@ -124,6 +126,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
+ curl_easy_setopt(curl, CURLOPT_FILETIME, true);
// FIXME: https: offer various options of verification
bool peer_verify = _config->FindB("Acquire::https::Verify-Peer", false);
@@ -158,10 +161,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
}
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
- // set time values
- curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
- curl_easy_setopt(curl, CURLOPT_TIMEVALUE, Itm->LastModified);
-
// speed limit
int dlLimit = _config->FindI("Acquire::http::Dl-Limit",0)*1024;
if (dlLimit > 0)
@@ -177,44 +176,71 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
// error handling
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errorstr);
- // In this case we send an if-range query with a range header
- if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
- curl_easy_setopt(curl, CURLOPT_RESUME_FROM, (long)SBuf.st_size);
+ // if we have the file send an if-range query with a range header
+ if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
+ {
+ char Buf[1000];
+ sprintf(Buf,"Range: bytes=%li-\r\nIf-Range: %s\r\n",
+ (long)SBuf.st_size - 1,
+ TimeRFC1123(SBuf.st_mtime).c_str());
+ headers = curl_slist_append(headers, Buf);
+ }
+ else if(Itm->LastModified > 0)
+ {
+ curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
+ curl_easy_setopt(curl, CURLOPT_TIMEVALUE, Itm->LastModified);
+ }
// go for it - if the file exists, append on it
File = new FileFd(Itm->DestFile, FileFd::WriteAny);
- File->Seek(File->Size());
+ if (File->Size() > 0)
+ File->Seek(File->Size() - 1);
// keep apt updated
Res.Filename = Itm->DestFile;
// get it!
CURLcode success = curl_easy_perform(curl);
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &curl_responsecode);
+ long curl_servdate;
+ curl_easy_getinfo(curl, CURLINFO_FILETIME, &curl_servdate);
// cleanup
- if(success != 0) {
+ if(success != 0)
+ {
+ unlink(File->Name().c_str());
_error->Error(curl_errorstr);
Fail();
return true;
}
+ File->Close();
- if (Res.Size == 0)
- Res.Size = File->Size();
+ // Timestamp
+ struct utimbuf UBuf;
+ if (curl_servdate != -1) {
+ UBuf.actime = curl_servdate;
+ UBuf.modtime = curl_servdate;
+ utime(File->Name().c_str(),&UBuf);
+ }
// check the downloaded result
struct stat Buf;
if (stat(File->Name().c_str(),&Buf) == 0)
{
- Res.Size = Buf.st_size;
Res.Filename = File->Name();
Res.LastModified = Buf.st_mtime;
Res.IMSHit = false;
- if (Itm->LastModified != 0 && Buf.st_mtime >= Itm->LastModified)
+ if (curl_responsecode == 304)
{
+ unlink(File->Name().c_str());
Res.IMSHit = true;
Res.LastModified = Itm->LastModified;
+ Res.Size = 0;
+ URIDone(Res);
+ return true;
}
+ Res.Size = Buf.st_size;
}
// take hashes
@@ -227,7 +253,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
URIDone(Res);
// cleanup
- File->Close();
Res.Size = 0;
delete File;
curl_slist_free_all(headers);
diff --git a/methods/makefile b/methods/makefile
index f178cbbea..e47539dbb 100644
--- a/methods/makefile
+++ b/methods/makefile
@@ -7,7 +7,7 @@ include ../buildlib/defaults.mak
BIN := $(BIN)/methods
# FIXME..
-LIB_APT_PKG_MAJOR = 4.4
+LIB_APT_PKG_MAJOR = 4.5
APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR)
# The file method
@@ -80,9 +80,9 @@ LIB_MAKES = apt-pkg/makefile
SOURCE = rsh.cc
include $(PROGRAM_H)
-# SSH and vzip2 method symlink
-binary: $(BIN)/ssh $(BIN)/bzip2
-veryclean: clean-$(BIN)/ssh clean-$(BIN)/bzip2
+# SSH and bzip2 method symlink
+binary: $(BIN)/ssh $(BIN)/bzip2 $(BIN)/lzma
+veryclean: clean-$(BIN)/ssh clean-$(BIN)/bzip2 clean-$(BIN)/lzma
$(BIN)/ssh:
echo "Installing ssh method link"
ln -fs rsh $(BIN)/ssh
@@ -92,5 +92,10 @@ clean-$(BIN)/ssh:
$(BIN)/bzip2:
echo "Installing bzip2 method link"
ln -fs gzip $(BIN)/bzip2
+$(BIN)/lzma:
+ echo "Installing lzma method link"
+ ln -fs gzip $(BIN)/lzma
clean-$(BIN)/bzip2:
-rm $(BIN)/bzip2
+clean-$(BIN)/lzma:
+ -rm $(BIN)/lzma