diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:51:37 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:51:37 +0000 |
commit | d38b7b3d803a719b189df80820aeda6a818f4909 (patch) | |
tree | 28143d1b948d8b31fc8bec91b50d2fdfe6ff3341 /apt-pkg | |
parent | c217f42adc1a82c7400e85178f61bf429fea1bc4 (diff) |
Needs Unpack fixes
Author: jgg
Date: 1998-11-23 07:02:58 GMT
Needs Unpack fixes
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/algorithms.cc | 10 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 21 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.h | 5 | ||||
-rw-r--r-- | apt-pkg/contrib/mmap.cc | 5 | ||||
-rw-r--r-- | apt-pkg/deb/dpkginit.cc | 105 | ||||
-rw-r--r-- | apt-pkg/deb/dpkginit.h | 33 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 3 | ||||
-rw-r--r-- | apt-pkg/deb/dpkgpm.h | 3 | ||||
-rw-r--r-- | apt-pkg/depcache.cc | 14 | ||||
-rw-r--r-- | apt-pkg/makefile | 4 | ||||
-rw-r--r-- | apt-pkg/packagemanager.cc | 12 | ||||
-rw-r--r-- | apt-pkg/pkgcache.cc | 4 |
12 files changed, 198 insertions, 21 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 210095810..6328a20eb 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: algorithms.cc,v 1.11 1998/11/14 07:20:06 jgg Exp $ +// $Id: algorithms.cc,v 1.12 1998/11/23 07:02:58 jgg Exp $ /* ###################################################################### Algorithms - A set of misc algorithms @@ -165,6 +165,14 @@ bool pkgApplyStatus(pkgDepCache &Cache) { for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) { + // Only choice for a ReInstReq package is to reinstall + if (I->InstState == pkgCache::State::ReInstReq || + I->InstState == pkgCache::State::HoldReInstReq) + { + Cache.MarkKeep(I); + continue; + } + switch (I->CurrentState) { // This means installation failed somehow diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 77e846117..3ca36377a 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.cc,v 1.13 1998/10/26 07:11:49 jgg Exp $ +// $Id: fileutl.cc,v 1.14 1998/11/23 07:03:06 jgg Exp $ /* ###################################################################### File Utilities @@ -119,6 +119,18 @@ string flNotDir(string File) return string(File,Res,Res - File.length()); } /*}}}*/ +// flNotFile - Strip the file from the directory name /*{{{*/ +// --------------------------------------------------------------------- +/* */ +string flNotFile(string File) +{ + string::size_type Res = File.rfind('/'); + if (Res == string::npos) + return File; + Res++; + return string(File,0,Res); +} + /*}}}*/ // SetCloseExec - Set the close on exec flag /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -184,12 +196,7 @@ FileFd::FileFd(string FileName,OpenMode Mode, unsigned long Perms) case WriteAny: iFd = open(FileName.c_str(),O_RDWR | O_CREAT,Perms); - break; - - // Dont use this in public directories - case LockEmpty: - iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms); - break; + break; } if (iFd < 0) diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 01dc46b13..31af3d28b 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.h,v 1.8 1998/10/26 07:11:50 jgg Exp $ +// $Id: fileutl.h,v 1.9 1998/11/23 07:03:07 jgg Exp $ /* ###################################################################### File Utilities @@ -38,7 +38,7 @@ class FileFd string FileName; public: - enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,LockEmpty}; + enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny}; bool Read(void *To,unsigned long Size); bool Write(void *From,unsigned long Size); @@ -69,5 +69,6 @@ bool WaitFd(int Fd); // File string manipulators string flNotDir(string File); +string flNotFile(string File); #endif diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index f6def2154..0ac202aef 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: mmap.cc,v 1.9 1998/11/12 03:14:39 jgg Exp $ +// $Id: mmap.cc,v 1.10 1998/11/23 07:03:08 jgg Exp $ /* ###################################################################### MMap Class - Provides 'real' mmap or a faked mmap using read(). @@ -130,6 +130,9 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop) DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace) : MMap(F,Flags | NoImmMap), WorkSpace(WorkSpace) { + if (_error->PendingError() == true) + return; + unsigned long EndOfFile = Fd.Size(); Fd.Seek(WorkSpace); char C = 0; diff --git a/apt-pkg/deb/dpkginit.cc b/apt-pkg/deb/dpkginit.cc new file mode 100644 index 000000000..095156d0d --- /dev/null +++ b/apt-pkg/deb/dpkginit.cc @@ -0,0 +1,105 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +// $Id: dpkginit.cc,v 1.1 1998/11/23 07:03:10 jgg Exp $ +/* ###################################################################### + + DPKG init - Initialize the dpkg stuff + + ##################################################################### */ + /*}}}*/ +// Includes /*{{{*/ +#ifdef __GNUG__ +#pragma implementation "apt-pkg/dpkginit.h" +#endif +#include <apt-pkg/dpkginit.h> +#include <apt-pkg/error.h> +#include <apt-pkg/configuration.h> +#include <apt-pkg/fileutl.h> + +#include <sys/types.h> +#include <unistd.h> +#include <dirent.h> + /*}}}*/ + +// DpkgLock::pkgDpkgLock - Constructor /*{{{*/ +// --------------------------------------------------------------------- +/* */ +pkgDpkgLock::pkgDpkgLock() +{ + LockFD = -1; + GetLock(); +} + /*}}}*/ +// DpkgLock::~pkgDpkgLock - Destructor /*{{{*/ +// --------------------------------------------------------------------- +/* */ +pkgDpkgLock::~pkgDpkgLock() +{ + Close(); +} + /*}}}*/ +// DpkgLock::GetLock - Get the lock /*{{{*/ +// --------------------------------------------------------------------- +/* This mirrors the operations dpkg does when it starts up. Note the + checking of the updates directory. */ +bool pkgDpkgLock::GetLock() +{ + // Disable file locking + if (_config->FindB("Debug::NoLocking",false) == true) + return true; + + Close(); + + // Create the lockfile + string AdminDir = flNotFile(_config->Find("Dir::State::status")); + LockFD = ::GetLock(AdminDir + "lock"); + if (LockFD == -1) + return _error->Errno("Open","Unable to lock the administration directory " + "%s, are you root?",AdminDir.c_str()); + + // Check for updates.. (dirty) + string File = AdminDir + "updates/"; + DIR *DirP = opendir(File.c_str()); + if (DirP != 0) + { + /* We ignore any files that are not all digits, this skips .,.. and + some tmp files dpkg will leave behind.. */ + bool Damaged = false; + for (struct dirent *Ent = readdir(DirP); Ent != 0; Ent = readdir(DirP)) + { + Damaged = true; + for (unsigned int I = 0; Ent->d_name[I] != 0; I++) + { + // Check if its not a digit.. + if (isdigit(Ent->d_name[I]) == 0) + { + Damaged = false; + break; + } + } + if (Damaged == true) + break; + } + closedir(DirP); + + // Woops, we have to run dpkg to rewrite the status file + if (Damaged == true) + { + Close(); + return _error->Error("dpkg was interrupted, you must manually " + "run 'dpkg --configure -a' to correct the problem. "); + } + } + + return true; +} + /*}}}*/ +// DpkgLock::Close - Close the lock /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgDpkgLock::Close() +{ + close(LockFD); + LockFD = -1; +} + /*}}}*/ diff --git a/apt-pkg/deb/dpkginit.h b/apt-pkg/deb/dpkginit.h new file mode 100644 index 000000000..288f50d04 --- /dev/null +++ b/apt-pkg/deb/dpkginit.h @@ -0,0 +1,33 @@ +// -*- mode: cpp; mode: fold -*- +// Description /*{{{*/ +// $Id: dpkginit.h,v 1.1 1998/11/23 07:03:11 jgg Exp $ +/* ###################################################################### + + DPKG init - Initialize the dpkg stuff + + This basically gets a lock in /var/lib/dpkg and checks the updates + directory + + ##################################################################### */ + /*}}}*/ +#ifndef PKGLIB_DPKGINIT_H +#define PKGLIB_DPKGINIT_H + +#ifdef __GNUG__ +#pragma interface "apt-pkg/dpkginit.h" +#endif + +class pkgDpkgLock +{ + int LockFD; + + public: + + bool GetLock(); + void Close(); + + pkgDpkgLock(); + ~pkgDpkgLock(); +}; + +#endif diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index dfdc0c4b5..e437ad7a3 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: dpkgpm.cc,v 1.2 1998/11/22 03:20:35 jgg Exp $ +// $Id: dpkgpm.cc,v 1.3 1998/11/23 07:03:11 jgg Exp $ /* ###################################################################### DPKG Package Manager - Provide an interface to dpkg @@ -163,6 +163,7 @@ bool pkgDPkgPM::Go() // This is the child if (Child == 0) { + signal(SIGPIPE,SIG_DFL); signal(SIGQUIT,SIG_DFL); signal(SIGINT,SIG_DFL); signal(SIGWINCH,SIG_DFL); diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index b5f08ea32..dcb6e9db0 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -1,13 +1,12 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: dpkgpm.h,v 1.1 1998/11/13 04:23:39 jgg Exp $ +// $Id: dpkgpm.h,v 1.2 1998/11/23 07:03:12 jgg Exp $ /* ###################################################################### DPKG Package Manager - Provide an interface to dpkg ##################################################################### */ /*}}}*/ -// Header section: pkglib #ifndef PKGLIB_DPKGPM_H #define PKGLIB_DPKGPM_H diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 90c07658b..b3a70d239 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: depcache.cc,v 1.6 1998/11/23 01:45:58 jgg Exp $ +// $Id: depcache.cc,v 1.7 1998/11/23 07:02:59 jgg Exp $ /* ###################################################################### Dependency Cache - Caches Dependency information. @@ -213,6 +213,7 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,long Mult) { iUsrSize += Mult*P.InstVerIter(*this)->InstalledSize; iDownloadSize += Mult*P.InstVerIter(*this)->Size; + return; } // Upgrading @@ -222,11 +223,22 @@ void pkgDepCache::AddSizes(const PkgIterator &Pkg,long Mult) iUsrSize += Mult*((signed)P.InstVerIter(*this)->InstalledSize - (signed)Pkg.CurrentVer()->InstalledSize); iDownloadSize += Mult*P.InstVerIter(*this)->Size; + return; + } + + // Reinstall + if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack) + { + iDownloadSize += Mult*P.InstVerIter(*this)->Size; + return; } // Removing if (Pkg->CurrentVer != 0 && P.InstallVer == 0) + { iUsrSize -= Mult*Pkg.CurrentVer()->InstalledSize; + return; + } } /*}}}*/ // DepCache::AddStates - Add the package to the state counter /*{{{*/ diff --git a/apt-pkg/makefile b/apt-pkg/makefile index f981a8895..d78fb7cdc 100644 --- a/apt-pkg/makefile +++ b/apt-pkg/makefile @@ -27,7 +27,7 @@ SOURCE+= pkgcache.cc version.cc fileutl.cc pkgcachegen.cc depcache.cc \ acquire-worker.cc acquire-method.cc init.cc templates.cc # Source code for the debian specific components -SOURCE+= deb/deblistparser.cc deb/debrecords.cc deb/dpkgpm.cc +SOURCE+= deb/deblistparser.cc deb/debrecords.cc deb/dpkgpm.cc deb/dpkginit.cc # Public apt-pkg header files HEADERS = algorithms.h depcache.h mmap.h pkgcachegen.h cacheiterators.h \ @@ -35,7 +35,7 @@ HEADERS = algorithms.h depcache.h mmap.h pkgcachegen.h cacheiterators.h \ packagemanager.h tagfile.h deblistparser.h init.h pkgcache.h \ version.h progress.h pkgrecords.h debrecords.h cmndline.h \ acquire.h acquire-worker.h acquire-item.h acquire-method.h md5.h \ - dpkgpm.h + dpkgpm.h dpkginit.h HEADERS := $(addprefix apt-pkg/,$(HEADERS)) diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 7dd6b8a27..04b77eb09 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: packagemanager.cc,v 1.7 1998/11/22 23:37:05 jgg Exp $ +// $Id: packagemanager.cc,v 1.8 1998/11/23 07:03:01 jgg Exp $ /* ###################################################################### Package Manager - Abstacts the package manager @@ -64,6 +64,10 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, // Skip packages to erase if (Cache[Pkg].Delete() == true) continue; + + // Skip Packages that need configure only. + if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure) + continue; new pkgAcqArchive(Owner,Sources,Recs,Cache[Pkg].InstVerIter(Cache), FileNames[Pkg->ID]); @@ -106,15 +110,19 @@ bool pkgPackageManager::CreateOrderList() // Generate the list of affected packages and sort it for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) { - // Consider all depends + // Mark the package for immediate configuration if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) { List->Flag(I,pkgOrderList::Immediate); + + // Look for other packages to make immediate configurea if (Cache[I].InstallVer != 0) for (DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++) if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) List->Flag(D.TargetPkg(),pkgOrderList::Immediate); + + // And again with the current version. if (I->CurrentVer != 0) for (DepIterator D = I.CurrentVer().DependsList(); D.end() == false; D++) diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 2b52a9977..2fbdc717f 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: pkgcache.cc,v 1.16 1998/11/14 07:20:09 jgg Exp $ +// $Id: pkgcache.cc,v 1.17 1998/11/23 07:03:05 jgg Exp $ /* ###################################################################### Package Cache - Accessor code for the cache @@ -203,7 +203,7 @@ void pkgCache::PkgIterator::operator ++(int) // --------------------------------------------------------------------- /* By this we mean if it is either cleanly installed or cleanly removed. */ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const -{ +{ if (Pkg->InstState == pkgCache::State::ReInstReq || Pkg->InstState == pkgCache::State::HoldReInstReq) return NeedsUnpack; |