74
76
if (Flag == FTW_DNR)
77
c1out << "W: Unable to read directory " << File << endl;
79
ioprintf(c1out, _("W: Unable to read directory %s\n"), File);
79
81
if (Flag == FTW_NS)
82
c1out << "W: Unable to stat " << File << endl;
84
ioprintf(c1out, _("W: Unable to stat %s\n"), File);
87
// See if it is a .deb
92
for (; Owner->Ext[CurExt] != 0; CurExt++)
93
if (strcmp(File+strlen(File)-strlen(Owner->Ext[CurExt]),
94
Owner->Ext[CurExt]) == 0)
96
if (Owner->Ext[CurExt] == 0)
89
const char *LastComponent = strrchr(File, '/');
90
if (LastComponent == NULL)
95
vector<string>::iterator I;
96
for(I = Owner->Patterns.begin(); I != Owner->Patterns.end(); ++I)
98
if (fnmatch((*I).c_str(), LastComponent, 0) == 0)
101
if (I == Owner->Patterns.end())
99
104
/* Process it. If the file is a link then resolve it into an absolute
174
179
if (InternalPrefix.empty() == true)
176
181
if (realpath(Dir.c_str(),RealPath) == 0)
177
return _error->Errno("realpath","Failed to resolve %s",Dir.c_str());
182
return _error->Errno("realpath",_("Failed to resolve %s"),Dir.c_str());
178
183
InternalPrefix = RealPath;
182
187
FILE *List = fopen(File.c_str(),"r");
184
return _error->Errno("fopen","Failed to open %s",File.c_str());
189
return _error->Errno("fopen",_("Failed to open %s"),File.c_str());
186
191
/* We are a tad tricky here.. We prefix the buffer with the directory
187
192
name, that way if we need a full path with just use line.. Sneaky and
241
c1out << " DeLink " << (OriginalPath + InternalPrefix.length())
242
<< " [" << SizeToStr(St.st_size) << "B]" << endl << flush;
246
ioprintf(c1out, _(" DeLink %s [%s]\n"), (OriginalPath + InternalPrefix.length()),
247
SizeToStr(St.st_size).c_str());
244
250
if (NoLinkAct == false)
246
252
char OldLink[400];
247
253
if (readlink(OriginalPath,OldLink,sizeof(OldLink)) == -1)
248
_error->Errno("readlink","Failed to readlink %s",OriginalPath);
254
_error->Errno("readlink",_("Failed to readlink %s"),OriginalPath);
251
257
if (unlink(OriginalPath) != 0)
252
_error->Errno("unlink","Failed to unlink %s",OriginalPath);
258
_error->Errno("unlink",_("Failed to unlink %s"),OriginalPath);
255
261
if (link(FileName.c_str(),OriginalPath) != 0)
257
263
// Panic! Restore the symlink
258
264
symlink(OldLink,OriginalPath);
259
return _error->Errno("link","*** Failed to link %s to %s",
265
return _error->Errno("link",_("*** Failed to link %s to %s"),
260
266
FileName.c_str(),
278
// FTWScanner::SetExts - Set extensions to support /*{{{*/
279
// ---------------------------------------------------------------------
281
bool FTWScanner::SetExts(string Vals)
284
TmpExt = new char[Vals.length()+1];
285
strcpy(TmpExt,Vals.c_str());
286
return TokSplitString(' ',TmpExt,(char **)Ext,sizeof(Ext)/sizeof(Ext[0]));
290
285
// PackagesWriter::PackagesWriter - Constructor /*{{{*/
291
286
// ---------------------------------------------------------------------
318
313
_error->DumpErrors();
316
// FTWScanner::SetExts - Set extensions to support /*{{{*/
317
// ---------------------------------------------------------------------
319
bool FTWScanner::SetExts(string Vals)
322
string::size_type Start = 0;
323
while (Start <= Vals.length()-1)
325
string::size_type Space = Vals.find(' ',Start);
326
string::size_type Length;
327
if (Space == string::npos)
329
Length = Vals.length()-Start;
333
Length = Space-Start;
335
AddPattern(string("*") + Vals.substr(Start, Length));
321
343
// PackagesWriter::DoPackage - Process a single package /*{{{*/
322
344
// ---------------------------------------------------------------------
641
661
unsigned int End = 0;
642
662
SetTFRewriteData(Changes[End++],"Source",Package.c_str(),"Package");
643
663
SetTFRewriteData(Changes[End++],"Files",Files);
644
SetTFRewriteData(Changes[End++],"Directory",Directory.c_str());
664
if (Directory != "./")
665
SetTFRewriteData(Changes[End++],"Directory",Directory.c_str());
645
666
SetTFRewriteData(Changes[End++],"Priority",BestPrio.c_str());
646
667
SetTFRewriteData(Changes[End++],"Status",0);
801
// ReleaseWriter::ReleaseWriter - Constructor /*{{{*/
802
// ---------------------------------------------------------------------
804
ReleaseWriter::ReleaseWriter(string DB)
806
AddPattern("Packages");
807
AddPattern("Packages.gz");
808
AddPattern("Packages.bz2");
809
AddPattern("Sources");
810
AddPattern("Sources.gz");
811
AddPattern("Sources.bz2");
812
AddPattern("Release");
813
AddPattern("md5sum.txt");
816
time_t now = time(NULL);
818
if (strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S UTC",
824
map<string,string> Fields;
825
Fields["Origin"] = "";
826
Fields["Label"] = "";
827
Fields["Suite"] = "";
828
Fields["Version"] = "";
829
Fields["Codename"] = "";
830
Fields["Date"] = datestr;
831
Fields["Architectures"] = "";
832
Fields["Components"] = "";
833
Fields["Description"] = "";
835
for(map<string,string>::const_iterator I = Fields.begin();
839
string Config = string("APT::FTPArchive::Release::") + (*I).first;
840
string Value = _config->Find(Config, (*I).second.c_str());
844
fprintf(Output, "%s: %s\n", (*I).first.c_str(), Value.c_str());
848
// ReleaseWriter::DoPackage - Process a single package /*{{{*/
849
// ---------------------------------------------------------------------
850
bool ReleaseWriter::DoPackage(string FileName)
852
// Strip the DirStrip prefix from the FileName and add the PathPrefix
854
if (DirStrip.empty() == false &&
855
FileName.length() > DirStrip.length() &&
856
stringcmp(FileName.begin(),FileName.begin() + DirStrip.length(),
857
DirStrip.begin(),DirStrip.end()) == 0)
859
NewFileName = string(FileName.begin() + DirStrip.length(),FileName.end());
860
while (NewFileName[0] == '/')
861
NewFileName = string(NewFileName.begin() + 1,NewFileName.end());
864
NewFileName = FileName;
866
if (PathPrefix.empty() == false)
867
NewFileName = flCombine(PathPrefix,NewFileName);
869
FileFd fd(FileName, FileFd::ReadOnly);
876
CheckSums[NewFileName].size = fd.Size();
879
MD5.AddFD(fd.Fd(), fd.Size());
880
CheckSums[NewFileName].MD5 = MD5.Result();
884
SHA1.AddFD(fd.Fd(), fd.Size());
885
CheckSums[NewFileName].SHA1 = SHA1.Result();
893
// ReleaseWriter::Finish - Output the checksums /*{{{*/
894
// ---------------------------------------------------------------------
895
void ReleaseWriter::Finish()
897
fprintf(Output, "MD5Sum:\n");
898
for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
899
I != CheckSums.end();
902
fprintf(Output, " %s %16ld %s\n",
903
(*I).second.MD5.c_str(),
908
fprintf(Output, "SHA1:\n");
909
for(map<string,struct CheckSum>::iterator I = CheckSums.begin();
910
I != CheckSums.end();
913
fprintf(Output, " %s %16ld %s\n",
914
(*I).second.SHA1.c_str(),