- if(Prog)
- Prog->SubProgress(0, "Reading deb file");
-
- // get the control data out of the deb file vid dpkg -I
- // ... can I haz libdpkg?
- Configuration::Item const *Opts = _config->Tree("DPkg::Options");
- std::string dpkg = _config->Find("Dir::Bin::dpkg","dpkg");
- std::vector<const char *> Args;
- Args.push_back(dpkg.c_str());
- if (Opts != 0)
- {
- Opts = Opts->Child;
- for (; Opts != 0; Opts = Opts->Next)
- {
- if (Opts->Value.empty() == true)
- continue;
- Args.push_back(Opts->Value.c_str());
- }
- }
- Args.push_back("-I");
- Args.push_back(DebFile.c_str());
- Args.push_back("control");
- Args.push_back(NULL);
- FileFd PipeFd;
- pid_t Child;
- if(Popen((const char**)&Args[0], 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-" + flNotDir(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;