]>
git.saurik.com Git - apt.git/blob - cmdline/apt-get.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: apt-get.cc,v 1.3 1998/10/19 23:45:36 jgg Exp $
4 /* ######################################################################
6 apt-get - Cover for dpkg
8 This is an allout cover for dpkg implementing a safer front end. It is
9 based largely on libapt-pkg.
11 The syntax is different,
12 apt-get [opt] command [things]
14 update - Resyncronize the package files from their sources
15 upgrade - Smart-Download the newest versions of all packages
16 dselect-upgrade - Follows dselect's changes to the Status: field
17 and installes new and removes old packages
18 dist-upgrade - Powerfull upgrader designed to handle the issues with
20 install - Download and install a given package (by name, not by .deb)
21 check - Update the package cache and check for broken packages
22 clean - Erase the .debs downloaded to /var/cache/apt/archives and
25 ##################################################################### */
27 // Include Files /*{{{*/
28 #include <apt-pkg/error.h>
29 #include <apt-pkg/cmndline.h>
30 #include <apt-pkg/init.h>
31 #include <apt-pkg/depcache.h>
32 #include <apt-pkg/sourcelist.h>
33 #include <apt-pkg/pkgcachegen.h>
34 #include <apt-pkg/algorithms.h>
44 ofstream
devnull("/dev/null");
45 unsigned int ScreenWidth
= 80;
47 // ShowList - Show a list /*{{{*/
48 // ---------------------------------------------------------------------
49 /* This prints out a string of space seperated words with a title and
50 a two space indent line wraped to the current screen width. */
51 void ShowList(ostream
&out
,string Title
,string List
)
53 if (List
.empty() == true)
56 // Acount for the leading space
57 int ScreenWidth
= ::ScreenWidth
- 3;
60 string::size_type Start
= 0;
61 while (Start
< List
.size())
63 string::size_type End
;
64 if (Start
+ ScreenWidth
>= List
.size())
67 End
= List
.rfind(' ',Start
+ScreenWidth
);
69 if (End
== string::npos
|| End
< Start
)
70 End
= Start
+ ScreenWidth
;
71 out
<< " " << string(List
,Start
,End
- Start
) << endl
;
76 // ShowBroken - Debugging aide /*{{{*/
77 // ---------------------------------------------------------------------
78 /* This prints out the names of all the packages that are broken along
79 with the name of each each broken dependency and a quite version
81 void ShowBroken(ostream
&out
,pkgDepCache
&Cache
)
83 out
<< "Sorry, but the following packages are broken - this means they have unmet" << endl
;
84 out
<< "dependencies:" << endl
;
85 pkgCache::PkgIterator I
= Cache
.PkgBegin();
86 for (;I
.end() != true; I
++)
88 if (Cache
[I
].InstBroken() == false)
91 // Print out each package and the failed dependencies
92 out
<<" " << I
.Name() << ":";
93 int Indent
= strlen(I
.Name()) + 3;
95 if (Cache
[I
].InstVerIter(Cache
).end() == true)
101 for (pkgCache::DepIterator D
= Cache
[I
].InstVerIter(Cache
).DependsList(); D
.end() == false; D
++)
103 if (Cache
.IsImportantDep(D
) == false || (Cache
[D
] &
104 pkgDepCache::DepInstall
) != 0)
108 for (int J
= 0; J
!= Indent
; J
++)
112 if (D
->Type
== pkgCache::Dep::Conflicts
)
113 out
<< " Conflicts:" << D
.TargetPkg().Name();
115 out
<< " Depends:" << D
.TargetPkg().Name();
117 // Show a quick summary of the version requirements
118 if (D
.TargetVer() != 0)
119 out
<< " (" << D
.CompType() << " " << D
.TargetVer() <<
122 /* Show a summary of the target package if possible. In the case
123 of virtual packages we show nothing */
125 pkgCache::PkgIterator Targ
= D
.TargetPkg();
126 if (Targ
->ProvidesList
== 0)
129 pkgCache::VerIterator Ver
= Cache
[Targ
].InstVerIter(Cache
);
130 if (Ver
.end() == false)
131 out
<< Ver
.VerStr() << " is installed";
134 if (Cache
[Targ
].CandidateVerIter(Cache
).end() == true)
136 if (Targ
->ProvidesList
== 0)
137 out
<< "it is not installable";
139 out
<< "it is a virtual package";
142 out
<< "it is not installed";
151 // ShowNew - Show packages to newly install /*{{{*/
152 // ---------------------------------------------------------------------
154 void ShowNew(ostream
&out
,pkgDepCache
&Dep
)
156 /* Print out a list of packages that are going to be removed extra
157 to what the user asked */
158 pkgCache::PkgIterator I
= Dep
.PkgBegin();
160 for (;I
.end() != true; I
++)
161 if (Dep
[I
].NewInstall() == true)
162 List
+= string(I
.Name()) + " ";
163 ShowList(out
,"The following NEW packages will be installed:",List
);
166 // ShowDel - Show packages to delete /*{{{*/
167 // ---------------------------------------------------------------------
169 void ShowDel(ostream
&out
,pkgDepCache
&Dep
)
171 /* Print out a list of packages that are going to be removed extra
172 to what the user asked */
173 pkgCache::PkgIterator I
= Dep
.PkgBegin();
175 for (;I
.end() != true; I
++)
176 if (Dep
[I
].Delete() == true)
177 List
+= string(I
.Name()) + " ";
178 ShowList(out
,"The following packages will be REMOVED:",List
);
181 // ShowKept - Show kept packages /*{{{*/
182 // ---------------------------------------------------------------------
184 void ShowKept(ostream
&out
,pkgDepCache
&Dep
)
186 pkgCache::PkgIterator I
= Dep
.PkgBegin();
188 for (;I
.end() != true; I
++)
191 if (Dep
[I
].Upgrade() == true || Dep
[I
].Upgradable() == false ||
192 I
->CurrentVer
== 0 || Dep
[I
].Delete() == true)
195 List
+= string(I
.Name()) + " ";
197 ShowList(out
,"The following packages have been kept back",List
);
200 // ShowUpgraded - Show upgraded packages /*{{{*/
201 // ---------------------------------------------------------------------
203 void ShowUpgraded(ostream
&out
,pkgDepCache
&Dep
)
205 pkgCache::PkgIterator I
= Dep
.PkgBegin();
207 for (;I
.end() != true; I
++)
210 if (Dep
[I
].Upgrade() == false || Dep
[I
].NewInstall() == true)
213 List
+= string(I
.Name()) + " ";
215 ShowList(out
,"The following packages will be upgraded",List
);
218 // ShowHold - Show held but changed packages /*{{{*/
219 // ---------------------------------------------------------------------
221 void ShowHold(ostream
&out
,pkgDepCache
&Dep
)
223 pkgCache::PkgIterator I
= Dep
.PkgBegin();
225 for (;I
.end() != true; I
++)
227 if (Dep
[I
].InstallVer
!= (pkgCache::Version
*)I
.CurrentVer() &&
228 I
->SelectedState
== pkgCache::State::Hold
)
229 List
+= string(I
.Name()) + " ";
232 ShowList(out
,"The following held packages will be changed:",List
);
235 // ShowEssential - Show an essential package warning /*{{{*/
236 // ---------------------------------------------------------------------
237 /* This prints out a warning message that is not to be ignored. It shows
238 all essential packages and their dependents that are to be removed.
239 It is insanely risky to remove the dependents of an essential package! */
240 void ShowEssential(ostream
&out
,pkgDepCache
&Dep
)
242 pkgCache::PkgIterator I
= Dep
.PkgBegin();
244 bool *Added
= new bool[Dep
.HeaderP
->PackageCount
];
245 for (int I
= 0; I
!= Dep
.HeaderP
->PackageCount
; I
++)
248 for (;I
.end() != true; I
++)
250 if ((I
->Flags
& pkgCache::Flag::Essential
) != pkgCache::Flag::Essential
)
253 // The essential package is being removed
254 if (Dep
[I
].Delete() == true)
256 if (Added
[I
->ID
] == false)
259 List
+= string(I
.Name()) + " ";
263 if (I
->CurrentVer
== 0)
266 // Print out any essential package depenendents that are to be removed
267 for (pkgDepCache::DepIterator D
= I
.CurrentVer().DependsList(); D
.end() == false; D
++)
269 pkgCache::PkgIterator P
= D
.SmartTargetPkg();
270 if (Dep
[P
].Delete() == true)
272 if (Added
[P
->ID
] == true)
275 List
+= string(P
.Name()) + " ";
280 if (List
.empty() == false)
281 out
<< "WARNING: The following essential packages will be removed" << endl
;
282 ShowList(out
,"This should NOT be done unless you know exactly what you are doing!",List
);
287 // Stats - Show some statistics /*{{{*/
288 // ---------------------------------------------------------------------
290 void Stats(ostream
&out
,pkgDepCache
&Dep
)
292 unsigned long Upgrade
= 0;
293 unsigned long Install
= 0;
294 for (pkgCache::PkgIterator I
= Dep
.PkgBegin(); I
.end() == false; I
++)
296 if (Dep
[I
].NewInstall() == true)
299 if (Dep
[I
].Upgrade() == true)
303 out
<< Upgrade
<< " packages upgraded, " <<
304 Install
<< " newly installed, " <<
305 Dep
.DelCount() << " to remove and " <<
306 Dep
.KeepCount() << " not upgraded." << endl
;
308 if (Dep
.BadCount() != 0)
309 out
<< Dep
.BadCount() << " packages not fully installed or removed." << endl
;
313 // class CacheFile - Cover class for some dependency cache functions /*{{{*/
314 // ---------------------------------------------------------------------
324 inline operator pkgDepCache
&() {return *Cache
;};
325 inline pkgDepCache
*operator ->() {return Cache
;};
326 inline pkgDepCache
&operator *() {return *Cache
;};
329 CacheFile() : File(0), Map(0), Cache(0) {};
338 // CacheFile::Open - Open the cache file /*{{{*/
339 // ---------------------------------------------------------------------
340 /* This routine generates the caches and then opens the dependency cache
341 and verifies that the system is OK. */
342 bool CacheFile::Open()
344 // Create a progress class
345 OpTextProgress
Progress(*_config
);
347 // Read the source list
349 if (List
.ReadMainList() == false)
350 return _error
->Error("The list of sources could not be read.");
352 // Build all of the caches
353 pkgMakeStatusCache(List
,Progress
);
354 if (_error
->PendingError() == true)
355 return _error
->Error("The package lists or status file could not be parsed or opened.");
359 // Open the cache file
360 File
= new FileFd(_config
->FindFile("Dir::Cache::pkgcache"),FileFd::ReadOnly
);
361 if (_error
->PendingError() == true)
364 Map
= new MMap(*File
,MMap::Public
| MMap::ReadOnly
);
365 if (_error
->PendingError() == true)
368 Cache
= new pkgDepCache(*Map
,Progress
);
369 if (_error
->PendingError() == true)
374 // Check that the system is OK
375 if (Cache
->DelCount() != 0 || Cache
->InstCount() != 0)
376 return _error
->Error("Internal Error, non-zero counts");
378 // Apply corrections for half-installed packages
379 if (pkgApplyStatus(*Cache
) == false)
383 if (Cache
->BrokenCount() == 0)
386 // Attempt to fix broken things
387 if (_config
->FindB("APT::Get::Fix-Broken",false) == true)
389 c1out
<< "Correcting dependencies..." << flush
;
390 if (pkgFixBroken(*Cache
) == false || Cache
->BrokenCount() != 0)
392 c1out
<< " failed." << endl
;
393 ShowBroken(c1out
,*this);
395 return _error
->Error("Unable to correct dependencies");
397 if (pkgMinimizeUpgrade(*Cache
) == false)
398 return _error
->Error("Unable to minimize the upgrade set");
400 c1out
<< " Done" << endl
;
404 c1out
<< "You might want to run `apt-get -f install' to correct these." << endl
;
405 ShowBroken(c1out
,*this);
407 return _error
->Error("Unmet dependencies. Try using -f.");
414 // InstallPackages - Actually download and install the packages /*{{{*/
415 // ---------------------------------------------------------------------
416 /* This displays the informative messages describing what is going to
417 happen and then calls the download routines */
418 bool InstallPackages(pkgDepCache
&Cache
,bool ShwKept
)
420 ShowDel(c1out
,Cache
);
421 ShowNew(c1out
,Cache
);
423 ShowKept(c1out
,Cache
);
424 ShowHold(c1out
,Cache
);
425 if (_config
->FindB("APT::Get::Show-Upgraded",false) == true)
426 ShowUpgraded(c1out
,Cache
);
427 ShowEssential(c1out
,Cache
);
431 if (Cache
.BrokenCount() != 0)
433 ShowBroken(c1out
,Cache
);
434 return _error
->Error("Internal Error, InstallPackages was called with broken packages!");
437 if (Cache
.DelCount() == 0 && Cache
.InstCount() == 0 &&
438 Cache
.BadCount() == 0)
445 // DoUpdate - Update the package lists /*{{{*/
446 // ---------------------------------------------------------------------
448 bool DoUpdate(CommandLine
&CmdL
)
452 // DoUpgrade - Upgrade all packages /*{{{*/
453 // ---------------------------------------------------------------------
454 /* Upgrade all packages without installing new packages or erasing old
456 bool DoUpgrade(CommandLine
&CmdL
)
459 if (Cache
.Open() == false)
463 pkgProblemResolver
Resolve(Cache
);
464 if (pkgAllUpgrade(Cache
) == false)
466 ShowBroken(c1out
,Cache
);
467 return _error
->Error("Internal Error, AllUpgrade broke stuff");
470 return InstallPackages(Cache
,true);
473 // DoInstall - Install packages from the command line /*{{{*/
474 // ---------------------------------------------------------------------
475 /* Install named packages */
476 bool DoInstall(CommandLine
&CmdL
)
479 if (Cache
.Open() == false)
482 int ExpectedInst
= 0;
484 pkgProblemResolver
Fix(Cache
);
486 bool DefRemove
= false;
487 if (strcasecmp(CmdL
.FileList
[0],"remove") == 0)
490 for (const char **I
= CmdL
.FileList
+ 1; *I
!= 0; I
++)
492 // Duplicate the string
493 unsigned int Length
= strlen(*I
);
495 if (Length
>= sizeof(S
))
499 // See if we are removing the package
500 bool Remove
= DefRemove
;
501 if (S
[Length
- 1] == '-')
506 if (S
[Length
- 1] == '+')
512 // Locate the package
513 pkgCache::PkgIterator Pkg
= Cache
->FindPkg(S
);
515 if (Pkg
.end() == true)
516 return _error
->Error("Couldn't find package %s",S
);
518 // Check if there is something new to install
519 pkgDepCache::StateCache
&State
= (*Cache
)[Pkg
];
520 if (State
.CandidateVer
== 0)
522 if (Pkg
->ProvidesList
!= 0)
524 c1out
<< "Package " << S
<< " is a virtual package provided by:" << endl
;
526 pkgCache::PrvIterator I
= Pkg
.ProvidesList();
527 for (; I
.end() == false; I
++)
529 pkgCache::PkgIterator Pkg
= I
.OwnerPkg();
531 if ((*Cache
)[Pkg
].CandidateVerIter(*Cache
) == I
.OwnerVer())
532 c1out
<< " " << Pkg
.Name() << " " << I
.OwnerVer().VerStr() << endl
;
534 if ((*Cache
)[Pkg
].InstVerIter(*Cache
) == I
.OwnerVer())
535 c1out
<< " " << Pkg
.Name() << " " << I
.OwnerVer().VerStr() <<
536 " [Installed]"<< endl
;
538 c1out
<< "You should explicly select one to install." << endl
;
542 c1out
<< "Package " << S
<< " has no available version, but exists in the database." << endl
;
543 c1out
<< "This typically means that the package was mentioned in a dependency and " << endl
;
544 c1out
<< "never uploaded, or that it is an obsolete package." << endl
;
547 return _error
->Error("Package %s has no installation candidate",S
);
554 Cache
->MarkDelete(Pkg
);
559 Cache
->MarkInstall(Pkg
,false);
560 if (State
.Install() == false)
561 c1out
<< "Sorry, " << S
<< " is already the newest version" << endl
;
565 // Install it with autoinstalling enabled.
566 if (State
.InstBroken() == true)
567 Cache
->MarkInstall(Pkg
,true);
570 // Call the scored problem resolver
571 Fix
.InstallProtect();
572 if (Fix
.Resolve(true) == false)
575 // Now we check the state of the packages,
576 if (Cache
->BrokenCount() != 0)
578 c1out
<< "Some packages could not be installed. This may mean that you have" << endl
;
579 c1out
<< "requested an impossible situation or if you are using the unstable" << endl
;
580 c1out
<< "distribution that some required packages have not yet been created" << endl
;
581 c1out
<< "or been moved out of Incoming." << endl
;
585 c1out
<< "Since you only requested a single operation it is extremely likely that" << endl
;
586 c1out
<< "the package is simply not installable and a bug report against" << endl
;
587 c1out
<< "that package should be filed." << endl
;
590 c1out
<< "The following information may help to resolve the situation:" << endl
;
592 ShowBroken(c1out
,Cache
);
593 return _error
->Error("Sorry, broken packages");
596 /* Print out a list of packages that are going to be installed extra
597 to what the user asked */
598 if (Cache
->InstCount() != ExpectedInst
)
601 pkgCache::PkgIterator I
= Cache
->PkgBegin();
602 for (;I
.end() != true; I
++)
604 if ((*Cache
)[I
].Install() == false)
608 for (J
= CmdL
.FileList
+ 1; *J
!= 0; J
++)
609 if (strcmp(*J
,I
.Name()) == 0)
613 List
+= string(I
.Name()) + " ";
616 ShowList(c1out
,"The following extra packages will be installed:",List
);
619 return InstallPackages(Cache
,false);
622 // DoDistUpgrade - Automatic smart upgrader /*{{{*/
623 // ---------------------------------------------------------------------
624 /* Intelligent upgrader that will install and remove packages at will */
625 bool DoDistUpgrade(CommandLine
&CmdL
)
628 if (Cache
.Open() == false)
631 c0out
<< "Calculating Upgrade... " << flush
;
632 if (pkgDistUpgrade(*Cache
) == false)
634 c0out
<< "Failed" << endl
;
635 ShowBroken(c1out
,Cache
);
639 c0out
<< "Done" << endl
;
641 return InstallPackages(Cache
,true);
644 // DoDSelectUpgrade - Do an upgrade by following dselects selections /*{{{*/
645 // ---------------------------------------------------------------------
646 /* Follows dselect's selections */
647 bool DoDSelectUpgrade(CommandLine
&CmdL
)
650 if (Cache
.Open() == false)
653 // Install everything with the install flag set
654 pkgCache::PkgIterator I
= Cache
->PkgBegin();
655 for (;I
.end() != true; I
++)
657 /* Install the package only if it is a new install, the autoupgrader
658 will deal with the rest */
659 if (I
->SelectedState
== pkgCache::State::Install
)
660 Cache
->MarkInstall(I
,false);
663 /* Now install their deps too, if we do this above then order of
664 the status file is significant for | groups */
665 for (I
= Cache
->PkgBegin();I
.end() != true; I
++)
667 /* Install the package only if it is a new install, the autoupgrader
668 will deal with the rest */
669 if (I
->SelectedState
== pkgCache::State::Install
)
670 Cache
->MarkInstall(I
);
673 // Apply erasures now, they override everything else.
674 for (I
= Cache
->PkgBegin();I
.end() != true; I
++)
677 if (I
->SelectedState
== pkgCache::State::DeInstall
||
678 I
->SelectedState
== pkgCache::State::Purge
)
679 Cache
->MarkDelete(I
);
682 /* Use updates smart upgrade to do the rest, it will automatically
684 if (pkgAllUpgrade(Cache
) == false)
686 ShowBroken(c1out
,Cache
);
687 return _error
->Error("Internal Error, AllUpgrade broke stuff");
690 return InstallPackages(Cache
,false);
693 // DoClean - Remove download archives /*{{{*/
694 // ---------------------------------------------------------------------
696 bool DoClean(CommandLine
&CmdL
)
701 // DoCheck - Perform the check operation /*{{{*/
702 // ---------------------------------------------------------------------
703 /* Opening automatically checks the system, this command is mostly used
705 bool DoCheck(CommandLine
&CmdL
)
714 // ShowHelp - Show a help screen /*{{{*/
715 // ---------------------------------------------------------------------
719 cout
<< PACKAGE
<< ' ' << VERSION
<< " for " << ARCHITECTURE
<<
720 " compiled on " << __DATE__
<< " " << __TIME__
<< endl
;
722 cout
<< "Usage: apt-get [options] command" << endl
;
723 cout
<< " apt-get [options] install pkg1 [pkg2 ...]" << endl
;
725 cout
<< "apt-get is a simple command line interface for downloading and" << endl
;
726 cout
<< "installing packages. The most frequently used commands are update" << endl
;
727 cout
<< "and install." << endl
;
729 cout
<< "Commands:" << endl
;
730 cout
<< " update - Retrieve new lists of packages" << endl
;
731 cout
<< " upgrade - Perform an upgrade" << endl
;
732 cout
<< " install - Install new packages (pkg is libc6 not libc6.deb)" << endl
;
733 cout
<< " remove - Remove packages" << endl
;
734 cout
<< " dist-upgrade - Distribution upgrade, see apt-get(8)" << endl
;
735 cout
<< " dselect-upgrade - Follow dselect selections" << endl
;
736 cout
<< " clean - Erase downloaded archive files" << endl
;
737 cout
<< " check - Verify that there are no broken dependencies" << endl
;
739 cout
<< "Options:" << endl
;
740 cout
<< " -h This help text." << endl
;
741 cout
<< " -q Loggable output - no progress indicator" << endl
;
742 cout
<< " -qq No output except for errors" << endl
;
743 cout
<< " -d Download only - do NOT install or unpack archives" << endl
;
744 cout
<< " -s No-act. Perform ordering simulation" << endl
;
745 cout
<< " -y Assume Yes to all queries and do not prompt" << endl
;
746 cout
<< " -f Attempt to continue if the integrity check fails" << endl
;
747 cout
<< " -m Attempt to continue if archives are unlocatable" << endl
;
748 cout
<< " -u Show a list of upgraded packages as well" << endl
;
749 cout
<< " -c=? Read this configuration file" << endl
;
750 cout
<< " -o=? Set an arbitary configuration option, ie -o dir::cache=/tmp" << endl
;
751 cout
<< "See the apt-get(8), sources.list(8) and apt.conf(8) manual" << endl
;
752 cout
<< "pages for more information." << endl
;
756 // GetInitialize - Initialize things for apt-get /*{{{*/
757 // ---------------------------------------------------------------------
761 _config
->Set("quiet",0);
762 _config
->Set("help",false);
763 _config
->Set("APT::Get::Download-Only",false);
764 _config
->Set("APT::Get::Simulate",false);
765 _config
->Set("APT::Get::Assume-Yes",false);
766 _config
->Set("APT::Get::Fix-Broken",false);
770 int main(int argc
,const char *argv
[])
772 CommandLine::Args Args
[] = {
773 {'h',"help","help",0},
774 {'q',"quiet","quiet",CommandLine::IntLevel
},
775 {'q',"silent","quiet",CommandLine::IntLevel
},
776 {'d',"download-only","APT::Get::Download-Only",0},
777 {'s',"simulate","APT::Get::Simulate",0},
778 {'s',"just-print","APT::Get::Simulate",0},
779 {'s',"recon","APT::Get::Simulate",0},
780 {'s',"no-act","APT::Get::Simulate",0},
781 {'y',"yes","APT::Get::Assume-Yes",0},
782 {'y',"assume-yes","APT::Get::Assume-Yes",0},
783 {'f',"fix-broken","APT::Get::Fix-Broken",0},
784 {'u',"show-upgraded","APT::Get::Show-Upgraded",0},
785 {'m',"ignore-missing","APT::Get::Fix-Broken",0},
786 {'c',"config-file",0,CommandLine::ConfigFile
},
787 {'o',"option",0,CommandLine::ArbItem
},
790 // Parse the command line and initialize the package library
791 CommandLine
CmdL(Args
,_config
);
792 if (pkgInitialize(*_config
) == false ||
793 CmdL
.Parse(argc
,argv
) == false)
795 _error
->DumpErrors();
799 // See if the help should be shown
800 if (_config
->FindB("help") == true ||
801 CmdL
.FileSize() == 0)
804 // Setup the output streams
805 c0out
.rdbuf(cout
.rdbuf());
806 c1out
.rdbuf(cout
.rdbuf());
807 c2out
.rdbuf(cout
.rdbuf());
808 if (_config
->FindI("quiet",0) > 0)
809 c0out
.rdbuf(devnull
.rdbuf());
810 if (_config
->FindI("quiet",0) > 1)
811 c1out
.rdbuf(devnull
.rdbuf());
813 // Match the operation
817 bool (*Handler
)(CommandLine
&);
818 } Map
[] = {{"update",&DoUpdate
},
819 {"upgrade",&DoUpgrade
},
820 {"install",&DoInstall
},
821 {"remove",&DoInstall
},
822 {"dist-upgrade",&DoDistUpgrade
},
823 {"dselect-upgrade",&DoDSelectUpgrade
},
828 for (I
= 0; Map
[I
].Match
!= 0; I
++)
830 if (strcmp(CmdL
.FileList
[0],Map
[I
].Match
) == 0)
832 Map
[I
].Handler(CmdL
);
838 if (Map
[I
].Match
== 0)
839 _error
->Error("Invalid operation %s", CmdL
.FileList
[0]);
841 // Print any errors or warnings found during parsing
842 if (_error
->empty() == false)
844 bool Errors
= _error
->PendingError();
845 _error
->DumpErrors();
847 cout
<< "Returning 100." << endl
;
848 return Errors
== true?100:0;