X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b2e465d6d32d2dc884f58b94acb7e35f671a87fe..1979e742ad5e2a0b6e547fbe3f4c4066b5a9bd2e:/apt-inst/deb/dpkgdb.cc?ds=sidebyside diff --git a/apt-inst/deb/dpkgdb.cc b/apt-inst/deb/dpkgdb.cc index 85fec1ccd..718e1ab98 100644 --- a/apt-inst/deb/dpkgdb.cc +++ b/apt-inst/deb/dpkgdb.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: dpkgdb.cc,v 1.2 2001/02/20 07:03:17 jgg Exp $ +// $Id: dpkgdb.cc,v 1.7.2.1 2004/01/16 18:58:50 mdz Exp $ /* ###################################################################### DPKGv1 Database Implemenation @@ -30,7 +30,11 @@ #include #include #include +#include +#include +#include /*}}}*/ +using namespace std; // EraseDir - Erase A Directory /*{{{*/ // --------------------------------------------------------------------- @@ -48,22 +52,22 @@ static bool EraseDir(const char *Dir) if (errno == ENOTDIR) { if (unlink(Dir) != 0) - return _error->Errno("unlink","Failed to remove %s",Dir); + return _error->Errno("unlink",_("Failed to remove %s"),Dir); return true; } // Should not happen if (errno != ENOTEMPTY) - return _error->Errno("rmdir","Failed to remove %s",Dir); + return _error->Errno("rmdir",_("Failed to remove %s"),Dir); // Purge it using rm - int Pid = ExecFork(); + pid_t Pid = ExecFork(); // Spawn the subprocess if (Pid == 0) { execlp(_config->Find("Dir::Bin::rm","/bin/rm").c_str(), - "rm","-rf","--",Dir,0); + "rm","-rf","--",Dir,(char *)NULL); _exit(100); } return ExecWait(Pid,_config->Find("dir::bin::rm","/bin/rm").c_str()); @@ -103,20 +107,20 @@ bool debDpkgDB::InitMetaTmp(string &Dir) { string Tmp = AdminDir + "tmp.ci/"; if (EraseDir(Tmp.c_str()) == false) - return _error->Error("Unable to create %s",Tmp.c_str()); + return _error->Error(_("Unable to create %s"),Tmp.c_str()); if (mkdir(Tmp.c_str(),0755) != 0) - return _error->Errno("mkdir","Unable to create %s",Tmp.c_str()); + return _error->Errno("mkdir",_("Unable to create %s"),Tmp.c_str()); // Verify it is on the same filesystem as the main info directory dev_t Dev; struct stat St; if (stat((AdminDir + "info").c_str(),&St) != 0) - return _error->Errno("stat","Failed to stat %sinfo",AdminDir.c_str()); + return _error->Errno("stat",_("Failed to stat %sinfo"),AdminDir.c_str()); Dev = St.st_dev; if (stat(Tmp.c_str(),&St) != 0) - return _error->Errno("stat","Failed to stat %s",Tmp.c_str()); + return _error->Errno("stat",_("Failed to stat %s"),Tmp.c_str()); if (Dev != St.st_dev) - return _error->Error("The info and temp directories need to be on the same filesystem"); + return _error->Error(_("The info and temp directories need to be on the same filesystem")); // Done Dir = Tmp; @@ -132,7 +136,7 @@ bool debDpkgDB::ReadyPkgCache(OpProgress &Progress) { if (Cache != 0) { - Progress.OverallProgress(1,1,1,"Reading Package Lists"); + Progress.OverallProgress(1,1,1,_("Reading package lists")); return true; } @@ -173,7 +177,7 @@ bool debDpkgDB::ReadFList(OpProgress &Progress) path components */ string Cwd = SafeGetCWD(); if (chdir((AdminDir + "info/").c_str()) != 0) - return _error->Errno("chdir","Failed to change to the admin dir %sinfo",AdminDir.c_str()); + return _error->Errno("chdir",_("Failed to change to the admin dir %sinfo"),AdminDir.c_str()); // Allocate a buffer. Anything larger than this buffer will be mmaped unsigned long BufSize = 32*1024; @@ -194,11 +198,11 @@ bool debDpkgDB::ReadFList(OpProgress &Progress) pkgFLCache::PkgIterator FlPkg = FList->GetPkg(I.Name(),0,true); if (FlPkg.end() == true) { - _error->Error("Internal Error getting a Package Name"); + _error->Error(_("Internal error getting a package name")); break; } - Progress.OverallProgress(Count,Total,1,"Reading File Listing"); + Progress.OverallProgress(Count,Total,1,_("Reading file listing")); // Open the list file snprintf(Name,sizeof(Name),"%s.list",I.Name()); @@ -209,9 +213,9 @@ bool debDpkgDB::ReadFList(OpProgress &Progress) struct stat Stat; if (Fd == -1 || fstat(Fd,&Stat) != 0) { - _error->Errno("open","Failed to open the list file '%sinfo/%s'. If you " + _error->Errno("open",_("Failed to open the list file '%sinfo/%s'. If you " "cannot restore this file then make it empty " - "and immediately re-install the same version of the package!", + "and immediately re-install the same version of the package!"), AdminDir.c_str(),Name); break; } @@ -222,7 +226,7 @@ bool debDpkgDB::ReadFList(OpProgress &Progress) { if (read(Fd,Buffer,Stat.st_size) != Stat.st_size) { - _error->Errno("read","Failed reading the list file %sinfo/%s", + _error->Errno("read",_("Failed reading the list file %sinfo/%s"), AdminDir.c_str(),Name); close(Fd); break; @@ -235,7 +239,7 @@ bool debDpkgDB::ReadFList(OpProgress &Progress) File = (char *)mmap(0,Stat.st_size,PROT_READ,MAP_PRIVATE,Fd,0); if (File == (char *)(-1)) { - _error->Errno("mmap","Failed reading the list file %sinfo/%s", + _error->Errno("mmap",_("Failed reading the list file %sinfo/%s"), AdminDir.c_str(),Name); close(Fd); break; @@ -259,7 +263,7 @@ bool debDpkgDB::ReadFList(OpProgress &Progress) FlPkg.Offset(),true,false); if (Node.end() == true) { - _error->Error("Internal Error getting a Node"); + _error->Error(_("Internal error getting a node")); break; } } @@ -302,7 +306,7 @@ bool debDpkgDB::ReadDiversions() FILE *Fd = fopen((AdminDir + "diversions").c_str(),"r"); if (Fd == 0) - return _error->Errno("fopen","Failed to open the diversions file %sdiversions",AdminDir.c_str()); + return _error->Errno("fopen",_("Failed to open the diversions file %sdiversions"),AdminDir.c_str()); FList->BeginDiverLoad(); while (1) @@ -317,24 +321,24 @@ bool debDpkgDB::ReadDiversions() if (fgets(To,sizeof(To),Fd) == 0 || fgets(Package,sizeof(Package),Fd) == 0) { - _error->Error("The diversion file is corrupted"); + _error->Error(_("The diversion file is corrupted")); break; } // Strip the \ns unsigned long Len = strlen(From); if (Len < 2 || From[Len-1] != '\n') - _error->Error("Invalid line in the diversion file: %s",From); + _error->Error(_("Invalid line in the diversion file: %s"),From); else From[Len-1] = 0; Len = strlen(To); if (Len < 2 || To[Len-1] != '\n') - _error->Error("Invalid line in the diversion file: %s",To); + _error->Error(_("Invalid line in the diversion file: %s"),To); else To[Len-1] = 0; Len = strlen(Package); if (Len < 2 || Package[Len-1] != '\n') - _error->Error("Invalid line in the diversion file: %s",Package); + _error->Error(_("Invalid line in the diversion file: %s"),Package); else Package[Len-1] = 0; @@ -348,14 +352,14 @@ bool debDpkgDB::ReadDiversions() pkgFLCache::PkgIterator FlPkg = FList->GetPkg(Package,0,true); if (FlPkg.end() == true) { - _error->Error("Internal Error getting a Package Name"); + _error->Error(_("Internal error getting a package name")); break; } // Install the diversion if (FList->AddDiversion(FlPkg,From,To) == false) { - _error->Error("Internal Error adding a diversion"); + _error->Error(_("Internal error adding a diversion")); break; } } @@ -376,10 +380,10 @@ bool debDpkgDB::ReadDiversions() bool debDpkgDB::ReadyFileList(OpProgress &Progress) { if (Cache == 0) - return _error->Error("The pkg cache must be initialize first"); + return _error->Error(_("The pkg cache must be initialized first")); if (FList != 0) { - Progress.OverallProgress(1,1,1,"Reading File List"); + Progress.OverallProgress(1,1,1,_("Reading file listing")); return true; } @@ -436,12 +440,12 @@ bool debDpkgDB::ReadConfFiles() const char *PkgStart; const char *PkgEnd; if (Section.Find("Package",PkgStart,PkgEnd) == false) - return _error->Error("Failed to find a Package: Header, offset %lu",Offset); + return _error->Error(_("Failed to find a Package: header, offset %lu"),Offset); // Snag a package record for it pkgFLCache::PkgIterator FlPkg = FList->GetPkg(PkgStart,PkgEnd,true); if (FlPkg.end() == true) - return _error->Error("Internal Error getting a Package Name"); + return _error->Error(_("Internal error getting a package name")); // Parse the conf file lines while (1) @@ -458,13 +462,13 @@ bool debDpkgDB::ReadConfFiles() const char *EndMd5 = StartMd5; for (; isspace(*EndMd5) == 0 && EndMd5 < Stop; EndMd5++); if (StartMd5 == EndMd5 || Start == End) - return _error->Error("Bad ConfFile section in the status file. Offset %lu",Offset); + return _error->Error(_("Bad ConfFile section in the status file. Offset %lu"),Offset); // Insert a new entry unsigned char MD5[16]; - if (Hex2Num(StartMd5,EndMd5,MD5,16) == false) - return _error->Error("Error parsing MD5. Offset %lu",Offset); - + if (Hex2Num(string(StartMd5,EndMd5-StartMd5),MD5,16) == false) + return _error->Error(_("Error parsing MD5. Offset %lu"),Offset); + if (FList->AddConfFile(Start,End,FlPkg,MD5) == false) return false; Start = EndMd5;