~mvo/apt/mvo

« back to all changes in this revision

Viewing changes to apt-pkg/packagemanager.cc

  • Committer: Arch Librarian
  • Date: 2004-09-20 16:56:32 UTC
  • Revision ID: Arch-1:apt@arch.ubuntu.com%apt--MAIN--0--patch-614
Join with aliencode
Author: jgg
Date: 2001-02-20 07:03:16 GMT
Join with aliencode

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// -*- mode: cpp; mode: fold -*-
2
2
// Description                                                          /*{{{*/
3
 
// $Id: packagemanager.cc,v 1.25 2000/05/12 04:26:42 jgg Exp $
 
3
// $Id: packagemanager.cc,v 1.26 2001/02/20 07:03:17 jgg Exp $
4
4
/* ######################################################################
5
5
 
6
6
   Package Manager - Abstacts the package manager
16
16
#ifdef __GNUG__
17
17
#pragma implementation "apt-pkg/packagemanager.h"
18
18
#endif
 
19
 
19
20
#include <apt-pkg/packagemanager.h>
20
21
#include <apt-pkg/orderlist.h>
21
22
#include <apt-pkg/depcache.h>
24
25
#include <apt-pkg/acquire-item.h>
25
26
#include <apt-pkg/algorithms.h>
26
27
#include <apt-pkg/configuration.h>
 
28
#include <apt-pkg/sptr.h>
 
29
    
 
30
#include <apti18n.h>    
27
31
                                                                        /*}}}*/
28
32
 
29
33
// PM::PackageManager - Constructor                                     /*{{{*/
30
34
// ---------------------------------------------------------------------
31
35
/* */
32
 
pkgPackageManager::pkgPackageManager(pkgDepCache &Cache) : Cache(Cache)
 
36
pkgPackageManager::pkgPackageManager(pkgDepCache *pCache) : Cache(*pCache)
33
37
{
34
38
   FileNames = new string[Cache.Head().PackageCount];
35
39
   List = 0;
88
92
   be downloaded. */
89
93
bool pkgPackageManager::FixMissing()
90
94
{   
91
 
   pkgProblemResolver Resolve(Cache);
 
95
   pkgProblemResolver Resolve(&Cache);
92
96
   List->SetFileList(FileNames);
93
97
   
94
98
   bool Bad = false;
124
128
      return true;
125
129
   
126
130
   delete List;
127
 
   List = new pkgOrderList(Cache);
 
131
   List = new pkgOrderList(&Cache);
128
132
   
129
133
   bool NoImmConfigure = _config->FindB("APT::Immediate-Configure",false);
130
134
   
193
197
{
194
198
   for (;D.end() == false; D++)
195
199
   {
196
 
      if (D->Type != pkgCache::Dep::Conflicts)
 
200
      if (D->Type != pkgCache::Dep::Conflicts &&
 
201
          D->Type != pkgCache::Dep::Obsoletes)
197
202
         continue;
198
203
 
199
204
      // The package hasnt been changed
204
209
      if (D.ParentPkg() == Pkg || D.ParentVer() != D.ParentPkg().CurrentVer())
205
210
         continue;
206
211
      
207
 
      if (pkgCheckDep(D.TargetVer(),Ver,D->CompareOp) == false)
 
212
      if (Cache.VS().CheckDep(Ver,D->CompareOp,D.TargetVer()) == false)
208
213
         continue;
209
 
      
 
214
 
210
215
      if (EarlyRemove(D.ParentPkg()) == false)
211
216
         return _error->Error("Reverse conflicts early remove for package '%s' failed",
212
217
                              Pkg.Name());
220
225
   that the final configuration is valid. */
221
226
bool pkgPackageManager::ConfigureAll()
222
227
{
223
 
   pkgOrderList OList(Cache);
 
228
   pkgOrderList OList(&Cache);
224
229
   
225
230
   // Populate the order list
226
231
   for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++)
251
256
   of it's dependents. */
252
257
bool pkgPackageManager::SmartConfigure(PkgIterator Pkg)
253
258
{
254
 
   pkgOrderList OList(Cache);
 
259
   pkgOrderList OList(&Cache);
255
260
 
256
261
   if (DepAdd(OList,Pkg) == false)
257
262
      return false;
258
263
   
259
264
   if (OList.OrderConfigure() == false)
260
265
      return false;
261
 
 
 
266
   
262
267
   // Perform the configuring
263
268
   for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++)
264
269
   {
288
293
      return true;
289
294
   if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == false)
290
295
      return false;
291
 
   
292
 
   
 
296
      
293
297
   // Put the package on the list
294
298
   OList.push_back(Pkg);
295
299
   OList.Flag(Pkg,pkgOrderList::Added);
314
318
         if (Bad == false)
315
319
            continue;
316
320
 
317
 
         Version **VList = D.AllTargets();
 
321
         SPtrArray<Version *> VList = D.AllTargets();
318
322
         for (Version **I = VList; *I != 0 && Bad == true; I++)
319
323
         {
320
324
            VerIterator Ver(Cache,*I);
332
336
            if (Cache[Pkg].InstallVer != *I || 
333
337
                (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing))
334
338
               continue;
 
339
            
335
340
            if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == true)
336
341
               Bad = !DepAdd(OList,Pkg,Depth);
337
342
            if (List->IsFlag(Pkg,pkgOrderList::Configured) == true)
338
343
               Bad = false;
339
344
         }
340
 
         delete [] VList;
341
345
      }
342
346
      
343
347
      if (Bad == true)
388
392
   if (IsEssential == true)
389
393
   {
390
394
      if (_config->FindB("APT::Force-LoopBreak",false) == false)
391
 
         return _error->Error("This installation run will require temporarily "
392
 
                              "removing the essential package %s due to a "
393
 
                              "Conflicts/Pre-Depends loop. This is often bad, "
394
 
                              "but if you really want to do it, activate the "
395
 
                              "APT::Force-LoopBreak option.",Pkg.Name());
 
395
         return _error->Error(_("This installation run will require temporarily "
 
396
                                "removing the essential package %s due to a "
 
397
                                "Conflicts/Pre-Depends loop. This is often bad, "
 
398
                                "but if you really want to do it, activate the "
 
399
                                "APT::Force-LoopBreak option."),Pkg.Name());
396
400
   }
397
401
   
398
402
   bool Res = SmartRemove(Pkg);
426
430
      List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States);
427
431
      if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true)
428
432
         if (SmartConfigure(Pkg) == false)
429
 
            return _error->Error("Internal Error, Could not perform immediate configuration");
 
433
            return _error->Error("Internal Error, Could not perform immediate configuration (1) on %s",Pkg.Name());
430
434
      return true;
431
435
   }
432
436
 
443
447
      while (End->Type == pkgCache::Dep::PreDepends)
444
448
      {
445
449
         // Look for possible ok targets.
446
 
         Version **VList = Start.AllTargets();
 
450
         SPtrArray<Version *> VList = Start.AllTargets();
447
451
         bool Bad = true;
448
452
         for (Version **I = VList; *I != 0 && Bad == true; I++)
449
453
         {
473
477
            Bad = !SmartConfigure(Pkg);
474
478
         }
475
479
         
476
 
         delete [] VList;
477
 
 
478
480
         /* If this or element did not match then continue on to the
479
481
            next or element until a matching element is found*/
480
482
         if (Bad == true)
487
489
            break;
488
490
      }
489
491
      
490
 
      if (End->Type == pkgCache::Dep::Conflicts)
 
492
      if (End->Type == pkgCache::Dep::Conflicts || 
 
493
          End->Type == pkgCache::Dep::Obsoletes)
491
494
      {
492
495
         /* Look for conflicts. Two packages that are both in the install
493
496
            state cannot conflict so we don't check.. */
494
 
         Version **VList = End.AllTargets();
 
497
         SPtrArray<Version *> VList = End.AllTargets();
495
498
         for (Version **I = VList; *I != 0; I++)
496
499
         {
497
500
            VerIterator Ver(Cache,*I);
504
507
                  return _error->Error("Internal Error, Could not early remove %s",Pkg.Name());
505
508
            }
506
509
         }
507
 
         delete [] VList;
508
510
      }
509
511
   }
510
512
 
525
527
   // Perform immedate configuration of the package.
526
528
   if (List->IsFlag(Pkg,pkgOrderList::Immediate) == true)
527
529
      if (SmartConfigure(Pkg) == false)
528
 
         return _error->Error("Internal Error, Could not perform immediate configuration");
 
530
         return _error->Error("Internal Error, Could not perform immediate configuration (2) on %s",Pkg.Name());
529
531
   
530
532
   return true;
531
533
}