diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 9 | ||||
-rw-r--r-- | apt-pkg/cdrom.cc | 155 | ||||
-rw-r--r-- | apt-pkg/cdrom.h | 4 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 12 | ||||
-rw-r--r-- | apt-pkg/init.cc | 2 |
5 files changed, 87 insertions, 95 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 1185908f3..60003c023 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -757,6 +757,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Has { // remove the just applied patch available_patches.erase(available_patches.begin()); + unlink((FinalFile + ".ed").c_str()); // move into place if(Debug) @@ -887,6 +888,14 @@ void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,string M // otherwise lists cleanup will eat the file DestFile = FinalFile; + // ensure the ed's are gone regardless of list-cleanup + for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin(); + I != allPatches->end(); ++I) + { + std::string patch = FinalFile + ".ed." + (*I)->patch.file + ".gz"; + unlink(patch.c_str()); + } + // all set and done Complete = true; if(Debug) diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index a5668a50a..3ae1e8b1d 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -561,45 +561,65 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source) return true; } /*}}}*/ -bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ +bool pkgCdrom::MountAndIdentCDROM(Configuration &Database, std::string &CDROM, std::string &ident, pkgCdromStatus * const log)/*{{{*/ { - stringstream msg; - // Startup - string CDROM = _config->FindDir("Acquire::cdrom::mount"); + CDROM = _config->FindDir("Acquire::cdrom::mount"); if (CDROM[0] == '.') CDROM= SafeGetCWD() + '/' + CDROM; if (log != NULL) { - msg.str(""); - ioprintf(msg, _("Using CD-ROM mount point %s\nMounting CD-ROM\n"), - CDROM.c_str()); - log->Update(msg.str()); + string msg; + log->SetTotal(STEP_LAST); + strprintf(msg, _("Using CD-ROM mount point %s\n"), CDROM.c_str()); + log->Update(msg, STEP_PREPARE); + } + + // Unmount the CD and get the user to put in the one they want + if (_config->FindB("APT::CDROM::NoMount", false) == false) + { + if(log != NULL) + log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT); + UnmountCdrom(CDROM); + + if(log != NULL) + { + log->Update(_("Waiting for disc...\n"), STEP_WAIT); + if(!log->ChangeCdrom()) { + // user aborted + return false; + } + } + + // Mount the new CDROM + if(log != NULL) + log->Update(_("Mounting CD-ROM...\n"), STEP_MOUNT); + + if (MountCdrom(CDROM) == false) + return _error->Error("Failed to mount the cdrom."); } - if (MountCdrom(CDROM) == false) - return _error->Error("Failed to mount the cdrom."); // Hash the CD to get an ID if (log != NULL) - log->Update(_("Identifying.. ")); - + log->Update(_("Identifying.. "), STEP_IDENT); if (IdentCdrom(CDROM,ident) == false) { ident = ""; + if (log != NULL) + log->Update("\n"); return false; } if (log != NULL) { - msg.str(""); - ioprintf(msg, "[%s]\n",ident.c_str()); - log->Update(msg.str()); + string msg; + strprintf(msg, "[%s]\n", ident.c_str()); + log->Update(msg); } // Read the database - Configuration Database; string DFile = _config->FindFile("Dir::State::cdroms"); if (FileExists(DFile) == true) { @@ -607,12 +627,22 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ return _error->Error("Unable to read the cdrom database %s", DFile.c_str()); } + return true; +} + /*}}}*/ +bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ +{ + Configuration Database; + std::string CDROM; + if (MountAndIdentCDROM(Database, CDROM, ident, log) == false) + return false; + if (log != NULL) { - msg.str(""); - ioprintf(msg, _("Stored label: %s\n"), - Database.Find("CD::"+ident).c_str()); - log->Update(msg.str()); + string msg; + strprintf(msg, _("Stored label: %s\n"), + Database.Find("CD::"+ident).c_str()); + log->Update(msg); } // Unmount and finish @@ -628,70 +658,13 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log) /*{{{*/ /*}}}*/ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { - stringstream msg; - - // Startup - string CDROM = _config->FindDir("Acquire::cdrom::mount"); - if (CDROM[0] == '.') - CDROM= SafeGetCWD() + '/' + CDROM; - - if(log != NULL) - { - log->SetTotal(STEP_LAST); - msg.str(""); - ioprintf(msg, _("Using CD-ROM mount point %s\n"), CDROM.c_str()); - log->Update(msg.str(), STEP_PREPARE); - } - - // Read the database Configuration Database; - string DFile = _config->FindFile("Dir::State::cdroms"); - if (FileExists(DFile) == true) - { - if (ReadConfigFile(Database,DFile) == false) - return _error->Error("Unable to read the cdrom database %s", - DFile.c_str()); - } - - // Unmount the CD and get the user to put in the one they want - if (_config->FindB("APT::CDROM::NoMount",false) == false) - { - if(log != NULL) - log->Update(_("Unmounting CD-ROM\n"), STEP_UNMOUNT); - UnmountCdrom(CDROM); - - if(log != NULL) - { - log->Update(_("Waiting for disc...\n"), STEP_WAIT); - if(!log->ChangeCdrom()) { - // user aborted - return false; - } - } - - // Mount the new CDROM - if(log != NULL) - log->Update(_("Mounting CD-ROM...\n"), STEP_MOUNT); - - if (MountCdrom(CDROM) == false) - return _error->Error("Failed to mount the cdrom."); - } - - // Hash the CD to get an ID - if(log != NULL) - log->Update(_("Identifying.. "), STEP_IDENT); - string ID; - if (IdentCdrom(CDROM,ID) == false) - { - if (log != NULL) - log->Update("\n"); + std::string ID, CDROM; + if (MountAndIdentCDROM(Database, CDROM, ID, log) == false) return false; - } + if(log != NULL) - { - log->Update("["+ID+"]\n"); log->Update(_("Scanning disc for index files..\n"),STEP_SCAN); - } // Get the CD structure vector<string> List; @@ -740,12 +713,12 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (_config->FindB("APT::CDROM::DropTranslation", true) == true) DropTranslation(TransList); if(log != NULL) { - msg.str(""); - ioprintf(msg, _("Found %zu package indexes, %zu source indexes, " + string msg; + strprintf(msg, _("Found %zu package indexes, %zu source indexes, " "%zu translation indexes and %zu signatures\n"), List.size(), SourceList.size(), TransList.size(), SigList.size()); - log->Update(msg.str(), STEP_SCAN); + log->Update(msg, STEP_SCAN); } if (List.empty() == true && SourceList.empty() == true) @@ -778,9 +751,9 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if(log != NULL) { - msg.str(""); - ioprintf(msg, _("Found label '%s'\n"), Name.c_str()); - log->Update(msg.str()); + string msg; + strprintf(msg, _("Found label '%s'\n"), Name.c_str()); + log->Update(msg); } Database.Set("CD::" + ID + "::Label",Name); } @@ -824,9 +797,9 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ Database.Set("CD::" + ID,Name); if(log != NULL) { - msg.str(""); - ioprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str()); - log->Update(msg.str()); + string msg; + strprintf(msg, _("This disc is called: \n'%s'\n"), Name.c_str()); + log->Update(msg); log->Update(_("Copying package lists..."), STEP_COPY); } @@ -884,7 +857,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if(log != NULL) { - msg.str(""); + stringstream msg; msg << "deb cdrom:[" << Name << "]/" << string(*I,0,Space) << " " << string(*I,Space+1) << endl; log->Update(msg.str()); @@ -902,7 +875,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ } if(log != NULL) { - msg.str(""); + stringstream msg; msg << "deb-src cdrom:[" << Name << "]/" << string(*I,0,Space) << " " << string(*I,Space+1) << endl; log->Update(msg.str()); diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 7d19eb813..db637b96d 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -69,6 +69,10 @@ class pkgCdrom /*{{{*/ public: bool Ident(std::string &ident, pkgCdromStatus *log); bool Add(pkgCdromStatus *log); + + private: + bool MountAndIdentCDROM(Configuration &Database, std::string &CDROM, + std::string &ident, pkgCdromStatus * const log); }; /*}}}*/ diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 37155b688..71ac9c73f 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1594,11 +1594,17 @@ unsigned long long FileFd::Tell() unsigned long long FileFd::FileSize() { struct stat Buf; - if ((d == NULL || d->pipe == false) && fstat(iFd,&Buf) != 0) - return FileFdErrno("fstat","Unable to determine the file size"); + + bool ispipe = (d != NULL && d->pipe == true); + if (ispipe == false) + { + if (fstat(iFd,&Buf) != 0) + return FileFdErrno("fstat","Unable to determine the file size"); + ispipe = S_ISFIFO(Buf.st_mode); + } // for compressor pipes st_size is undefined and at 'best' zero - if ((d != NULL && d->pipe == true) || S_ISFIFO(Buf.st_mode)) + if (ispipe == true) { // we set it here, too, as we get the info here for free // in theory the Open-methods should take care of it already diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index a2e58fae2..5d21b3847 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -93,7 +93,7 @@ bool pkgInitConfig(Configuration &Cnf) // Read an alternate config file const char *Cfg = getenv("APT_CONFIG"); - if (Cfg != 0) + if (Cfg != 0 && strlen(Cfg) != 0) { if (RealFileExists(Cfg) == true) Res &= ReadConfigFile(Cnf,Cfg); |