diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2012-03-22 13:09:22 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2012-03-22 13:09:22 +0100 |
commit | 9c257550854273ff6defb1816cb210d51f64db03 (patch) | |
tree | 5d6e76ba02f8b785e54a08bb13574ec2e31422bf | |
parent | 2e30ddbe95ff8ecfcf7d15a8b3c69ede6cda027a (diff) | |
download | apt-9c257550854273ff6defb1816cb210d51f64db03.tar.gz |
* apt-inst/database.{cc,h}, apt-inst/deb/dpkgdb.{cc,h}:
- drop instead of fix as it is only needed if you want to reimplement dpkg
and comes straight from the beginning of last decade (Closes: #663372)
* apt-inst/deb/debfile.cc:
- {Extract,Merge}Control() is another instance of "lets reimplement dpkg"
so shot of this code before someone ends up using this…
-rw-r--r-- | apt-inst/database.cc | 35 | ||||
-rw-r--r-- | apt-inst/database.h | 60 | ||||
-rw-r--r-- | apt-inst/deb/debfile.cc | 63 | ||||
-rw-r--r-- | apt-inst/deb/debfile.h | 10 | ||||
-rw-r--r-- | apt-inst/deb/dpkgdb.cc | 493 | ||||
-rw-r--r-- | apt-inst/deb/dpkgdb.h | 55 | ||||
-rw-r--r-- | apt-inst/makefile | 7 | ||||
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | debian/libapt-inst1.4.symbols | 28 | ||||
-rw-r--r-- | test/interactive-helper/makefile | 12 | ||||
-rw-r--r-- | test/interactive-helper/testextract.cc | 104 |
11 files changed, 15 insertions, 860 deletions
diff --git a/apt-inst/database.cc b/apt-inst/database.cc deleted file mode 100644 index da761349..00000000 --- a/apt-inst/database.cc +++ /dev/null @@ -1,35 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -// $Id: database.cc,v 1.2 2001/02/20 07:03:16 jgg Exp $ -/* ###################################################################### - - Data Base Abstraction - - ##################################################################### */ - /*}}}*/ -// Include Files /*{{{*/ -#include<config.h> - -#include <apt-pkg/database.h> -#include <apt-pkg/filelist.h> -#include <apt-pkg/pkgcachegen.h> - /*}}}*/ - -// DataBase::GetMetaTmp - Get the temp dir /*{{{*/ -// --------------------------------------------------------------------- -/* This re-initializes the meta temporary directory if it hasn't yet - been inited for this cycle. The flag is the emptyness of MetaDir */ -bool pkgDataBase::GetMetaTmp(std::string &Dir) -{ - if (MetaDir.empty() == true) - if (InitMetaTmp(MetaDir) == false) - return false; - Dir = MetaDir; - return true; -} - /*}}}*/ -pkgDataBase::~pkgDataBase() -{ - delete Cache; - delete FList; -} diff --git a/apt-inst/database.h b/apt-inst/database.h deleted file mode 100644 index 64e149f9..00000000 --- a/apt-inst/database.h +++ /dev/null @@ -1,60 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -// $Id: database.h,v 1.2 2001/02/20 07:03:16 jgg Exp $ -/* ###################################################################### - - Data Base Abstraction - - This class provides a simple interface to an abstract notion of a - database directory for storing state information about the system. - - The 'Meta' information for a package is the control information and - setup scripts stored inside the archive. GetMetaTmp returns the name of - a directory that is used to store named files containing the control - information. - - The File Listing is the database of installed files. It is loaded - into the memory/persistent cache structure by the ReadFileList method. - - ##################################################################### */ - /*}}}*/ -#ifndef PKGLIB_DATABASE_H -#define PKGLIB_DATABASE_H - -#include <apt-pkg/pkgcachegen.h> - -#include <string> - -#ifndef APT_8_CLEANER_HEADERS -#include <apt-pkg/filelist.h> -#endif - -class pkgFLCache; -class OpProgress; - -class pkgDataBase -{ - protected: - - pkgCacheGenerator *Cache; - pkgFLCache *FList; - std::string MetaDir; - virtual bool InitMetaTmp(std::string &Dir) = 0; - - public: - - // Some manipulators for the cache and generator - inline pkgCache &GetCache() {return Cache->GetCache();}; - inline pkgFLCache &GetFLCache() {return *FList;}; - inline pkgCacheGenerator &GetGenerator() {return *Cache;}; - - bool GetMetaTmp(std::string &Dir); - virtual bool ReadyFileList(OpProgress &Progress) = 0; - virtual bool ReadyPkgCache(OpProgress &Progress) = 0; - virtual bool LoadChanges() = 0; - - pkgDataBase() : Cache(0), FList(0) {}; - virtual ~pkgDataBase(); -}; - -#endif diff --git a/apt-inst/deb/debfile.cc b/apt-inst/deb/debfile.cc index aeab82e8..ab403791 100644 --- a/apt-inst/deb/debfile.cc +++ b/apt-inst/deb/debfile.cc @@ -18,7 +18,6 @@ // Include Files /*{{{*/ #include<config.h> -#include <apt-pkg/database.h> #include <apt-pkg/debfile.h> #include <apt-pkg/extracttar.h> #include <apt-pkg/error.h> @@ -90,42 +89,6 @@ const ARArchive::Member *debDebFile::GotoMember(const char *Name) return Member; } /*}}}*/ -// DebFile::ExtractControl - Extract Control information /*{{{*/ -// --------------------------------------------------------------------- -/* Extract the control information into the Database's temporary - directory. */ -bool debDebFile::ExtractControl(pkgDataBase &DB) -{ - // Get the archive member and positition the file - const ARArchive::Member *Member = GotoMember("control.tar.gz"); - if (Member == 0) - return false; - - // Prepare Tar - ControlExtract Extract; - ExtractTar Tar(File,Member->Size,"gzip"); - if (_error->PendingError() == true) - return false; - - // Get into the temporary directory - std::string Cwd = SafeGetCWD(); - std::string Tmp; - if (DB.GetMetaTmp(Tmp) == false) - return false; - if (chdir(Tmp.c_str()) != 0) - return _error->Errno("chdir",_("Couldn't change to %s"),Tmp.c_str()); - - // Do extraction - if (Tar.Go(Extract) == false) - return false; - - // Switch out of the tmp directory. - if (chdir(Cwd.c_str()) != 0) - return _error->Errno("chdir",_("Unable to change to %s"),Cwd.c_str()); - - return true; -} - /*}}}*/ // DebFile::ExtractArchive - Extract the archive data itself /*{{{*/ // --------------------------------------------------------------------- /* Simple wrapper around tar.. */ @@ -167,32 +130,6 @@ bool debDebFile::ExtractArchive(pkgDirStream &Stream) return Tar.Go(Stream); } /*}}}*/ -// DebFile::MergeControl - Merge the control information /*{{{*/ -// --------------------------------------------------------------------- -/* This reads the extracted control file into the cache and returns the - version that was parsed. All this really does is select the correct - parser and correct file to parse. */ -pkgCache::VerIterator debDebFile::MergeControl(pkgDataBase &DB) -{ - // Open the control file - std::string Tmp; - if (DB.GetMetaTmp(Tmp) == false) - return pkgCache::VerIterator(DB.GetCache()); - FileFd Fd(Tmp + "control",FileFd::ReadOnly); - if (_error->PendingError() == true) - return pkgCache::VerIterator(DB.GetCache()); - - // Parse it - debListParser Parse(&Fd); - pkgCache::VerIterator Ver(DB.GetCache()); - if (DB.GetGenerator().MergeList(Parse,&Ver) == false) - return pkgCache::VerIterator(DB.GetCache()); - - if (Ver.end() == true) - _error->Error(_("Failed to locate a valid control file")); - return Ver; -} - /*}}}*/ // DebFile::ControlExtract::DoItem - Control Tar Extraction /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-inst/deb/debfile.h b/apt-inst/deb/debfile.h index 5e1ea1d2..d94b7444 100644 --- a/apt-inst/deb/debfile.h +++ b/apt-inst/deb/debfile.h @@ -29,12 +29,7 @@ #include <apt-pkg/tagfile.h> #include <apt-pkg/pkgcache.h> -#ifndef APT_8_CLEANER_HEADERS -#include <apt-pkg/database.h> -#endif - class FileFd; -class pkgDataBase; class debDebFile { @@ -46,13 +41,10 @@ class debDebFile bool CheckMember(const char *Name); public: - class ControlExtract; class MemControlExtract; - - bool ExtractControl(pkgDataBase &DB); + bool ExtractArchive(pkgDirStream &Stream); - pkgCache::VerIterator MergeControl(pkgDataBase &DB); const ARArchive::Member *GotoMember(const char *Name); inline FileFd &GetFile() {return File;}; diff --git a/apt-inst/deb/dpkgdb.cc b/apt-inst/deb/dpkgdb.cc deleted file mode 100644 index 71a0c217..00000000 --- a/apt-inst/deb/dpkgdb.cc +++ /dev/null @@ -1,493 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -// $Id: dpkgdb.cc,v 1.7.2.1 2004/01/16 18:58:50 mdz Exp $ -/* ###################################################################### - - DPKGv1 Database Implemenation - - This class provides parsers and other implementations for the DPKGv1 - database. It reads the diversion file, the list files and the status - file to build both the list of currently installed files and the - currently installed package list. - - ##################################################################### */ - /*}}}*/ -// Include Files /*{{{*/ -#include<config.h> - -#include <apt-pkg/dpkgdb.h> -#include <apt-pkg/configuration.h> -#include <apt-pkg/error.h> -#include <apt-pkg/progress.h> -#include <apt-pkg/tagfile.h> -#include <apt-pkg/strutl.h> -#include <apt-pkg/fileutl.h> -#include <apt-pkg/filelist.h> - -#include <stdio.h> -#include <errno.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <fcntl.h> -#include <unistd.h> -#include <ctype.h> -#include <iostream> -#include <apti18n.h> - /*}}}*/ -using namespace std; - -// EraseDir - Erase A Directory /*{{{*/ -// --------------------------------------------------------------------- -/* This is necessary to create a new empty sub directory. The caller should - invoke mkdir after this with the proper permissions and check for - error. Maybe stick this in fileutils */ -static bool EraseDir(const char *Dir) -{ - // First we try a simple RM - if (rmdir(Dir) == 0 || - errno == ENOENT) - return true; - - // A file? Easy enough.. - if (errno == ENOTDIR) - { - if (unlink(Dir) != 0) - 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); - - // Purge it using rm - pid_t Pid = ExecFork(); - - // Spawn the subprocess - if (Pid == 0) - { - execlp(_config->Find("Dir::Bin::rm","/bin/rm").c_str(), - "rm","-rf","--",Dir,(char *)NULL); - _exit(100); - } - return ExecWait(Pid,_config->Find("dir::bin::rm","/bin/rm").c_str()); -} - /*}}}*/ -// DpkgDB::debDpkgDB - Constructor /*{{{*/ -// --------------------------------------------------------------------- -/* */ -debDpkgDB::debDpkgDB() : CacheMap(0), FileMap(0) -{ - AdminDir = flNotFile(_config->Find("Dir::State::status")); - DiverInode = 0; - DiverTime = 0; -} - /*}}}*/ -// DpkgDB::~debDpkgDB - Destructor /*{{{*/ -// --------------------------------------------------------------------- -/* */ -debDpkgDB::~debDpkgDB() -{ - delete Cache; - Cache = 0; - delete CacheMap; - CacheMap = 0; - - delete FList; - FList = 0; - delete FileMap; - FileMap = 0; -} - /*}}}*/ -// DpkgDB::InitMetaTmp - Get the temp dir for meta information /*{{{*/ -// --------------------------------------------------------------------- -/* This creats+empties the meta temporary directory /var/lib/dpkg/tmp.ci - Only one package at a time can be using the returned meta directory. */ -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()); - if (mkdir(Tmp.c_str(),0755) != 0) - 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()); - Dev = St.st_dev; - if (stat(Tmp.c_str(),&St) != 0) - 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")); - - // Done - Dir = Tmp; - return true; -} - /*}}}*/ -// DpkgDB::ReadyPkgCache - Prepare the cache with the current status /*{{{*/ -// --------------------------------------------------------------------- -/* This reads in the status file into an empty cache. This really needs - to be somehow unified with the high level APT notion of the Database - directory, but there is no clear way on how to do that yet. */ -bool debDpkgDB::ReadyPkgCache(OpProgress &Progress) -{ - if (Cache != 0) - { - Progress.OverallProgress(1,1,1,_("Reading package lists")); - return true; - } - - if (CacheMap != 0) - { - delete CacheMap; - CacheMap = 0; - } - - if (pkgCacheGenerator::MakeOnlyStatusCache(&Progress,&CacheMap) == false) - return false; - Cache->DropProgress(); - - return true; -} - /*}}}*/ -// DpkgDB::ReadFList - Read the File Listings in /*{{{*/ -// --------------------------------------------------------------------- -/* This reads the file listing in from the state directory. This is a - performance critical routine, as it needs to parse about 50k lines of - text spread over a hundred or more files. For an initial cold start - most of the time is spent in reading file inodes and so on, not - actually parsing. */ -bool debDpkgDB::ReadFList(OpProgress &Progress) -{ - // Count the number of packages we need to read information for - unsigned long Total = 0; - pkgCache &Cache = this->Cache->GetCache(); - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) - { - // Only not installed packages have no files. - if (I->CurrentState == pkgCache::State::NotInstalled) - continue; - Total++; - } - - /* Switch into the admin dir, this prevents useless lookups for the - 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()); - - // Allocate a buffer. Anything larger than this buffer will be mmaped - unsigned long BufSize = 32*1024; - char *Buffer = new char[BufSize]; - - // Begin Loading them - unsigned long Count = 0; - char Name[300]; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) - { - /* Only not installed packages have no files. ConfFile packages have - file lists but we don't want to read them in */ - if (I->CurrentState == pkgCache::State::NotInstalled || - I->CurrentState == pkgCache::State::ConfigFiles) - continue; - - // Fetch a package handle to associate with the file - pkgFLCache::PkgIterator FlPkg = FList->GetPkg(I.Name(),0,true); - if (FlPkg.end() == true) - { - _error->Error(_("Internal error getting a package name")); - break; - } - - Progress.OverallProgress(Count,Total,1,_("Reading file listing")); - - // Open the list file - snprintf(Name,sizeof(Name),"%s.list",I.Name()); - int Fd = open(Name,O_RDONLY); - - /* Okay this is very strange and bad.. Best thing is to bail and - instruct the user to look into it. */ - struct stat Stat; - if (Fd == -1 || fstat(Fd,&Stat) != 0) - { - _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!"), - AdminDir.c_str(),Name); - break; - } - - // Set File to be a memory buffer containing the whole file - char *File; - if ((unsigned)Stat.st_size < BufSize) - { - if (read(Fd,Buffer,Stat.st_size) != Stat.st_size) - { - _error->Errno("read",_("Failed reading the list file %sinfo/%s"), - AdminDir.c_str(),Name); - close(Fd); - break; - } - File = Buffer; - } - else - { - // Use mmap - 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"), - AdminDir.c_str(),Name); - close(Fd); - break; - } - } - - // Parse it - const char *Start = File; - const char *End = File; - const char *Finish = File + Stat.st_size; - for (; End < Finish; End++) - { - // Not an end of line - if (*End != '\n' && End + 1 < Finish) - continue; - - // Skip blank lines - if (End - Start > 1) - { - pkgFLCache::NodeIterator Node = FList->GetNode(Start,End, - FlPkg.Offset(),true,false); - if (Node.end() == true) - { - _error->Error(_("Internal error getting a node")); - break; - } - } - - // Skip past the end of line - for (; *End == '\n' && End < Finish; End++); - Start = End; - } - - close(Fd); - if ((unsigned)Stat.st_size >= BufSize) - munmap((caddr_t)File,Stat.st_size); - - // Failed - if (End < Finish) - break; - - Count++; - } - - delete [] Buffer; - if (chdir(Cwd.c_str()) != 0) - return _error->Errno("chdir",_("Unable to change to %s"),Cwd.c_str()); - return !_error->PendingError(); -} - /*}}}*/ -// DpkgDB::ReadDiversions - Load the diversions file /*{{{*/ -// --------------------------------------------------------------------- -/* Read the diversion file in from disk. This is usually invoked by - LoadChanges before performing an operation that uses the FLCache. */ -bool debDpkgDB::ReadDiversions() -{ - struct stat Stat; - if (stat((AdminDir + "diversions").c_str(),&Stat) != 0) - return true; - - if (_error->PendingError() == true) - return false; - - 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()); - - FList->BeginDiverLoad(); - while (1) - { - char From[300]; - char To[300]; - char Package[100]; - - // Read the three lines in - if (fgets(From,sizeof(From),Fd) == 0) - break; - if (fgets(To,sizeof(To),Fd) == 0 || - fgets(Package,sizeof(Package),Fd) == 0) - { - _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); - 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); - 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); - else - Package[Len-1] = 0; - - // Make sure the lines were parsed OK - if (_error->PendingError() == true) - break; - - // Fetch a package - if (strcmp(Package,":") == 0) - Package[0] = 0; - pkgFLCache::PkgIterator FlPkg = FList->GetPkg(Package,0,true); - if (FlPkg.end() == true) - { - _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")); - break; - } - } - if (_error->PendingError() == false) - FList->FinishDiverLoad(); - - DiverInode = Stat.st_ino; - DiverTime = Stat.st_mtime; - - fclose(Fd); - return !_error->PendingError(); -} - /*}}}*/ -// DpkgDB::ReadFileList - Read the file listing /*{{{*/ -// --------------------------------------------------------------------- -/* Read in the file listing. The file listing is created from three - sources, *.list, Conffile sections and the Diversion table. */ -bool debDpkgDB::ReadyFileList(OpProgress &Progress) -{ - if (Cache == 0) - return _error->Error(_("The pkg cache must be initialized first")); - if (FList != 0) - { - Progress.OverallProgress(1,1,1,_("Reading file listing")); - return true; - } - - // Create the cache and read in the file listing - FileMap = new DynamicMMap(MMap::Public); - FList = new pkgFLCache(*FileMap); - if (_error->PendingError() == true || - ReadFList(Progress) == false || - ReadConfFiles() == false || - ReadDiversions() == false) - { - delete FList; - delete FileMap; - FileMap = 0; - FList = 0; - return false; - } - - cout << "Node: " << FList->HeaderP->NodeCount << ',' << FList->HeaderP->UniqNodes << endl; - cout << "Dir: " << FList->HeaderP->DirCount << endl; - cout << "Package: " << FList->HeaderP->PackageCount << endl; - cout << "HashSize: " << FList->HeaderP->HashSize << endl; - cout << "Size: " << FileMap->Size() << endl; - cout << endl; - - return true; -} - /*}}}*/ -// DpkgDB::ReadConfFiles - Read the conf file sections from the s-file /*{{{*/ -// --------------------------------------------------------------------- -/* Reading the conf files is done by reparsing the status file. This is - actually rather fast so it is no big deal. */ -bool debDpkgDB::ReadConfFiles() -{ - FileFd File(_config->FindFile("Dir::State::status"),FileFd::ReadOnly); - pkgTagFile Tags(&File); - if (_error->PendingError() == true) - return false; - - pkgTagSection Section; - while (1) - { - // Skip to the next section - unsigned long Offset = Tags.Offset(); - if (Tags.Step(Section) == false) - break; - - // Parse the line - const char *Start; - const char *Stop; - if (Section.Find("Conffiles",Start,Stop) == false) - continue; - - 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); - - // 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")); - - // Parse the conf file lines - while (1) - { - for (; isspace(*Start) != 0 && Start < Stop; Start++); - if (Start == Stop) - break; - - // Split it into words - const char *End = Start; - for (; isspace(*End) == 0 && End < Stop; End++); - const char *StartMd5 = End; - for (; isspace(*StartMd5) != 0 && StartMd5 < Stop; StartMd5++); - 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); - - // 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); - - if (FList->AddConfFile(Start,End,FlPkg,MD5) == false) - return false; - Start = EndMd5; - } - } - - return true; -} - /*}}}*/ -// DpkgDB::LoadChanges - Read in any changed state files /*{{{*/ -// --------------------------------------------------------------------- -/* The only file in the dpkg system that can change while packages are - unpacking is the diversions file. */ -bool debDpkgDB::LoadChanges() -{ - struct stat Stat; - if (stat((AdminDir + "diversions").c_str(),&Stat) != 0) - return true; - if (DiverInode == Stat.st_ino && DiverTime == Stat.st_mtime) - return true; - return ReadDiversions(); -} - /*}}}*/ diff --git a/apt-inst/deb/dpkgdb.h b/apt-inst/deb/dpkgdb.h deleted file mode 100644 index f28563a9..00000000 --- a/apt-inst/deb/dpkgdb.h +++ /dev/null @@ -1,55 +0,0 @@ -// -*- mode: cpp; mode: fold -*- -// Description /*{{{*/ -// $Id: dpkgdb.h,v 1.2 2001/02/20 07:03:17 jgg Exp $ -/* ###################################################################### - - DPKGv1 Data Base Implemenation - - The DPKGv1 database is typically stored in /var/lib/dpkg/. For - DPKGv1 the 'meta' information is the contents of the .deb control.tar.gz - member prepended by the package name. The meta information is unpacked - in its temporary directory and then migrated into the main list dir - at a checkpoint. - - Journaling is providing by syncronized file writes to the updates sub - directory. - - ##################################################################### */ - /*}}}*/ -#ifndef PKGLIB_DPKGDB_H -#define PKGLIB_DPKGDB_H - - -#include <apt-pkg/database.h> - -#include <string> - -class DynamicMMap; -class OpProgress; - -class debDpkgDB : public pkgDataBase -{ - protected: - - std::string AdminDir; - DynamicMMap *CacheMap; - DynamicMMap *FileMap; - unsigned long DiverInode; - signed long DiverTime; - - virtual bool InitMetaTmp(std::string &Dir); - bool ReadFList(OpProgress &Progress); - bool ReadDiversions(); - bool ReadConfFiles(); - - public: - - virtual bool ReadyFileList(OpProgress &Progress); - virtual bool ReadyPkgCache(OpProgress &Progress); - virtual bool LoadChanges(); - - debDpkgDB(); - virtual ~debDpkgDB(); -}; - -#endif diff --git a/apt-inst/makefile b/apt-inst/makefile index 1b9cc267..c716b8c9 100644 --- a/apt-inst/makefile +++ b/apt-inst/makefile @@ -23,12 +23,11 @@ APT_DOMAIN:=libapt-inst$(MAJOR) SOURCE = contrib/extracttar.cc contrib/arfile.cc # Source code for the main library -SOURCE+= filelist.cc database.cc dirstream.cc extract.cc \ - deb/dpkgdb.cc deb/debfile.cc +SOURCE+= filelist.cc dirstream.cc extract.cc deb/debfile.cc # Public header files -HEADERS = extracttar.h arfile.h filelist.h database.h extract.h \ - dpkgdb.h dirstream.h debfile.h +HEADERS = extracttar.h arfile.h filelist.h extract.h \ + dirstream.h debfile.h HEADERS := $(addprefix apt-pkg/,$(HEADERS)) include $(LIBRARY_H) diff --git a/debian/changelog b/debian/changelog index e1e023c7..127152b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,12 @@ apt (0.8.16~exp14) UNRELEASED; urgency=low causes timestamp changes for the mo files which therefore can't be refcounted by dpkg for your M-A: same packages (Closes: #659333, LP: #924628) + * apt-inst/database.{cc,h}, apt-inst/deb/dpkgdb.{cc,h}: + - drop instead of fix as it is only needed if you want to reimplement dpkg + and comes straight from the beginning of last decade (Closes: #663372) + * apt-inst/deb/debfile.cc: + - {Extract,Merge}Control() is another instance of "lets reimplement dpkg" + so shot of this code before someone ends up using this… * debian/libapt-pkg4.12: - update symbols file * debian/apt-utils.install: @@ -46,7 +52,7 @@ apt (0.8.16~exp14) UNRELEASED; urgency=low * doc/apt-get.8.xml: - typofix: respect → respecting, thanks Mike Erickson! (Closes: #664833) - -- David Kalnischkies <kalnischkies@gmail.com> Thu, 22 Mar 2012 10:33:17 +0100 + -- David Kalnischkies <kalnischkies@gmail.com> Thu, 22 Mar 2012 12:53:34 +0100 apt (0.8.16~exp13) experimental; urgency=low diff --git a/debian/libapt-inst1.4.symbols b/debian/libapt-inst1.4.symbols index bba2cb65..cade0990 100644 --- a/debian/libapt-inst1.4.symbols +++ b/debian/libapt-inst1.4.symbols @@ -7,11 +7,9 @@ libapt-inst.so.1.4 libapt-inst1.4 #MINVER# (c++)"ExtractTar::~ExtractTar()@Base" 0.8.0 (c++)"debDebFile::GotoMember(char const*)@Base" 0.8.0 (c++)"debDebFile::CheckMember(char const*)@Base" 0.8.0 - (c++)"debDebFile::MergeControl(pkgDataBase&)@Base" 0.8.0 (c++)"debDebFile::ControlExtract::DoItem(pkgDirStream::Item&, int&)@Base" 0.8.0 (c++)"debDebFile::ControlExtract::~ControlExtract()@Base" 0.8.0 (c++)"debDebFile::ExtractArchive(pkgDirStream&)@Base" 0.8.0 - (c++)"debDebFile::ExtractControl(pkgDataBase&)@Base" 0.8.0 (c++)"debDebFile::MemControlExtract::TakeControl(void const*, unsigned long)@Base" 0.8.0 (c++)"debDebFile::MemControlExtract::Read(debDebFile&)@Base" 0.8.0 (c++)"debDebFile::MemControlExtract::DoItem(pkgDirStream::Item&, int&)@Base" 0.8.0 @@ -39,16 +37,11 @@ libapt-inst.so.1.4 libapt-inst1.4 #MINVER# (c++)"pkgFLCache::HashNode(pkgFLCache::NodeIterator const&)@Base" 0.8.0 (c++)"pkgFLCache::PrintTree(unsigned int, unsigned long)@Base" 0.8.0 (c++)"pkgFLCache::pkgFLCache(DynamicMMap&)@Base" 0.8.0 - (c++)"pkgDataBase::GetMetaTmp(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)@Base" 0.8.0 - (c++)"pkgDataBase::~pkgDataBase()@Base" 0.8.0 (c++)"pkgDirStream::FinishedFile(pkgDirStream::Item&, int)@Base" 0.8.0 (c++)"pkgDirStream::Fail(pkgDirStream::Item&, int)@Base" 0.8.0 (c++)"pkgDirStream::DoItem(pkgDirStream::Item&, int&)@Base" 0.8.0 (c++)"pkgDirStream::Process(pkgDirStream::Item&, unsigned char const*, unsigned long, unsigned long)@Base" 0.8.0 (c++)"pkgDirStream::~pkgDirStream()@Base" 0.8.0 - (c++|optional)"debListParser::~debListParser()@Base" 0.8.0 - (c++|optional)"pkgCacheGenerator::ListParser::CollectFileProvides(pkgCache&, pkgCache::VerIterator&)@Base" 0.8.0 - (c++|optional)"pkgCacheGenerator::ListParser::~ListParser()@Base" 0.8.0 (c++|optional)"pkgCache::DepIterator::operator++(int)@Base" 0.8.0 (c++|optional)"pkgCache::DepIterator::operator++()@Base" 0.8.0 (c++|optional)"pkgCache::VerIterator::operator++(int)@Base" 0.8.0 @@ -56,15 +49,6 @@ libapt-inst.so.1.4 libapt-inst1.4 #MINVER# (c++)"ARArchive::LoadHeaders()@Base" 0.8.0 (c++)"ARArchive::ARArchive(FileFd&)@Base" 0.8.0 (c++)"ARArchive::~ARArchive()@Base" 0.8.0 - (c++)"debDpkgDB::InitMetaTmp(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)@Base" 0.8.0 - (c++)"debDpkgDB::LoadChanges()@Base" 0.8.0 - (c++)"debDpkgDB::ReadConfFiles()@Base" 0.8.0 - (c++)"debDpkgDB::ReadyFileList(OpProgress&)@Base" 0.8.0 - (c++)"debDpkgDB::ReadyPkgCache(OpProgress&)@Base" 0.8.0 - (c++)"debDpkgDB::ReadDiversions()@Base" 0.8.0 - (c++)"debDpkgDB::ReadFList(OpProgress&)@Base" 0.8.0 - (c++)"debDpkgDB::debDpkgDB()@Base" 0.8.0 - (c++)"debDpkgDB::~debDpkgDB()@Base" 0.8.0 (c++)"pkgFLCache::NodeIterator::RealPackage() const@Base" 0.8.0 (c++)"pkgFLCache::Header::CheckSizes(pkgFLCache::Header&) const@Base" 0.8.0 (c++|optional)"pkgCache::DepIterator::OwnerPointer() const@Base" 0.8.0 @@ -72,42 +56,30 @@ libapt-inst.so.1.4 libapt-inst1.4 #MINVER# (c++)"ARArchive::FindMember(char const*) const@Base" 0.8.0 (c++)"typeinfo for ExtractTar@Base" 0.8.0 (c++)"typeinfo for pkgExtract@Base" 0.8.0 - (c++)"typeinfo for pkgDataBase@Base" 0.8.0 (c++)"typeinfo for pkgDirStream@Base" 0.8.0 - (c++)"typeinfo for debDpkgDB@Base" 0.8.0 (c++)"typeinfo for debDebFile::ControlExtract@Base" 0.8.0 (c++)"typeinfo for debDebFile::MemControlExtract@Base" 0.8.0 - (c++|optional)"typeinfo for pkgCacheGenerator::ListParser@Base" 0.8.0 (c++|optional)"typeinfo for pkgCache::DepIterator@Base" 0.8.0 (c++|optional)"typeinfo for pkgCache::VerIterator@Base" 0.8.0 (c++|optional)"typeinfo for pkgCache::Iterator<pkgCache::Dependency, pkgCache::DepIterator>@Base" 0.8.0 - (c++|optional)"typeinfo for pkgCache::Iterator<pkgCache::Package, pkgCache::PkgIterator>@Base" 0.8.0 (c++|optional)"typeinfo for pkgCache::Iterator<pkgCache::Version, pkgCache::VerIterator>@Base" 0.8.0 (c++)"typeinfo name for ExtractTar@Base" 0.8.0 (c++)"typeinfo name for pkgExtract@Base" 0.8.0 - (c++)"typeinfo name for pkgDataBase@Base" 0.8.0 (c++)"typeinfo name for pkgDirStream@Base" 0.8.0 - (c++)"typeinfo name for debDpkgDB@Base" 0.8.0 (c++)"typeinfo name for debDebFile::ControlExtract@Base" 0.8.0 (c++)"typeinfo name for debDebFile::MemControlExtract@Base" 0.8.0 - (c++|optional)"typeinfo name for pkgCacheGenerator::ListParser@Base" 0.8.0 (c++|optional)"typeinfo name for pkgCache::DepIterator@Base" 0.8.0 (c++|optional)"typeinfo name for pkgCache::VerIterator@Base" 0.8.0 (c++|optional)"typeinfo name for pkgCache::Iterator<pkgCache::Dependency, pkgCache::DepIterator>@Base" 0.8.0 - (c++|optional)"typeinfo name for pkgCache::Iterator<pkgCache::Package, pkgCache::PkgIterator>@Base" 0.8.0 (c++|optional)"typeinfo name for pkgCache::Iterator<pkgCache::Version, pkgCache::VerIterator>@Base" 0.8.0 (c++)"vtable for ExtractTar@Base" 0.8.0 (c++)"vtable for pkgExtract@Base" 0.8.0 - (c++)"vtable for pkgDataBase@Base" 0.8.0 (c++)"vtable for pkgDirStream@Base" 0.8.0 - (c++)"vtable for debDpkgDB@Base" 0.8.0 (c++)"vtable for debDebFile::ControlExtract@Base" 0.8.0 (c++)"vtable for debDebFile::MemControlExtract@Base" 0.8.0 - (c++|optional)"vtable for pkgCacheGenerator::ListParser@Base" 0.8.0 (c++|optional)"vtable for pkgCache::DepIterator@Base" 0.8.0 (c++|optional)"vtable for pkgCache::VerIterator@Base" 0.8.0 (c++|optional)"vtable for pkgCache::Iterator<pkgCache::Dependency, pkgCache::DepIterator>@Base" 0.8.0 - (c++|optional)"vtable for pkgCache::Iterator<pkgCache::Package, pkgCache::PkgIterator>@Base" 0.8.0 (c++|optional)"vtable for pkgCache::Iterator<pkgCache::Version, pkgCache::VerIterator>@Base" 0.8.0 ### gcc-4.4 specific # (c++|regex|optional=std)"^char\* std::[^ ]+<.+ >::_.+@Base$" 0.8.0 diff --git a/test/interactive-helper/makefile b/test/interactive-helper/makefile index b96139fd..10d1e44e 100644 --- a/test/interactive-helper/makefile +++ b/test/interactive-helper/makefile @@ -11,28 +11,24 @@ SLIBS = SOURCE = mthdcat.cc include $(PROGRAM_H) -# Version compare tester -PROGRAM=testextract -SLIBS = -lapt-pkg -lapt-inst -LIB_MAKES = apt-pkg/makefile apt-inst/makefile -SOURCE = testextract.cc -include $(PROGRAM_H) - # Program for testing the tar/deb extractor PROGRAM=testdeb SLIBS = -lapt-pkg -lapt-inst +LIB_MAKES = apt-pkg/makefile apt-inst/makefile SOURCE = testdeb.cc include $(PROGRAM_H) # Program for testing tar extraction PROGRAM=extract-control SLIBS = -lapt-pkg -lapt-inst +LIB_MAKES = apt-pkg/makefile apt-inst/makefile SOURCE = extract-control.cc include $(PROGRAM_H) # Program for testing udevcdrom PROGRAM=test_udevcdrom -SLIBS = -lapt-pkg +SLIBS = -lapt-pkg +LIB_MAKES = apt-pkg/makefile SOURCE = test_udevcdrom.cc include $(PROGRAM_H) diff --git a/test/interactive-helper/testextract.cc b/test/interactive-helper/testextract.cc deleted file mode 100644 index 8dfe68fc..00000000 --- a/test/interactive-helper/testextract.cc +++ /dev/null @@ -1,104 +0,0 @@ -#include <apt-pkg/dpkgdb.h> -#include <apt-pkg/debfile.h> -#include <apt-pkg/error.h> -#include <apt-pkg/configuration.h> -#include <apt-pkg/progress.h> -#include <apt-pkg/extract.h> -#include <apt-pkg/init.h> -#include <apt-pkg/strutl.h> -#include <apt-pkg/fileutl.h> -#include <apt-pkg/pkgsystem.h> - -#include <stdio.h> -#include <stdlib.h> - -using namespace std; - -bool Go(int argc,char *argv[]) -{ - // Init the database - debDpkgDB Db; - { - OpTextProgress Prog; - - if (Db.ReadyPkgCache(Prog) == false) - return false; - Prog.Done(); - - if (Db.ReadyFileList(Prog) == false) - return false; - } - - for (int I = 1; I < argc; I++) - { - const char *Fake = 0; - for (unsigned J = 0; argv[I][J] != 0; J++) - { - if (argv[I][J] != ',') - continue; - Fake = argv[I] + J + 1; - argv[I][J] = 0; - } - - FileFd F(argv[I],FileFd::ReadOnly); - debDebFile Deb(F); - - if (_error->PendingError() == true) - return false; - - if (Deb.ExtractControl(Db) == false) - return false; - cout << argv[I] << endl; - - pkgCache::VerIterator Ver = Deb.MergeControl(Db); - if (Ver.end() == true) - return false; - - cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl; - - pkgExtract Extract(Db.GetFLCache(),Ver); - - if (Fake != 0) - { - pkgExtract::Item Itm; - memset(&Itm,0,sizeof(Itm)); - FILE *F = fopen(Fake,"r"); - while (feof(F) == 0) - { - char Line[300]; - if (fgets(Line,sizeof(Line),F) == NULL) - return false; - Itm.Name = _strstrip(Line); - Itm.Type = pkgDirStream::Item::File; - if (Line[strlen(Line)-1] == '/') - Itm.Type = pkgDirStream::Item::Directory; - - int Fd; - if (Extract.DoItem(Itm,Fd) == false) { - fclose(F); - return false; - } - } - fclose(F); - } - else - if (Deb.ExtractArchive(Extract) == false) - return false; - } - return true; -} - -int main(int argc,char *argv[]) -{ - pkgInitConfig(*_config); - pkgInitSystem(*_config,_system); - _config->Set("Dir::State::status","/tmp/testing/status"); - - Go(argc,argv); - - if (_error->PendingError() == true) - { - _error->DumpErrors(); - return 0; - } -} |