Explorar o código

merged from debian-sid

Michael Vogt %!s(int64=17) %!d(string=hai) anos
pai
achega
5772271425
Modificáronse 100 ficheiros con 10849 adicións e 5420 borrados
  1. 0 4
      .cvsignore
  2. 16 135
      COPYING
  3. 1 1
      apt-inst/contrib/arfile.cc
  4. 40 62
      apt-pkg/acquire-item.cc
  5. 22 22
      apt-pkg/acquire-item.h
  6. 0 2
      apt-pkg/acquire-method.cc
  7. 2 5
      apt-pkg/acquire.cc
  8. 13 13
      apt-pkg/acquire.h
  9. 73 37
      apt-pkg/algorithms.cc
  10. 4 4
      apt-pkg/algorithms.h
  11. 4 5
      apt-pkg/cachefile.cc
  12. 30 20
      apt-pkg/cacheiterators.h
  13. 92 12
      apt-pkg/cdrom.cc
  14. 39 3
      apt-pkg/cdrom.h
  15. 0 1
      apt-pkg/clean.cc
  16. 10 3
      apt-pkg/contrib/cdromutl.cc
  17. 2 1
      apt-pkg/contrib/cdromutl.h
  18. 4 3
      apt-pkg/contrib/configuration.cc
  19. 7 6
      apt-pkg/contrib/error.cc
  20. 13 11
      apt-pkg/contrib/hashes.cc
  21. 9 4
      apt-pkg/contrib/md5.cc
  22. 86 34
      apt-pkg/contrib/mmap.cc
  23. 2 0
      apt-pkg/contrib/mmap.h
  24. 13 19
      apt-pkg/contrib/sha256.cc
  25. 11 0
      apt-pkg/contrib/strutl.cc
  26. 2 0
      apt-pkg/contrib/strutl.h
  27. 4 0
      apt-pkg/deb/deblistparser.cc
  28. 7 0
      apt-pkg/deb/debmetaindex.cc
  29. 1 0
      apt-pkg/deb/debmetaindex.h
  30. 8 0
      apt-pkg/deb/debsrcrecords.cc
  31. 1 0
      apt-pkg/deb/debsrcrecords.h
  32. 2 2
      apt-pkg/deb/debsystem.cc
  33. 117 60
      apt-pkg/depcache.cc
  34. 47 4
      apt-pkg/depcache.h
  35. 8 8
      apt-pkg/indexcopy.cc
  36. 10 12
      apt-pkg/indexcopy.h
  37. 0 1
      apt-pkg/indexfile.cc
  38. 7 7
      apt-pkg/indexrecords.cc
  39. 13 5
      apt-pkg/init.cc
  40. 1 1
      apt-pkg/init.h
  41. 2 2
      apt-pkg/makefile
  42. 7 1
      apt-pkg/metaindex.h
  43. 2 8
      apt-pkg/orderlist.cc
  44. 1 3
      apt-pkg/packagemanager.cc
  45. 55 2
      apt-pkg/pkgcache.cc
  46. 26 25
      apt-pkg/pkgcache.h
  47. 23 19
      apt-pkg/pkgcachegen.cc
  48. 4 4
      apt-pkg/pkgcachegen.h
  49. 4 4
      apt-pkg/pkgrecords.h
  50. 82 2
      apt-pkg/policy.cc
  51. 1 0
      apt-pkg/policy.h
  52. 6 2
      apt-pkg/sourcelist.cc
  53. 16 5
      apt-pkg/tagfile.cc
  54. 4 1
      apt-pkg/tagfile.h
  55. 10 9
      apt-pkg/vendorlist.cc
  56. 24 13
      apt-pkg/versionmatch.cc
  57. 13 8
      apt-pkg/versionmatch.h
  58. 9 14
      cmdline/apt-cache.cc
  59. 3 7
      cmdline/apt-cdrom.cc
  60. 2 2
      cmdline/apt-config.cc
  61. 2 2
      cmdline/apt-extracttemplates.cc
  62. 29 16
      cmdline/apt-get.cc
  63. 4 4
      cmdline/apt-sortpkgs.cc
  64. 1 1
      configure.in
  65. 0 13
      debian/.cvsignore
  66. 27 2
      debian/apt.cron.daily
  67. 1 0
      debian/apt.dirs
  68. 160 54
      debian/changelog
  69. 2 2
      debian/control
  70. 0 14
      doc/.cvsignore
  71. 15 2
      doc/apt-get.8.xml
  72. 37 4
      doc/apt.conf.5.xml
  73. 7 0
      doc/apt.ent
  74. 86 4
      doc/apt_preferences.5.xml
  75. 0 14
      doc/es/.cvsignore
  76. 9 2
      doc/examples/configure-index
  77. 0 13
      doc/fr/.cvsignore
  78. 1 1
      doc/fr/apt-get.fr.8.xml
  79. 424 110
      doc/fr/apt.conf.fr.5.xml
  80. 0 3
      doc/pt_BR/.cvsignore
  81. 104 25
      methods/cdrom.cc
  82. 2 2
      methods/makefile
  83. 72 0
      po/ChangeLog
  84. 462 363
      po/apt-all.pot
  85. 372 276
      po/ar.po
  86. 2999 0
      po/ast.po
  87. 382 329
      po/bg.po
  88. 362 276
      po/bs.po
  89. 443 294
      po/ca.po
  90. 378 277
      po/cs.po
  91. 375 276
      po/cy.po
  92. 377 317
      po/da.po
  93. 388 293
      po/de.po
  94. 374 312
      po/dz.po
  95. 374 312
      po/el.po
  96. 378 277
      po/en_GB.po
  97. 383 283
      po/es.po
  98. 422 281
      po/eu.po
  99. 382 328
      po/fi.po
  100. 0 0
      po/fr.po

+ 0 - 4
.cvsignore

@@ -1,4 +0,0 @@
-autom4te.cache
-aclocal.m4
-configure
-build

+ 16 - 135
COPYING

@@ -1,142 +1,23 @@
 Apt is copyright 1997, 1998, 1999 Jason Gunthorpe and others.
+Apt is currently developed by APT Development Team <deity@lists.debian.org>.
 
-Apt is licensed under the terms of the GNU General Public License (GPL),
-version 2.0 or later, as published by the Free Software Foundation.  See
-the file COPYING.GPL [included], /usr/share/common-licenses/GPL, or
-<http://www.gnu.org/copyleft/gpl.txt> for the terms of the latest version
-of the GNU General Public License.
-
-In addition, prior to November 15th, 2000, apt may be distributed under
-terms identical to the above with the following addition:
-
-Works using apt may link against the GUI library "libqt", copyright by
-Troll Tech AS, Norway, provided that:
-
-1. The version of "libqt" is licensed under the terms of the "Qt Free Edition
-   License" published by Troll Tech AS.  The license terms identified as
-   the Qt Free Edition License below are the only such terms under which
-   distribution of works derived from both apt and "libqt" are permitted;
-
-and
-
-2. The source code of the version of "libqt" used is
-
-   a) Distributed with the binary version;
-
-   or
-
-   b) Downloadable by anyone, without fee, using a publicly-announced
-      URL on the Internet, for a duration of at least three years
-      starting with distribution of the binary version.
-
-On and after November 15th, 2000, the above additional terms lose all
-force, and apt will be licensed only under the terms of the GNU General
-Public License, version 2.0 or later.
-
-      _______________________________________________________________
-
-The following text, up to the text of the Qt Free Edition License, is
-informational and not part of the license terms on apt.
-
-Modifications to apt in either source or compiled form must be licensed
-under the terms of the GNU General Public License, version 2.0 (or later),
-but need not include the above clause permitting usage of the "libqt"
-library under the Qt Free Edition License.  Note that removal of this
-clause will result in software which is not licensed for binary
-redistribution linked against software governed by the Qt Free Edition
-License.  In the event that a version of "libqt" is released that is
-licensed under terms that do not conflict with the GPL, the additional
-clause above is not required to grant permission for distribution of works
-that are derived from both apt and "libqt".
-
-No part of apt is licensed under the Qt Free Edition License.  The terms
-below are provided to help identify the circumstances under which the
-"libqt" library may be used with apt (or a work derived from both).  The
-terms below are copied from the LICENSE file of the qt-1.44 distribution,
-as of November 10th, 1999.
-
-      _______________________________________________________________
-
-                        QT FREE EDITION LICENSE
+License: GPLv2+
 
-Copyright (C) 1992-1999 Troll Tech AS. All rights reserved. 
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
 
-This is the license for Qt Free Edition version 1.44; it covers private use,
-use of third-party application programs based on Qt, and development of
-free software for the free software community. 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-                      COPYRIGHT AND RESTRICTIONS
-
-The Qt toolkit is a product of Troll Tech AS. The Qt Free Edition is limited
-to use with the X Window System. 
-
-You may copy this version of the Qt Free Edition provided that the entire
-archive is distributed unchanged and as a whole, including this notice. 
-
-You may use this version of the Qt Free Edition to compile, link and run
-application programs legally developed by third parties. 
-
-You may use the Qt Free Edition to create application programs
-provided that: 
-
-      You accept this license. 
-      Your software does not require modifications to Qt Free Edition.
-      You satisfy ONE of the following three requirements 
-      EITHER 
-            Users of your software can freely obtain source code for the
-            software, freely modify the source code (possibly with
-            restrictions on copyright notices, attributions and legal
-            responsibility), and freely redistribute original or modified
-            versions of the software. 
-      OR 
-            Your software is distributed under the GNU GENERAL
-            PUBLIC LICENSE, version 2 or later, as defined by the
-            Free Software Foundation. 
-      OR 
-            Your software is distributed under the GNU LIBRARY
-            GENERAL PUBLIC LICENSE, version 2 or later, as
-            defined by the Free Software Foundation. 
-
-If you are paid to develop something with Qt Free Edition or it is a part of
-your job the following conditions also apply: 
-
-      Your software must not require libraries, programs, data or
-      documentation that are not available outside your organization in
-      order to compile or use. 
-      If and when your organization starts using the software, you must
-      notify Troll Tech AS of the following: 
-            Your organization's name and purpose. 
-            The software's name and purpose. 
-            The software's license. 
-            That your organization considers the software to be free
-            software. 
-
-You may also use the Qt Free Edition to create reusable components
-(such as libraries) provided that you accept the terms above, and in
-addition that: 
-
-      Your components' license includes the following text: 
-
-            [Your package] requires the Qt library, which is
-            copyright Troll Tech AS. Freely distributable
-            programs may generally use Qt Free Edition free of
-            charge, see [README.QT] for details. 
-
-      README.QT is distributed along with your components. 
-      Qt Free Edition is not distributed as an integral part of your
-      components. 
-
-                       LIMITATIONS OF LIABILITY
-
-Troll Tech AS makes no obligation under this license to support or
-upgrade Qt Free Edition, or assist in the use of Qt Free Edition. 
-
-In no event shall Troll Tech AS be liable for any lost revenue or profits or
-other direct, indirect, special, incidental or consequential damages, even
-if Troll Tech has been advised of the possibility of such damages. 
+See /usr/share/common-licenses/GPL-2, or
+<http://www.gnu.org/copyleft/gpl.txt> for the terms of the latest version
+of the GNU General Public License.
 
-QT FREE EDITION IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND,
-INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE.
-      _______________________________________________________________

+ 1 - 1
apt-inst/contrib/arfile.cc

@@ -111,7 +111,7 @@ bool ARArchive::LoadHeaders()
       else
       {
 	 unsigned int I = sizeof(Head.Name) - 1;
-	 for (; Head.Name[I] == ' '; I--);
+	 for (; Head.Name[I] == ' ' || Head.Name[I] == '/'; I--);
 	 Memb->Name = string(Head.Name,I+1);
       }
 

+ 40 - 62
apt-pkg/acquire-item.cc

@@ -131,9 +131,7 @@ void pkgAcquire::Item::Rename(string From,string To)
    }   
 }
 									/*}}}*/
-
-
-// AcqDiffIndex::AcqDiffIndex - Constructor			
+// AcqDiffIndex::AcqDiffIndex - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 /* Get the DiffIndex file first and see if there are patches availabe 
  * If so, create a pkgAcqIndexDiffs fetcher that will get and apply the
@@ -184,7 +182,7 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
    QueueURI(Desc);
 
 }
-
+									/*}}}*/
 // AcqIndex::Custom600Headers - Insert custom request headers		/*{{{*/
 // ---------------------------------------------------------------------
 /* The only header we use is the last-modified header. */
@@ -202,9 +200,8 @@ string pkgAcqDiffIndex::Custom600Headers()
    
    return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
-
-
-bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)
+									/*}}}*/
+bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)		/*{{{*/
 {
    if(Debug)
       std::clog << "pkgAcqIndexDiffs::ParseIndexDiff() " << IndexDiffFile 
@@ -291,8 +288,8 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)
       std::clog << "Can't find a patch in the index file" << std::endl;
    return false;
 }
-
-void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+									/*}}}*/
+void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)	/*{{{*/
 {
    if(Debug)
       std::clog << "pkgAcqDiffIndex failed: " << Desc.URI << std::endl
@@ -305,8 +302,8 @@ void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    Status = StatDone;
    Dequeue();
 }
-
-void pkgAcqDiffIndex::Done(string Message,unsigned long Size,string Md5Hash,
+									/*}}}*/
+void pkgAcqDiffIndex::Done(string Message,unsigned long Size,string Md5Hash,	/*{{{*/
 			   pkgAcquire::MethodConfig *Cnf)
 {
    if(Debug)
@@ -335,10 +332,8 @@ void pkgAcqDiffIndex::Done(string Message,unsigned long Size,string Md5Hash,
    Dequeue();
    return;
 }
-
-
-
-// AcqIndexDiffs::AcqIndexDiffs - Constructor			
+									/*}}}*/
+// AcqIndexDiffs::AcqIndexDiffs - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 /* The package diff is added to the queue. one object is constructed
  * for each diff and the index
@@ -372,9 +367,8 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
       QueueNextDiff();
    }
 }
-
-
-void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+									/*}}}*/
+void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)	/*{{{*/
 {
    if(Debug)
       std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << std::endl
@@ -383,9 +377,8 @@ void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 		   ExpectedHash);
    Finish();
 }
-
-
-// helper that cleans the item out of the fetcher queue
+									/*}}}*/
+// Finish - helper that cleans the item out of the fetcher queue	/*{{{*/
 void pkgAcqIndexDiffs::Finish(bool allDone)
 {
    // we restore the original name, this is required, otherwise
@@ -420,10 +413,8 @@ void pkgAcqIndexDiffs::Finish(bool allDone)
    Dequeue();
    return;
 }
-
-
-
-bool pkgAcqIndexDiffs::QueueNextDiff()
+									/*}}}*/
+bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
 {
 
    // calc sha1 of the just patched file
@@ -469,10 +460,8 @@ bool pkgAcqIndexDiffs::QueueNextDiff()
 
    return true;
 }
-
-
-
-void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash,
+									/*}}}*/
+void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash,	/*{{{*/
 			    pkgAcquire::MethodConfig *Cnf)
 {
    if(Debug)
@@ -543,8 +532,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash,
 	 return Finish(true);
    }
 }
-
-
+									/*}}}*/
 // AcqIndex::AcqIndex - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 /* The package file is added to the queue and a second class is 
@@ -594,8 +582,7 @@ string pkgAcqIndex::Custom600Headers()
    return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
 									/*}}}*/
-
-void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)	/*{{{*/
 {
    bool descChanged = false;
    // no .bz2 found, retry with .gz
@@ -630,8 +617,7 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 
    Item::Failed(Message,Cnf);
 }
-
-
+									/*}}}*/
 // AcqIndex::Done - Finished a fetch					/*{{{*/
 // ---------------------------------------------------------------------
 /* This goes through a number of states.. On the initial fetch the
@@ -735,7 +721,7 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
    QueueURI(Desc);
    Mode = decompProg;
 }
-
+									/*}}}*/
 // AcqIndexTrans::pkgAcqIndexTrans - Constructor			/*{{{*/
 // ---------------------------------------------------------------------
 /* The Translation file is added to the queue */
@@ -744,7 +730,6 @@ pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
   : pkgAcqIndex(Owner, URI, URIDesc, ShortDesc, HashString(), "")
 {
 }
-
 									/*}}}*/
 // AcqIndexTrans::Failed - Silence failure messages for missing files	/*{{{*/
 // ---------------------------------------------------------------------
@@ -764,8 +749,7 @@ void pkgAcqIndexTrans::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    Item::Failed(Message,Cnf);
 }
 									/*}}}*/
-
-pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
+pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,				/*{{{*/
 			     string URI,string URIDesc,string ShortDesc,
 			     string MetaIndexURI, string MetaIndexURIDesc,
 			     string MetaIndexShortDesc,
@@ -854,7 +838,7 @@ void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5,
 
 }
 									/*}}}*/
-void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/
 {
    string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI);
 
@@ -890,8 +874,8 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    
    Item::Failed(Message,Cnf);
 }
-
-pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner,
+									/*}}}*/
+pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner,			/*{{{*/
 				 string URI,string URIDesc,string ShortDesc,
 				 string SigFile,
 				 const vector<struct IndexTarget*>* IndexTargets,
@@ -910,7 +894,6 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner,
 
    QueueURI(Desc);
 }
-
 									/*}}}*/
 // pkgAcqMetaIndex::Custom600Headers - Insert custom request headers	/*{{{*/
 // ---------------------------------------------------------------------
@@ -926,8 +909,8 @@ string pkgAcqMetaIndex::Custom600Headers()
    
    return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }
-
-void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash,
+									/*}}}*/
+void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash,	/*{{{*/
 			   pkgAcquire::MethodConfig *Cfg)
 {
    Item::Done(Message,Size,Hash,Cfg);
@@ -968,8 +951,8 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash,
       }
    }
 }
-
-void pkgAcqMetaIndex::RetrievalDone(string Message)
+									/*}}}*/
+void pkgAcqMetaIndex::RetrievalDone(string Message)			/*{{{*/
 {
    // We have just finished downloading a Release file (it is not
    // verified yet)
@@ -1007,8 +990,8 @@ void pkgAcqMetaIndex::RetrievalDone(string Message)
    chmod(FinalFile.c_str(),0644);
    DestFile = FinalFile;
 }
-
-void pkgAcqMetaIndex::AuthDone(string Message)
+									/*}}}*/
+void pkgAcqMetaIndex::AuthDone(string Message)				/*{{{*/
 {
    // At this point, the gpgv method has succeeded, so there is a
    // valid signature from a key in the trusted keyring.  We
@@ -1041,8 +1024,8 @@ void pkgAcqMetaIndex::AuthDone(string Message)
    Rename(SigFile,VerifiedSigFile);
    chmod(VerifiedSigFile.c_str(),0644);
 }
-
-void pkgAcqMetaIndex::QueueIndexes(bool verify)
+									/*}}}*/
+void pkgAcqMetaIndex::QueueIndexes(bool verify)				/*{{{*/
 {
    for (vector <struct IndexTarget*>::const_iterator Target = IndexTargets->begin();
         Target != IndexTargets->end();
@@ -1084,8 +1067,8 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify)
 			    (*Target)->ShortDesc, ExpectedIndexHash);
    }
 }
-
-bool pkgAcqMetaIndex::VerifyVendor(string Message)
+									/*}}}*/
+bool pkgAcqMetaIndex::VerifyVendor(string Message)			/*{{{*/
 {
 //    // Maybe this should be made available from above so we don't have
 //    // to read and parse it every time?
@@ -1171,9 +1154,8 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message)
 
    return true;
 }
-       								/*}}}*/
-// pkgAcqMetaIndex::Failed - no Release file present or no signature
-//      file present	                                        /*{{{*/
+									/*}}}*/
+// pkgAcqMetaIndex::Failed - no Release file present or no signature file present	/*{{{*/
 // ---------------------------------------------------------------------
 /* */
 void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
@@ -1210,9 +1192,7 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    // back to queueing Packages files without verification
    QueueIndexes(false);
 }
-
 									/*}}}*/
-
 // AcqArchive::AcqArchive - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 /* This just sets up the initial fetch environment and queues the first
@@ -1495,14 +1475,13 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    }
 }
 									/*}}}*/
-// AcqArchive::IsTrusted - Determine whether this archive comes from a
-// trusted source							/*{{{*/
+// AcqArchive::IsTrusted - Determine whether this archive comes from a trusted source /*{{{*/
 // ---------------------------------------------------------------------
 bool pkgAcqArchive::IsTrusted()
 {
    return Trusted;
 }
-
+									/*}}}*/
 // AcqArchive::Finished - Fetching has finished, tidy up		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -1514,7 +1493,6 @@ void pkgAcqArchive::Finished()
    StoreFilename = string();
 }
 									/*}}}*/
-
 // AcqFile::pkgAcqFile - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 /* The file is added to the queue */

+ 22 - 22
apt-pkg/acquire-item.h

@@ -34,7 +34,7 @@
  *  \file acquire-item.h
  */
 
-/** \brief Represents the process by which a pkgAcquire object should
+/** \brief Represents the process by which a pkgAcquire object should	{{{
  *  retrieve a file or a collection of files.
  *
  *  By convention, Item subclasses should insert themselves into the
@@ -261,8 +261,8 @@ class pkgAcquire::Item
     */
    virtual ~Item();
 };
-
-/** \brief Information about an index patch (aka diff). */
+									/*}}}*/
+/** \brief Information about an index patch (aka diff). */		/*{{{*/
 struct DiffInfo {
    /** The filename of the diff. */
    string file;
@@ -273,8 +273,8 @@ struct DiffInfo {
    /** The size of the diff. */
    unsigned long size;
 };
-
-/** \brief An item that is responsible for fetching an index file of
+									/*}}}*/
+/** \brief An item that is responsible for fetching an index file of	{{{
  *  package list diffs and starting the package list's download.
  *
  *  This item downloads the Index file and parses it, then enqueues
@@ -348,8 +348,8 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
    pkgAcqDiffIndex(pkgAcquire *Owner,string URI,string URIDesc,
 		   string ShortDesc, HashString ExpectedHash);
 };
-
-/** \brief An item that is responsible for fetching all the patches
+									/*}}}*/
+/** \brief An item that is responsible for fetching all the patches	{{{
  *  that need to be applied to a given package index file.
  *
  *  After downloading and applying a single patch, this item will
@@ -477,8 +477,8 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
 		    string ShortDesc, HashString ExpectedHash,
 		    vector<DiffInfo> diffs=vector<DiffInfo>());
 };
-
-/** \brief An acquire item that is responsible for fetching an index
+									/*}}}*/
+/** \brief An acquire item that is responsible for fetching an index	{{{
  *  file (e.g., Packages or Sources).
  *
  *  \sa pkgAcqDiffIndex, pkgAcqIndexDiffs, pkgAcqIndexTrans
@@ -545,8 +545,8 @@ class pkgAcqIndex : public pkgAcquire::Item
    pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc,
 	       string ShortDesc, HashString ExpectedHash, string compressExt="");
 };
-
-/** \brief An acquire item that is responsible for fetching a
+									/*}}}*/
+/** \brief An acquire item that is responsible for fetching a		{{{
  *  translated index file.
  *
  *  The only difference from pkgAcqIndex is that transient failures
@@ -579,8 +579,8 @@ class pkgAcqIndexTrans : public pkgAcqIndex
    pkgAcqIndexTrans(pkgAcquire *Owner,string URI,string URIDesc,
 		    string ShortDesc);
 };
-
-/** \brief Information about an index file. */
+									/*}}}*/
+/** \brief Information about an index file. */				/*{{{*/
 struct IndexTarget
 {
    /** \brief A URI from which the index file can be downloaded. */
@@ -597,8 +597,8 @@ struct IndexTarget
     */
    string MetaKey;
 };
-
-/** \brief An acquire item that downloads the detached signature
+									/*}}}*/
+/** \brief An acquire item that downloads the detached signature	{{{
  *  of a meta-index (Release) file, then queues up the release
  *  file itself.
  *
@@ -660,8 +660,8 @@ class pkgAcqMetaSig : public pkgAcquire::Item
 		 const vector<struct IndexTarget*>* IndexTargets,
 		 indexRecords* MetaIndexParser);
 };
-
-/** \brief An item that is responsible for downloading the meta-index
+									/*}}}*/
+/** \brief An item that is responsible for downloading the meta-index	{{{
  *  file (i.e., Release) itself and verifying its signature.
  *
  *  Once the download and verification are complete, the downloads of
@@ -756,8 +756,8 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
 		   const vector<struct IndexTarget*>* IndexTargets,
 		   indexRecords* MetaIndexParser);
 };
-
-/** \brief An item that is responsible for fetching a package file.
+									/*}}}*/
+/** \brief An item that is responsible for fetching a package file.	{{{
  *
  *  If the package file already exists in the cache, nothing will be
  *  done.
@@ -840,8 +840,8 @@ class pkgAcqArchive : public pkgAcquire::Item
 		 pkgRecords *Recs,pkgCache::VerIterator const &Version,
 		 string &StoreFilename);
 };
-
-/** \brief Retrieve an arbitrary file to the current directory.
+									/*}}}*/
+/** \brief Retrieve an arbitrary file to the current directory.		{{{
  *
  *  The file is retrieved even if it is accessed via a URL type that
  *  normally is a NOP, such as "file".  If the download fails, the
@@ -902,7 +902,7 @@ class pkgAcqFile : public pkgAcquire::Item
 	      string Desc, string ShortDesc,
 	      const string &DestDir="", const string &DestFilename="");
 };
-
+									/*}}}*/
 /** @} */
 
 #endif

+ 0 - 2
apt-pkg/acquire-method.cc

@@ -446,7 +446,6 @@ void pkgAcqMethod::Status(const char *Format,...)
       exit(100);
 }
 									/*}}}*/
-
 // AcqMethod::Redirect - Send a redirect message                       /*{{{*/
 // ---------------------------------------------------------------------
 /* This method sends the redirect message and also manipulates the queue
@@ -478,7 +477,6 @@ void pkgAcqMethod::Redirect(const string &NewURI)
       QueueBack = I->Next;
 }
                                                                         /*}}}*/
-
 // AcqMethod::FetchResult::FetchResult - Constructor			/*{{{*/
 // ---------------------------------------------------------------------
 /* */

+ 2 - 5
apt-pkg/acquire.cc

@@ -266,7 +266,7 @@ pkgAcquire::MethodConfig *pkgAcquire::GetConfig(string Access)
       return 0;
 
    /* if a method uses DownloadLimit, we switch to SingleInstance mode */
-   if(_config->FindI("Acquire::"+Access+"::DlLimit",0) > 0)
+   if(_config->FindI("Acquire::"+Access+"::Dl-Limit",0) > 0)
       Conf->SingleInstance = true;
     
    return Conf;
@@ -485,7 +485,7 @@ double pkgAcquire::PartialPresent()
 	 Total += (*I)->PartialSize;
    return Total;
 }
-
+									/*}}}*/
 // Acquire::UriBegin - Start iterator for the uri list			/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -502,7 +502,6 @@ pkgAcquire::UriIterator pkgAcquire::UriEnd()
    return UriIterator(0);
 }
 									/*}}}*/
-
 // Acquire::MethodConfig::MethodConfig - Constructor			/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -516,7 +515,6 @@ pkgAcquire::MethodConfig::MethodConfig()
    Next = 0;
 }
 									/*}}}*/
-
 // Queue::Queue - Constructor						/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -728,7 +726,6 @@ void pkgAcquire::Queue::Bump()
    Cycle();
 }
 									/*}}}*/
-
 // AcquireStatus::pkgAcquireStatus - Constructor			/*{{{*/
 // ---------------------------------------------------------------------
 /* */

+ 13 - 13
apt-pkg/acquire.h

@@ -30,7 +30,7 @@
    ##################################################################### */
 									/*}}}*/
 
-/** \defgroup acquire Acquire system
+/** \defgroup acquire Acquire system					{{{
  *
  *  \brief The Acquire system is responsible for retrieving files from
  *  local or remote URIs and postprocessing them (for instance,
@@ -54,7 +54,7 @@
  *  once, but it is not clear what its behavior in this case is, and
  *  no subclass of pkgAcquire::Item seems to actually use this
  *  capability.
- */
+ */									/*}}}*/
 
 /** \addtogroup acquire
  *
@@ -78,7 +78,7 @@ using std::string;
 
 class pkgAcquireStatus;
 
-/** \brief The core download scheduler.
+/** \brief The core download scheduler.					{{{
  *
  *  This class represents an ongoing download.  It manages the lists
  *  of active and pending downloads and handles setting up and tearing
@@ -366,8 +366,8 @@ struct pkgAcquire::ItemDesc
    /** brief The underlying item which is to be downloaded. */
    Item *Owner;
 };
-
-/** \brief A single download queue in a pkgAcquire object.
+									/*}}}*/
+/** \brief A single download queue in a pkgAcquire object.		{{{
  *
  *  \todo Why so many protected values?
  */
@@ -528,8 +528,8 @@ class pkgAcquire::Queue
     */
    ~Queue();
 };
-
-/** \brief Iterates over all the URIs being fetched by a pkgAcquire object. */
+									/*}}}*/
+/** \brief Iterates over all the URIs being fetched by a pkgAcquire object.	{{{*/
 class pkgAcquire::UriIterator
 {
    /** The next queue to iterate over. */
@@ -539,7 +539,7 @@ class pkgAcquire::UriIterator
    
    public:
    
-   inline void operator ++() {operator ++();};
+   inline void operator ++() {operator ++(0);};
 
    void operator ++(int)
    {
@@ -568,8 +568,8 @@ class pkgAcquire::UriIterator
       }
    }   
 };
-
-/** \brief Information about the properties of a single acquire method. */
+									/*}}}*/
+/** \brief Information about the properties of a single acquire method.	{{{*/
 struct pkgAcquire::MethodConfig
 {
    /** \brief The next link on the acquire method list.
@@ -621,8 +621,8 @@ struct pkgAcquire::MethodConfig
     */
    MethodConfig();
 };
-
-/** \brief A monitor object for downloads controlled by the pkgAcquire class.
+									/*}}}*/
+/** \brief A monitor object for downloads controlled by the pkgAcquire class.	{{{
  *
  *  \todo Why protected members?
  *
@@ -762,7 +762,7 @@ class pkgAcquireStatus
    pkgAcquireStatus();
    virtual ~pkgAcquireStatus() {};
 };
-
+									/*}}}*/
 /** @} */
 
 #endif

+ 73 - 37
apt-pkg/algorithms.cc

@@ -442,7 +442,6 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache)
    return true;
 }
 									/*}}}*/
-
 // ProblemResolver::pkgProblemResolver - Constructor			/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -489,6 +488,36 @@ void pkgProblemResolver::MakeScores()
    unsigned long Size = Cache.Head().PackageCount;
    memset(Scores,0,sizeof(*Scores)*Size);
 
+   // Important Required Standard Optional Extra
+   signed short PrioMap[] = {
+      0,
+      _config->FindI("pkgProblemResolver::Scores::Important",3),
+      _config->FindI("pkgProblemResolver::Scores::Required",2),
+      _config->FindI("pkgProblemResolver::Scores::Standard",1),
+      _config->FindI("pkgProblemResolver::Scores::Optional",-1),
+      _config->FindI("pkgProblemResolver::Scores::Extra",-2)
+   };
+   signed short PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100);
+   signed short PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1);
+   signed short PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1);
+   signed short PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1);
+   signed short AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000);
+   signed short AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000);
+
+   if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true)
+      clog << "Settings used to calculate pkgProblemResolver::Scores::" << endl
+         << "  Important => " << PrioMap[1] << endl
+         << "  Required => " << PrioMap[2] << endl
+         << "  Standard => " << PrioMap[3] << endl
+         << "  Optional => " << PrioMap[4] << endl
+         << "  Extra => " << PrioMap[5] << endl
+         << "  Essentials => " << PrioEssentials << endl
+         << "  InstalledAndNotObsolete => " << PrioInstalledAndNotObsolete << endl
+         << "  Depends => " << PrioDepends << endl
+         << "  Recommends => " << PrioRecommends << endl
+         << "  AddProtected => " << AddProtected << endl
+         << "  AddEssential => " << AddEssential << endl;
+
    // Generate the base scores for a package based on its properties
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
@@ -502,11 +531,9 @@ void pkgProblemResolver::MakeScores()
 	 to allow an obsolete essential packages to be removed by
 	 a conflicts on a powerfull normal package (ie libc6) */
       if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
-	 Score += 100;
+	 Score += PrioEssentials;
 
       // We transform the priority
-      // Important Required Standard Optional Extra
-      signed short PrioMap[] = {0,3,2,1,-1,-2};
       if (Cache[I].InstVerIter(Cache)->Priority <= 5)
 	 Score += PrioMap[Cache[I].InstVerIter(Cache)->Priority];
       
@@ -515,7 +542,7 @@ void pkgProblemResolver::MakeScores()
 	 if those are not obsolete
       */
       if (I->CurrentVer != 0 && Cache[I].CandidateVer != 0 && Cache[I].CandidateVerIter(Cache).Downloadable())
-	 Score += 1;
+	 Score += PrioInstalledAndNotObsolete;
    }
 
    // Now that we have the base scores we go and propogate dependencies
@@ -527,9 +554,10 @@ void pkgProblemResolver::MakeScores()
       for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++)
       {
 	 if (D->Type == pkgCache::Dep::Depends || 
-	     D->Type == pkgCache::Dep::PreDepends || 
-	     D->Type == pkgCache::Dep::Recommends) 
-	    Scores[D.TargetPkg()->ID]++;
+	     D->Type == pkgCache::Dep::PreDepends)
+	    Scores[D.TargetPkg()->ID] += PrioDepends;
+	 else if (D->Type == pkgCache::Dep::Recommends)
+	    Scores[D.TargetPkg()->ID] += PrioRecommends;
       }
    }   
    
@@ -576,10 +604,10 @@ void pkgProblemResolver::MakeScores()
    for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
    {
       if ((Flags[I->ID] & Protected) != 0)
-	 Scores[I->ID] += 10000;
+	 Scores[I->ID] += AddProtected;
       if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential)
-	 Scores[I->ID] += 5000;
-   }   
+	 Scores[I->ID] += AddEssential;
+   }
 }
 									/*}}}*/
 // ProblemResolver::DoUpgrade - Attempt to upgrade this package		/*{{{*/
@@ -755,19 +783,21 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
       *PEnd++ = I;
    This = this;
    qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
-   
-/* for (pkgCache::Package **K = PList; K != PEnd; K++)
-      if (Scores[(*K)->ID] != 0)
-      {
-	 pkgCache::PkgIterator Pkg(Cache,*K);
-	 clog << Scores[(*K)->ID] << ' ' << Pkg.Name() <<
-	    ' ' << (pkgCache::Version *)Pkg.CurrentVer() << ' ' << 
-	    Cache[Pkg].InstallVer << ' ' << Cache[Pkg].CandidateVer << endl;
-      } */
+
+   if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true)
+   {
+      clog << "Show Scores" << endl;
+      for (pkgCache::Package **K = PList; K != PEnd; K++)
+         if (Scores[(*K)->ID] != 0)
+         {
+           pkgCache::PkgIterator Pkg(Cache,*K);
+           clog << Scores[(*K)->ID] << ' ' << Pkg << std::endl;
+         }
+   }
 
    if (Debug == true)
       clog << "Starting 2" << endl;
-   
+
    /* Now consider all broken packages. For each broken package we either
       remove the package or fix it's problem. We do this once, it should
       not be possible for a loop to form (that is a < b < c and fixing b by
@@ -882,7 +912,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 	    }
 	    
 	    if (Debug == true)
-	       clog << "Package " << I.Name() << " has broken dep on " << Start.TargetPkg().Name() << endl;
+	       clog << "Package " << I.Name() << " has broken " << Start.DepType() << " on " << Start.TargetPkg().Name() << endl;
 
 	    /* Look across the version list. If there are no possible
 	       targets then we keep the package and bail. This is necessary
@@ -964,12 +994,9 @@ bool pkgProblemResolver::Resolve(bool BrokenFix)
 			   if (Debug == true)
 			      clog << "  Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl;
 			   Cache.MarkDelete(I);
-			   if (Counter > 1)
-			   {
-			      if (Scores[Pkg->ID] > Scores[I->ID])
-				 Scores[I->ID] = Scores[Pkg->ID];
-			   }			   
-			}			
+			   if (Counter > 1 && Scores[Pkg->ID] > Scores[I->ID])
+			      Scores[I->ID] = Scores[Pkg->ID];
+			}
 		     }
 		  }
 		  		  
@@ -1141,9 +1168,6 @@ bool pkgProblemResolver::ResolveByKeep()
 
    unsigned long Size = Cache.Head().PackageCount;
 
-   if (Debug == true)      
-      clog << "Entering ResolveByKeep" << endl;
-   
    MakeScores();
    
    /* We have to order the packages so that the broken fixing pass 
@@ -1156,7 +1180,21 @@ bool pkgProblemResolver::ResolveByKeep()
       *PEnd++ = I;
    This = this;
    qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort);
-   
+
+   if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true)
+   {
+      clog << "Show Scores" << endl;
+      for (pkgCache::Package **K = PList; K != PEnd; K++)
+         if (Scores[(*K)->ID] != 0)
+         {
+           pkgCache::PkgIterator Pkg(Cache,*K);
+           clog << Scores[(*K)->ID] << ' ' << Pkg << std::endl;
+         }
+   }
+
+   if (Debug == true)
+      clog << "Entering ResolveByKeep" << endl;
+
    // Consider each broken package 
    pkgCache::Package **LastStop = 0;
    for (pkgCache::Package **K = PList; K != PEnd; K++)
@@ -1202,8 +1240,8 @@ bool pkgProblemResolver::ResolveByKeep()
 	 while (true)
 	 {
 	    if (Debug == true)
-	       clog << "Package " << I.Name() << " has broken dep on " << Start.TargetPkg().Name() << endl;
-	    
+	       clog << "Package " << I.Name() << " has broken " << Start.DepType() << " on " << Start.TargetPkg().Name() << endl;
+
 	    // Look at all the possible provides on this package
 	    SPtrArray<pkgCache::Version *> VList = Start.AllTargets();
 	    for (pkgCache::Version **V = VList; *V != 0; V++)
@@ -1219,7 +1257,7 @@ bool pkgProblemResolver::ResolveByKeep()
 	       if ((Flags[I->ID] & Protected) == 0)
 	       {
 		  if (Debug == true)
-		     clog << "  Keeping Package " << Pkg.Name() << " due to dep" << endl;
+		     clog << "  Keeping Package " << Pkg.Name() << " due to " << Start.DepType() << endl;
 		  Cache.MarkKeep(Pkg, false, false);
 	       }
 	       
@@ -1276,7 +1314,6 @@ void pkgProblemResolver::InstallProtect()
    }   
 }
 									/*}}}*/
-
 // PrioSortList - Sort a list of versions by priority			/*{{{*/
 // ---------------------------------------------------------------------
 /* This is ment to be used in conjunction with AllTargets to get a list 
@@ -1307,7 +1344,6 @@ void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List)
    qsort(List,Count,sizeof(*List),PrioComp);
 }
 									/*}}}*/
-
 // CacheFile::ListUpdate - update the cache files                    	/*{{{*/
 // ---------------------------------------------------------------------
 /* This is a simple wrapper to update the cache. it will fetch stuff

+ 4 - 4
apt-pkg/algorithms.h

@@ -39,7 +39,7 @@
 
 using std::ostream;
 
-class pkgSimulate : public pkgPackageManager
+class pkgSimulate : public pkgPackageManager				/*{{{*/
 {
    protected:
 
@@ -75,8 +75,8 @@ private:
 
    pkgSimulate(pkgDepCache *Cache);
 };
-
-class pkgProblemResolver
+									/*}}}*/
+class pkgProblemResolver						/*{{{*/
 {
    pkgDepCache &Cache;
    typedef pkgCache::PkgIterator PkgIterator;
@@ -124,7 +124,7 @@ class pkgProblemResolver
    pkgProblemResolver(pkgDepCache *Cache);
    ~pkgProblemResolver();
 };
-
+									/*}}}*/
 bool pkgDistUpgrade(pkgDepCache &Cache);
 bool pkgApplyStatus(pkgDepCache &Cache);
 bool pkgFixBroken(pkgDepCache &Cache);

+ 4 - 5
apt-pkg/cachefile.cc

@@ -24,7 +24,6 @@
     
 #include <apti18n.h>
 									/*}}}*/
-
 // CacheFile::CacheFile - Constructor					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -49,6 +48,7 @@ pkgCacheFile::~pkgCacheFile()
 /* */
 bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
 {
+   const bool ErrorWasEmpty = _error->empty();
    if (WithLock == true)
       if (_system->Lock() == false)
 	 return false;
@@ -71,7 +71,7 @@ bool pkgCacheFile::BuildCaches(OpProgress &Progress,bool WithLock)
       return _error->Error(_("The package lists or status file could not be parsed or opened."));
 
    /* This sux, remove it someday */
-   if (_error->empty() == false)
+   if (ErrorWasEmpty == true && _error->empty() == false)
       _error->Warning(_("You may want to run apt-get update to correct these problems"));
 
    Cache = new pkgCache(Map);
@@ -92,7 +92,8 @@ bool pkgCacheFile::Open(OpProgress &Progress,bool WithLock)
    Policy = new pkgPolicy(Cache);
    if (_error->PendingError() == true)
       return false;
-   if (ReadPinFile(*Policy) == false)
+
+   if (ReadPinFile(*Policy) == false || ReadPinDir(*Policy) == false)
       return false;
    
    // Create the dependency cache
@@ -108,8 +109,6 @@ bool pkgCacheFile::Open(OpProgress &Progress,bool WithLock)
    return true;
 }
 									/*}}}*/
-
-
 // CacheFile::Close - close the cache files				/*{{{*/
 // ---------------------------------------------------------------------
 /* */

+ 30 - 20
apt-pkg/cacheiterators.h

@@ -32,7 +32,7 @@
 #define PKGLIB_CACHEITERATORS_H
 
 
-// Package Iterator
+// Package Iterator							/*{{{*/
 class pkgCache::PkgIterator
 {
    friend class pkgCache;
@@ -80,7 +80,13 @@ class pkgCache::PkgIterator
    inline PrvIterator ProvidesList() const;
    inline unsigned long Index() const {return Pkg - Owner->PkgP;};
    OkState State() const;
-   
+
+   //Nice printable representation
+   friend std::ostream& operator<<(std::ostream& out, pkgCache::PkgIterator Pkg);
+
+   const char *CandVersion() const;
+   const char *CurVersion() const;
+
    // Constructors
    inline PkgIterator(pkgCache &Owner,Package *Trg) : Pkg(Trg), Owner(&Owner),
           HashIndex(0) 
@@ -90,8 +96,8 @@ class pkgCache::PkgIterator
    };
    inline PkgIterator() : Pkg(0), Owner(0), HashIndex(0) {};
 };
-
-// Version Iterator
+									/*}}}*/
+// Version Iterator							/*{{{*/
 class pkgCache::VerIterator
 {
    Version *Ver;
@@ -111,7 +117,10 @@ class pkgCache::VerIterator
    inline bool operator ==(const VerIterator &B) const {return Ver == B.Ver;};
    inline bool operator !=(const VerIterator &B) const {return Ver != B.Ver;};
    int CompareVer(const VerIterator &B) const;
-   
+
+   // Testing
+   inline bool IsGood() const { return Ver && Owner && ! end();};
+
    // Accessors
    inline Version *operator ->() {return Ver;};
    inline Version const *operator ->() const {return Ver;};
@@ -146,8 +155,8 @@ class pkgCache::VerIterator
 	 Ver = Owner.VerP;
    };
 };
-
-// Description Iterator
+									/*}}}*/
+// Description Iterator							/*{{{*/
 class pkgCache::DescIterator
 {
    Description *Desc;
@@ -190,8 +199,8 @@ class pkgCache::DescIterator
 	 Desc = Owner.DescP;
    };
 };
-
-// Dependency iterator
+									/*}}}*/
+// Dependency iterator							/*{{{*/
 class pkgCache::DepIterator
 {
    Dependency *Dep;
@@ -249,8 +258,8 @@ class pkgCache::DepIterator
    };
    inline DepIterator() : Dep(0), Type(DepVer), Owner(0) {};
 };
-
-// Provides iterator
+									/*}}}*/
+// Provides iterator							/*{{{*/
 class pkgCache::PrvIterator
 {
    Provides *Prv;
@@ -302,8 +311,8 @@ class pkgCache::PrvIterator
 	 Prv = Owner.ProvideP;
    };
 };
-
-// Package file 
+									/*}}}*/
+// Package file								/*{{{*/
 class pkgCache::PkgFileIterator
 {
    pkgCache *Owner;
@@ -333,6 +342,7 @@ class pkgCache::PkgFileIterator
    inline const char *Component() const {return File->Component == 0?0:Owner->StrP + File->Component;};
    inline const char *Version() const {return File->Version == 0?0:Owner->StrP + File->Version;};
    inline const char *Origin() const {return File->Origin == 0?0:Owner->StrP + File->Origin;};
+   inline const char *Codename() const {return File->Codename ==0?0:Owner->StrP + File->Codename;};
    inline const char *Label() const {return File->Label == 0?0:Owner->StrP + File->Label;};
    inline const char *Site() const {return File->Site == 0?0:Owner->StrP + File->Site;};
    inline const char *Architecture() const {return File->Architecture == 0?0:Owner->StrP + File->Architecture;};
@@ -348,8 +358,8 @@ class pkgCache::PkgFileIterator
    inline PkgFileIterator(pkgCache &Owner) : Owner(&Owner), File(Owner.PkgFileP) {};
    inline PkgFileIterator(pkgCache &Owner,PackageFile *Trg) : Owner(&Owner), File(Trg) {};
 };
-
-// Version File 
+									/*}}}*/
+// Version File								/*{{{*/
 class pkgCache::VerFileIterator
 {
    pkgCache *Owner;
@@ -380,8 +390,8 @@ class pkgCache::VerFileIterator
    inline VerFileIterator() : Owner(0), FileP(0) {};
    inline VerFileIterator(pkgCache &Owner,VerFile *Trg) : Owner(&Owner), FileP(Trg) {};
 };
-
-// Description File 
+									/*}}}*/
+// Description File							/*{{{*/
 class pkgCache::DescFileIterator
 {
    pkgCache *Owner;
@@ -412,8 +422,8 @@ class pkgCache::DescFileIterator
    inline DescFileIterator() : Owner(0), FileP(0) {};
    inline DescFileIterator(pkgCache &Owner,DescFile *Trg) : Owner(&Owner), FileP(Trg) {};
 };
-
-// Inlined Begin functions cant be in the class because of order problems
+									/*}}}*/
+// Inlined Begin functions cant be in the class because of order problems /*{{{*/
 inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const
        {return VerIterator(*Owner,Owner->VerP + Pkg->VersionList);};
 inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const
@@ -432,5 +442,5 @@ inline pkgCache::VerFileIterator pkgCache::VerIterator::FileList() const
        {return VerFileIterator(*Owner,Owner->VerFileP + Ver->FileList);};
 inline pkgCache::DescFileIterator pkgCache::DescIterator::FileList() const
        {return DescFileIterator(*Owner,Owner->DescFileP + Desc->FileList);};
-
+									/*}}}*/
 #endif

+ 92 - 12
apt-pkg/cdrom.cc

@@ -16,7 +16,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <algorithm>
-
+#include <dlfcn.h>
 
 #include "indexcopy.h"
 
@@ -160,7 +160,7 @@ bool pkgCdrom::FindPackages(string CD,
    
    return !_error->PendingError();
 }
-
+									/*}}}*/
 // Score - We compute a 'score' for a path				/*{{{*/
 // ---------------------------------------------------------------------
 /* Paths are scored based on how close they come to what I consider
@@ -210,7 +210,6 @@ int pkgCdrom::Score(string Path)
 
    return Res;
 }
-
 									/*}}}*/
 // DropBinaryArch - Dump dirs with a string like /binary-<foo>/		/*{{{*/
 // ---------------------------------------------------------------------
@@ -248,8 +247,7 @@ bool pkgCdrom::DropBinaryArch(vector<string> &List)
    
    return true;
 }
-
-
+									/*}}}*/
 // DropRepeats - Drop repeated files resulting from symlinks		/*{{{*/
 // ---------------------------------------------------------------------
 /* Here we go and stat every file that we found and strip dup inodes. */
@@ -304,7 +302,6 @@ bool pkgCdrom::DropRepeats(vector<string> &List,const char *Name)
    return true;
 }
 									/*}}}*/
-
 // ReduceSourceList - Takes the path list and reduces it		/*{{{*/
 // ---------------------------------------------------------------------
 /* This takes the list of source list expressed entires and collects
@@ -513,9 +510,8 @@ bool pkgCdrom::WriteSourceList(string Name,vector<string> &List,bool Source)
    
    return true;
 }
-
-
-bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log)
+									/*}}}*/
+bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log)		/*{{{*/
 {
    stringstream msg;
 
@@ -573,9 +569,8 @@ bool pkgCdrom::Ident(string &ident, pkgCdromStatus *log)
 
    return true;
 }
-
-
-bool pkgCdrom::Add(pkgCdromStatus *log)
+									/*}}}*/
+bool pkgCdrom::Add(pkgCdromStatus *log)					/*{{{*/
 {
    stringstream msg;
 
@@ -844,3 +839,88 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
 
    return true;
 }
+									/*}}}*/
+pkgUdevCdromDevices::pkgUdevCdromDevices()                     		/*{{{*/
+   : libudev_handle(NULL)
+{
+
+}
+									/*}}}*/
+
+bool
+pkgUdevCdromDevices::Dlopen()                     		        /*{{{*/
+{
+   // alread open
+   if(libudev_handle != NULL)
+      return true;
+
+   // see if we can get libudev
+   void *h = ::dlopen("libudev.so.0", RTLD_LAZY);
+   if(h == NULL)
+      return false;
+
+   // get the pointers to the udev structs
+   libudev_handle = h;
+   udev_new = (udev* (*)(void)) dlsym(h, "udev_new");
+   udev_enumerate_add_match_property = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_property");
+   udev_enumerate_scan_devices = (int (*)(udev_enumerate*))dlsym(h, "udev_enumerate_scan_devices");
+   udev_enumerate_get_list_entry = (udev_list_entry* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_list_entry");
+   udev_device_new_from_syspath = (udev_device* (*)(udev*, const char*))dlsym(h, "udev_device_new_from_syspath");
+   udev_enumerate_get_udev = (udev* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_udev");
+   udev_list_entry_get_name = (const char* (*)(udev_list_entry*))dlsym(h, "udev_list_entry_get_name");
+   udev_device_get_devnode = (const char* (*)(udev_device*))dlsym(h, "udev_device_get_devnode");
+   udev_enumerate_new = (udev_enumerate* (*)(udev*))dlsym(h, "udev_enumerate_new");
+   udev_list_entry_get_next = (udev_list_entry* (*)(udev_list_entry*))dlsym(h, "udev_list_entry_get_next");
+   udev_device_get_property_value = (const char* (*)(udev_device *, const char *))dlsym(h, "udev_device_get_property_value");
+
+   return true;
+}
+									/*}}}*/
+vector<CdromDevice>
+pkgUdevCdromDevices::Scan()                                             /*{{{*/
+{
+   vector<CdromDevice> cdrom_devices;
+   struct udev_enumerate *enumerate;
+   struct udev_list_entry *l, *devices;
+   struct udev *udev_ctx;
+
+   if(libudev_handle == NULL)
+      return cdrom_devices;
+
+   udev_ctx = udev_new();
+   enumerate = udev_enumerate_new (udev_ctx);
+   udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1");
+
+   udev_enumerate_scan_devices (enumerate);
+   devices = udev_enumerate_get_list_entry (enumerate);
+   for (l = devices; l != NULL; l = udev_list_entry_get_next (l))
+   {
+      CdromDevice cdrom;
+      struct udev_device *udevice;
+      udevice = udev_device_new_from_syspath (udev_enumerate_get_udev (enumerate), udev_list_entry_get_name (l));
+      if (udevice == NULL)
+	 continue;
+      const char* devnode = udev_device_get_devnode(udevice);
+      const char* mountpath = udev_device_get_property_value(udevice, "FSTAB_DIR");
+
+      // fill in the struct
+      cdrom.DeviceName = string(devnode);
+      if (mountpath) {
+	 cdrom.MountPath = mountpath;
+	 string s = string(mountpath);
+	 cdrom.Mounted = IsMounted(s);
+      } else {
+	 cdrom.Mounted = false;
+	 cdrom.MountPath = "";
+      }
+      cdrom_devices.push_back(cdrom);
+   } 
+   return cdrom_devices;
+}
+									/*}}}*/
+
+pkgUdevCdromDevices::~pkgUdevCdromDevices()                             /*{{{*/
+{ 
+   dlclose(libudev_handle);
+}
+									/*}}}*/

+ 39 - 3
apt-pkg/cdrom.h

@@ -8,7 +8,7 @@
 
 using namespace std;
 
-class pkgCdromStatus
+class pkgCdromStatus							/*{{{*/
 {
  protected:
    int totalSteps;
@@ -29,8 +29,8 @@ class pkgCdromStatus
    // Progress indicator for the Index rewriter
    virtual OpProgress* GetOpProgress() {return NULL; };
 };
-
-class pkgCdrom 
+									/*}}}*/
+class pkgCdrom								/*{{{*/
 {
  protected:
    enum {
@@ -65,7 +65,43 @@ class pkgCdrom
    bool Ident(string &ident, pkgCdromStatus *log);
    bool Add(pkgCdromStatus *log);
 };
+									/*}}}*/
 
 
+// class that uses libudev to find cdrom devices dynamically
+struct CdromDevice							/*{{{*/
+{
+   string DeviceName;
+   bool Mounted;
+   string MountPath;
+};
+									/*}}}*/
+class pkgUdevCdromDevices						/*{{{*/
+{
+ protected:
+   // libudev dlopen stucture
+   void *libudev_handle;
+   struct udev* (*udev_new)(void);
+   int (*udev_enumerate_add_match_property)(struct udev_enumerate *udev_enumerate, const char *property, const char *value);
+   int (*udev_enumerate_scan_devices)(struct udev_enumerate *udev_enumerate);
+   struct udev_list_entry* (*udev_enumerate_get_list_entry)(struct udev_enumerate *udev_enumerate);
+   struct udev_device* (*udev_device_new_from_syspath)(struct udev *udev, const char *syspath);
+   struct udev* (*udev_enumerate_get_udev)(struct udev_enumerate *udev_enumerate);
+   const char* (*udev_list_entry_get_name)(struct udev_list_entry *list_entry);
+   const char* (*udev_device_get_devnode)(struct udev_device *udev_device);
+   struct udev_enumerate *(*udev_enumerate_new) (struct udev *udev);
+   struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *list_entry);
+   const char* (*udev_device_get_property_value)(struct udev_device *udev_device, const char *key);
+   // end libudev dlopen
+   
+ public:
+   pkgUdevCdromDevices();
+   virtual ~pkgUdevCdromDevices();
+
+   // try to open 
+   bool Dlopen();
+   vector<CdromDevice> Scan();
+};
+									/*}}}*/
 
 #endif

+ 0 - 1
apt-pkg/clean.cc

@@ -19,7 +19,6 @@
 #include <sys/stat.h>
 #include <unistd.h>
 									/*}}}*/
-
 // ArchiveCleaner::Go - Perform smart cleanup of the archive		/*{{{*/
 // ---------------------------------------------------------------------
 /* Scan the directory for files to erase, we check the version information

+ 10 - 3
apt-pkg/contrib/cdromutl.cc

@@ -98,7 +98,7 @@ bool UnmountCdrom(string Path)
 // MountCdrom - Mount a cdrom						/*{{{*/
 // ---------------------------------------------------------------------
 /* We fork mount and drop all messages */
-bool MountCdrom(string Path)
+bool MountCdrom(string Path, string DeviceName)
 {
    if (IsMounted(Path) == true)
       return true;
@@ -122,8 +122,15 @@ bool MountCdrom(string Path)
       {
 	 const char *Args[10];
 	 Args[0] = "mount";
-	 Args[1] = Path.c_str();
-	 Args[2] = 0;
+	 if (DeviceName == "") 
+	 {
+	    Args[1] = Path.c_str();
+	    Args[2] = 0;
+	 } else {
+	    Args[1] = DeviceName.c_str();
+	    Args[2] = Path.c_str();
+	    Args[3] = 0;
+	 }
 	 execvp(Args[0],(char **)Args);      
 	 _exit(100);
       }      

+ 2 - 1
apt-pkg/contrib/cdromutl.h

@@ -14,7 +14,8 @@
 
 using std::string;
 
-bool MountCdrom(string Path);
+// mount cdrom, DeviceName (e.g. /dev/sr0) is optional
+bool MountCdrom(string Path, string DeviceName="");
 bool UnmountCdrom(string Path);
 bool IdentCdrom(string CD,string &Res,unsigned int Version = 2);
 bool IsMounted(string &Path);

+ 4 - 3
apt-pkg/contrib/configuration.cc

@@ -182,9 +182,9 @@ string Configuration::FindFile(const char *Name,const char *Default) const
    if (Itm == 0 || Itm->Value.empty() == true)
    {
       if (Default == 0)
-	 return "";
+	 return rootDir;
       else
-	 return Default;
+	 return rootDir + Default;
    }
    
    string val = Itm->Value;
@@ -521,6 +521,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
 	  F.getline(Buffer,sizeof(Buffer) / 2);
 
 	  Input += Buffer;
+	  delete[] Buffer;
 	}
       while (F.fail() && !F.eof());
 
@@ -582,7 +583,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
 	 if (InQuote == true)
 	    continue;
 	 
-	 if (*I == '/' && I + 1 != End && I[1] == '/')
+	 if ((*I == '/' && I + 1 != End && I[1] == '/') || *I == '#')
          {
 	    End = I;
 	    break;

+ 7 - 6
apt-pkg/contrib/error.cc

@@ -84,17 +84,17 @@ bool GlobalError::Errno(const char *Function,const char *Description,...)
    char S[400];
    vsnprintf(S,sizeof(S),Description,args);
    snprintf(S + strlen(S),sizeof(S) - strlen(S),
-	    " - %s (%i %s)",Function,errno,strerror(errno));
+	    " - %s (%i: %s)",Function,errno,strerror(errno));
 
    // Put it on the list
    Item *Itm = new Item;
    Itm->Text = S;
    Itm->Error = true;
    Insert(Itm);
-   
+
    PendingFlag = true;
 
-   return false;   
+   return false;
 }
 									/*}}}*/
 // GlobalError::WarningE - Get part of the warn string from errno	/*{{{*/
@@ -112,15 +112,16 @@ bool GlobalError::WarningE(const char *Function,const char *Description,...)
    // sprintf the description
    char S[400];
    vsnprintf(S,sizeof(S),Description,args);
-   snprintf(S + strlen(S),sizeof(S) - strlen(S)," - %s (%i %s)",Function,errno,strerror(errno));
+   snprintf(S + strlen(S),sizeof(S) - strlen(S),
+	    " - %s (%i: %s)",Function,errno,strerror(errno));
 
    // Put it on the list
    Item *Itm = new Item;
    Itm->Text = S;
    Itm->Error = false;
    Insert(Itm);
-   
-   return false;   
+
+   return false;
 }
 									/*}}}*/
 // GlobalError::Error - Add an error to the list			/*{{{*/

+ 13 - 11
apt-pkg/contrib/hashes.cc

@@ -34,7 +34,7 @@ HashString::HashString(string Type, string Hash) : Type(Type), Hash(Hash)
 {
 }
 
-HashString::HashString(string StringedHash)
+HashString::HashString(string StringedHash)				/*{{{*/
 {
    // legacy: md5sum without "MD5Sum:" prefix
    if (StringedHash.find(":") == string::npos && StringedHash.size() == 32)
@@ -50,9 +50,8 @@ HashString::HashString(string StringedHash)
    if(_config->FindB("Debug::Hashes",false) == true)
       std::clog << "HashString(string): " << Type << " : " << Hash << std::endl;
 }
-
-
-bool HashString::VerifyFile(string filename) const
+									/*}}}*/
+bool HashString::VerifyFile(string filename) const			/*{{{*/
 {
    FileFd fd;
    MD5Summation MD5;
@@ -83,7 +82,7 @@ bool HashString::VerifyFile(string filename) const
 
    return (fileHash == Hash);
 }
-
+									/*}}}*/
 const char** HashString::SupportedHashes()
 {
    return _SupportedHashes;
@@ -94,13 +93,11 @@ bool HashString::empty() const
    return (Type.empty() || Hash.empty());
 }
 
-
 string HashString::toStr() const
 {
    return Type+string(":")+Hash;
 }
 
-
 // Hashes::AddFD - Add the contents of the FD				/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -108,11 +105,16 @@ bool Hashes::AddFD(int Fd,unsigned long Size)
 {
    unsigned char Buf[64*64];
    int Res = 0;
-   while (Size != 0)
+   int ToEOF = (Size == 0);
+   while (Size != 0 || ToEOF)
    {
-      Res = read(Fd,Buf,min(Size,(unsigned long)sizeof(Buf)));
-      if (Res < 0 || (unsigned)Res != min(Size,(unsigned long)sizeof(Buf)))
-	 return false;
+      unsigned n = sizeof(Buf);
+      if (!ToEOF) n = min(Size,(unsigned long)n);
+      Res = read(Fd,Buf,n);
+      if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+         return false;
+      if (ToEOF && Res == 0) // EOF
+         break;
       Size -= Res;
       MD5.Add(Buf,Res);
       SHA1.Add(Buf,Res);

+ 9 - 4
apt-pkg/contrib/md5.cc

@@ -294,11 +294,16 @@ bool MD5Summation::AddFD(int Fd,unsigned long Size)
 {
    unsigned char Buf[64*64];
    int Res = 0;
-   while (Size != 0)
+   int ToEOF = (Size == 0);
+   while (Size != 0 || ToEOF)
    {
-      Res = read(Fd,Buf,min(Size,(unsigned long)sizeof(Buf)));
-      if (Res < 0 || (unsigned)Res != min(Size,(unsigned long)sizeof(Buf)))
-	 return false;
+      unsigned n = sizeof(Buf);
+      if (!ToEOF) n = min(Size,(unsigned long)n);
+      Res = read(Fd,Buf,n);
+      if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+         return false;
+      if (ToEOF && Res == 0) // EOF
+         break;
       Size -= Res;
       Add(Buf,Res);
    }

+ 86 - 34
apt-pkg/contrib/mmap.cc

@@ -13,11 +13,6 @@
    libc6 generates warnings -- which should be errors, g++ isn't properly
    strict.
    
-   The configure test notes that some OS's have broken private mmap's
-   so on those OS's we can't use mmap. This means we have to use
-   configure to test mmap and can't rely on the POSIX
-   _POSIX_MAPPED_FILES test.
-   
    ##################################################################### */
 									/*}}}*/
 // Include Files							/*{{{*/
@@ -31,6 +26,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <stdlib.h>
 
 #include <cstring>
    									/*}}}*/
@@ -144,7 +140,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop)
 // DynamicMMap::DynamicMMap - Constructor				/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace) : 
+DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace) :
              MMap(F,Flags | NoImmMap), Fd(&F), WorkSpace(WorkSpace)
 {
    if (_error->PendingError() == true)
@@ -166,15 +162,34 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long WorkSpace)
 									/*}}}*/
 // DynamicMMap::DynamicMMap - Constructor for a non-file backed map	/*{{{*/
 // ---------------------------------------------------------------------
-/* This is just a fancy malloc really.. */
+/* We try here to use mmap to reserve some space - this is much more
+   cooler than the fallback solution to simply allocate a char array
+   and could come in handy later than we are able to grow such an mmap */
 DynamicMMap::DynamicMMap(unsigned long Flags,unsigned long WorkSpace) :
              MMap(Flags | NoImmMap | UnMapped), Fd(0), WorkSpace(WorkSpace)
 {
    if (_error->PendingError() == true)
       return;
-   
+
+#ifdef _POSIX_MAPPED_FILES
+   // Set the permissions.
+   int Prot = PROT_READ;
+   int Map = MAP_PRIVATE | MAP_ANONYMOUS;
+   if ((Flags & ReadOnly) != ReadOnly)
+      Prot |= PROT_WRITE;
+   if ((Flags & Public) == Public)
+      Map = MAP_SHARED | MAP_ANONYMOUS;
+
+   // use anonymous mmap() to get the memory
+   Base = (unsigned char*) mmap(0, WorkSpace, Prot, Map, -1, 0);
+
+   if(Base == MAP_FAILED)
+      _error->Errno("DynamicMMap",_("Couldn't make mmap of %lu bytes"),WorkSpace);
+#else
+   // fallback to a static allocated space
    Base = new unsigned char[WorkSpace];
    memset(Base,0,WorkSpace);
+#endif
    iSize = 0;
 }
 									/*}}}*/
@@ -185,7 +200,11 @@ DynamicMMap::~DynamicMMap()
 {
    if (Fd == 0)
    {
+#ifdef _POSIX_MAPPED_FILES
+      munmap(Base, WorkSpace);
+#else
       delete [] (unsigned char *)Base;
+#endif
       return;
    }
    
@@ -204,17 +223,19 @@ unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln)
    unsigned long Result = iSize;
    if (Aln != 0)
       Result += Aln - (iSize%Aln);
-   
+
    iSize = Result + Size;
-   
-   // Just in case error check
-   if (Result + Size > WorkSpace)
+
+   // try to grow the buffer
+   while(Result + Size > WorkSpace)
    {
-	  _error->Error(_("Dynamic MMap ran out of room. Please increase the size "
-				  "of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace);
-      return 0;
+      if(!Grow())
+      {
+	 _error->Error(_("Dynamic MMap ran out of room. Please increase the size "
+			 "of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace);
+	 return 0;
+      }
    }
-
    return Result;
 }
 									/*}}}*/
@@ -223,7 +244,7 @@ unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln)
 /* This allocates an Item of size ItemSize so that it is aligned to its
    size in the file. */
 unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
-{   
+{
    // Look for a matching pool entry
    Pool *I;
    Pool *Empty = 0;
@@ -234,7 +255,6 @@ unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
       if (I->ItemSize == ItemSize)
 	 break;
    }
-
    // No pool is allocated, use an unallocated one
    if (I == Pools + PoolCount)
    {
@@ -249,17 +269,24 @@ unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
       I->ItemSize = ItemSize;
       I->Count = 0;
    }
-   
+
+   unsigned long Result = 0;
    // Out of space, allocate some more
    if (I->Count == 0)
    {
-      I->Count = 20*1024/ItemSize;
-      I->Start = RawAllocate(I->Count*ItemSize,ItemSize);
-   }   
+      const unsigned long size = 20*1024;
+      I->Count = size/ItemSize;
+      Result = RawAllocate(size,ItemSize);
+      // Does the allocation failed ?
+      if (Result == 0 && _error->PendingError())
+	 return 0;
+      I->Start = Result;
+   }
+   else
+      Result = I->Start;
 
    I->Count--;
-   unsigned long Result = I->Start;
-   I->Start += ItemSize;  
+   I->Start += ItemSize;
    return Result/ItemSize;
 }
 									/*}}}*/
@@ -269,20 +296,45 @@ unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
 unsigned long DynamicMMap::WriteString(const char *String,
 				       unsigned long Len)
 {
-   unsigned long Result = iSize;
-   // Just in case error check
-   if (Result + Len > WorkSpace)
-   {
-	  _error->Error(_("Dynamic MMap ran out of room. Please increase the size "
-				  "of APT::Cache-Limit. Current value: %lu. (man 5 apt.conf)"), WorkSpace);
-      return 0;
-   }   
-   
    if (Len == (unsigned long)-1)
       Len = strlen(String);
-   iSize += Len + 1;
+
+   unsigned long Result = RawAllocate(Len+1,0);
+
+   if (Result == 0 && _error->PendingError())
+      return 0;
+
    memcpy((char *)Base + Result,String,Len);
    ((char *)Base)[Result + Len] = 0;
    return Result;
 }
 									/*}}}*/
+// DynamicMMap::Grow - Grow the mmap					/*{{{*/
+// ---------------------------------------------------------------------
+/* This method will try to grow the mmap we currently use. This doesn't
+   work most of the time because we can't move the mmap around in the
+   memory for now as this would require to adjust quite a lot of pointers
+   but why we should not at least try to grow it before we give up? */
+bool DynamicMMap::Grow()
+{
+#ifdef _POSIX_MAPPED_FILES
+   unsigned long newSize = WorkSpace + 1024*1024;
+
+   if(Fd != 0)
+   {
+      Fd->Seek(newSize - 1);
+      char C = 0;
+      Fd->Write(&C,sizeof(C));
+   }
+
+   Base = mremap(Base, WorkSpace, newSize, 0);
+   if(Base == MAP_FAILED)
+      return false;
+
+   WorkSpace = newSize;
+   return true;
+#else
+   return false;
+#endif
+}
+									/*}}}*/

+ 2 - 0
apt-pkg/contrib/mmap.h

@@ -84,6 +84,8 @@ class DynamicMMap : public MMap
    unsigned long WorkSpace;
    Pool *Pools;
    unsigned int PoolCount;
+
+   bool Grow();
    
    public:
 

+ 13 - 19
apt-pkg/contrib/sha256.cc

@@ -1,5 +1,5 @@
 /*
- * Cryptographic API.
+ * Cryptographic API.							{{{
  *
  * SHA-256, as specified in
  * http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
@@ -17,7 +17,7 @@
  * Software Foundation; either version 2 of the License, or (at your option) 
  * any later version.
  *
- */
+ */									/*}}}*/
 
 #ifdef __GNUG__
 #pragma implementation "apt-pkg/sha256.h"
@@ -65,20 +65,20 @@ static inline u32 Maj(u32 x, u32 y, u32 z)
 #define H6         0x1f83d9ab
 #define H7         0x5be0cd19
 
-static inline void LOAD_OP(int I, u32 *W, const u8 *input)
+static inline void LOAD_OP(int I, u32 *W, const u8 *input)		/*{{{*/
 {
 	W[I] = (  ((u32) input[I * 4 + 0] << 24)
 		| ((u32) input[I * 4 + 1] << 16)
 		| ((u32) input[I * 4 + 2] << 8)
 		| ((u32) input[I * 4 + 3]));
 }
-
+									/*}}}*/
 static inline void BLEND_OP(int I, u32 *W)
 {
         W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
 }
 
-static void sha256_transform(u32 *state, const u8 *input)
+static void sha256_transform(u32 *state, const u8 *input)		/*{{{*/
 {
         u32 a, b, c, d, e, f, g, h, t1, t2;
         u32 W[64];
@@ -240,8 +240,8 @@ static void sha256_transform(u32 *state, const u8 *input)
         a = b = c = d = e = f = g = h = t1 = t2 = 0;
         memset(W, 0, 64 * sizeof(u32));
 }
-
-SHA256Summation::SHA256Summation()
+									/*}}}*/
+SHA256Summation::SHA256Summation()					/*{{{*/
 {
         Sum.state[0] = H0;
         Sum.state[1] = H1;
@@ -255,8 +255,8 @@ SHA256Summation::SHA256Summation()
         memset(Sum.buf, 0, sizeof(Sum.buf));
         Done = false;
 }
-
-bool SHA256Summation::Add(const u8 *data, unsigned long len)
+									/*}}}*/
+bool SHA256Summation::Add(const u8 *data, unsigned long len)		/*{{{*/
 {
         struct sha256_ctx *sctx = &Sum;
         unsigned int i, index, part_len;
@@ -291,8 +291,8 @@ bool SHA256Summation::Add(const u8 *data, unsigned long len)
 
         return true;
 }
-
-SHA256SumValue SHA256Summation::Result()
+									/*}}}*/
+SHA256SumValue SHA256Summation::Result()				/*{{{*/
 {
    struct sha256_ctx *sctx = &Sum;
    if (!Done) {
@@ -340,7 +340,7 @@ SHA256SumValue SHA256Summation::Result()
 
    return res;
 }
-
+									/*}}}*/
 // SHA256SumValue::SHA256SumValue - Constructs the sum from a string   /*{{{*/
 // ---------------------------------------------------------------------
 /* The string form of a SHA256 is a 64 character hex number */
@@ -349,7 +349,6 @@ SHA256SumValue::SHA256SumValue(string Str)
    memset(Sum,0,sizeof(Sum));
    Set(Str);
 }
-
                                                                        /*}}}*/
 // SHA256SumValue::SHA256SumValue - Default constructor                /*{{{*/
 // ---------------------------------------------------------------------
@@ -358,7 +357,6 @@ SHA256SumValue::SHA256SumValue()
 {
    memset(Sum,0,sizeof(Sum));
 }
-
                                                                        /*}}}*/
 // SHA256SumValue::Set - Set the sum from a string                     /*{{{*/
 // ---------------------------------------------------------------------
@@ -391,9 +389,7 @@ string SHA256SumValue::Value() const
 
    return string(Result);
 }
-
-
-
+									/*}}}*/
 // SHA256SumValue::operator == - Comparator                            /*{{{*/
 // ---------------------------------------------------------------------
 /* Call memcmp on the buffer */
@@ -402,8 +398,6 @@ bool SHA256SumValue::operator == (const SHA256SumValue & rhs) const
    return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0;
 }
                                                                        /*}}}*/
-
-
 // SHA256Summation::AddFD - Add content of file into the checksum      /*{{{*/
 // ---------------------------------------------------------------------
 /* */

+ 11 - 0
apt-pkg/contrib/strutl.cc

@@ -387,6 +387,17 @@ string SubstVar(string Str,const struct SubstVar *Vars)
    return Str;
 }
 									/*}}}*/
+// OutputInDepth - return a string with separator multiplied with depth /*{{{*/
+// ---------------------------------------------------------------------
+/* Returns a string with the supplied separator depth + 1 times in it */
+std::string OutputInDepth(const unsigned long Depth, const char* Separator)
+{
+   std::string output = "";
+   for(unsigned long d=Depth+1; d > 0; d--)
+      output.append(Separator);
+   return output;
+}
+									/*}}}*/
 // URItoFileName - Convert the uri into a unique file name		/*{{{*/
 // ---------------------------------------------------------------------
 /* This converts a URI into a safe filename. It quotes all unsafe characters

+ 2 - 0
apt-pkg/contrib/strutl.h

@@ -48,6 +48,7 @@ string DeQuoteString(const string &Str);
 string SizeToStr(double Bytes);
 string TimeToStr(unsigned long Sec);
 string Base64Encode(const string &Str);
+string OutputInDepth(const unsigned long Depth, const char* Separator="  ");
 string URItoFileName(const string &URI);
 string TimeRFC1123(time_t Date);
 bool StrToTime(const string &Val,time_t &Result);
@@ -65,6 +66,7 @@ bool CheckDomainList(const string &Host, const string &List);
 int tolower_ascii(int c);
 
 #define APT_MKSTRCMP(name,func) \
+inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \
 inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \
 inline int name(string A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \
 inline int name(string A,string B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \

+ 4 - 0
apt-pkg/deb/deblistparser.cc

@@ -109,6 +109,8 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver)
       return false;
    if (ParseDepends(Ver,"Replaces",pkgCache::Dep::Replaces) == false)
       return false;
+   if (ParseDepends(Ver,"Enhances",pkgCache::Dep::Enhances) == false)
+      return false;
 
    // Obsolete.
    if (ParseDepends(Ver,"Optional",pkgCache::Dep::Suggests) == false)
@@ -637,6 +639,8 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator FileI,
       FileI->Version = WriteUniqString(Start,Stop - Start);
    if (Section.Find("Origin",Start,Stop) == true)
       FileI->Origin = WriteUniqString(Start,Stop - Start);
+   if (Section.Find("Codename",Start,Stop) == true)
+      FileI->Codename = WriteUniqString(Start,Stop - Start);
    if (Section.Find("Label",Start,Stop) == true)
       FileI->Label = WriteUniqString(Start,Stop - Start);
    if (Section.Find("Architecture",Start,Stop) == true)

+ 7 - 0
apt-pkg/deb/debmetaindex.cc

@@ -115,6 +115,13 @@ debReleaseIndex::debReleaseIndex(string URI,string Dist)
    this->Type = "deb";
 }
 
+debReleaseIndex::~debReleaseIndex()
+{
+   for (vector<const debSectionEntry *>::const_iterator I = SectionEntries.begin();
+	I != SectionEntries.end(); I++)
+      delete *I;
+}
+
 vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const
 {
    vector <struct IndexTarget *>* IndexTargets = new vector <IndexTarget *>;

+ 1 - 0
apt-pkg/deb/debmetaindex.h

@@ -22,6 +22,7 @@ class debReleaseIndex : public metaIndex {
    public:
 
    debReleaseIndex(string URI, string Dist);
+   ~debReleaseIndex();
 
    virtual string ArchiveURI(string File) const {return URI + File;};
    virtual bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const;

+ 8 - 0
apt-pkg/deb/debsrcrecords.cc

@@ -152,3 +152,11 @@ bool debSrcRecordParser::Files(vector<pkgSrcRecords::File> &List)
    return true;
 }
 									/*}}}*/
+// SrcRecordParser::~SrcRecordParser - Destructor			/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+debSrcRecordParser::~debSrcRecordParser()
+{
+   delete[] Buffer;
+}
+									/*}}}*/

+ 1 - 0
apt-pkg/deb/debsrcrecords.h

@@ -50,6 +50,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
    debSrcRecordParser(string File,pkgIndexFile const *Index) 
       : Parser(Index), Fd(File,FileFd::ReadOnly), Tags(&Fd,102400), 
         Buffer(0), BufSize(0) {}
+   ~debSrcRecordParser();
 };
 
 #endif

+ 2 - 2
apt-pkg/deb/debsystem.cc

@@ -17,8 +17,8 @@
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
-#include <apti18n.h>    
-
+#include <apti18n.h>
+    
 #include <sys/types.h>
 #include <unistd.h>
 #include <dirent.h>

+ 117 - 60
apt-pkg/depcache.cc

@@ -15,6 +15,7 @@
 #include <apt-pkg/algorithms.h>
 
 #include <apt-pkg/fileutl.h>
+#include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/tagfile.h>
@@ -26,8 +27,8 @@
 #include <sys/stat.h>
 
 #include <apti18n.h>    
-
-// helper for Install-Recommends-Sections and Never-MarkAuto-Sections
+									/*}}}*/
+// helper for Install-Recommends-Sections and Never-MarkAuto-Sections	/*{{{*/
 static bool 
 ConfigValueInSubTree(const char* SubTree, const char *needle)
 {
@@ -46,9 +47,8 @@ ConfigValueInSubTree(const char* SubTree, const char *needle)
    }
    return false;
 }
-
-
-pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) :
+									/*}}}*/
+pkgDepCache::ActionGroup::ActionGroup(pkgDepCache &cache) :		/*{{{*/
   cache(cache), released(false)
 {
   ++cache.group_level;
@@ -76,13 +76,15 @@ pkgDepCache::ActionGroup::~ActionGroup()
 {
   release();
 }
-
+									/*}}}*/
 // DepCache::pkgDepCache - Constructors					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
 pkgDepCache::pkgDepCache(pkgCache *pCache,Policy *Plcy) :
   group_level(0), Cache(pCache), PkgState(0), DepState(0)
 {
+   DebugMarker = _config->FindB("Debug::pkgDepCache::Marker", false);
+   DebugAutoInstall = _config->FindB("Debug::pkgDepCache::AutoInstall", false);
    delLocalPolicy = 0;
    LocalPolicy = Plcy;
    if (LocalPolicy == 0)
@@ -127,7 +129,7 @@ bool pkgDepCache::Init(OpProgress *Prog)
    int Done = 0;
    for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++)
    {
-      if (Prog != 0)
+      if (Prog != 0 && Done%20 == 0)
 	 Prog->Progress(Done);
       
       // Find the proper cache slot
@@ -159,8 +161,7 @@ bool pkgDepCache::Init(OpProgress *Prog)
    return true;
 } 
 									/*}}}*/
-
-bool pkgDepCache::readStateFile(OpProgress *Prog)
+bool pkgDepCache::readStateFile(OpProgress *Prog)			/*{{{*/
 {
    FileFd state_file;
    string state = _config->FindDir("Dir::State") + "extended_states";
@@ -174,6 +175,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)
       pkgTagFile tagfile(&state_file);
       pkgTagSection section;
       int amt=0;
+      bool debug_autoremove=_config->FindB("Debug::pkgAutoRemove",false);
       while(tagfile.Step(section)) {
 	 string pkgname = section.FindS("Package");
 	 pkgCache::PkgIterator pkg=Cache->FindPkg(pkgname);
@@ -183,7 +185,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)
 	    short reason = section.FindI("Auto-Installed", 0);
 	    if(reason > 0)
 	       PkgState[pkg->ID].Flags  |= Flag::Auto;
-	    if(_config->FindB("Debug::pkgAutoRemove",false))
+	    if(debug_autoremove)
 	       std::cout << "Auto-Installed : " << pkgname << std::endl;
 	    amt+=section.size();
 	    if(Prog != NULL)
@@ -198,10 +200,12 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)
 
    return true;
 }
-
-bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)
+									/*}}}*/
+bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)	/*{{{*/
 {
-   if(_config->FindB("Debug::pkgAutoRemove",false))
+   bool debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
+   
+   if(debug_autoremove)
       std::clog << "pkgDepCache::writeStateFile()" << std::endl;
 
    FileFd StateFile;
@@ -256,14 +260,14 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)
    for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) {
       if(PkgState[pkg->ID].Flags & Flag::Auto) {
 	 if (pkgs_seen.find(pkg.Name()) != pkgs_seen.end()) {
-	    if(_config->FindB("Debug::pkgAutoRemove",false))
+	    if(debug_autoremove)
 	       std::clog << "Skipping already written " << pkg.Name() << std::endl;
 	    continue;
 	 }
          // skip not installed ones if requested
          if(InstalledOnly && pkg->CurrentVer == 0)
             continue;
-	 if(_config->FindB("Debug::pkgAutoRemove",false))
+	 if(debug_autoremove)
 	    std::clog << "Writing new AutoInstall: " 
 		      << pkg.Name() << std::endl;
 	 ostr.str(string(""));
@@ -281,7 +285,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)
 
    return true;
 }
-
+									/*}}}*/
 // DepCache::CheckDep - Checks a single dependency			/*{{{*/
 // ---------------------------------------------------------------------
 /* This first checks the dependency against the main target package and
@@ -699,13 +703,12 @@ void pkgDepCache::Update(PkgIterator const &Pkg)
 	   P.end() != true; P++)
 	 Update(P.ParentPkg().RevDependsList());
 }
-
 									/*}}}*/
-
 // DepCache::MarkKeep - Put the package in the keep state		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser)
+void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser,
+                           unsigned long Depth)
 {
    // Simplifies other routines.
    if (Pkg.end() == true)
@@ -746,6 +749,9 @@ void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser)
      P.Flags &= ~Flag::Auto;
 #endif
 
+   if (DebugMarker == true)
+      std::clog << OutputInDepth(Depth) << "MarkKeep " << Pkg << " FU=" << FromUser << std::endl;
+
    RemoveSizes(Pkg);
    RemoveStates(Pkg);
 
@@ -765,7 +771,8 @@ void pkgDepCache::MarkKeep(PkgIterator const &Pkg, bool Soft, bool FromUser)
 // DepCache::MarkDelete - Put the package in the delete state		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge)
+void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge,
+                             unsigned long Depth, bool FromUser)
 {
    // Simplifies other routines.
    if (Pkg.end() == true)
@@ -787,6 +794,13 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge)
    if (Pkg->VersionList == 0)
       return;
 
+   // check if we are allowed to install the package
+   if (IsDeleteOk(Pkg,rPurge,Depth,FromUser) == false)
+      return;
+
+   if (DebugMarker == true)
+      std::clog << OutputInDepth(Depth) << "MarkDelete " << Pkg << " FU=" << FromUser << std::endl;
+
    RemoveSizes(Pkg);
    RemoveStates(Pkg);
    
@@ -801,6 +815,23 @@ void pkgDepCache::MarkDelete(PkgIterator const &Pkg, bool rPurge)
    AddSizes(Pkg);
 }
 									/*}}}*/
+// DepCache::IsDeleteOk - check if it is ok to remove this package	/*{{{*/
+// ---------------------------------------------------------------------
+/* The default implementation just honors dpkg hold
+   But an application using this library can override this method
+   to control the MarkDelete behaviour */
+bool pkgDepCache::IsDeleteOk(PkgIterator const &Pkg,bool rPurge,
+			      unsigned long Depth, bool FromUser)
+{
+   if (FromUser == false && Pkg->SelectedState == pkgCache::State::Hold)
+   {
+      if (DebugMarker == true)
+	 std::clog << OutputInDepth(Depth) << "Hold prevents MarkDelete of " << Pkg << " FU=" << FromUser << std::endl;
+      return false;
+   }
+   return true;
+}
+									/*}}}*/
 // DepCache::MarkInstall - Put the package in the install state		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -826,7 +857,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	P.CandidateVer == (Version *)Pkg.CurrentVer()))
    {
       if (P.CandidateVer == (Version *)Pkg.CurrentVer() && P.InstallVer == 0)
-	 MarkKeep(Pkg, false, FromUser);
+	 MarkKeep(Pkg, false, FromUser, Depth+1);
       return;
    }
 
@@ -836,6 +867,11 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
    // We dont even try to install virtual packages..
    if (Pkg->VersionList == 0)
       return;
+
+   // check if we are allowed to install the package
+   if (IsInstallOk(Pkg,AutoInst,Depth,FromUser) == false)
+      return;
+
    /* Target the candidate version and remove the autoflag. We reset the
       autoflag below if this was called recursively. Otherwise the user
       should have the ability to de-auto a package by changing its state */
@@ -864,10 +900,13 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
    AddStates(Pkg);
    Update(Pkg);
    AddSizes(Pkg);
-   
+
    if (AutoInst == false)
       return;
 
+   if (DebugMarker == true)
+      std::clog << OutputInDepth(Depth) << "MarkInstall " << Pkg << " FU=" << FromUser << std::endl;
+
    DepIterator Dep = P.InstVerIter(*this).DependsList();
    for (; Dep.end() != true;)
    {
@@ -937,12 +976,12 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	 }
       }
       if(isNewImportantDep)
-	 if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
-	    std::clog << "new important dependency: " 
+	 if(DebugAutoInstall == true)
+	    std::clog << OutputInDepth(Depth) << "new important dependency: "
 		      << Start.TargetPkg().Name() << std::endl;
       if(isPreviouslySatisfiedImportantDep)
-	if(_config->FindB("Debug::pkgDepCache::AutoInstall", false) == true)
-	  std::clog << "previously satisfied important dependency on "
+	if(DebugAutoInstall == true)
+	  std::clog << OutputInDepth(Depth) << "previously satisfied important dependency on "
 		    << Start.TargetPkg().Name() << std::endl;
 
       // skip important deps if the package is already installed
@@ -991,17 +1030,18 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	    }
 	 }
 	 
-	 if (InstPkg.end() == false) 
+	 if (InstPkg.end() == false)
 	 {
-	    if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
-	       std::clog << "Installing " << InstPkg.Name() 
-			 << " as dep of " << Pkg.Name() 
+	    if(DebugAutoInstall == true)
+	       std::clog << OutputInDepth(Depth) << "Installing " << InstPkg.Name()
+			 << " as " << Start.DepType() << " of " << Pkg.Name()
 			 << std::endl;
  	    // now check if we should consider it a automatic dependency or not
  	    if(Pkg.Section() && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", Pkg.Section()))
  	    {
- 	       if(_config->FindB("Debug::pkgDepCache::AutoInstall",false) == true)
- 		  std::clog << "Setting NOT as auto-installed (direct dep of pkg in APT::Never-MarkAuto-Sections)" << std::endl;
+	       if(DebugAutoInstall == true)
+		  std::clog << OutputInDepth(Depth) << "Setting NOT as auto-installed (direct "
+                            << Start.DepType() << " of pkg in APT::Never-MarkAuto-Sections)" << std::endl;
  	       MarkInstall(InstPkg,true,Depth + 1, true);
  	    }
  	    else 
@@ -1028,16 +1068,32 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
 	    PkgIterator Pkg = Ver.ParentPkg();
 
 	    if (Start->Type != Dep::DpkgBreaks)
-	       MarkDelete(Pkg);
-	    else
-	       if (PkgState[Pkg->ID].CandidateVer != *I)
-		  MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps);
+	       MarkDelete(Pkg,false,Depth + 1, false);
+	    else if (PkgState[Pkg->ID].CandidateVer != *I)
+	       MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps);
 	 }
 	 continue;
       }      
    }
 }
 									/*}}}*/
+// DepCache::IsInstallOk - check if it is ok to install this package	/*{{{*/
+// ---------------------------------------------------------------------
+/* The default implementation just honors dpkg hold
+   But an application using this library can override this method
+   to control the MarkInstall behaviour */
+bool pkgDepCache::IsInstallOk(PkgIterator const &Pkg,bool AutoInst,
+			      unsigned long Depth, bool FromUser)
+{
+   if (FromUser == false && Pkg->SelectedState == pkgCache::State::Hold)
+   {
+      if (DebugMarker == true)
+	 std::clog << OutputInDepth(Depth) << "Hold prevents MarkInstall of " << Pkg << " FU=" << FromUser << std::endl;
+      return false;
+   }
+   return true;
+}
+									/*}}}*/
 // DepCache::SetReInstall - Set the reinstallation flag			/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -1137,7 +1193,6 @@ const char *pkgDepCache::StateCache::StripEpoch(const char *Ver)
    return Ver;
 }
 									/*}}}*/
-
 // Policy::GetCandidateVer - Returns the Candidate install version	/*{{{*/
 // ---------------------------------------------------------------------
 /* The default just returns the highest available version that is not
@@ -1174,7 +1229,6 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator Pkg)
    return Last;
 }
 									/*}}}*/
-
 // Policy::IsImportantDep - True if the dependency is important		/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -1200,8 +1254,7 @@ bool pkgDepCache::Policy::IsImportantDep(DepIterator Dep)
    return false;
 }
 									/*}}}*/
-
-pkgDepCache::DefaultRootSetFunc::DefaultRootSetFunc()
+pkgDepCache::DefaultRootSetFunc::DefaultRootSetFunc()			/*{{{*/
   : constructedSuccessfully(false)
 {
   Configuration::Item const *Opts;
@@ -1230,8 +1283,8 @@ pkgDepCache::DefaultRootSetFunc::DefaultRootSetFunc()
 
   constructedSuccessfully = true;
 }
-
-pkgDepCache::DefaultRootSetFunc::~DefaultRootSetFunc()
+									/*}}}*/
+pkgDepCache::DefaultRootSetFunc::~DefaultRootSetFunc()			/*{{{*/
 {
   for(unsigned int i = 0; i < rootSetRegexp.size(); i++)
     {
@@ -1239,9 +1292,8 @@ pkgDepCache::DefaultRootSetFunc::~DefaultRootSetFunc()
       delete rootSetRegexp[i];
     }
 }
-
-
-bool pkgDepCache::DefaultRootSetFunc::InRootSet(const pkgCache::PkgIterator &pkg)
+									/*}}}*/
+bool pkgDepCache::DefaultRootSetFunc::InRootSet(const pkgCache::PkgIterator &pkg) /*{{{*/
 {
    for(unsigned int i = 0; i < rootSetRegexp.size(); i++)
       if (regexec(rootSetRegexp[i], pkg.Name(), 0, 0, 0) == 0)
@@ -1249,8 +1301,8 @@ bool pkgDepCache::DefaultRootSetFunc::InRootSet(const pkgCache::PkgIterator &pkg
 
    return false;
 }
-
-pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc()
+									/*}}}*/
+pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc()		/*{{{*/
 {
   DefaultRootSetFunc *f = new DefaultRootSetFunc;
   if(f->wasConstructedSuccessfully())
@@ -1261,7 +1313,7 @@ pkgDepCache::InRootSetFunc *pkgDepCache::GetRootSetFunc()
       return NULL;
     }
 }
-
+									/*}}}*/
 bool pkgDepCache::MarkFollowsRecommends()
 {
   return _config->FindB("APT::AutoRemove::RecommendsImportant", true);
@@ -1272,11 +1324,12 @@ bool pkgDepCache::MarkFollowsSuggests()
   return _config->FindB("APT::AutoRemove::SuggestsImportant", false);
 }
 
-// the main mark algorithm
+// pkgDepCache::MarkRequired - the main mark algorithm			/*{{{*/
 bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc)
 {
    bool follow_recommends;
    bool follow_suggests;
+   bool debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
 
    // init the states
    for(PkgIterator p = PkgBegin(); !p.end(); ++p)
@@ -1285,8 +1338,7 @@ bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc)
       PkgState[p->ID].Garbage = false;
 
       // debug output
-      if(_config->FindB("Debug::pkgAutoRemove",false) 
-	 && PkgState[p->ID].Flags & Flag::Auto)
+      if(debug_autoremove && PkgState[p->ID].Flags & Flag::Auto)
   	 std::clog << "AutoDep: " << p.Name() << std::endl;
    }
 
@@ -1317,8 +1369,8 @@ bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc)
 
    return true;
 }
-
-// mark a single package in Mark-and-Sweep
+									/*}}}*/
+// MarkPackage - mark a single package in Mark-and-Sweep		/*{{{*/
 void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
 			      const pkgCache::VerIterator &ver,
 			      bool follow_recommends,
@@ -1357,7 +1409,9 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
    if(state.Marked)
       return;
 
-   if(_config->FindB("Debug::pkgAutoRemove",false))
+   bool debug_autoremove = _config->FindB("Debug::pkgAutoRemove", false);
+   
+   if(debug_autoremove)
      {
        std::clog << "Marking: " << pkg.Name();
        if(!ver.end())
@@ -1388,7 +1442,7 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
 	   {
 	      if(_system->VS->CheckDep(V.VerStr(), d->CompareOp, d.TargetVer()))
 	      {
-		if(_config->FindB("Debug::pkgAutoRemove",false))
+		if(debug_autoremove)
 		  {
 		    std::clog << "Following dep: " << d.ParentPkg().Name()
 			      << " " << d.ParentVer().VerStr() << " "
@@ -1412,7 +1466,7 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
 	      if(_system->VS->CheckDep(prv.ProvideVersion(), d->CompareOp, 
 				       d.TargetVer()))
 	      {
-		if(_config->FindB("Debug::pkgAutoRemove",false))
+		if(debug_autoremove)
 		  {
 		    std::clog << "Following dep: " << d.ParentPkg().Name()
 			      << " " << d.ParentVer().VerStr() << " "
@@ -1437,12 +1491,14 @@ void pkgDepCache::MarkPackage(const pkgCache::PkgIterator &pkg,
      }
    }
 }
-
-bool pkgDepCache::Sweep()
+									/*}}}*/
+bool pkgDepCache::Sweep()						/*{{{*/
 {
+   bool debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false);
+
    // do the sweep
    for(PkgIterator p=PkgBegin(); !p.end(); ++p)
-  {
+   {
      StateCache &state=PkgState[p->ID];
 
      // skip required packages
@@ -1454,10 +1510,11 @@ bool pkgDepCache::Sweep()
      if(!state.Marked && (!p.CurrentVer().end() || state.Install()))
      {
 	state.Garbage=true;
-	if(_config->FindB("Debug::pkgAutoRemove",false))
+	if(debug_autoremove)
 	   std::cout << "Garbage: " << p.Name() << std::endl;
      }
   }   
 
    return true;
 }
+									/*}}}*/

+ 47 - 4
apt-pkg/depcache.h

@@ -294,7 +294,10 @@ class pkgDepCache : protected pkgCache::Namespace
    unsigned long iBrokenCount;
    unsigned long iPolicyBrokenCount;
    unsigned long iBadCount;
-   
+
+   bool DebugMarker;
+   bool DebugAutoInstall;
+
    Policy *delLocalPolicy;           // For memory clean up..
    Policy *LocalPolicy;
    
@@ -387,18 +390,58 @@ class pkgDepCache : protected pkgCache::Namespace
     */
    // @{
    void MarkKeep(PkgIterator const &Pkg, bool Soft = false,
-		 bool FromUser = true);
-   void MarkDelete(PkgIterator const &Pkg,bool Purge = false);
+		 bool FromUser = true, unsigned long Depth = 0);
+   void MarkDelete(PkgIterator const &Pkg, bool Purge = false,
+                   unsigned long Depth = 0, bool FromUser = true);
    void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true,
 		    unsigned long Depth = 0, bool FromUser = true,
 		    bool ForceImportantDeps = false);
+
    void SetReInstall(PkgIterator const &Pkg,bool To);
    void SetCandidateVersion(VerIterator TargetVer);
 
    /** Set the "is automatically installed" flag of Pkg. */
    void MarkAuto(const PkgIterator &Pkg, bool Auto);
    // @}
-   
+
+   /** \return \b true if it's OK for MarkInstall to install
+    *  the given package.
+    *
+    *  See the default implementation for a simple example how this
+    *  method can be used.
+    *  Overriding implementations should use the hold-state-flag to cache
+    *  results from previous checks of this package - also it should
+    *  be used if the default resolver implementation is also used to
+    *  ensure that these packages are handled like "normal" dpkg holds.
+    *
+    *  The parameters are the same as in the calling MarkInstall:
+    *  \param Pkg       the package that MarkInstall wants to install.
+    *  \param AutoInst  needs a previous MarkInstall this package?
+    *  \param Depth     recursive deep of this Marker call
+    *  \param FromUser  was the install requested by the user?
+    */
+   virtual bool IsInstallOk(const PkgIterator &Pkg,bool AutoInst = true,
+			    unsigned long Depth = 0, bool FromUser = true);
+
+   /** \return \b true if it's OK for MarkDelete to remove
+    *  the given package.
+    *
+    *  See the default implementation for a simple example how this
+    *  method can be used.
+    *  Overriding implementations should use the hold-state-flag to cache
+    *  results from previous checks of this package - also it should
+    *  be used if the default resolver implementation is also used to
+    *  ensure that these packages are handled like "normal" dpkg holds.
+    *
+    *  The parameters are the same as in the calling MarkDelete:
+    *  \param Pkg       the package that MarkDelete wants to remove.
+    *  \param Purge     should we purge instead of "only" remove?
+    *  \param Depth     recursive deep of this Marker call
+    *  \param FromUser  was the remove requested by the user?
+    */
+   virtual bool IsDeleteOk(const PkgIterator &Pkg,bool Purge = false,
+			    unsigned long Depth = 0, bool FromUser = true);
+
    // This is for debuging
    void Update(OpProgress *Prog = 0);
 

+ 8 - 8
apt-pkg/indexcopy.cc

@@ -551,8 +551,8 @@ bool SigVerify::Verify(string prefix, string file, indexRecords *MetaIndex)
 
    return true;
 }
-
-bool SigVerify::CopyMetaIndex(string CDROM, string CDName, 
+									/*}}}*/
+bool SigVerify::CopyMetaIndex(string CDROM, string CDName,		/*{{{*/
 			      string prefix, string file)
 {
       char S[400];
@@ -572,8 +572,8 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName,
    
       return true;
 }
-
-bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
+									/*}}}*/
+bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,	/*{{{*/
 			      vector<string> PkgList,vector<string> SrcList)
 {
    if (SigList.size() == 0)
@@ -675,10 +675,9 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
 
    return true;
 }
-
-
-bool TranslationsCopy::CopyTranslations(string CDROM,string Name,vector<string> &List,
-			     pkgCdromStatus *log)
+									/*}}}*/
+bool TranslationsCopy::CopyTranslations(string CDROM,string Name,	/*{{{*/
+				vector<string> &List, pkgCdromStatus *log)
 {
    OpProgress *Progress = NULL;
    if (List.size() == 0)
@@ -850,3 +849,4 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,vector<string>
 
    return true;
 }
+									/*}}}*/

+ 10 - 12
apt-pkg/indexcopy.h

@@ -22,7 +22,7 @@ class FileFd;
 class indexRecords;
 class pkgCdromStatus;
 
-class IndexCopy
+class IndexCopy								/*{{{*/
 {
    protected:
    
@@ -45,8 +45,8 @@ class IndexCopy
 		     pkgCdromStatus *log);
    virtual ~IndexCopy() {};
 };
-
-class PackageCopy : public IndexCopy
+									/*}}}*/
+class PackageCopy : public IndexCopy					/*{{{*/
 {
    protected:
    
@@ -57,8 +57,8 @@ class PackageCopy : public IndexCopy
    
    public:
 };
-
-class SourceCopy : public IndexCopy
+									/*}}}*/
+class SourceCopy : public IndexCopy					/*{{{*/
 {
    protected:
    
@@ -69,8 +69,8 @@ class SourceCopy : public IndexCopy
    
    public:
 };
-
-class TranslationsCopy
+									/*}}}*/
+class TranslationsCopy							/*{{{*/
 {
    protected:
    pkgTagSection *Section;
@@ -79,9 +79,8 @@ class TranslationsCopy
    bool CopyTranslations(string CDROM,string Name,vector<string> &List,
 			 pkgCdromStatus *log);
 };
-
-
-class SigVerify 
+									/*}}}*/
+class SigVerify								/*{{{*/
 {
    bool Verify(string prefix,string file, indexRecords *records);
    bool CopyMetaIndex(string CDROM, string CDName, 
@@ -91,7 +90,6 @@ class SigVerify
    bool CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
 		      vector<string> PkgList,vector<string> SrcList);
 };
-
-
+									/*}}}*/
 
 #endif

+ 0 - 1
apt-pkg/indexfile.cc

@@ -41,7 +41,6 @@ pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
    return 0;
 }
 									/*}}}*/
-    
 // IndexFile::ArchiveInfo - Stub					/*{{{*/
 // ---------------------------------------------------------------------
 /* */

+ 7 - 7
apt-pkg/indexrecords.cc

@@ -9,7 +9,7 @@
 #include <apt-pkg/strutl.h>
 #include <apti18n.h>
 #include <sys/stat.h>
-
+									/*}}}*/
 string indexRecords::GetDist() const
 {
    return this->Dist;
@@ -31,7 +31,7 @@ const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey)
    return Entries[MetaKey];
 }
 
-bool indexRecords::Load(const string Filename)
+bool indexRecords::Load(const string Filename)				/*{{{*/
 {
    FileFd Fd(Filename, FileFd::ReadOnly);
    pkgTagFile TagFile(&Fd, Fd.Size() + 256); // XXX
@@ -85,8 +85,8 @@ bool indexRecords::Load(const string Filename)
    string Strdate = Section.FindS("Date"); // FIXME: verify this somehow?
    return true;
 }
-
-vector<string> indexRecords::MetaKeys()
+									/*}}}*/
+vector<string> indexRecords::MetaKeys()					/*{{{*/
 {
    std::vector<std::string> keys;
    std::map<string,checkSum *>::iterator I = Entries.begin();
@@ -96,8 +96,8 @@ vector<string> indexRecords::MetaKeys()
    }
    return keys;
 }
-
-bool indexRecords::parseSumData(const char *&Start, const char *End,
+									/*}}}*/
+bool indexRecords::parseSumData(const char *&Start, const char *End,	/*{{{*/
 				   string &Name, string &Hash, size_t &Size)
 {
    Name = "";
@@ -154,7 +154,7 @@ bool indexRecords::parseSumData(const char *&Start, const char *End,
    Start = EntryEnd; //prepare for the next round
    return true;
 }
-
+									/*}}}*/
 indexRecords::indexRecords()
 {
 }

+ 13 - 5
apt-pkg/init.cc

@@ -67,6 +67,7 @@ bool pkgInitConfig(Configuration &Cnf)
    Cnf.Set("Dir::Etc::main","apt.conf");
    Cnf.Set("Dir::Etc::parts","apt.conf.d");
    Cnf.Set("Dir::Etc::preferences","preferences");
+   Cnf.Set("Dir::Etc::preferencesparts","preferences.d");
    Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
 
    // State   
@@ -80,19 +81,26 @@ bool pkgInitConfig(Configuration &Cnf)
    
    // Read an alternate config file
    const char *Cfg = getenv("APT_CONFIG");
-   if (Cfg != 0 && FileExists(Cfg) == true)
-      Res &= ReadConfigFile(Cnf,Cfg);
-   
+   if (Cfg != 0)
+   {
+      if (FileExists(Cfg) == true)
+	 Res &= ReadConfigFile(Cnf,Cfg);
+      else
+	 _error->WarningE("FileExists",_("Unable to read %s"),Cfg);
+   }
+
    // Read the configuration parts dir
    string Parts = Cnf.FindDir("Dir::Etc::parts");
    if (FileExists(Parts) == true)
       Res &= ReadConfigDir(Cnf,Parts);
-      
+   else
+      _error->WarningE("FileExists",_("Unable to read %s"),Parts.c_str());
+
    // Read the main config file
    string FName = Cnf.FindFile("Dir::Etc::main");
    if (FileExists(FName) == true)
       Res &= ReadConfigFile(Cnf,FName);
-   
+
    if (Res == false)
       return false;
    

+ 1 - 1
apt-pkg/init.h

@@ -18,7 +18,7 @@
 
 // See the makefile
 #define APT_PKG_MAJOR 4
-#define APT_PKG_MINOR 6
+#define APT_PKG_MINOR 8
 #define APT_PKG_RELEASE 0
     
 extern const char *pkgVersion;

+ 2 - 2
apt-pkg/makefile

@@ -13,9 +13,9 @@ include ../buildlib/defaults.mak
 # methods/makefile - FIXME
 LIBRARY=apt-pkg
 LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
-MAJOR=4.7
+MAJOR=4.8
 MINOR=0
-SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil
+SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil -ldl
 APT_DOMAIN:=libapt-pkg$(MAJOR)
 
 # Source code for the contributed non-core things

+ 7 - 1
apt-pkg/metaindex.h

@@ -39,7 +39,13 @@ class metaIndex
    virtual vector<pkgIndexFile *> *GetIndexFiles() = 0; 
    virtual bool IsTrusted() const = 0;
 
-   virtual ~metaIndex() {};
+   virtual ~metaIndex() {
+      if (Indexes == 0)
+	 return;
+      for (vector<pkgIndexFile *>::iterator I = (*Indexes).begin(); I != (*Indexes).end(); ++I)
+	 delete *I;
+      delete Indexes;
+   }
 };
 
 #endif

+ 2 - 8
apt-pkg/orderlist.cc

@@ -129,7 +129,6 @@ bool pkgOrderList::IsMissing(PkgIterator Pkg)
    return true;
 }
 									/*}}}*/
-
 // OrderList::DoRun - Does an order run					/*{{{*/
 // ---------------------------------------------------------------------
 /* The caller is expeted to have setup the desired probe state */
@@ -282,7 +281,6 @@ bool pkgOrderList::OrderConfigure()
    return DoRun();
 }
 									/*}}}*/
-
 // OrderList::Score - Score the package for sorting			/*{{{*/
 // ---------------------------------------------------------------------
 /* Higher scores order earlier */
@@ -433,7 +431,6 @@ int pkgOrderList::OrderCompareB(const void *a, const void *b)
    return strcmp(A.Name(),B.Name());
 }
 									/*}}}*/
-
 // OrderList::VisitDeps - Visit forward install dependencies		/*{{{*/
 // ---------------------------------------------------------------------
 /* This calls the dependency function for the normal forwards dependencies
@@ -590,7 +587,6 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg)
    return true;
 }
 									/*}}}*/
-
 // OrderList::DepUnPackCrit - Critical UnPacking ordering		/*{{{*/
 // ---------------------------------------------------------------------
 /* Critical unpacking ordering strives to satisfy Conflicts: and 
@@ -668,13 +664,12 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D)
    }   
    return true;
 }
-
+									/*}}}*/
 // OrderList::DepUnPackPreD - Critical UnPacking ordering with depends	/*{{{*/
 // ---------------------------------------------------------------------
 /* Critical PreDepends (also configure immediate and essential) strives to
    ensure not only that all conflicts+predepends are met but that this
-   package will be immediately configurable when it is unpacked. 
-
+   package will be immediately configurable when it is unpacked.
    Loops are preprocessed and logged. */
 bool pkgOrderList::DepUnPackPreD(DepIterator D)
 {
@@ -892,7 +887,6 @@ bool pkgOrderList::DepRemove(DepIterator D)
    return true;
 }
 									/*}}}*/
-
 // OrderList::AddLoop - Add a loop to the loop list			/*{{{*/
 // ---------------------------------------------------------------------
 /* We record the loops. This is a relic since loop breaking is done 

+ 1 - 3
apt-pkg/packagemanager.cc

@@ -26,7 +26,7 @@
 #include <apti18n.h>    
 #include <iostream>
 #include <fcntl.h> 
-
+									/*}}}*/
 using namespace std;
 
 // PM::PackageManager - Constructor					/*{{{*/
@@ -117,7 +117,6 @@ bool pkgPackageManager::FixMissing()
    return Resolve.ResolveByKeep() == true && Cache.BrokenCount() == 0;   
 }
 									/*}}}*/
-
 // PM::ImmediateAdd - Add the immediate flag recursivly			/*{{{*/
 // ---------------------------------------------------------------------
 /* This adds the immediate flag to the pkg and recursively to the
@@ -152,7 +151,6 @@ void pkgPackageManager::ImmediateAdd(PkgIterator I, bool UseInstallVer)
    return;
 }
 									/*}}}*/
-
 // PM::CreateOrderList - Create the ordering class			/*{{{*/
 // ---------------------------------------------------------------------
 /* This populates the ordering list with all the packages that are

+ 55 - 2
apt-pkg/pkgcache.cc

@@ -21,6 +21,7 @@
 									/*}}}*/
 // Include Files							/*{{{*/
 #include <apt-pkg/pkgcache.h>
+#include <apt-pkg/policy.h>
 #include <apt-pkg/indexfile.h>
 #include <apt-pkg/version.h>
 #include <apt-pkg/error.h>
@@ -49,7 +50,7 @@ pkgCache::Header::Header()
    
    /* Whenever the structures change the major version should be bumped,
       whenever the generator changes the minor version should be bumped. */
-   MajorVersion = 7;
+   MajorVersion = 8;
    MinorVersion = 0;
    Dirty = false;
    
@@ -223,7 +224,7 @@ const char *pkgCache::DepType(unsigned char Type)
 {
    const char *Types[] = {"",_("Depends"),_("PreDepends"),_("Suggests"),
                           _("Recommends"),_("Conflicts"),_("Replaces"),
-                          _("Obsoletes"),_("Breaks")};
+                          _("Obsoletes"),_("Breaks"), _("Enhances")};
    if (Type < sizeof(Types)/sizeof(*Types))
       return Types[Type];
    return "";
@@ -290,6 +291,56 @@ pkgCache::PkgIterator::OkState pkgCache::PkgIterator::State() const
    return NeedsNothing;
 }
 									/*}}}*/
+// PkgIterator::CandVersion - Returns the candidate version string	/*{{{*/
+// ---------------------------------------------------------------------
+/* Return string representing of the candidate version. */
+const char *
+pkgCache::PkgIterator::CandVersion() const 
+{
+  //TargetVer is empty, so don't use it.
+  VerIterator version = pkgPolicy::pkgPolicy(Owner).GetCandidateVer(*this);
+  if (version.IsGood())
+    return version.VerStr();
+  return 0;
+};
+									/*}}}*/
+// PkgIterator::CurVersion - Returns the current version string		/*{{{*/
+// ---------------------------------------------------------------------
+/* Return string representing of the current version. */
+const char *
+pkgCache::PkgIterator::CurVersion() const 
+{
+  VerIterator version = CurrentVer();
+  if (version.IsGood())
+    return CurrentVer().VerStr();
+  return 0;
+};
+									/*}}}*/
+// ostream operator to handle string representation of a package	/*{{{*/
+// ---------------------------------------------------------------------
+/* Output name < cur.rent.version -> candid.ate.version | new.est.version > (section)
+   Note that the characters <|>() are all literal above. Versions will be ommited
+   if they provide no new information (e.g. there is no newer version than candidate)
+   If no version and/or section can be found "none" is used. */
+std::ostream& 
+operator<<(ostream& out, pkgCache::PkgIterator Pkg) 
+{
+   if (Pkg.end() == true)
+      return out << "invalid package";
+
+   string current = string(Pkg.CurVersion() == 0 ? "none" : Pkg.CurVersion());
+   string candidate = string(Pkg.CandVersion() == 0 ? "none" : Pkg.CandVersion());
+   string newest = string(Pkg.VersionList().end() ? "none" : Pkg.VersionList().VerStr());
+
+   out << Pkg.Name() << " < " << current;
+   if (current != candidate)
+      out << " -> " << candidate;
+   if ( newest != "none" && candidate != newest)
+      out << " | " << newest;
+   out << " > ( " << string(Pkg.Section()==0?"none":Pkg.Section()) << " )";
+   return out;
+}
+									/*}}}*/
 // DepIterator::IsCritical - Returns true if the dep is important	/*{{{*/
 // ---------------------------------------------------------------------
 /* Currently critical deps are defined as depends, predepends and
@@ -607,6 +658,8 @@ string pkgCache::PkgFileIterator::RelStr()
       Res = Res + (Res.empty() == true?"o=":",o=")  + Origin();
    if (Archive() != 0)
       Res = Res + (Res.empty() == true?"a=":",a=")  + Archive();
+   if (Codename() != 0)
+      Res = Res + (Res.empty() == true?"n=":",n=")  + Codename();
    if (Label() != 0)
       Res = Res + (Res.empty() == true?"l=":",l=")  + Label();
    if (Component() != 0)

+ 26 - 25
apt-pkg/pkgcache.h

@@ -27,7 +27,7 @@
 using std::string;
     
 class pkgVersioningSystem;
-class pkgCache
+class pkgCache								/*{{{*/
 {
    public:
    // Cache element predeclarations
@@ -70,7 +70,7 @@ class pkgCache
    struct Dep
    {
       enum DepType {Depends=1,PreDepends=2,Suggests=3,Recommends=4,
-	 Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8};
+	 Conflicts=5,Replaces=6,Obsoletes=7,DpkgBreaks=8,Enhances=9};
       enum DepCompareOp {Or=0x10,NoOp=0,LessEq=0x1,GreaterEq=0x2,Less=0x3,
 	 Greater=0x4,Equals=0x5,NotEquals=0x6};
    };
@@ -146,8 +146,8 @@ class pkgCache
    pkgCache(MMap *Map,bool DoMap = true);
    virtual ~pkgCache() {};
 };
-
-// Header structure
+									/*}}}*/
+// Header structure							/*{{{*/
 struct pkgCache::Header
 {
    // Signature information
@@ -195,8 +195,8 @@ struct pkgCache::Header
    bool CheckSizes(Header &Against) const;
    Header();
 };
-
-struct pkgCache::Package
+									/*}}}*/
+struct pkgCache::Package						/*{{{*/
 {
    // Pointers
    map_ptrloc Name;              // Stringtable
@@ -217,12 +217,13 @@ struct pkgCache::Package
    unsigned int ID;
    unsigned long Flags;
 };
-
-struct pkgCache::PackageFile
+									/*}}}*/
+struct pkgCache::PackageFile						/*{{{*/
 {
    // Names
    map_ptrloc FileName;        // Stringtable
    map_ptrloc Archive;         // Stringtable
+   map_ptrloc Codename;        // Stringtable
    map_ptrloc Component;       // Stringtable
    map_ptrloc Version;         // Stringtable
    map_ptrloc Origin;          // Stringtable
@@ -238,24 +239,24 @@ struct pkgCache::PackageFile
    unsigned int ID;
    time_t mtime;                  // Modification time for the file
 };
-
-struct pkgCache::VerFile
+									/*}}}*/
+struct pkgCache::VerFile						/*{{{*/
 {
    map_ptrloc File;           // PackageFile
    map_ptrloc NextFile;       // PkgVerFile
    map_ptrloc Offset;         // File offset
    unsigned short Size;
 };
-
-struct pkgCache::DescFile
+									/*}}}*/
+struct pkgCache::DescFile						/*{{{*/
 {
    map_ptrloc File;           // PackageFile
    map_ptrloc NextFile;       // PkgVerFile
    map_ptrloc Offset;         // File offset
    unsigned short Size;
 };
-
-struct pkgCache::Version
+									/*}}}*/
+struct pkgCache::Version						/*{{{*/
 {
    map_ptrloc VerStr;            // Stringtable
    map_ptrloc Section;           // StringTable (StringItem)
@@ -275,8 +276,8 @@ struct pkgCache::Version
    unsigned int ID;
    unsigned char Priority;
 };
-
-struct pkgCache::Description
+									/*}}}*/
+struct pkgCache::Description						/*{{{*/
 {
    // Language Code store the description translation language code. If
    // the value has a 0 lenght then this is readed using the Package
@@ -291,8 +292,8 @@ struct pkgCache::Description
 
    unsigned int ID;
 };
-
-struct pkgCache::Dependency
+									/*}}}*/
+struct pkgCache::Dependency						/*{{{*/
 {
    map_ptrloc Version;         // Stringtable
    map_ptrloc Package;         // Package
@@ -305,8 +306,8 @@ struct pkgCache::Dependency
    unsigned char Type;
    unsigned char CompareOp;
 };
-
-struct pkgCache::Provides
+									/*}}}*/
+struct pkgCache::Provides						/*{{{*/
 {
    map_ptrloc ParentPkg;        // Pacakge
    map_ptrloc Version;          // Version
@@ -314,13 +315,13 @@ struct pkgCache::Provides
    map_ptrloc NextProvides;     // Provides
    map_ptrloc NextPkgProv;      // Provides
 };
-
-struct pkgCache::StringItem
+									/*}}}*/
+struct pkgCache::StringItem						/*{{{*/
 {
    map_ptrloc String;        // Stringtable
    map_ptrloc NextItem;      // StringItem
 };
-
+									/*}}}*/
 #include <apt-pkg/cacheiterators.h>
 
 inline pkgCache::PkgIterator pkgCache::PkgBegin() 
@@ -333,7 +334,7 @@ inline pkgCache::PkgFileIterator pkgCache::FileEnd()
        {return PkgFileIterator(*this,PkgFileP);};
 
 // Oh I wish for Real Name Space Support
-class pkgCache::Namespace
+class pkgCache::Namespace						/*{{{*/
 {   
    public:
 
@@ -351,5 +352,5 @@ class pkgCache::Namespace
    typedef pkgCache::Dep Dep;
    typedef pkgCache::Flag Flag;
 };
-
+									/*}}}*/
 #endif

+ 23 - 19
apt-pkg/pkgcachegen.cc

@@ -53,14 +53,16 @@ pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) :
    {
       // Setup the map interface..
       Cache.HeaderP = (pkgCache::Header *)Map.Data();
-      Map.RawAllocate(sizeof(pkgCache::Header));
+      if (Map.RawAllocate(sizeof(pkgCache::Header)) == 0 && _error->PendingError() == true)
+	 return;
+
       Map.UsePools(*Cache.HeaderP->Pools,sizeof(Cache.HeaderP->Pools)/sizeof(Cache.HeaderP->Pools[0]));
-      
+
       // Starting header
       *Cache.HeaderP = pkgCache::Header();
       Cache.HeaderP->VerSysName = Map.WriteString(_system->VS->Label);
       Cache.HeaderP->Architecture = Map.WriteString(_config->Find("APT::Architecture"));
-      Cache.ReMap(); 
+      Cache.ReMap();
    }
    else
    {
@@ -135,7 +137,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
  	 pkgCache::VerIterator Ver = Pkg.VersionList();
  	 map_ptrloc *LastVer = &Pkg->VersionList;
 
-  	 for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) 
+	 for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++)
  	 {
  	    pkgCache::DescIterator Desc = Ver.DescriptionList();
  	    map_ptrloc *LastDesc = &Ver->DescriptionList;
@@ -143,7 +145,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
 
 	    // don't add a new description if we have one for the given
 	    // md5 && language
- 	    for ( ; Desc.end() == false; Desc++)
+	    for ( ; Desc.end() == false; Desc++)
 	       if (MD5SumValue(Desc.md5()) == CurMd5 && 
 	           Desc.LanguageCode() == List.DescriptionLanguage())
 		  duplicate=true;
@@ -151,7 +153,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
 	       continue;
 	    
  	    for (Desc = Ver.DescriptionList();
-		 Desc.end() == false; 
+		 Desc.end() == false;
 		 LastDesc = &Desc->NextDesc, Desc++)
 	    {
  	       if (MD5SumValue(Desc.md5()) == CurMd5) 
@@ -160,7 +162,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
  		  *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc);
  		  Desc->ParentPkg = Pkg.Index();
 		  
- 		  if (NewFileDesc(Desc,List) == false)
+		  if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
  		     return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),PackageName.c_str());
  		  break;
  	       }
@@ -220,7 +222,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
       Ver->ParentPkg = Pkg.Index();
       Ver->Hash = Hash;
 
-      if (List.NewVersion(Ver) == false)
+      if ((*LastVer == 0 && _error->PendingError()) || List.NewVersion(Ver) == false)
 	 return _error->Error(_("Error occurred while processing %s (NewVersion1)"),
 			      PackageName.c_str());
 
@@ -252,7 +254,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List,
       *LastDesc = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc);
       Desc->ParentPkg = Pkg.Index();
 
-      if (NewFileDesc(Desc,List) == false)
+      if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false)
 	 return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),PackageName.c_str());
    }
 
@@ -419,7 +421,7 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc,
    // Get a structure
    unsigned long DescFile = Map.Allocate(sizeof(pkgCache::DescFile));
    if (DescFile == 0)
-      return 0;
+      return false;
 
    pkgCache::DescFileIterator DF(Cache,Cache.DescFileP + DescFile);
    DF->File = CurrentFile - Cache.PkgFileP;
@@ -460,6 +462,8 @@ map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc,
    Desc->ID = Cache.HeaderP->DescriptionCount++;
    Desc->language_code = Map.WriteString(Lang);
    Desc->md5sum = Map.WriteString(md5sum.Value());
+   if (Desc->language_code == 0 || Desc->md5sum == 0)
+      return 0;
 
    return Description;
 }
@@ -652,7 +656,6 @@ unsigned long pkgCacheGenerator::WriteUniqString(const char *S,
    return ItemP->String;
 }
 									/*}}}*/
-
 // CheckValidity - Check that a cache is up-to-date			/*{{{*/
 // ---------------------------------------------------------------------
 /* This just verifies that each file in the list of index files exists,
@@ -667,7 +670,7 @@ static bool CheckValidity(const string &CacheFile, FileIterator Start,
    
    // Map it
    FileFd CacheF(CacheFile,FileFd::ReadOnly);
-   SPtr<MMap> Map = new MMap(CacheF,MMap::Public | MMap::ReadOnly);
+   SPtr<MMap> Map = new MMap(CacheF,0);
    pkgCache Cache(Map);
    if (_error->PendingError() == true || Map->Size() == 0)
    {
@@ -810,7 +813,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
    unsigned long EndOfSource = Files.size();
    if (_system->AddStatusFiles(Files) == false)
       return false;
-   
+
    // Decide if we can write to the files..
    string CacheFile = _config->FindFile("Dir::Cache::pkgcache");
    string SrcCacheFile = _config->FindFile("Dir::Cache::srcpkgcache");
@@ -851,7 +854,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
    else
    {
       // Just build it in memory..
-      Map = new DynamicMMap(MMap::Public,MapSize);
+      Map = new DynamicMMap(0,MapSize);
    }
    
    // Lets try the source cache.
@@ -862,8 +865,10 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
    {
       // Preload the map with the source cache
       FileFd SCacheF(SrcCacheFile,FileFd::ReadOnly);
-      if (SCacheF.Read((unsigned char *)Map->Data() + Map->RawAllocate(SCacheF.Size()),
-		       SCacheF.Size()) == false)
+      unsigned long alloc = Map->RawAllocate(SCacheF.Size());
+      if ((alloc == 0 && _error->PendingError())
+		|| SCacheF.Read((unsigned char *)Map->Data() + alloc,
+				SCacheF.Size()) == false)
 	 return false;
 
       TotalSize = ComputeSize(Files.begin()+EndOfSource,Files.end());
@@ -924,7 +929,7 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
       if (CacheF != 0)
       {
 	 delete Map.UnGuard();
-	 *OutMap = new MMap(*CacheF,MMap::Public | MMap::ReadOnly);
+	 *OutMap = new MMap(*CacheF,0);
       }
       else
       {
@@ -946,8 +951,7 @@ bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap)
    if (_system->AddStatusFiles(Files) == false)
       return false;
    
-   SPtr<DynamicMMap> Map;   
-   Map = new DynamicMMap(MMap::Public,MapSize);
+   SPtr<DynamicMMap> Map = new DynamicMMap(0,MapSize);
    unsigned long CurrentSize = 0;
    unsigned long TotalSize = 0;
    

+ 4 - 4
apt-pkg/pkgcachegen.h

@@ -28,7 +28,7 @@ class OpProgress;
 class MMap;
 class pkgIndexFile;
 
-class pkgCacheGenerator
+class pkgCacheGenerator							/*{{{*/
 {
    private:
    
@@ -76,8 +76,8 @@ class pkgCacheGenerator
    pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
    ~pkgCacheGenerator();
 };
-
-// This is the abstract package list parser class.
+									/*}}}*/
+// This is the abstract package list parser class.			/*{{{*/
 class pkgCacheGenerator::ListParser
 {
    pkgCacheGenerator *Owner;
@@ -126,7 +126,7 @@ class pkgCacheGenerator::ListParser
    ListParser() : FoundFileDeps(false) {};
    virtual ~ListParser() {};
 };
-
+									/*}}}*/
 bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
 			MMap **OutMap = 0,bool AllowMem = false);
 bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap);

+ 4 - 4
apt-pkg/pkgrecords.h

@@ -22,7 +22,7 @@
 #include <apt-pkg/fileutl.h>
 #include <vector>
 
-class pkgRecords
+class pkgRecords							/*{{{*/
 {
    public:
    class Parser;
@@ -42,8 +42,8 @@ class pkgRecords
    pkgRecords(pkgCache &Cache);
    ~pkgRecords();
 };
-
-class pkgRecords::Parser
+									/*}}}*/
+class pkgRecords::Parser						/*{{{*/
 {
    protected:
    
@@ -73,5 +73,5 @@ class pkgRecords::Parser
    
    virtual ~Parser() {};
 };
-
+									/*}}}*/
 #endif

+ 82 - 2
apt-pkg/policy.cc

@@ -32,6 +32,9 @@
     
 #include <apti18n.h>
 
+#include <dirent.h>
+#include <sys/stat.h>
+#include <algorithm>
 #include <iostream>
 #include <sstream>
 									/*}}}*/
@@ -120,6 +123,14 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator Pkg)
    signed Max = GetPriority(Pkg);
    pkgCache::VerIterator Pref = GetMatch(Pkg);
 
+   // no package = no candidate version
+   if (Pkg.end() == true)
+      return Pref;
+
+   // packages with a pin lower than 0 have no newer candidate than the current version
+   if (Max < 0)
+      return Pkg.CurrentVer();
+
    /* Falling through to the default version.. Setting Max to zero
       effectively excludes everything <= 0 which are the non-automatic
       priorities.. The status file is given a prio of 100 which will exclude
@@ -239,7 +250,76 @@ signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
    return 0;
 }
 									/*}}}*/
+// PreferenceSection class - Overriding the default TrimRecord method	/*{{{*/
+// ---------------------------------------------------------------------
+/* The preference file is a user generated file so the parser should
+   therefore be a bit more friendly by allowing comments and new lines
+   all over the place rather than forcing a special format */
+class PreferenceSection : public pkgTagSection
+{
+   void TrimRecord(bool BeforeRecord, const char* &End)
+   {
+      for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r' || Stop[0] == '#'); Stop++)
+	 if (Stop[0] == '#')
+	    Stop = (const char*) memchr(Stop,'\n',End-Stop);
+   }
+};
+									/*}}}*/
+// ReadPinDir - Load the pin files from this dir into a Policy		/*{{{*/
+// ---------------------------------------------------------------------
+/* This will load each pin file in the given dir into a Policy. If the
+   given dir is empty the dir set in Dir::Etc::PreferencesParts is used.
+   Note also that this method will issue a warning if the dir does not
+   exists but it will return true in this case! */
+bool ReadPinDir(pkgPolicy &Plcy,string Dir)
+{
+   if (Dir.empty() == true)
+      Dir = _config->FindDir("Dir::Etc::PreferencesParts");
+
+   if (FileExists(Dir) == false)
+   {
+      _error->WarningE("FileExists",_("Unable to read %s"),Dir.c_str());
+      return true;
+   }
+
+   DIR *D = opendir(Dir.c_str());
+   if (D == 0)
+      return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
+
+   vector<string> List;
 
+   for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D))
+   {
+      if (Ent->d_name[0] == '.')
+	 continue;
+
+      // Skip bad file names ala run-parts
+      const char *C = Ent->d_name;
+      for (; *C != 0; C++)
+	 if (isalpha(*C) == 0 && isdigit(*C) == 0 && *C != '_' && *C != '-')
+	    break;
+      if (*C != 0)
+	 continue;
+
+      // Make sure it is a file and not something else
+      string File = flCombine(Dir,Ent->d_name);
+      struct stat St;
+      if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
+	 continue;
+
+      List.push_back(File);
+   }
+   closedir(D);
+
+   sort(List.begin(),List.end());
+
+   // Read the files
+   for (vector<string>::const_iterator I = List.begin(); I != List.end(); I++)
+      if (ReadPinFile(Plcy, *I) == false)
+	 return false;
+   return true;
+}
+									/*}}}*/
 // ReadPinFile - Load the pin file into a Policy			/*{{{*/
 // ---------------------------------------------------------------------
 /* I'd like to see the preferences file store more than just pin information
@@ -259,12 +339,12 @@ bool ReadPinFile(pkgPolicy &Plcy,string File)
    if (_error->PendingError() == true)
       return false;
    
-   pkgTagSection Tags;
+   PreferenceSection Tags;
    while (TF.Step(Tags) == true)
    {
       string Name = Tags.FindS("Package");
       if (Name.empty() == true)
-	 return _error->Error(_("Invalid record in the preferences file, no Package header"));
+	 return _error->Error(_("Invalid record in the preferences file %s, no Package header"), File.c_str());
       if (Name == "*")
 	 Name = string();
       

+ 1 - 0
apt-pkg/policy.h

@@ -84,5 +84,6 @@ class pkgPolicy : public pkgDepCache::Policy
 };
 
 bool ReadPinFile(pkgPolicy &Plcy,string File = "");
+bool ReadPinDir(pkgPolicy &Plcy,string Dir = "");
 
 #endif

+ 6 - 2
apt-pkg/sourcelist.cc

@@ -158,12 +158,16 @@ bool pkgSourceList::ReadMainList()
    //                  entries in sources.list.d.
    string Main = _config->FindFile("Dir::Etc::sourcelist");
    if (FileExists(Main) == true)
-      Res &= ReadAppend(Main);   
+      Res &= ReadAppend(Main);
+   else
+      _error->WarningE("FileExists",_("Unable to read %s"),Main.c_str());
 
    string Parts = _config->FindDir("Dir::Etc::sourceparts");
    if (FileExists(Parts) == true)
       Res &= ReadSourceDir(Parts);
-   
+   else
+      _error->WarningE("FileExists",_("Unable to read %s"),Parts.c_str());
+
    return Res;
 }
 									/*}}}*/

+ 16 - 5
apt-pkg/tagfile.cc

@@ -81,7 +81,7 @@ bool pkgTagFile::Resize()
    End = Start + EndSize;
    return true;
 }
-
+									/*}}}*/
 // TagFile::Step - Advance to the next section				/*{{{*/
 // ---------------------------------------------------------------------
 /* If the Section Scanner fails we refill the buffer and try again. 
@@ -212,10 +212,12 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength)
 
    if (Stop == 0)
       return false;
-   
+
    TagCount = 0;
    while (TagCount+1 < sizeof(Indexes)/sizeof(Indexes[0]) && Stop < End)
    {
+       TrimRecord(true,End);
+
       // Start a new index and add it to the hash
       if (isspace(Stop[0]) == 0)
       {
@@ -227,14 +229,14 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength)
       
       if (Stop == 0)
 	 return false;
-      
+
       for (; Stop+1 < End && Stop[1] == '\r'; Stop++);
 
       // Double newline marks the end of the record
       if (Stop+1 < End && Stop[1] == '\n')
       {
 	 Indexes[TagCount] = Stop - Section;
-	 for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r'); Stop++);
+	 TrimRecord(false,End);
 	 return true;
       }
       
@@ -244,6 +246,16 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength)
    return false;
 }
 									/*}}}*/
+// TagSection::TrimRecord - Trim off any garbage before/after a record	/*{{{*/
+// ---------------------------------------------------------------------
+/* There should be exactly 2 newline at the end of the record, no more. */
+void pkgTagSection::TrimRecord(bool BeforeRecord, const char*& End)
+{
+   if (BeforeRecord == true)
+      return;
+   for (; Stop < End && (Stop[0] == '\n' || Stop[0] == '\r'); Stop++);
+}
+									/*}}}*/
 // TagSection::Trim - Trim off any trailing garbage			/*{{{*/
 // ---------------------------------------------------------------------
 /* There should be exactly 1 newline at the end of the buffer, no more. */
@@ -390,7 +402,6 @@ bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags,
    return true;
 }
 									/*}}}*/
-
 // TFRewrite - Rewrite a control record					/*{{{*/
 // ---------------------------------------------------------------------
 /* This writes the control record to stdout rewriting it as necessary. The

+ 4 - 1
apt-pkg/tagfile.h

@@ -27,7 +27,6 @@
 class pkgTagSection
 {
    const char *Section;
-   const char *Stop;
    
    // We have a limit of 256 tags per section.
    unsigned int Indexes[256];
@@ -35,6 +34,9 @@ class pkgTagSection
    
    unsigned int TagCount;
      
+   protected:
+   const char *Stop;
+
    public:
    
    inline bool operator ==(const pkgTagSection &rhs) {return Section == rhs.Section;};
@@ -49,6 +51,7 @@ class pkgTagSection
    bool Scan(const char *Start,unsigned long MaxLength);
    inline unsigned long size() const {return Stop - Section;};
    void Trim();
+   virtual void TrimRecord(bool BeforeRecord, const char* &End);
    
    inline unsigned int Count() const {return TagCount;};
    inline void Get(const char *&Start,const char *&Stop,unsigned int I) const

+ 10 - 9
apt-pkg/vendorlist.cc

@@ -10,7 +10,7 @@ pkgVendorList::~pkgVendorList()
       delete *I;
 }
 
-// pkgVendorList::ReadMainList - Read list of known package vendors		/*{{{*/
+// pkgVendorList::ReadMainList - Read list of known package vendors	/*{{{*/
 // ---------------------------------------------------------------------
 /* This also scans a directory of vendor files similar to apt.conf.d 
    which can contain the usual suspects of distribution provided data.
@@ -31,8 +31,8 @@ bool pkgVendorList::ReadMainList()
 
    return CreateList(Cnf);
 }
-
-bool pkgVendorList::Read(string File)
+									/*}}}*/
+bool pkgVendorList::Read(string File)					/*{{{*/
 {
    Configuration Cnf;
    if (ReadConfigFile(Cnf,File,true) == false)
@@ -40,8 +40,8 @@ bool pkgVendorList::Read(string File)
 
    return CreateList(Cnf);
 }
-
-bool pkgVendorList::CreateList(Configuration& Cnf)
+									/*}}}*/
+bool pkgVendorList::CreateList(Configuration& Cnf)			/*{{{*/
 {
    for (vector<const Vendor *>::const_iterator I = VendorList.begin(); 
 	I != VendorList.end(); I++)
@@ -110,8 +110,8 @@ bool pkgVendorList::CreateList(Configuration& Cnf)
    
    return !_error->PendingError();
 }
-
-const Vendor* pkgVendorList::LookupFingerprint(string Fingerprint)
+									/*}}}*/
+const Vendor* pkgVendorList::LookupFingerprint(string Fingerprint)	/*{{{*/
 {
    for (const_iterator I = VendorList.begin(); I != VendorList.end(); ++I)
    {
@@ -121,8 +121,8 @@ const Vendor* pkgVendorList::LookupFingerprint(string Fingerprint)
 
    return NULL;
 }
-
-const Vendor* pkgVendorList::FindVendor(const std::vector<string> GPGVOutput)
+									/*}}}*/
+const Vendor* pkgVendorList::FindVendor(const std::vector<string> GPGVOutput)	/*{{{*/
 {
    for (std::vector<string>::const_iterator I = GPGVOutput.begin(); I != GPGVOutput.end(); I++)
    {
@@ -142,3 +142,4 @@ const Vendor* pkgVendorList::FindVendor(const std::vector<string> GPGVOutput)
 
    return NULL;
 }
+									/*}}}*/

+ 24 - 13
apt-pkg/versionmatch.cc

@@ -63,8 +63,8 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type)
 	 if (isdigit(Data[0]))
 	    RelVerStr = Data;
 	 else
-	    RelArchive = Data;
-	 
+	    RelRelease = Data;
+
 	 if (RelVerStr.length() > 0 && RelVerStr.end()[-1] == '*')
 	 {
 	    RelVerPrefixMatch = true;
@@ -87,19 +87,21 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type)
       {
 	 if (strlen(Fragments[J]) < 3)
 	    continue;
-	    
+
 	 if (stringcasecmp(Fragments[J],Fragments[J]+2,"v=") == 0)
 	    RelVerStr = Fragments[J]+2;
 	 else if (stringcasecmp(Fragments[J],Fragments[J]+2,"o=") == 0)
 	    RelOrigin = Fragments[J]+2;
 	 else if (stringcasecmp(Fragments[J],Fragments[J]+2,"a=") == 0)
 	    RelArchive = Fragments[J]+2;
+	 else if (stringcasecmp(Fragments[J],Fragments[J]+2,"n=") == 0)
+	    RelCodename = Fragments[J]+2;
 	 else if (stringcasecmp(Fragments[J],Fragments[J]+2,"l=") == 0)
 	    RelLabel = Fragments[J]+2;
 	 else if (stringcasecmp(Fragments[J],Fragments[J]+2,"c=") == 0)
 	    RelComponent = Fragments[J]+2;
       }
-      
+
       if (RelVerStr.end()[-1] == '*')
       {
 	 RelVerPrefixMatch = true;
@@ -169,15 +171,16 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File)
    {
       if (MatchAll == true)
 	 return true;
-      
+
 /*      cout << RelVerStr << ',' << RelOrigin << ',' << RelArchive << ',' << RelLabel << endl;
       cout << File.Version() << ',' << File.Origin() << ',' << File.Archive() << ',' << File.Label() << endl;*/
-      
+
       if (RelVerStr.empty() == true && RelOrigin.empty() == true &&
 	  RelArchive.empty() == true && RelLabel.empty() == true &&
+	  RelRelease.empty() == true && RelCodename.empty() == true &&
 	  RelComponent.empty() == true)
 	 return false;
-      
+
       if (RelVerStr.empty() == false)
 	 if (File->Version == 0 ||
 	     MatchVer(File.Version(),RelVerStr,RelVerPrefixMatch) == false)
@@ -187,11 +190,19 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File)
 	     stringcasecmp(RelOrigin,File.Origin()) != 0)
 	    return false;
       if (RelArchive.empty() == false)
-      {
-	 if (File->Archive == 0 || 
+	 if (File->Archive == 0 ||
 	     stringcasecmp(RelArchive,File.Archive()) != 0)
-	    return false;
-      }      
+            return false;
+      if (RelCodename.empty() == false)
+	 if (File->Codename == 0 ||
+	     stringcasecmp(RelCodename,File.Codename()) != 0)
+            return false;
+      if (RelRelease.empty() == false)
+	 if ((File->Archive == 0 ||
+	     stringcasecmp(RelRelease,File.Archive()) != 0) &&
+             (File->Codename == 0 ||
+	      stringcasecmp(RelRelease,File.Codename()) != 0))
+	       return false;
       if (RelLabel.empty() == false)
 	 if (File->Label == 0 ||
 	     stringcasecmp(RelLabel,File.Label()) != 0)
@@ -202,7 +213,7 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File)
 	    return false;
       return true;
    }
-   
+
    if (Type == Origin)
    {
       if (OrSite.empty() == false) {
@@ -213,7 +224,7 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File)
 	    return false;
       return (OrSite == File.Site());		/* both strings match */
    }
-   
+
    return false;
 }
 									/*}}}*/

+ 13 - 8
apt-pkg/versionmatch.h

@@ -3,29 +3,32 @@
 // $Id: versionmatch.h,v 1.4 2001/05/29 03:07:12 jgg Exp $
 /* ######################################################################
 
-   Version Matching 
-   
+   Version Matching
+
    This module takes a matching string and a type and locates the version
    record that satisfies the constraint described by the matching string.
 
      Version: 1.2*
      Release: o=Debian,v=2.1*,c=main
      Release: v=2.1*
+     Release: a=testing
+     Release: n=squeeze
      Release: *
      Origin: ftp.debian.org
-   
+
    Release may be a complex type that can specify matches for any of:
       Version (v= with prefix)
       Origin (o=)
-      Archive (a=)
+      Archive (a=) eg, unstable, testing, stable
+      Codename (n=) e.g. etch, lenny, squeeze, sid
       Label (l=)
       Component (c=)
    If there are no equals signs in the string then it is scanned in short
-   form - if it starts with a number it is Version otherwise it is an 
-   Archive.
-   
+   form - if it starts with a number it is Version otherwise it is an
+   Archive or a Codename.
+
    Release may be a '*' to match all releases.
-   
+
    ##################################################################### */
 									/*}}}*/
 #ifndef PKGLIB_VERSIONMATCH_H
@@ -47,6 +50,8 @@ class pkgVersionMatch
    string RelVerStr;
    bool RelVerPrefixMatch;
    string RelOrigin;
+   string RelRelease;
+   string RelCodename;
    string RelArchive;
    string RelLabel;
    string RelComponent;

+ 9 - 14
cmdline/apt-cache.cc

@@ -399,7 +399,7 @@ bool DumpAvail(CommandLine &Cmd)
    pkgCache &Cache = *GCache;
 
    pkgPolicy Plcy(&Cache);
-   if (ReadPinFile(Plcy) == false)
+   if (ReadPinFile(Plcy) == false || ReadPinDir(Plcy) == false)
       return false;
    
    unsigned long Count = Cache.HeaderP->PackageCount+1;
@@ -626,7 +626,7 @@ bool Depends(CommandLine &CmdL)
    
    return true;
 }
-
+									/*}}}*/
 // RDepends - Print out a reverse dependency tree - mbc			/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -714,10 +714,7 @@ bool RDepends(CommandLine &CmdL)
    
    return true;
 }
-
 									/*}}}*/
-
-
 // xvcg - Generate a graph for xvcg					/*{{{*/
 // ---------------------------------------------------------------------
 // Code contributed from Junichi Uekawa <dancer@debian.org> on 20 June 2002.
@@ -937,8 +934,6 @@ bool XVcg(CommandLine &CmdL)
    return true;
 }
 									/*}}}*/
-
-
 // Dotty - Generate a graph for Dotty					/*{{{*/
 // ---------------------------------------------------------------------
 /* Dotty is the graphvis program for generating graphs. It is a fairly
@@ -1274,15 +1269,16 @@ bool DisplayRecord(pkgCache::VerIterator V)
    return true;
 }
 									/*}}}*/
-// Search - Perform a search						/*{{{*/
-// ---------------------------------------------------------------------
-/* This searches the package names and package descriptions for a pattern */
+
 struct ExDescFile
 {
    pkgCache::DescFile *Df;
    bool NameMatch;
 };
 
+// Search - Perform a search						/*{{{*/
+// ---------------------------------------------------------------------
+/* This searches the package names and package descriptions for a pattern */
 bool Search(CommandLine &CmdL)
 {
    pkgCache &Cache = *GCache;
@@ -1519,7 +1515,7 @@ bool Policy(CommandLine &CmdL)
    
    pkgCache &Cache = *GCache;
    pkgPolicy Plcy(&Cache);
-   if (ReadPinFile(Plcy) == false)
+   if (ReadPinFile(Plcy) == false || ReadPinDir(Plcy) == false)
       return false;
    
    // Print out all of the package files
@@ -1696,7 +1692,6 @@ bool Madison(CommandLine &CmdL)
 
    return true;
 }
-
 									/*}}}*/
 // GenCaches - Call the main cache generator				/*{{{*/
 // ---------------------------------------------------------------------
@@ -1770,8 +1765,7 @@ void CacheInitialize()
    _config->Set("help",false);
 }
 									/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[])					/*{{{*/
 {
    CommandLine::Args Args[] = {
       {'h',"help","help",0},
@@ -1878,3 +1872,4 @@ int main(int argc,const char *argv[])
           
    return 0;
 }
+									/*}}}*/

+ 3 - 7
cmdline/apt-cdrom.cc

@@ -40,8 +40,7 @@
 
 using namespace std;
 
-                                                                        /*{{{*/
-class pkgCdromTextStatus : public pkgCdromStatus
+class pkgCdromTextStatus : public pkgCdromStatus			/*{{{*/
 {
 protected:
    OpTextProgress Progress;
@@ -98,9 +97,7 @@ OpProgress* pkgCdromTextStatus::GetOpProgress()
 { 
    return &Progress; 
 };
-
 									/*}}}*/
-
 // DoAdd - Add a new CDROM						/*{{{*/
 // ---------------------------------------------------------------------
 /* This does the main add bit.. We show some status and things. The
@@ -129,7 +126,6 @@ bool DoIdent(CommandLine &)
    return cdrom.Ident(ident, &log);
 }
 									/*}}}*/
-
 // ShowHelp - Show the help screen					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -164,8 +160,7 @@ int ShowHelp()
    return 0;
 }
 									/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[])					/*{{{*/
 {
    CommandLine::Args Args[] = {
       {'h',"help","help",0},
@@ -222,3 +217,4 @@ int main(int argc,const char *argv[])
    
    return 0;
 }
+									/*}}}*/

+ 2 - 2
cmdline/apt-config.cc

@@ -88,8 +88,7 @@ int ShowHelp()
    return 0;
 }
 									/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[])					/*{{{*/
 {
    CommandLine::Args Args[] = {
       {'h',"help","help",0},
@@ -133,3 +132,4 @@ int main(int argc,const char *argv[])
    
    return 0;
 }
+									/*}}}*/

+ 2 - 2
cmdline/apt-extracttemplates.cc

@@ -348,8 +348,7 @@ bool Go(CommandLine &CmdL)
 	return !_error->PendingError();
 }
 									/*}}}*/
-
-int main(int argc, const char **argv)
+int main(int argc, const char **argv)					/*{{{*/
 {
 	CommandLine::Args Args[] = {
 		{'h',"help","help",0},
@@ -391,3 +390,4 @@ int main(int argc, const char **argv)
 	
 	return 0;
 }
+									/*}}}*/

+ 29 - 16
cmdline/apt-get.cc

@@ -111,6 +111,9 @@ class CacheFile : public pkgCacheFile
 	 return Open(true);
    }
    CacheFile() : List(0) {};
+   ~CacheFile() {
+      delete[] List;
+   }
 };
 									/*}}}*/
 
@@ -594,7 +597,6 @@ void Stats(ostream &out,pkgDepCache &Dep)
 	       Dep.BadCount());
 }
 									/*}}}*/
-
 // CacheFile::NameComp - QSort compare by name				/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -687,7 +689,10 @@ bool CacheFile::CheckDeps(bool AllowBroken)
       
    return true;
 }
-
+									/*}}}*/
+// CheckAuth - check if each download comes form a trusted source	/*{{{*/
+// ---------------------------------------------------------------------
+/* */
 static bool CheckAuth(pkgAcquire& Fetcher)
 {
    string UntrustedList;
@@ -728,10 +733,7 @@ static bool CheckAuth(pkgAcquire& Fetcher)
 
    return _error->Error(_("There are problems and -y was used without --force-yes"));
 }
-
-
 									/*}}}*/
-
 // InstallPackages - Actually download and install the packages		/*{{{*/
 // ---------------------------------------------------------------------
 /* This displays the informative messages describing what is going to 
@@ -1301,9 +1303,9 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
    while ((Parse = SrcRecs.Find(Src.c_str(), MatchSrcOnly)) != 0)
    {
       string Ver = Parse->Version();
-      
+
       // show name mismatches
-      if (IsMatch == true && Parse->Package() != Src) 
+      if (IsMatch == true && Parse->Package() != Src)       
 	 ioprintf(c1out,  _("No source package '%s' picking '%s' instead\n"), Parse->Package().c_str(), Src.c_str());
       
       if (VerTag.empty() == false)
@@ -1335,7 +1337,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
    return Last;
 }
 									/*}}}*/
-
 // DoUpdate - Update the package lists					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -1457,7 +1458,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
    }
    return true;
 }
-
+									/*}}}*/
 // DoUpgrade - Upgrade all packages					/*{{{*/
 // ---------------------------------------------------------------------
 /* Upgrade all packages without installing new packages or erasing old
@@ -1532,7 +1533,7 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix,
    regfree(&Pattern);
    return res;
 }
-
+									/*}}}*/
 // DoInstall - Install packages from the command line			/*{{{*/
 // ---------------------------------------------------------------------
 /* Install named packages */
@@ -1870,7 +1871,8 @@ bool DoInstall(CommandLine &CmdL)
    // cache.commit()
    if (AutoMarkChanged > 0 &&
        Cache->DelCount() == 0 && Cache->InstCount() == 0 &&
-       Cache->BadCount() == 0)
+       Cache->BadCount() == 0 &&
+       _config->FindB("APT::Get::Simulate",false) == false)
       Cache->writeStateFile(NULL);
 
    // See if we need to prompt
@@ -2522,7 +2524,7 @@ bool DoBuildDep(CommandLine &CmdL)
             {
                // We successfully installed something; skip remaining alternatives
                skipAlternatives = hasAlternatives;
-	       if(_config->FindB("APT::Get::Build-Dep-Automatic", true) == true)
+	       if(_config->FindB("APT::Get::Build-Dep-Automatic", false) == true)
 		  Cache->MarkAuto(Pkg, true);
                continue;
             }
@@ -2698,8 +2700,7 @@ void SigWinch(int)
 #endif
 }
 									/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[])					/*{{{*/
 {
    CommandLine::Args Args[] = {
       {'h',"help","help",0},
@@ -2739,7 +2740,6 @@ int main(int argc,const char *argv[])
       {0,"only-source","APT::Get::Only-Source",0},
       {0,"arch-only","APT::Get::Arch-Only",0},
       {0,"auto-remove","APT::Get::AutomaticRemove",0},
-      {0,"build-dep-automatic","APT::Get::Build-Dep-Automatic",0},
       {0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0},
       {0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean},
       {0,"fix-policy","APT::Get::Fix-Policy-Broken",0},
@@ -2789,7 +2789,19 @@ int main(int argc,const char *argv[])
       ShowHelp(CmdL);
       return 0;
    }
-   
+
+   // simulate user-friendly if apt-get has no root privileges
+   if (getuid() != 0 && _config->FindB("APT::Get::Simulate") == true)
+   {
+      if (_config->FindB("APT::Get::Show-User-Simulation-Note",true) == true)
+	 cout << _("NOTE: This is only a simulation!\n"
+	    "      apt-get needs root privileges for real execution.\n"
+	    "      Keep also in mind that locking is deactivated,\n"
+	    "      so don't depend on the relevance to the real current situation!"
+	 ) << std::endl;
+      _config->Set("Debug::NoLocking",true);
+   }
+
    // Deal with stdout not being a tty
    if (!isatty(STDOUT_FILENO) && _config->FindI("quiet",0) < 1)
       _config->Set("quiet","1");
@@ -2821,3 +2833,4 @@ int main(int argc,const char *argv[])
    
    return 0;   
 }
+									/*}}}*/

+ 4 - 4
cmdline/apt-sortpkgs.cc

@@ -31,7 +31,7 @@
 
 using namespace std;
 
-struct PkgName
+struct PkgName								/*{{{*/
 {
    string Name;
    string Ver;
@@ -55,7 +55,7 @@ struct PkgName
    bool operator >(const PkgName &x) const {return Compare3(x) > 0;};
    bool operator ==(const PkgName &x) const {return Compare3(x) == 0;};
 };
-
+									/*}}}*/
 // DoIt - Sort a single file						/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -161,8 +161,7 @@ int ShowHelp()
    return 0;
 }
 									/*}}}*/
-
-int main(int argc,const char *argv[])
+int main(int argc,const char *argv[])					/*{{{*/
 {
    CommandLine::Args Args[] = {
       {'h',"help","help",0},
@@ -206,3 +205,4 @@ int main(int argc,const char *argv[])
    
    return 0;   
 }
+									/*}}}*/

+ 1 - 1
configure.in

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.7.20~exp3")
+AC_DEFINE_UNQUOTED(VERSION,"0.7.21")
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)

+ 0 - 13
debian/.cvsignore

@@ -1,13 +0,0 @@
-copyright
-apt
-apt-doc
-apt-utils
-apt-utils.substvars
-apt.substvars
-files
-libapt-pkg-dev
-libapt-pkg-doc
-shlibs.local
-shlibs.local.apt
-shlibs.local.apt-utils
-*.debhelper

+ 27 - 2
debian/apt.cron.daily

@@ -69,7 +69,7 @@ check_stamp()
     interval="$2"
 
     if [ $interval -eq 0 ]; then
-	debug_echo "check_stamp: interval=0."
+	debug_echo "check_stamp: interval=0"
 	# treat as no time has passed
         return 1
     fi
@@ -81,13 +81,38 @@ check_stamp()
     fi
 
     # compare midnight today to midnight the day the stamp was updated
-    stamp=$(date -r $stamp '+%s')
+    stamp_file="$stamp"
+    stamp=$(date --date=$(date -r $stamp_file --iso-8601) +%s 2>/dev/null)
+    if [ "$?" != "0" ]; then
+        # Due to some timezones returning 'invalid date' for midnight on
+        # certain dates (eg America/Sao_Paulo), if date returns with error
+        # remove the stamp file and return 0. See coreutils bug:
+        # http://lists.gnu.org/archive/html/bug-coreutils/2007-09/msg00176.html
+        rm -f "$stamp_file"
+        return 0
+    fi
+
+    now=$(date --date=$(date --iso-8601) +%s 2>/dev/null)
+    if [ "$?" != "0" ]; then
+        # As above, due to some timezones returning 'invalid date' for midnight
+        # on certain dates (eg America/Sao_Paulo), if date returns with error
+        # return 0.
+        return 0
+    fi
+
     delta=$(($now-$stamp))
 
     # intervall is in days, convert to sec.
     interval=$(($interval*60*60*24))
     debug_echo "check_stamp: interval=$interval, now=$now, stamp=$stamp, delta=$delta (sec)"
 
+    # remove timestamps a day (or more) in the future and force re-check
+    if [ $stamp -gt $(($now+86400)) ]; then
+         echo "WARNING: file $stamp_file has a timestamp in the future: $stamp"
+         rm -f "$stamp_file"
+         return 0
+    fi
+
     if [ $delta -ge $interval ]; then
         return 0
     fi

+ 1 - 0
debian/apt.dirs

@@ -3,6 +3,7 @@ usr/lib/apt/methods
 usr/lib/dpkg/methods/apt
 etc/apt
 etc/apt/apt.conf.d
+etc/apt/preferences.d
 etc/apt/sources.list.d
 etc/logrotate.d
 var/cache/apt/archives/partial

+ 160 - 54
debian/changelog

@@ -1,4 +1,4 @@
-apt (0.7.22) unstable; urgency=low
+apt (0.7.23) unstable; urgency=low
 
   * cmdline/apt-get.cc:
     - honor APT::Get::Only-Source properly in FindSrc() (thanks to
@@ -6,16 +6,55 @@ apt (0.7.22) unstable; urgency=low
 
  -- Michael Vogt <michael.vogt@ubuntu.com>  Thu, 30 Jul 2009 15:27:30 +0200
 
-apt (0.7.21) UNRELEASED; urgency=low
+apt (0.7.22) unstable; urgency=low
 
-  [ Osamu Aoki ]
-  * Updated cron script to support backups by hardlinks and 
-    verbose levels.  All features turned off by default. 
-  * Added more error handlings.  Closes: #438803, #462734, #454989, 
-  * Documented all cron script related configuration items in 
-    configure-index.
+  [ Christian Perrier ]
+  * Documentation translations:
+    - Fix a typo in apt-get(8) French translation. Closes: #525043
+      Thanks to Guillaume Delacour for spotting it.
+    - Updated apt.conf(5) manpgae French translation.
+      Thanks to Aurélien Couderc.
+  * Translations:
+    - fr.po
+    - sk.po. Closes: #525857 
+    - ru.po. Closes: #526816
+    - eu.po. Closes: #528985
+    - zh_CN.po. Closes: #531390
+    - fr.po
+    - it.po. Closes: #531758
+    - ca.po. Closes: #531921
+    - de.po. Closes: #536430
+  * Added translations
+    - ast.po (Asturian by Marcos Alvareez Costales).
+      Closes: #529007, #529730, #535328
+  
+  [ David Kalnischkies ]
+  * [ABI break] support '#' in apt.conf and /etc/apt/preferences
+    (closes: #189866)
+  * [ABI break] Allow pinning by codename (closes: #97564)
+  * support running "--simulate" as user
+  * add depth information to the debug output and show what depends
+    type triggers a autoinst (closes: #458389)
+  * add Debug::pkgDepCache::Marker with more detailed debug output 
+    (closes: #87520)
+  * add Debug::pkgProblemResolver::ShowScores and make the scores
+    adjustable
+  * do not write state file in simulate mode (closes: #433007)
+  * add hook for MarkInstall and MarkDelete (closes: #470035)
+  * fix typo in apt-pkg/acquire.cc which prevents Dl-Limit to work
+    correctly when downloading from multiple sites (Closes: #534752)
+  * add the various foldmarkers in apt-pkg & cmdline (no code change)
+  * versions with a pin of -1 shouldn't be a candidate (Closes: #355237)
+  * prefer mmap as memory allocator in MMap instead of a static char
+    array which can (at least in theory) grow dynamic
+  * eliminate (hopefully all) segfaults in pkgcachegen.cc and mmap.cc
+    which can arise if cache doesn't fit into the mmap (Closes: #535218)
+  * display warnings instead of errors if the parts dirs doesn't exist
 
   [ Michael Vogt ]
+  * honor the dpkg hold state in new Marker hooks (closes: #64141)
+  * debian/apt.cron.daily:
+    - if the timestamp is too far in the future, delete it
   * apt-pkg/acquire.cc:
     - make the max pipeline depth of the acquire queue configurable
       via Acquire::Max-Pipeline-Depth
@@ -23,6 +62,8 @@ apt (0.7.21) UNRELEASED; urgency=low
     - add Dpkg::UseIoNice boolean option to run dpkg with ionice -c3
       (off by default)
     - send "dpkg-exec" message on the status fd when dpkg is run
+    - provide DPkg::Chroot-Directory config option (useful for testing)
+    - fix potential hang when in a backgroud process group
   * apt-pkg/algorithms.cc:
     - consider recommends when making the scores for the problem 
       resolver
@@ -33,8 +74,6 @@ apt (0.7.21) UNRELEASED; urgency=low
   * methods/http.cc:
     - ignore SIGPIPE, we deal with EPIPE from write in 
       HttpMethod::ServerDie() (LP: #385144)
-  * apt-pkg/deb/dpkgpm.cc:
-    - provide DPkg::Chroot-Directory config option (useful for testing)
   * Only run Download-Upgradable and Unattended-Upgrades if the initial
     update was successful Closes: #341970
   * apt-pkg/indexcopy.cc:
@@ -43,60 +82,126 @@ apt (0.7.21) UNRELEASED; urgency=low
      (LP: #255545)
     - remove the gettext from a string that consists entirely 
       of variables (LP: #56792)
-  * doc/makefile:
-    - add examples/apt-https-method-example.conf
   * apt-pkg/cacheiterators.h:
     - add missing checks for Owner == 0 in end()
-  * apt-pkg/deb/dpkgpm.cc:
-    - fix potential hang when in a backgroud process group
   * apt-pkg/indexrecords.cc:
     - fix some i18n issues
   * apt-pkg/contrib/strutl.h:
     - add new strprintf() function to make i18n strings easier
-  * methods/gpgv.cc:
     - fix compiler warning
-  * cmdline/apt-get.cc:
-    - fix "apt-get source pkg=ver" if binary name != source name
-      and show a message (LP: #202219)
-    - fix "apt-get source pkg" if there is a binary package and
-      a source package of the same name but from different 
-      packages (LP: #330103)
   * apt-pkg/deb/debsystem.cc:
     - make strings i18n able 
-  * apt-pkg/contrib/strutl.cc:
-    - fix TimeToStr i18n (LP: #289807)
-  * [ABI break] merge support for http redirects, thanks to
-    Jeff Licquia and Anthony Towns
-  * [ABI break] use int for the package IDs (thanks to Steve Cotton)
-  * apt-pkg/pkgcache.cc:
-    - do not run "dpkg --configure pkg" if pkg is in trigger-awaited
-      state (LP: #322955)
-  * methods/https.cc:
-    - add Acquire::https::AllowRedirect support
-  * methods/gpgv.cc:
-    - properly check for expired and revoked keys (closes: #433091)
   * fix problematic use of tolower() when calculating the version 
     hash by using locale independant tolower_ascii() function. 
     Thanks to M. Vefa Bicakci (LP: #80248)
   * build fixes for g++-4.4
   * cmdline/apt-mark:
     - add "showauto" option to show automatically installed packages
+  * document --install-recommends and --no-install-recommends
+    (thanks to Dereck Wonnacott, LP: #126180)
   * doc/apt.conf.5.xml:
     - merged patch from Aurélien Couderc to improve the text
       (thanks!)
+  * [ABI] merged the libudev-dlopen branch, this allows to pass
+    "apt-udev-auto" to Acquire::Cdrom::mount and the cdrom method will  
+    dynamically find/mount the cdrom device (if libhal is available)
+
+  [ Julian Andres Klode ]
+  * apt-pkg/contrib/configuration.cc: Fix a small memory leak in
+    ReadConfigFile.
+  * Introduce support for the Enhances field. (Closes: #137583) 
+  * Support /etc/apt/preferences.d, by adding ReadPinDir() (Closes: #535512)
+  * configure-index: document Dir::Etc::SourceParts and some other options
+    (Closes: #459605)
+  * Remove Eugene V. Lyubimkin from uploaders as requested.
+  * apt-pkg/contrib/hashes.cc, apt-pkg/contrib/md5.cc:
+    - Support reading until EOF if Size=0 to match behaviour of
+      SHA1Summation and SHA256Summation
+
+  [ Osamu Aoki ]
+  * Updated cron script to support backups by hardlinks and 
+    verbose levels.  All features turned off by default. 
+  * Added more error handlings.  Closes: #438803, #462734, #454989, 
+  * Documented all cron script related configuration items in 
+    configure-index.
 
   [ Dereck Wonnacott ]
   * apt-ftparchive might write corrupt Release files (LP: #46439)
   * Apply --important option to apt-cache depends (LP: #16947) 
-  * Clarify the --help for 'purge' (LP: #243948)
 
+  [ Otavio Salvador ]
+  * Apply patch from Sami Liedes <sliedes@cc.hut.fi> to reduce the
+    number of times we call progress bar updating and debugging
+    configuration settings.
+  * Apply patch from Sami Liedes <sliedes@cc.hut.fi> to avoid unecessary
+    temporary allocations.
+
+ -- Michael Vogt <mvo@debian.org>  Wed, 29 Jul 2009 19:16:22 +0200
+
+apt (0.7.21) unstable; urgency=low
+
+  [ Christian Perrier ]
+  * Translations:
+    - bg.po. Closes: #513211
+    - zh_TW.po. Closes: #513311
+    - nb.po. Closes: #513843
+    - fr.po. Closes: #520430
+    - sv.po. Closes: #518070
+    - sk.po. Closes: #520403
+    - it.po. Closes: #522222
+    - sk.po. Closes: #520403
+  
+  [ Jamie Strandboge ]
+  * apt.cron.daily: catch invalid dates due to DST time changes
+    in the stamp files
+
+  [ Michael Vogt ]
+  * methods/gpgv.cc:
+    - properly check for expired and revoked keys (closes: #433091)
+  * apt-pkg/contrib/strutl.cc:
+    - fix TimeToStr i18n (LP: #289807)
+  * [ABI break] merge support for http redirects, thanks to
+    Jeff Licquia and Anthony Towns
+  * [ABI break] use int for the package IDs (thanks to Steve Cotton)
+  * apt-pkg/pkgcache.cc:
+    - do not run "dpkg --configure pkg" if pkg is in trigger-awaited
+      state (LP: #322955)
+  * methods/https.cc:
+    - add Acquire::https::AllowRedirect support
+  * Clarify the --help for 'purge' (LP: #243948)
+  * cmdline/apt-get.cc
+    - fix "apt-get source pkg" if there is a binary package and
+      a source package of the same name but from different 
+      packages (LP: #330103)
 
   [ Colin Watson ]
   * cmdline/acqprogress.cc:
     - Call pkgAcquireStatus::Pulse even if quiet, so that we still get
       dlstatus messages on the status-fd (LP: #290234).
 
- -- Michael Vogt <michael.vogt@ubuntu.com>  Fri, 12 Sep 2008 11:34:24 +0200
+ -- Michael Vogt <mvo@debian.org>  Tue, 14 Apr 2009 14:12:51 +0200
+
+apt (0.7.20.2) unstable; urgency=medium
+
+  [ Eugene V. Lyubimkin ]
+  * Urgency set to medium due to RC bug fix.
+  * doc/apt.ent, apt-get.8.xml:
+    - Fix invalid XML entities. (Closes: #514402)
+
+ -- Eugene V. Lyubimkin <jackyf.devel@gmail.com>  Sat, 07 Feb 2009 16:48:21 +0200
+
+apt (0.7.20.1) unstable; urgency=low
+
+  [ Michael Vogt ]
+  * apt-pkg/pkgcachegen.cc:
+    - fix apt-cache search for localized description 
+      (closes: #512110)
+  
+  [ Christian Perrier ]
+  * Translations:
+    - fr.po: fix spelling error to "défectueux". Thanks to Thomas Péteul.
+
+ -- Michael Vogt <mvo@debian.org>  Tue, 20 Jan 2009 09:35:05 +0100
 
 apt (0.7.20) unstable; urgency=low
 
@@ -112,35 +217,37 @@ apt (0.7.20) unstable; urgency=low
       (Closes: #457265)
     - Mentioned 'APT::Periodic' and 'APT::Archives' groups of options.
       (Closes: #438559)
-
-  [ Michael Vogt ]
-  * apt-pkg/depcache.cc:
-    - when checking for new important deps, skip critical ones
-      (LP: #236360)
-  * document --install-recommends and --no-install-recommends
-    (thanks to Dereck Wonnacott, LP: #126180)
-  * make "apt-get build-dep" installed packages marked automatic
-    by default. This can be changed by setting the value of
-    APT::Get::Build-Dep-Automatic to false (thanks to Aaron 
-    Haviland, closes: #44874, LP: #248268)
-
- -- Eugene V. Lyubimkin <jackyf.devel@gmail.com>  Sat, 06 Dec 2008 20:57:00 +0200
-
-apt (0.7.20~exp2) unstable; urgency=low
-
-  [ Eugene V. Lyubimkin ]
+    - Mentioned '/* ... */' comments. (Closes: #507601)
   * doc/examples/sources.list:
     - Removed obsolete commented non-us deb-src entry, replaced it with
       'deb-src security.debian.org' one. (Closes: #411298)
   * apt-pkg/contrib/mmap.cc:
     - Added instruction how to work around MMap error in MMap error message.
       (Closes: #385674, 436028)
+  * COPYING:
+    - Actualized. Removed obsolete Qt section, added GPLv2 clause.
+      (Closes: #440049, #509337)
+
+  [ Michael Vogt ]
+  * add option to "apt-get build-dep" to mark the needed 
+    build-dep packages as automatic installed. 
+    This is controlled via the value of
+    APT::Get::Build-Dep-Automatic and is set "false" by default.  
+    Thanks to Aaron Haviland, closes: #448743
+  * apt-inst/contrib/arfile.cc:
+    - support members ending with '/' as well (thanks to Michal Cihr,
+      closes: #500988)
 
   [ Christian Perrier ]
   * Translations:
+    - Finnish updated. Closes: #508449 
+    - Galician updated. Closes: #509151
+    - Catalan updated. Closes: #509375
+    - Vietnamese updated. Closes: #509422
+    - Traditional Chinese added. Closes: #510664
     - French corrected (remove awful use of first person) 
 
- -- Michael Vogt <mvo@debian.org>  Tue, 02 Dec 2008 20:30:14 +0100
+ -- Michael Vogt <mvo@debian.org>  Mon, 05 Jan 2009 08:59:20 +0100
 
 apt (0.7.19) unstable; urgency=low
 
@@ -158,7 +265,6 @@ apt (0.7.19) unstable; urgency=low
       is a request to install only one package and it is not installable.
       (Closes: #419521)
 
-
   [ Michael Vogt ]
     - fix SIGHUP handling (closes: #463030)
 

+ 2 - 2
debian/control

@@ -4,8 +4,8 @@ Priority: important
 Maintainer: APT Development Team <deity@lists.debian.org>
 Uploaders: Michael Vogt <mvo@debian.org>, Otavio Salvador <otavio@debian.org>,
  Christian Perrier <bubulle@debian.org>, Daniel Burrows <dburrows@debian.org>,
- Luca Bruno <lethalman88@gmail.com>, Eugene V. Lyubimkin <jackyf.devel@gmail.com>
-Standards-Version: 3.8.0
+ Luca Bruno <lethalman88@gmail.com>
+Standards-Version: 3.8.1.0
 Build-Depends: debhelper (>= 5.0), libdb-dev, gettext (>= 0.12), libcurl4-gnutls-dev | libcurl3-gnutls-dev (>= 7.15.5), debiandoc-sgml, docbook-utils (>= 0.6.12), xsltproc, docbook-xsl, xmlto
 Vcs-Bzr: http://bzr.debian.org/apt/debian-sid/
 

+ 0 - 14
doc/.cvsignore

@@ -1,14 +0,0 @@
-apt-cache.8
-apt-get.8
-apt-cdrom.8
-apt.conf.5
-sources.list.5
-apt-config.8
-apt-sortpkgs.1
-apt-ftparchive.1
-manpage.links
-manpage.refs
-manpage.log
-apt_preferences.5
-apt-extracttemplates.1
-vendors.list.5

+ 15 - 2
doc/apt-get.8.xml

@@ -53,6 +53,9 @@
 			  <arg choice='plain'>
 				  <replaceable>target_release_number_expression</replaceable>
 			  </arg>
+			  <arg choice='plain'>
+				  <replaceable>target_release_codename</replaceable>
+			  </arg>
 		  </group>
       </arg>
 
@@ -71,6 +74,9 @@
 						<arg choice='plain'>
 							/<replaceable>target_release_name</replaceable>
 						</arg>
+						<arg choice='plain'>
+							/<replaceable>target_release_codename</replaceable>
+						</arg>
 					</group>
 				</arg>
 			 </arg>
@@ -357,6 +363,12 @@
      actually change the system. 
      Configuration Item: <literal>APT::Get::Simulate</literal>.</para>
 
+     <para>Simulation run as user will deactivate locking (<literal>Debug::NoLocking</literal>)
+     automatical. Also a notice will be displayed indicating that this is only a simulation,
+     if the option <literal>APT::Get::Show-User-Simulation-Note</literal> is set (Default: true)
+     Neigther NoLocking nor the notice will be triggered if run as root (root should know what
+     he is doing without further warnings by <literal>apt-get</literal>).</para>
+
      <para>Simulate prints out
      a series of lines each one representing a dpkg operation, Configure (Conf),
      Remove (Remv), Unpack (Inst). Square brackets indicate broken packages with
@@ -463,7 +475,8 @@
      of this option. In short, this option
      lets you have simple control over which distribution packages will be
      retrieved from. Some common examples might be 
-     <option>-t '2.1*'</option> or <option>-t unstable</option>.
+     <option>-t '2.1*'</option>, <option>-t unstable</option>
+     or <option>-t sid</option>.
      Configuration Item: <literal>APT::Default-Release</literal>;
      see also the &apt-preferences; manual page.</para></listitem>
      </varlistentry>
@@ -589,8 +602,8 @@
 	 <title>CURRENT AUTHORS</title>
 	 <para>
 		 &apt-author.team;
-		 &apt-qapage;
 	 </para>
+		 &apt-qapage;
  </refsect1>
  &manbugs;
 </refentry>

+ 37 - 4
doc/apt.conf.5.xml

@@ -21,7 +21,7 @@
    &apt-email;
    &apt-product;
    <!-- The last update date -->
-   <date>06 December 2008</date>
+   <date>10 December 2008</date>
  </refentryinfo>
  
  <refmeta>
@@ -53,8 +53,9 @@
    parent groups.</para> 
 
    <para>Syntactically the configuration language is modeled after what the ISC tools
-   such as bind and dhcp use.  Lines starting with
-   <literal>//</literal> are treated as comments (ignored).
+   such as bind and dhcp use. Lines starting with
+   <literal>//</literal> are treated as comments (ignored), as well as all text
+   between <literal>/*</literal> and <literal>*/</literal>, just like C/C++ comments.
    Each line is of the form
    <literal>APT::Get::Assume-Yes "true";</literal> The trailing 
    semicolon is required and the quotes are optional. A new scope can be
@@ -110,7 +111,7 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
      
      <varlistentry><term>Default-Release</term>
 	 <listitem><para>Default release to install packages from if more than one
-	 version available. Contains release name or release version. Examples: 'stable', 'testing', 'unstable', '4.0', '5.0*'. Release codenames ('etch', 'lenny' etc.) are not allowed now. See also &apt-preferences;.</para></listitem>
+	 version available. Contains release name, codename or release version. Examples: 'stable', 'testing', 'unstable', 'lenny', 'squeeze', '4.0', '5.0*'. See also &apt-preferences;.</para></listitem>
      </varlistentry>
      
      <varlistentry><term>Ignore-Hold</term>
@@ -679,6 +680,27 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
        </listitem>
      </varlistentry>
 
+     <varlistentry>
+       <term><literal>Debug::pkgDepCache::Marker</literal></term>
+       <listitem>
+        <para>
+           Generate debug messages describing which package is marked
+          as keep/install/remove while the ProblemResolver does his work.
+          Each addition or deletion may trigger additional actions;
+          they are shown indented two additional space under the original entry.
+          The format for each line is <literal>MarkKeep</literal>,
+          <literal>MarkDelete</literal> or <literal>MarkInstall</literal> followed by
+          <literal>package-name &lt;a.b.c -&gt; d.e.f | x.y.z&gt; (section)</literal>
+          where <literal>a.b.c</literal> is the current version of the package,
+          <literal>d.e.f</literal> is the version considered for installation and
+          <literal>x.y.z</literal> is a newer version, but not considered for installation
+          (because of a low pin score). The later two can be omitted if there is none or if
+          it is the same version as the installed.
+          <literal>section</literal> is the name of the section the package appears in.
+        </para>
+       </listitem>
+     </varlistentry>
+
      <!-- Question: why doesn't this do anything?  The code says it should. -->
      <varlistentry>
        <term><literal>Debug::pkgInitConfig</literal></term>
@@ -756,6 +778,17 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
        </listitem>
      </varlistentry>
 
+     <varlistentry>
+       <term><literal>Debug::pkgProblemResolver::ShowScores</literal></term>
+       <listitem>
+        <para>
+          Display a list of all installed packages with their calculated score
+          used by the pkgProblemResolver. The description of the package
+          is the same as described in <literal>Debug::pkgDepCache::Marker</literal>
+        </para>
+       </listitem>
+     </varlistentry>
+
      <varlistentry>
        <term><literal>Debug::sourceList</literal></term>
 

+ 7 - 0
doc/apt.ent

@@ -179,6 +179,13 @@
    </author>
 ">
 
+<!ENTITY apt-author.moconnor "
+   <author>
+    <firstname>Mike</firstname>
+    <surname>O'Connor</surname>
+   </author>
+">
+
 <!ENTITY apt-author.team "
    <author>
     <othername>APT team</othername>

+ 86 - 4
doc/apt_preferences.5.xml

@@ -14,7 +14,7 @@
    &apt-email;
    &apt-product;
    <!-- The last update date -->
-   <date>29 February 2004</date>
+   <date>04 May 2009</date>
  </refentryinfo>
 
  <refmeta>
@@ -190,6 +190,15 @@ Pin: release a=unstable
 Pin-Priority: 50
 </programlisting>
 
+<simpara>The following record assigns a high priority to all package versions
+belonging to any distribution whose Codename is "<literal>squeeze</literal>".</simpara>
+
+<programlisting>
+Package: *
+Pin: release n=squeeze
+Pin-Priority: 900
+</programlisting>
+
 <simpara>The following record assigns a high priority to all package versions
 belonging to any release whose Archive name is "<literal>stable</literal>"
 and whose release Version number is "<literal>3.0</literal>".</simpara>
@@ -327,10 +336,11 @@ file are relevant for setting APT priorities:
 
 <variablelist>
 <varlistentry>
-<term>the <literal>Archive:</literal> line</term>
+<term>the <literal>Archive:</literal> or <literal>Suite:</literal> line</term>
 <listitem><simpara>names the archive to which all the packages
 in the directory tree belong.  For example, the line
-"Archive: stable"
+"Archive: stable" or
+"Suite: stable"
 specifies that all of the packages in the directory
 tree below the parent of the <filename>Release</filename> file are in a
 <literal>stable</literal> archive.  Specifying this value in the APT preferences file
@@ -342,6 +352,22 @@ Pin: release a=stable
 </listitem>
 </varlistentry>
 
+<varlistentry>
+<term>the <literal>Codename:</literal> line</term>
+<listitem><simpara>names the codename to which all the packages
+in the directory tree belong.  For example, the line
+"Codename: squeeze"
+specifies that all of the packages in the directory
+tree below the parent of the <filename>Release</filename> file belong to a version named
+<literal>squeeze</literal>.  Specifying this value in the APT preferences file
+would require the line:
+</simpara>
+<programlisting>
+Pin: release n=squeeze
+</programlisting>
+</listitem>
+</varlistentry>
+
 <varlistentry>
 <term>the <literal>Version:</literal> line</term>
 <listitem><simpara>names the release version.  For example, the
@@ -522,7 +548,64 @@ version.
 apt-get install <replaceable>package</replaceable>/unstable
 </programlisting>
 </para>
+</refsect2>
+
+
+<refsect2>
+<title>Tracking the evolution of a codename release</title>
+
+<para>The following APT preferences file will cause APT to assign a
+priority higher than the default (500) to all package versions belonging
+to a specified codename of a distribution and a prohibitively low priority to
+package versions belonging to other <literal>Debian</literal> distributions,
+codenames and archives.
+Note that with this APT preference APT will follow the migration of a release
+from the archive <literal>testing</literal> to <literal>stable</literal> and
+later <literal>oldstable</literal>. If you want to follow for example the progress
+in <literal>testing</literal> notwithstanding the codename changes you should use
+the example configurations above.
+
+<programlisting>
+Explanation: Uninstall or do not install any Debian-originated package versions
+Explanation: other than those in the distribution codenamed with squeeze or sid
+Package: *
+Pin: release n=squeeze
+Pin-Priority: 900
+
+Explanation: Debian unstable is always codenamed with sid
+Package: *
+Pin: release a=sid
+Pin-Priority: 800
+
+Package: *
+Pin: release o=Debian
+Pin-Priority: -10
+</programlisting>
+</para>
+
+<para>With a suitable &sources-list; file and the above preferences file,
+any of the following commands will cause APT to upgrade to the
+latest version(s) in the release codenamed with <literal>squeeze</literal>.
+
+<programlisting>
+apt-get install <replaceable>package-name</replaceable>
+apt-get upgrade
+apt-get dist-upgrade
+</programlisting>
+</para>
+
+<para>The following command will cause APT to upgrade the specified
+package to the latest version from the <literal>sid</literal> distribution.
+Thereafter, <command>apt-get upgrade</command> will upgrade
+the package to the most recent <literal>squeeze</literal> version if that is
+more recent than the installed version, otherwise, to the most recent
+<literal>sid</literal> version if that is more recent than the installed
+version.
 
+<programlisting>
+apt-get install <replaceable>package</replaceable>/sid
+</programlisting>
+</para>
 </refsect2>
 </refsect1>
 
@@ -535,4 +618,3 @@ apt-get install <replaceable>package</replaceable>/unstable
  &manbugs;
 
 </refentry>
-

+ 0 - 14
doc/es/.cvsignore

@@ -1,14 +0,0 @@
-apt-cache.es.8
-apt-get.es.8
-apt-cdrom.es.8
-apt.conf.es.5
-sources.list.es.5
-apt-config.es.8
-apt-sortpkgs.es.1
-apt-ftparchive.es.1
-manpage.links
-manpage.refs
-manpage.log
-apt_preferences.es.5
-apt-extracttemplates.es.1
-vendors.list.es.5

+ 9 - 2
doc/examples/configure-index

@@ -55,6 +55,7 @@ APT
      Diff-Only "false";
      Tar-Only "false";
      Build-Dep-Automatic "true";
+     Show-User-Simulation-Note "true";
   };
 
   Cache 
@@ -271,10 +272,14 @@ Dir "/"
   
   // Config files
   Etc "etc/apt/" {
-     SourceList "sources.list";
      Main "apt.conf";
-     Preferences "preferences";     
      Parts "apt.conf.d/";
+     Preferences "preferences";
+     PreferencesParts "preferences.d";
+     SourceList "sources.list";
+     SourceParts "sources.list.d";
+     VendorList "vendors.list";
+     VendorParts "vendors.list.d";
   };
   
   // Locations of binaries
@@ -340,7 +345,9 @@ DPkg
 Debug 
 {
   pkgProblemResolver "false";
+  pkgProblemResolver::ShowScores "false";
   pkgDepCache::AutoInstall "false"; // what packages apt install to satify dependencies
+  pkgDepCache::Marker "false"; 
   pkgAcquire "false";
   pkgAcquire::Worker "false";
   pkgAcquire::Auth "false";

+ 0 - 13
doc/fr/.cvsignore

@@ -1,13 +0,0 @@
-apt-cdrom.fr.8
-apt-config.fr.8
-apt-extracttemplates.fr.1
-apt-ftparchive.fr.1
-apt-sortpkgs.fr.1
-apt.conf.fr.5
-apt_preferences.fr.5
-manpage.links
-manpage.refs
-sources.list.fr.5
-apt-cache.fr.8
-apt-get.fr.8
-vendors.list.fr.5

+ 1 - 1
doc/fr/apt-get.fr.8.xml

@@ -201,7 +201,7 @@ semblables 
 <listitem><para>   
 Avec la commande <literal>build-dep</literal>, apt-get installe ou supprime des paquets
 dans le but de satisfaire les dépendances de construction d'un paquet source.
-Pour l'instant, dans la cas d'un paquet virtuel, un paquet est choisi au
+Pour l'instant, dans le cas d'un paquet virtuel, un paquet est choisi au
 hasard.
      </para></listitem>
 </varlistentry>

+ 424 - 110
doc/fr/apt.conf.fr.5.xml

@@ -15,7 +15,7 @@
    &apt-email;
    &apt-product;
    <!-- The last update date -->
-   <date>29 Février 2004</date>
+   <date>11 juillet 2008</date>
  </refentryinfo>
 
 <refmeta>
@@ -33,26 +33,30 @@ Le fichier <filename>apt.conf</filename> est le principal fichier de configurati
 de la collection d'outils que constitue APT&nbsp;; tous les outils font appel à ce 
 fichier de configuration et utilisent un analyseur syntaxique en ligne de 
 commande commun afin de fournir un environnement uniforme. Quand un outil
-d'APT démarre, il lit (si elle existe) la variable d'environnement 
-<envar>APT_CONFIG</envar>&nbsp;; puis il lit les fichiers situés dans 
+d'APT démarre, il lit la configuration désignée par variable d'environnement 
+<envar>APT_CONFIG</envar> (si elle existe), puis il lit les fichiers situés dans 
 <literal>Dir::Etc::Parts</literal> ainsi que le principal fichier de configuration
 indiqué par <literal>Dir::Etc::main</literal>&nbsp;; enfin il applique les options de 
-la ligne de commande qui annulent les directives de configuration, chargeant,
-si nécessaire, d'autres fichiers de configuration.
+la ligne de commande qui prévalent sur les directives de configuration, chargeant
+si nécessaire d'autres fichiers de configuration.
    </para>
 <para>
 Le fichier de configuration est construit comme un arbre d'options
 organisées en groupes fonctionnels. On se sert du double deux points («&nbsp;::&nbsp;») 
 pour indiquer une option&nbsp;; par exemple, <literal>APT::Get::Assume-Yes</literal> est
-une option pour le groupe d'outils APT, destinée à l'outil Get. Les options
-n'héritent pas des groupes de leurs parents.
+une option pour le groupe d'outils APT, destinée à l'outil Get. Il n'y a pas d'héritage
+des options des groupes parents.
    </para>
 <para>
 Syntaxiquement, le langage de configuration est conçu sur le même modèle
 que les langages utilisés par des outils ISC tels que bind et dhcp. Une ligne
-qui commence par <literal>//</literal> est un commentaire et elle est ignorée.
+qui commence par <literal>//</literal> est traitée comme un commentaire et ignorée, de
+même que les sections de texte placées entre <literal>/*</literal> et
+<literal>*/</literal>, tout comme les commentaires C/C++.
 Chaque ligne est de la forme&nbsp;:
-   <literal>APT::Get::Assume-Yes "true";</literal> 
+<informalexample><programlisting>
+<literal>APT::Get::Assume-Yes "true";</literal> 
+     </programlisting></informalexample>
 Le point-virgule final est obligatoire et les guillemets sont optionnels.
 On peut déclarer un nouveau champ d'action avec des accolades, comme 
 suit&nbsp;:
@@ -68,10 +72,9 @@ APT {
 </programlisting></informalexample>
 
 <para>
-avec des retours à la ligne pour faciliter la lecture. On peut créer des 
-listes en ouvrant un champ d'action et en mettant un seul mot entre 
-apostrophes suivi d'un point-virgule. On peut mettre plusieurs entrées,
-séparées par un point-virgule.
+avec des retours à la ligne pour faciliter la lecture. On peut créer une liste
+en ouvrant un champ d'action et en y insérant une chaîne entre guillemets suivie
+d'un point virgule pour chaque élément de la liste.
 </para>
 
 <informalexample><programlisting>   
@@ -79,14 +82,21 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
 </programlisting></informalexample>
 
 <para>
-Les modèles <filename>&docdir;examples/apt.conf</filename> &configureindex;
+Les modèles <filename>&docdir;examples/apt.conf</filename> et &configureindex;
 montrent à quoi devrait ressembler le fichier de configuration.
    </para>
 <para>
+Les identifiants des options de configuration ne sont pas sensibles à la casse.
+Dans l'exemple précédent, on pourrait donc aussi bien utiliser 
+<literal>dpkg::pre-install-pkgs</literal>.
+   </para>
+<para>
 Deux éléments spéciaux sont autorisés&nbsp;: <literal>#include</literal> et 
-<literal>#clear</literal>. <literal>#include</literal> inclut le fichier donné en argument,
-à moins que le nom ne se termine par une barre oblique. <literal>#clear</literal> sert à 
-effacer une liste de noms.
+<literal>#clear</literal>. <literal>#include</literal> inclut le fichier donné en
+argument, à moins que le nom ne se termine par une barre oblique auquel cas le
+répertoire entier est inclus. <literal>#clear</literal> sert à 
+effacer une partie de l'arbre de configuration. L'élément désigné et tout ses
+descendants sont supprimés.
    </para>
 <para>
 Tous les outils d'APT possèdent une option <option>-o</option> qui permet de 
@@ -95,20 +105,31 @@ syntaxe consiste en un nom complet d'option (par exemple
 <literal>APT::Get::Assume-Yes</literal>) suivi par un signe égal, puis par la nouvelle 
 valeur de l'option. On peut compléter une liste en ajoutant un «&nbsp;::&nbsp;» au nom 
 de la liste.
- </para>
+   </para>
 </refsect1>
 
 <refsect1><title>Le groupe APT</title>
-<para>   
-Ce groupe d'options contrôle aussi bien le comportement global d'APT que
-la prise en compte des options pour chaque outil.
+<para>
+Ce groupe d'options contrôle le comportement global d'APT et contient également
+des options communes à tous les outils.
 </para>
    <variablelist>
 <varlistentry><term>Architecture</term>
 <listitem><para>
 L'architecture du système&nbsp;; cette option positionne l'architecture à utiliser 
-pour récupérer des fichiers et analyser des listes de paquets. L'architecture 
-interne par défaut est celle pour laquelle APT a été compilé.
+pour récupérer des fichiers et analyser des listes de paquets. La valeur interne par
+défaut est l'architecture pour laquelle APT a été compilé.
+     </para></listitem>
+</varlistentry>
+
+<varlistentry><term>Default-Release</term>
+<listitem><para>
+Indique la distribution à utiliser par défaut lors de l'installation d'un
+paquet si plusieurs versions sont disponibles. La valeur peut être un nom de
+distribution ou un numéro de version. Exemples&nbsp;: «&nbsp;stable&nbsp;»,
+«&nbsp;testing&nbsp;», «&nbsp;4.0&nbsp;», «&nbsp;5.0*&nbsp;». Les noms de codes
+des distributions («&nbsp;etch&nbsp;», «&nbsp;lenny&nbsp;», etc.) ne sont pas
+permis pour l'instant. Voir aussi &apt-preferences;.
      </para></listitem>
 </varlistentry>
 
@@ -123,7 +144,7 @@ dans sa prise de d
 <varlistentry><term>Clean-Installed</term>
 <listitem><para>
 Avec cette option qui est activée par défaut, la fonctionnalité «&nbsp;autoclean&nbsp;»
-supprime tout paquet qui ne peut plus être récupéré dans le cache.
+supprime du cache tout paquet qui ne peut plus être récupéré.
 Quand cette option est désactivée, les paquets qui sont installés localement
 sont aussi exclus du nettoyage - mais notez que APT ne fournit aucun moyen
 direct pour les réinstaller.
@@ -134,9 +155,9 @@ direct pour les r
 <listitem><para>
 Désactive la configuration immédiate&nbsp;; cette dangereuse option désactive
 une partie du code de mise en ordre de APT pour que ce dernier effectue le
-moins d'appels possible à Dpkg. C'est peut-être nécessaire sur des systèmes
-lents à un seul utilisateur mais c'est extrêmement dangereux et cela peut 
-faire échouer les scripts d'installation, voire pire.
+moins d'appels possible à &dpkg;. Ça peut être nécessaire sur des systèmes
+à un seul utilisateur extrêmement lents, mais cette option est très dangereuse et
+peut faire échouer les scripts d'installation, voire pire.
 Utilisez-la à vos risques et périls.
      </para></listitem>
 </varlistentry>
@@ -155,39 +176,37 @@ ou tous les paquets dont ces paquets d
 
 <varlistentry><term>Cache-Limit</term>
 <listitem><para>
-APT utilise un fichier cache d'une taille mémoire fixe pour ranger les
-informations du fichier «&nbsp;available&nbsp;». Cette option fixe la taille 
-de ce cache.
+APT utilise un fichier de cache chargé en mémoire avec mmap pour ranger les
+informations sur les paquets disponibles. Cette option fixe la taille mémoire
+allouée pour le chargement de ce cache.
      </para></listitem>
 </varlistentry>
 
 <varlistentry><term>Build-Essential</term>
 <listitem><para>
      Cette option définit les paquets qui sont considérés comme faisant partie
-des dépendances essentielles pour la construction des paquets.
+des dépendances essentielles pour la construction de paquets.
      </para></listitem>
 </varlistentry>
 
 <varlistentry><term>Get</term>
 <listitem><para>La sous-section <literal>Get</literal> contrôle l'outil &apt-get;, 
-veuillez consulter
-sa documentation pour avoir plus d'informations sur les options en question.
+veuillez consulter sa documentation pour avoir plus d'informations sur les options
+en question.
      </para></listitem>
 </varlistentry>
 
 <varlistentry><term>Cache</term>
-<listitem><para>La sous-section <literal>Cache</literal> contrôle l'outil &apt-cache;, 
-veuillez 
-consulter sa documentation pour avoir plus d'informations sur les options en 
-question.
+<listitem><para>La sous-section <literal>Cache</literal> contrôle l'outil
+&apt-cache;, veuillez consulter sa documentation pour avoir plus d'informations
+sur les options en question.
      </para></listitem>
 </varlistentry>
 
 <varlistentry><term>CDROM</term>
-<listitem><para>La sous-section <literal>CDROM</literal> contrôle l'outil&apt-cdrom;, 
-veuillez 
-consulter sa documentation pour avoir plus d'informations sur les options en 
-question.
+<listitem><para>La sous-section <literal>CDROM</literal> contrôle l'outil
+&apt-cdrom;, veuillez consulter sa documentation pour avoir plus d'informations
+sur les options en question.
      </para></listitem>
 </varlistentry>
 </variablelist>
@@ -199,13 +218,20 @@ Le groupe d'options <literal>Acquire</literal> contr
 les gestionnaires d'URI.
 
    <variablelist>
+<varlistentry><term>PDiffs</term>
+<listitem><para>Essayer de télécharger les fichiers différentiels appelés
+<literal>PDiffs</literal> pour les paquets ou les fichiers sources, plutôt que
+de les télécharger entièrement. Par défaut à «&nbsp;true&nbsp;».
+     </para></listitem>
+</varlistentry>
+
 <varlistentry><term>Queue-Mode</term>
 <listitem><para>
-Le mode file d'attente&nbsp;; <literal>Queue-Mode</literal> peut prendre une valeur 
-parmi <literal>host</literal> ou <literal>access</literal> et cela détermine comment APT 
-parallélise les connexions sortantes. <literal>Host</literal> signifie qu'une 
-connexion par cible sera initiée, tandis que <literal>access</literal> signifie qu'une 
-connexion par type d'URI sera initiée.
+Le mode de file d'attente&nbsp;; <literal>Queue-Mode</literal> peut prendre les
+valeurs <literal>host</literal> ou <literal>access</literal> et cela détermine
+comment APT parallélise les connexions sortantes. <literal>Host</literal> signifie
+qu'une connexion par cible sera initiée, tandis que <literal>access</literal> signifie
+qu'une connexion par type d'URI sera initiée.
      </para></listitem>
 </varlistentry>
 
@@ -227,30 +253,32 @@ Par d
 
 <varlistentry><term>http</term>
 <listitem><para>
-URI HTTP ; http::Proxy est le mandataire (proxy) http à utiliser par défaut.
+URI HTTP&nbsp;; http::Proxy est le mandataire (proxy) HTTP à utiliser par défaut.
 Il se présente sous la forme standard&nbsp;:
-<literal>http://[[user][:pass]@]host[:port]/</literal>. En utilisant la syntaxe&nbsp;:
-<literal>http::Proxy::&lt;host&gt;</literal>, où le mot-clé spécial <literal>DIRECT</literal>
-indique de n'utiliser aucun mandataire, on peut spécifier un mandataire
-pour chaque machine distante. La variable d'environnement <envar>http_proxy</envar>
-remplace tous ces paramètres.
+<literal>http://[[user][:pass]@]host[:port]/</literal>. On peut spécifier un
+mandataire particulier par hôte distant en utilisant la syntaxe&nbsp;:
+<literal>http::Proxy::&lt;hôte&gt;</literal>. Le mot-clé spécial
+<literal>DIRECT</literal> indique alors de n'utiliser aucun mandataire pour
+l'hôte.
+Lorsqu'elle est définie, la variable d'environnement <envar>http_proxy</envar>
+annule et remplace toutes les options de mandataire HTTP.
      </para>
 <para>
-Trois options de configuration sont fournies pour le contrôle des caches qui
-sont compatibles avec HTTP/1.1. <literal>No-Cache</literal> signifie que le mandataire
-ne doit pas du tout utiliser les réponses qu'il a stockées&nbsp;; <literal>Max-Age</literal>
+Trois options de configuration sont fournies pour le contrôle des caches compatibles
+avec HTTP/1.1. <literal>No-Cache</literal> signifie que le mandataire ne doit jamais
+utiliser les réponses qu'il a stockées&nbsp;; <literal>Max-Age</literal>
 sert uniquement pour les fichiers d'index&nbsp;: cela demande au cache de les 
 mettre à jour quand leur ancienneté est supérieure au nombre de secondes 
-donné. Debian met à jour son fichier d'index de manière journalière, la
+donné. Debian met à jour ses fichiers d'index de manière quotidienne&nbsp;; la
 valeur par défaut est donc de 1 jour. <literal>No-Store</literal> sert uniquement
-pour les fichiers d'archive&nbsp;: cela demande au cache de ne jamais garder 
+pour les fichiers d'archive&nbsp; et demande au cache de ne jamais garder 
 la requête. Cela peut éviter de polluer un cache mandataire avec des 
 fichiers .deb très grands. Note&nbsp;: Squid 2.0.2 ne prend en compte aucune de 
 ces options.
      </para>
 <para>
 L'option <literal>timeout</literal> positionne le compteur de temps mort (timeout)
-utilisé par la méthode&nbsp;: cela vaut pour tout (connexion, données).
+utilisé par la méthode. Cela vaut pour tout, connexion et données.
      </para>
 <para>
 Une option de configuration est fournie pour contrôler la profondeur du tube
@@ -264,27 +292,62 @@ ne respectent pas la RFC 2068.
      </para></listitem>
 </varlistentry>
 
+<varlistentry><term>https</term>
+<listitem><para>
+URI HTTPS. Les options de contrôle de cache et de mandataire (proxy) sont les
+mêmes que pour la méthode <literal>http</literal>. L'option
+<literal>Pipeline-Depth</literal> n'est pas encore supportée.
+     </para>
+
+<para>La sous-option <literal>CaInfo</literal> spécifie le fichier contenant
+les informations sur les certificats de confiance.
+La sous-option booléenne <literal>Verify-Peer</literal> précise si le
+certificat d'hôte du serveur doit être confronté aux certificats de confiance
+ou pas. La sous-option booléenne <literal>Verify-Host</literal> précise s'il
+faut vérifier ou pas le nom d'hôte du serveur. <literal>SslCert</literal>
+détermine le certificat à utiliser pour l'authentification du client.
+<literal>SslKey</literal> détermine quelle clef privée doit être utilisée pour
+l'authentification du client. <literal>SslForceVersion</literal> surcharge la
+valeur par défaut pour la version de SSL à utiliser et peut contenir l'une des
+chaînes 'TLSv1' ou 'SSLv3'.
+     </para>
+<para>Chacune de ces options peut être spécifiée pour un hôte particulier en
+utilisant <literal>&lt;hôte&gt;::CaInfo</literal>,
+<literal>&lt;hôte&gt;::Verify-Peer</literal>,
+<literal>&lt;hôte&gt;::Verify-Host</literal>,
+<literal>&lt;hôte&gt;::SslCert</literal>,
+<literal>&lt;hôte&gt;::SslKey</literal> et
+<literal>&lt;hôte&gt;::SslForceVersion</literal> respectivement.
+     </para></listitem>
+</varlistentry>
+
 <varlistentry><term>ftp</term>
 <listitem><para>
-URI FTP ; ftp::Proxy est le serveur mandataire par défaut à utiliser. Il se
-présente sous la forme standard&nbsp;: 
-<literal>ftp://[[user][:pass]@]host[:port]/</literal>&nbsp;; il est remplacé par la 
-variable d'environnement <envar>ftp_proxy</envar>. Pour utiliser un mandataire ftp,
-vous devez renseigner l'entrée <literal>ftp::ProxyLogin</literal> dans le fichier de
-configuration. Cette entrée spécifie les commandes qui disent au serveur
-mandataire comment se connecter. Voyez &configureindex; pour savoir
-comment faire. Les variables de substitution disponibles sont&nbsp;:
-<literal>$(PROXY_USER)</literal>, <literal>$(PROXY_PASS)</literal>, <literal>$(SITE_USER)</literal>,
-<literal>$(SITE_PASS)</literal>, <literal>$(SITE)</literal>, et <literal>$(SITE_PORT)</literal>.
-Chacune correspond à un élément de l'URI.
+URI FTP&nbsp;; ftp::Proxy est le mandataire (proxy) FTP à utiliser par défaut.
+Il se présente sous la forme standard&nbsp;: 
+<literal>ftp://[[user][:pass]@]host[:port]/</literal>. On peut spécifier un
+mandataire particulier par hôte distant en utilisant la syntaxe&nbsp;:
+<literal>ftp::Proxy::&lt;hôte&gt;</literal>. Le mot-clé spécial
+<literal>DIRECT</literal> indique alors de n'utiliser aucun mandataire pour
+l'hôte. Lorsqu'elle est définie, la variable d'environnement
+<envar>ftp_proxy</envar> annule et replace toutes les options de mandataire
+FTP. Pour utiliser un mandataire FTP, vous devrez renseigner l'entrée
+<literal>ftp::ProxyLogin</literal> dans le fichier de configuration. Cette
+entrée spécifie les commandes à envoyer au mandataire pour lui préciser à quoi
+il doit se connecter. Voyez &configureindex; pour savoir comment faire. Les
+variables de substitution disponibles sont&nbsp;:
+<literal>$(PROXY_USER)</literal>, <literal>$(PROXY_PASS)</literal>,
+<literal>$(SITE_USER)</literal>, <literal>$(SITE_PASS)</literal>,
+<literal>$(SITE)</literal> et <literal>$(SITE_PORT)</literal>. Chacune
+correspond à l'élément respectif de l'URI.
      </para>
 <para>
-L'option <literal>timeout</literal> positionne le compteur de temps mort (timeout)
-utilisé par la méthode&nbsp;: cela vaut pour tout (connexion, données).
+L'option <literal>timeout</literal> positionne le compteur de temps mort
+(timeout) utilisé par la méthode. Cela vaut pour tout, connexion et données.
      </para>
 <para>
 Plusieurs options de configuration sont fournies pour contrôler le mode 
-passif. Généralement, c'est plus sûr d'activer le mode passif&nbsp;; cela 
+passif. Il est généralement plus sûr d'activer le mode passif et cela 
 marche dans presque tous les environnements. Cependant, certaines situations
 nécessitent que le mode passif soit désactivé et que le mode 
 «&nbsp;port&nbsp;» de ftp
@@ -293,16 +356,18 @@ connexions qui passent par un mandataire ou pour une machine
 spécifique (examinez le modèle de fichier de configuration).
      </para>
 <para>
-On peut utiliser un mandataire FTP pour atteindre une cible HTTP en
-positionnant la variable d'environnement <envar>ftp_proxy</envar> à une url http --
-consultez la méthode http ci-dessus pour la syntaxe. On ne peut pas fixer
-cette variable dans le fichier de configuration et il n'est pas recommandé
-d'utiliser HTTP par FTP à cause de son peu d'efficacité.
+Il est possible de faire transiter le trafic FTP par un mandataire HTTP en
+positionnant la variable d'environnement <envar>ftp_proxy</envar> à une URL
+HTTP --
+consultez la méthode http ci-dessus pour la syntaxe. On ne peut pas le faire
+dans le fichier de configuration et il n'est de toute façon pas recommandé
+d'utiliser FTP au travers de HTTP en raison la faible efficacité de cette
+méthode.
      </para>
 <para>
 L'option <literal>ForceExtended</literal> contrôle l'utilisation des commandes liées 
 à la RFC 2428, <literal>EPSV</literal> et <literal>EPRT</literal>. Par défaut, elle vaut 
-«&nbsp;false&nbsp;»&nbsp;; ce qui signifie que ces commandes ne sont 
+«&nbsp;false&nbsp;» ce qui signifie que ces commandes ne sont 
 utilisées que pour une connexion de type IPv6. Quand elle vaut 
 «&nbsp;true&nbsp;», on les utilise même si la connexion est de type IPv4. La 
 plupart des serveurs FTP ne suivent pas la RFC 2428.
@@ -311,7 +376,7 @@ plupart des serveurs FTP ne suivent pas la RFC 2428.
 
 <varlistentry><term>cdrom</term>
 <listitem><para>
-URI CDROM&nbsp;; la seule option de configuration pour les URI de CDROM
+URI cédérom&nbsp;; la seule option de configuration pour les URI de cédérom
 est le point de montage&nbsp;: <literal>cdrom::Mount</literal>&nbsp;; il doit 
 représenter le point de montage du lecteur de cédérom indiqué dans 
 <filename>/etc/fstab</filename>. 
@@ -326,9 +391,9 @@ peuvent 
 
      <varlistentry><term>gpgv</term>
      <listitem><para>
-URI GPGV ; la seule option pour les URI GPGV est celle qui permet de
+URI GPGV&nbsp;; la seule option pour les URI GPGV est celle qui permet de
      passer des paramètres à gpgv.
-     <literal>gpgv::Options</literal> Options supplémentaires passées à
+     <literal>gpgv::Options</literal>&nbsp;: options supplémentaires passées à
      gpgv.
 </para>
 	  </listitem>
@@ -341,7 +406,8 @@ URI GPGV ; la seule option pour les URI GPGV est celle qui permet de
 <para>   
 Les répertoires de la section <literal>Dir::State</literal> concernent le système
 local. <literal>lists</literal> est le répertoire où placer les listes de paquets
-téléchargés et <literal>status</literal> est le nom du fichier d'état de Dpkg.
+téléchargés et <literal>status</literal> est le nom du fichier d'état de
+&dpkg;.
 <literal>preferences</literal> concerne APT&nbsp;: c'est le nom du fichier des 
 préférences.
 <literal>Dir::State</literal> contient le répertoire par défaut préfixé à tous les
@@ -353,8 +419,8 @@ ou <filename>./</filename>.
 cache local&nbsp;: par exemple, les deux caches de paquets 
 <literal>srcpkgcache</literal> et <literal>pkgcache</literal>, et aussi l'endroit où sont 
 placées les archives téléchargées, <literal>Dir::Cache::archives</literal>. On peut 
-empêcher la création des caches en laissant leur nom en blanc. Cela ralentit 
-le démarrage mais cela sauve de l'espace disque. Il vaut mieux se passer du 
+empêcher la création des caches en saisissant un nom vide. Cela ralentit 
+le démarrage mais sauve de l'espace disque. Il vaut mieux se passer du 
 cache <literal>pkgcache</literal> plutôt que se passer du cache <literal>srcpkgcache</literal>. 
 Comme pour <literal>Dir::State</literal>, le répertoire par défaut est contenu dans
 <literal>Dir::Cache</literal>.
@@ -375,11 +441,22 @@ de configuration est charg
 Les programmes binaires sont pointés par <literal>Dir::Bin</literal>.
 L'emplacement des gestionnaires de méthodes est indiqué par
 <literal>Dir::Bin::Methods</literal>&nbsp;; <literal>gzip</literal>, 
-<literal>Dpkg</literal>, <literal>apt-get</literal>,
+<literal>dpkg</literal>, <literal>apt-get</literal>,
 <literal>dpkg-source</literal>, <literal>dpkg-buildpackage</literal> 
 et <literal>apt-cache</literal>
 indiquent l'emplacement des programmes correspondants.
- </para>
+   </para>
+<para>
+L'option de configuration <literal>RootDir</literal> a une signification
+particulière. Lorsqu'elle est définie, tous les chemins déclarés dans
+<literal>Dir::</literal> sont considérés relativement à
+<literal>RootDir</literal>, <emphasis>même les chemins spécifiés de manière
+absolue</emphasis>. Ainsi par exemple si <literal>RootDir</literal> est
+défini comme <filename>/tmp/staging</filename>, et que chemin du fichier d'état
+<literal>Dir::State::status</literal> est déclaré comme
+<filename>/var/lib/dpkg/status</filename> alors ce fichier sera cherché
+dans <filename>/tmp/staging/var/lib/dpkg/status</filename>.
+   </para>
 </refsect1>
 
 <refsect1><title>APT et DSelect</title>
@@ -406,14 +483,14 @@ de nouveaux paquets.
 
 <varlistentry><term>Options</term>
 <listitem><para>
-Le contenu de cette variable est passé à &apt-get; avec les options de la ligne
-de commande quand ce programme est utilisé dans la phase d'installation.
+Le contenu de cette variable est passé comme options de ligne de commande à
+&apt-get; lors de la phase d'installation.
      </para></listitem>
 </varlistentry>
 <varlistentry><term>UpdateOptions</term>
 <listitem><para>
-Le contenu de cette variable est passé à &apt-get; avec les options de la 
-ligne de commande quand ce programme est utilisé dans la phase de mise à jour.
+Le contenu de cette variable est passé comme options de ligne de commande à
+&apt-get; lors de la phase de mise à jour.
      </para></listitem>
 </varlistentry>
 
@@ -427,7 +504,7 @@ qu'en cas d'erreur que l'on propose 
 </variablelist>
 </refsect1>
 
-<refsect1><title>Comment APT appelle Dpkg</title>
+<refsect1><title>Comment APT appelle &dpkg;</title>
 <para>   
 Plusieurs directives de configuration contrôlent la manière dont APT
 invoque &dpkg;&nbsp;: elles figurent dans la section <literal>DPkg</literal>.
@@ -435,8 +512,8 @@ invoque &dpkg;&nbsp;: elles figurent dans la section <literal>DPkg</literal>.
    <variablelist>
 <varlistentry><term>Options</term>
 <listitem><para>
-Il s'agit d'une liste d'options à passer à dpkg. Les options doivent être
-déclarées en utilisant la notation de liste et chaque élément de liste est
+Il s'agit d'une liste d'options à passer à &dpkg;. Les options doivent être
+déclarées en utilisant la notation de liste et chaque élément de la liste est
 passé comme un seul argument à &dpkg;.
      </para></listitem>
 </varlistentry>
@@ -450,7 +527,7 @@ liste. Les commandes sont appel
 </varlistentry>
 <varlistentry><term>Pre-Install-Pkgs</term>
 <listitem><para>
-Il s'agit d'une liste de commandes shell à exécuter avant d'appeler Dpkg. 
+Il s'agit d'une liste de commandes shell à exécuter avant d'appeler &dpkg;. 
 Tout comme pour <literal>Options</literal>, on doit utiliser la notation de liste.
 Les commandes sont appelées dans l'ordre, en utilisant 
 <filename>/bin/sh</filename>&nbsp;: APT s'arrête dès que l'une d'elles échoue. Sur 
@@ -467,7 +544,7 @@ commande pass
 </varlistentry>
 <varlistentry><term>Run-Directory</term>
 <listitem><para>
-APT se place dans ce répertoire avant d'appeler Dpkg&nbsp;; par défaut c'est 
+APT se place dans ce répertoire avant d'appeler &dpkg;&nbsp;; par défaut c'est 
 le répertoire <filename>/</filename>.
      </para></listitem>
 </varlistentry>
@@ -481,25 +558,262 @@ cr
 </variablelist>
  </refsect1>
 
+<refsect1>
+<title>Options «&nbsp;Periodic&nbsp;» et «&nbsp;Archive&nbsp;»</title>
+<para>
+Les groupes d'options <literal>APT::Periodic</literal> et
+<literal>APT::Archive</literal> configurent les comportements périodiques
+réalisés par le script <literal>/etc/cron.daily/apt</literal>, lancé
+quotidiennement.
+   </para>
+<variablelist>
+<varlistentry><term>APT::Periodic</term>
+<para>Les options de cette section permettent de configurer la fréquence
+d'exécution des tâches APT lancées automatiquement. Ces paramètre prennent
+comme valeurs des périodicités d'exécution en nombre de jours.
+   </para>
+<listitem><para>
+<literal>Update-Package-List</literal>&nbsp;: périodicité de mise à jour de la
+liste des paquets disponibles. (0 = désactivé)
+     </para></listitem>
+<listitem><para>
+<literal>Download-Upgradable-Packages</literal>&nbsp;: périodicité de
+téléchargement dans le cache des paquets pour lesquels une mise à jour est
+disponible. (0 = désactivé)
+     </para></listitem>
+<listitem><para>
+<literal>AutocleanInterval</literal>&nbsp;: périodicité des
+«&nbsp;autoclean&nbsp;», c'est à dire de la suppression du cache des paquets
+qui ne peuvent plus être téléchargés. (0 = désactivé)
+     </para></listitem>
+<listitem><para>
+<literal>Unattended-Upgrade</literal>&nbsp;: périodicité de mise à jour
+automatique du système sans intervention humaine. Le paquet
+<literal>unattended-upgrades</literal> doit être installé pour que cette tâche
+s'exécute. Le cas échéant un fichier journal est écrit dans
+<literal>/var/log/unattended-upgrades</literal>. (0 = désactivé)
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>APT::Archive</term>
+<para>Les options de la section APT::Archive permettent de contrôler la taille
+du cache de paquets.
+   </para>
+<listitem><para>
+<literal>MaxAge</literal>&nbsp;: ancienneté maximale d'un paquet dans le cache,
+en nombre de jours. Les paquets plus anciens sont supprimés. (0 = désactivé)
+     </para></listitem>
+<listitem><para>
+<literal>MaxSize</literal>&nbsp;: taille maximale du cache en Mo. (0 =
+désactive) Si ce maximum est dépassé, des paquets sont supprimés jusqu'à ce
+que la taille du cache repasse sous la limite. Les paquets les plus volumineux
+sont supprimés en premier.
+     </para></listitem>
+<listitem><para>
+<literal>MinAge</literal>&nbsp;: age minimum d'un paquet du cache, en nombre de
+jours (0 = désactivé). Un paquet plus récent ne sera pas supprimé. Cette option
+est utile pour garder à disposition une version des paquets en cas de problème
+grave.
+     </para></listitem>
+</varlistentry>
+</variablelist>
+</refsect1>
+
 <refsect1><title>Les options de débogage</title>
-<para>   
-La plupart des options de la section <literal>debug</literal> n'ont aucun intérêt
-pour le simple utilisateur&nbsp;; cependant, 
-<literal>Debug::pkgProblemResolver</literal> affiche d'intéressantes informations sur 
-les décisions que prend la commande dist-upgrade. <literal>Debug::NoLocking</literal> 
-désactive le verrouillage de fichier de manière à ce que APT puisse effectuer 
-quelques opérations sans être «&nbsp;root&nbsp;» et 
-<literal>Debug::pkgDPkgPM</literal> affiche la ligne de commande à chaque appel de 
-Dpkg. <literal>Debug::IdentCdrom</literal> désactive l'inclusion de 
-données de type statfs dans les ID de CDROM.
-<literal>Debug::Acquire::gpgv</literal> Débogage de la méthode gpgv.
- </para>
+<para>
+Les options de la section <literal>Debug::</literal> servent soit à provoquer
+l'affichage d'informations de débogage sur la sortie d'erreur standard du
+programme qui utilise les librairies APT, soit à activer des modes de
+fonctionnement spéciaux qui sont principalement utiles pour déboguer le
+comportement de <literal>APT</literal>. La plupart de ces options n'ont pas
+d'intérêt pour un utilisateur normal, mais certaines peuvent tout de même être
+utiles&nbsp;:
+   </para>
+<itemizedlist>
+<listitem><para>
+<literal>Debug::pkgProblemResolver</literal> affiche d'intéressantes
+informations sur les décisions prises par les commandes <literal>dist-upgrade,
+upgrade, install, remove et purge</literal>.
+     </para></listitem>
+<listitem><para>
+<literal>Debug::NoLocking</literal> désactive le verrouillage de fichier de
+manière à ce que APT puisse effectuer quelques opérations (telles que
+<literal>apt-get -s install</literal>) sans être «&nbsp;root&nbsp;».
+     </para></listitem>
+<listitem><para>
+<literal>Debug::pkgDPkgPM</literal> affiche la ligne de commande à chaque appel
+de &dpkg;.
+     </para></listitem>
+<listitem><para>
+<literal>Debug::IdentCdrom</literal> désactive l'inclusion de données de type
+statfs dans les ID de cédérom.
+     </para></listitem>
+</itemizedlist>
+
+<para>Voici une liste complète des options de débogage de APT.</para>
+<variablelist>
+<varlistentry><term>Debug::Acquire::cdrom</term>
+<listitem><para>
+Affiche les informations concernant les sources de type cdrom://
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::Acquire::ftp</term>
+<listitem><para>
+Affiche les informations concernant le téléchargement de paquets par FTP.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::Acquire::http</term>
+<listitem><para>
+Affiche les informations concernant le téléchargement de paquets par HTTP.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::Acquire::https</term>
+<listitem><para>
+Affiche les informations concernant le téléchargement de paquets par HTTPS.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::Acquire::gpgv</term>
+<listitem><para>
+Affiche les informations relatives à la vérification de signatures
+cryptographiques avec <literal>gpg</literal>.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::aptcdrom</term>
+<listitem><para>
+Affiche des informations concernant l'accès aux collections de paquets
+stockées sur cédérom.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::BuildDeps</term>
+<listitem><para>
+Décrit le processus de résolution des dépendances pour la construction de
+paquets source (&nbsp;«&nbsp;build-dependencies&nbsp;»&nbsp;) par &apt-get;.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::Hashes</term>
+<listitem><para>
+Affiche toutes les clefs de hachage cryptographiques générées par les
+librairies APT.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::IdentCdrom</term>
+<listitem><para>Désactive l'inclusion des données de type
+<literal>statfs</literal> pour la génération des ID de cédérom, à savoir le
+nombre de blocs libres et utilisés sur le système de fichier du cédérom.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::NoLocking</term>
+<listitem><para>
+Désactive le verrouillage de fichiers. Cela permet par exemple de lancer deux
+instances de «&nbsp;apt-get update&nbsp;» en même temps.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgAcquire</term>
+<listitem><para>
+Trace les ajouts et suppressions d'éléments de la queue globale de
+téléchargement.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgAcquire::Auth</term>
+<listitem><para>
+Affiche les détails de la vérification des sommes de contrôle et des signatures
+cryptographiques des fichiers téléchargés, ainsi que les erreurs éventuelles.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgAcquire::Diffs</term>
+<listitem><para>
+Affiche les informations de téléchargement et de prise en compte des fichiers
+différentiels des indexes de paquets, ainsi que les erreurs éventuelles.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgAcquire::RRed</term>
+<listitem><para>
+Affiche les détails de la vérification des sommes de contrôle et des signatures
+cryptographiques des fichiers téléchargés, ainsi que les erreurs éventuelles.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgAcquire::Worker</term>
+<listitem><para>
+Affiche toutes les interactions avec les processus enfants qui se chargent
+effectivement des téléchargements.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgAcquire::pkgAutoRemove</term>
+<listitem><para>
+Affiche les changements concernant le marquage des paquets comme installés
+automatiquement, et la suppression des paquets inutiles. 
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgDepCache::AutoInstall</term>
+<listitem><para>
+Génère les informations de débogage décrivant quels paquets sont installés
+automatiquement pour satisfaire les dépendances. Cela concerne la passe
+initiale d'installation automatique effectuée par exemple par
+<literal>apt-get install</literal> et pas le système de résolution de
+dépendances complet de APT&nbsp;; voir
+<literal>Debug::pkgProblemResolver</literal> pour ce dernier.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgInitConfig</term>
+<listitem><para>
+Au lancement, affiche l'ensemble de la configuration sur la sortie d'erreur
+standard.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgDPkgPM</term>
+<listitem><para>
+Affiche la commande exacte d'invocation de &dpkg; à chaque appel&nbsp;; les
+arguments sont séparés par des espaces.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgDPkgProgressReporting</term>
+<listitem><para> Affiche l'ensemble des informations reçues de &dpkg; par
+l'intermédiaire du descripteur de fichier d'état, et les éventuelles erreurs
+d'analyse de ce fichier.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgOrderList</term>
+<listitem><para>
+Affiche les étapes de l'algorithme utilisé pour choisir l'ordre dans lequel APT
+passe les paquets à &dpkg;.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgPackageManager</term>
+<listitem><para>
+Affiche le détail des opérations liées à l'invocation de &dpkg;. 
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgPolicy</term>
+<listitem><para>
+Au lancement, affiche la priorité de chaque liste de paquets.
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::pkgProblemResolver</term>
+<listitem><para>
+Affiche la trace d'exécution du système de résolution de dépendances (ne
+concerne que les cas où un problème de dépendances complexe se présente).
+     </para></listitem>
+</varlistentry>
+<varlistentry><term>Debug::sourceList</term>
+<listitem><para>
+Affiche les fournisseurs déclarés dans le fichier
+<filename>/etc/apt/vendors.list</filename>.
+     </para></listitem>
+</varlistentry>
+<!-- 2009/07/11 Utilisé nulle part actuellement, le code est commenté.
+<varlistentry><term>Debug::Vendor</term>
+<listitem><para>
+Affiche les informations sur la recherche de fournisseurs.
+     </para></listitem>
+</varlistentry>
+-->
+</variablelist>
+
 </refsect1>
 
 <refsect1><title>Exemples</title>
 <para>
-Le fichier &configureindex; contient un modèle de fichier montrant les valeurs par
-défaut de toutes les options possibles.
+Le fichier &configureindex; contient un modèle de fichier montrant des exemples
+pour toutes les options existantes.
  </para>
 </refsect1>
 
@@ -514,4 +828,4 @@ d
 
 &manbugs;
 &deux-traducteurs;
-</refentry>
+</refentry>

+ 0 - 3
doc/pt_BR/.cvsignore

@@ -1,3 +0,0 @@
-apt_preferences.pt_BR.5
-manpage.links
-manpage.refs

+ 104 - 25
methods/cdrom.cc

@@ -9,6 +9,7 @@
 									/*}}}*/
 // Include Files							/*{{{*/
 #include <apt-pkg/acquire-method.h>
+#include <apt-pkg/cdrom.h>
 #include <apt-pkg/cdromutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
@@ -17,6 +18,7 @@
 
 #include <sys/stat.h>
 #include <unistd.h>
+#include <dlfcn.h>
 
 #include <iostream>
 #include <apti18n.h>
@@ -27,15 +29,20 @@ using namespace std;
 class CDROMMethod : public pkgAcqMethod
 {
    bool DatabaseLoaded;
+   bool Debug;
+
    ::Configuration Database;
    string CurrentID;
    string CDROM;
    bool MountedByApt;
-   
+   pkgUdevCdromDevices UdevCdroms;
+ 
+   bool IsCorrectCD(URI want, string MountPath);
+   bool AutoDetectAndMount(URI);
    virtual bool Fetch(FetchItem *Itm);
    string GetID(string Name);
    virtual void Exit();
-   
+      
    public:
    
    CDROMMethod();
@@ -50,14 +57,15 @@ CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly |
                                           DatabaseLoaded(false), 
                                           MountedByApt(false)
 {
+   UdevCdroms.Dlopen();
 };
 									/*}}}*/
 // CDROMMethod::Exit - Unmount the disc if necessary			/*{{{*/
 // ---------------------------------------------------------------------
 /* */
 void CDROMMethod::Exit()
-{
-   if (MountedByApt == true)
+{ 
+  if (MountedByApt == true)
       UnmountCdrom(CDROM);
 }
 									/*}}}*/
@@ -81,16 +89,94 @@ string CDROMMethod::GetID(string Name)
    return string();
 }
 									/*}}}*/
+// CDROMMethod::AutoDetectAndMount                                      /*{{{*/
+// ---------------------------------------------------------------------
+/* Modifies class varaiable CDROM to the mountpoint */
+bool CDROMMethod::AutoDetectAndMount(URI Get)
+{
+   vector<struct CdromDevice> v = UdevCdroms.Scan();
+
+   // first check if its mounted somewhere already
+   for (unsigned int i=0; i < v.size(); i++)
+   {
+      if (v[i].Mounted)
+      {
+	 if (Debug)
+	    clog << "Checking mounted cdrom device " << v[i].DeviceName << endl;
+	 if (IsCorrectCD(Get, v[i].MountPath))
+	 {
+	    CDROM = v[i].MountPath;
+	    return true;
+	 }
+      }
+   }
+
+   // we are not supposed to mount, exit
+   if (_config->FindB("APT::CDROM::NoMount",false) == true)
+      return false;
+
+   // check if we have the mount point
+   if (!FileExists("/media/apt"))
+      mkdir("/media/apt", 0755);
+
+   // now try mounting
+   for (unsigned int i=0; i < v.size(); i++)
+   {
+      if (!v[i].Mounted)
+      {
+	 if(MountCdrom("/media/apt", v[i].DeviceName)) 
+	 {
+	    if (IsCorrectCD(Get, "/media/apt"))
+	    {
+	       MountedByApt = true;
+	       CDROM = "/media/apt";
+	       return true;
+	    } else {
+	       UnmountCdrom("/media/apt");
+	    }
+	 }
+      }
+   }
+
+   return false;
+}
+									/*}}}*/
+// CDROMMethod::IsCorrectCD                                             /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool CDROMMethod::IsCorrectCD(URI want, string MountPath)
+{
+   string NewID;
+
+   for (unsigned int Version = 2; Version != 0; Version--)
+   {
+      if (IdentCdrom(MountPath,NewID,Version) == false)
+	 return false;
+      
+      if (Debug)
+	 clog << "ID " << Version << " " << NewID << endl;
+      
+      // A hit
+      if (Database.Find("CD::" + NewID) == want.Host)
+	 return true;
+   }
+   
+   return false;
+}
+									/*}}}*/
 // CDROMMethod::Fetch - Fetch a file					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
 bool CDROMMethod::Fetch(FetchItem *Itm)
 {
+   FetchResult Res;
+
    URI Get = Itm->Uri;
    string File = Get.Path;
-   FetchResult Res;
+   Debug = _config->FindB("Debug::Acquire::cdrom", false);
 
-   bool Debug = _config->FindB("Debug::Acquire::cdrom",false);
+   if (Debug)
+      clog << "CDROMMethod::Fetch " << Itm->Uri << endl;
 
    /* All IMS queries are returned as a hit, CDROMs are readonly so 
       time stamps never change */
@@ -126,38 +212,31 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    }
 
    // We already have a CD inserted, but it is the wrong one
-   if (CurrentID.empty() == false && Database.Find("CD::" + CurrentID) != Get.Host)
+   if (CurrentID.empty() == false && 
+       CurrentID != "FAIL" &&
+       Database.Find("CD::" + CurrentID) != Get.Host)
    {
       Fail(_("Wrong CD-ROM"),true);
       return true;
    }
-   
+
    CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+   if (Debug)
+      clog << "Looking for CDROM at " << CDROM << endl;
+
    if (CDROM[0] == '.')
       CDROM= SafeGetCWD() + '/' + CDROM;
    string NewID;
+
    while (CurrentID.empty() == true)
    {
-      bool Hit = false;
+      if (CDROM == "apt-udev-auto/") 
+	 AutoDetectAndMount(Get);
+
       if(!IsMounted(CDROM))
 	 MountedByApt = MountCdrom(CDROM);
-      for (unsigned int Version = 2; Version != 0; Version--)
-      {
-	 if (IdentCdrom(CDROM,NewID,Version) == false)
-	    return false;
-	 
-	 if (Debug == true)
-	    clog << "ID " << Version << " " << NewID << endl;
       
-	 // A hit
-	 if (Database.Find("CD::" + NewID) == Get.Host)
-	 {
-	    Hit = true;
-	    break;
-	 }	 
-      }
-
-      if (Hit == true)
+      if (IsCorrectCD(Get, CDROM))
 	 break;
 	 
       // I suppose this should prompt somehow?

+ 2 - 2
methods/makefile

@@ -7,7 +7,7 @@ include ../buildlib/defaults.mak
 BIN := $(BIN)/methods
 
 # FIXME..
-LIB_APT_PKG_MAJOR = 4.7
+LIB_APT_PKG_MAJOR = 4.8
 APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR)
 
 # The file method
@@ -40,7 +40,7 @@ include $(PROGRAM_H)
 
 # The cdrom method
 PROGRAM=cdrom
-SLIBS = -lapt-pkg $(INTLLIBS)
+SLIBS = -lapt-pkg -ldl $(INTLLIBS)
 LIB_MAKES = apt-pkg/makefile
 SOURCE = cdrom.cc
 include $(PROGRAM_H)

+ 72 - 0
po/ChangeLog

@@ -1,3 +1,75 @@
+2009-06-05  Jordi Mallach  <jordi@debian.org>
+
+	* ca.po: Updated to 539t
+
+2009-06-04  Milo Casagrande  <milo@ubuntu.com>
+
+	* it.po: Updated to 539t
+
+2009-06-01  Deng Xiyue  <manphiz-guest@users.alioth.debian.org>
+
+	* zh_CN.po: Updated to 539t
+
+2009-05-21  Marcos  <marcos.alvarez.costales@gmail.com>
+
+	* ast.po: Updated to 539t
+
+2009-04-28  Ivan Masár  <helix84@centrum.sk>
+
+	* sk.po: Updated to 539t
+
+2009-04-23  Christian Perrier  <bubulle@debian.org>
+
+	* Update all PO files and apt-all.pot. 545 strings.
+	  Formerly complete PO files are now 539t1f6u
+	* fr.po: updated to 545t.
+
+2009-03-19  Ivan Masár  <helix84@centrum.sk>
+
+	* sk.po: Updated to 539t
+
+2009-03-04  Daniel Nylander  <po@danielnylander.se>
+
+	* sv.po: Updated to 539t
+
+2009-02-23  Christian Perrier  <bubulle@debian.org>
+
+	* Update all PO files and apt-all.pot. 539 strings.
+	  Formerly complete PO files are now 538t1u
+	* fr.po: updated to 539t.
+
+2009-02-01  Hans Fredrik Nordhaug  <hans@nordhaug.priv.no>
+
+	* nb.po: updated to 539t.
+
+2009-01-27  Damyan Ivanov  <dmn@debian.org>
+
+	* bg.po: updated to 539t.
+
+2008-12-11  Christian Perrier  <bubulle@debian.org>
+
+	* fr.po: fix spelling error to "défectueux"
+
+2009-01-04  Tetralet  <tetralet@gmail.com>
+
+	* zh_TW.po: Added as 538t1u.
+
+2008-12-22  Clytie Siddall  <clytie@riverland.net.au>
+
+	* vi.po: updated to 539t.
+
+2008-12-22  Jordi Mallach  <jordi@debian.org>
+
+	* ca.po: updated to 539t.
+
+2008-12-19  Marcelino Villarino  <mvillarino@gmail.com>
+
+	* gl.po: updated to 539t.
+
+2008-12-12  Tapio Lehtonen  <tale@debian.org>
+
+	* fi.po: updated to 539t.
+
 2008-12-06  Christian Perrier  <bubulle@debian.org>
 
 	* fr.po: dropped awful use of first person

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 462 - 363
po/apt-all.pot


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 372 - 276
po/ar.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 2999 - 0
po/ast.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 382 - 329
po/bg.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 362 - 276
po/bs.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 443 - 294
po/ca.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 378 - 277
po/cs.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 375 - 276
po/cy.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 377 - 317
po/da.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 388 - 293
po/de.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 374 - 312
po/dz.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 374 - 312
po/el.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 378 - 277
po/en_GB.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 383 - 283
po/es.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 422 - 281
po/eu.po


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 382 - 328
po/fi.po


+ 0 - 0
po/fr.po


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio