- if(Prog)
- Prog->SubProgress(0, "Reading deb file");
-
- // get the control data out of the deb file vid dpkg -I
- // ... can I haz libdpkg?
- std::string dpkg = _config->Find("Dir::Bin::dpkg","dpkg");
- const char *Args[5] = {dpkg.c_str(),
- "-I",
- DebFile.c_str(),
- "control",
- NULL};
- FileFd PipeFd;
- pid_t Child;
- if(Popen(Args, PipeFd, Child, FileFd::ReadOnly) == false)
- return _error->Error("Popen failed");
- // FIXME: static buffer
- char buf[8*1024];
- unsigned long long n = 0;
- if(PipeFd.Read(buf, sizeof(buf)-1, &n) == false)
- return _error->Errno("read", "Failed to read dpkg pipe");
- ExecWait(Child, "Popen");
-
- // now write the control data to a tempfile
- SPtr<FileFd> DebControl = GetTempFile("deb-file-" + DebFile);
- if(DebControl == NULL)
- return false;
- DebControl->Write(buf, n);
- // append size of the file
- FileFd Fd(DebFile, FileFd::ReadOnly);
- string Size;
- strprintf(Size, "Size: %llu\n", Fd.Size());
- DebControl->Write(Size.c_str(), Size.size());
- // and rewind for the listparser
- DebControl->Seek(0);
-
- // and give it to the list parser
- debDebFileParser Parser(DebControl, DebFile);
- if(Gen.SelectFile(DebFile, "local", *this) == false)
- return _error->Error("Problem with SelectFile %s", DebFile.c_str());
-
- pkgCache::PkgFileIterator File = Gen.GetCurFile();
- File->Size = DebControl->Size();
- File->mtime = DebControl->ModificationTime();
-
- if (Gen.MergeList(Parser) == false)
- return _error->Error("Problem with MergeLister for %s", DebFile.c_str());
-
- return true;