// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: dpkgdb.cc,v 1.5 2002/03/26 07:38:58 jgg Exp $
+// $Id: dpkgdb.cc,v 1.7.2.1 2004/01/16 18:58:50 mdz Exp $
/* ######################################################################
DPKGv1 Database Implemenation
#include <unistd.h>
#include <ctype.h>
#include <iostream>
+#include <apti18n.h>
/*}}}*/
+using namespace std;
// EraseDir - Erase A Directory /*{{{*/
// ---------------------------------------------------------------------
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());
{
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;
{
if (Cache != 0)
{
- Progress.OverallProgress(1,1,1,"Reading Package Lists");
+ Progress.OverallProgress(1,1,1,_("Reading package lists"));
return true;
}
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;
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());
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;
}
{
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;
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;
FlPkg.Offset(),true,false);
if (Node.end() == true)
{
- _error->Error("Internal Error getting a Node");
+ _error->Error(_("Internal error getting a node"));
break;
}
}
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)
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;
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;
}
}
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;
}
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)
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(string(StartMd5,EndMd5-StartMd5),MD5,16) == false)
- return _error->Error("Error parsing MD5. Offset %lu",Offset);
+ return _error->Error(_("Error parsing MD5. Offset %lu"),Offset);
if (FList->AddConfFile(Start,End,FlPkg,MD5) == false)
return false;