summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2010-09-10 20:44:15 +0200
committerMichael Vogt <mvo@debian.org>2010-09-10 20:44:15 +0200
commitab588494d571f7bd30a0f525864241c760ab74fa (patch)
treef4d277eb91080873d9737916d829e71c90cb6598
parent2493f4b5dfa4b4d7fcaa944e9fd4bd2573ae3ec1 (diff)
parent4dc7b4a76ee7344c2c7743ab8dd070b85bf6935a (diff)
merged from lp:~mvo/apt/mvo
-rw-r--r--apt-pkg/contrib/cdromutl.cc24
-rw-r--r--debian/changelog5
2 files changed, 26 insertions, 3 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 6dce82fe1..68b980407 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -156,6 +156,19 @@ bool MountCdrom(string Path, string DeviceName)
bool IdentCdrom(string CD,string &Res,unsigned int Version)
{
MD5Summation Hash;
+ bool writable_media = false;
+
+ // if we are on a writable medium (like a usb-stick) that is just
+ // used like a cdrom don't use "." as it will constantly change,
+ // use .disk instead
+ if (access(CD.c_str(), W_OK) == 0 && DirectoryExists(CD+string("/.disk")))
+ {
+ writable_media = true;
+ CD = CD.append("/.disk");
+ if (_config->FindB("Debug::aptcdrom",false) == true)
+ std::clog << "Found writable cdrom, using alternative path: " << CD
+ << std::endl;
+ }
string StartDir = SafeGetCWD();
if (chdir(CD.c_str()) != 0)
@@ -202,10 +215,15 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
struct statvfs Buf;
if (statvfs(CD.c_str(),&Buf) != 0)
return _error->Errno("statfs",_("Failed to stat the cdrom"));
-
+
// We use a kilobyte block size to advoid overflow
- sprintf(S,"%lu %lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)),
- (long)(Buf.f_bfree*(Buf.f_bsize/1024)));
+ if (writable_media)
+ {
+ sprintf(S,"%lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)));
+ } else {
+ sprintf(S,"%lu %lu",(long)(Buf.f_blocks*(Buf.f_bsize/1024)),
+ (long)(Buf.f_bfree*(Buf.f_bsize/1024)));
+ }
Hash.Add(S);
sprintf(S,"-%u",Version);
}
diff --git a/debian/changelog b/debian/changelog
index 6ea08c042..2204b0082 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,11 @@ apt (0.8.4) UNRELEASED; urgency=low
* ftparchive/writer.cc:
- write out {Files,Checksum-Sha1,Checksum-Sha256} only if
available LP: #633967. Thanks to Colin Watson
+ * apt-pkg/contrib/cdromutl.cc:
+ - if apt-cdrom is used on writable media (like usb-sticks), do
+ not use the root directory to identify the medium (as all
+ changes there change the ident id). Use the .disk directory
+ instead
[ David Kalnischkies ]
* ftparchive/writer.cc: