]> git.saurik.com Git - apt.git/commitdiff
* doc/files.sgml:
authorMichael Vogt <michael.vogt@ubuntu.com>
Tue, 4 May 2010 18:55:08 +0000 (20:55 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Tue, 4 May 2010 18:55:08 +0000 (20:55 +0200)
  - sync documentation with status quo, regarding files/directories in
    use, extended_states and uri schemes.
* doc/cache.sgml:
  - drop the file in favor of inplace documentation with doxygen
* apt-pkg/pkgcache.h:
  - enhance the Groups ABI by providing a ID as the other structs does
  - check also the size of the Group struct then checking for the others

15 files changed:
Makefile
apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h
apt-pkg/acquire-worker.h
apt-pkg/acquire.h
apt-pkg/contrib/weakptr.h [new file with mode: 0644]
apt-pkg/depcache.cc
apt-pkg/makefile
apt-pkg/pkgcache.cc
apt-pkg/policy.cc
cmdline/apt-get.cc
cmdline/apt-mark
debian/changelog
methods/connect.cc
test/libapt/getlanguages_test.cc

index 664caca41f2d9d67a63f1aeb4f170b9b3c00f4b5..6cf669ef83c730a7d80e53cfbffd3306039da0f1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,12 +13,7 @@ default: startup all
 all headers library clean veryclean binary program doc dirs:
        $(MAKE) -C apt-pkg $@
        $(MAKE) -C apt-inst $@
-       $(MAKE) -C methods $@
        $(MAKE) -C cmdline $@
-       $(MAKE) -C ftparchive $@
-       $(MAKE) -C dselect $@
-       $(MAKE) -C doc $@
-       $(MAKE) -C po $@
 
 # Some very common aliases
 .PHONY: maintainer-clean dist-clean distclean pristine sanity 
index 916fca71eeaaf0e1722129c71d90010e36c2cc23..1f253bb81b96966d3ca9982aaaa713618eb9d086 100644 (file)
@@ -1561,8 +1561,9 @@ void pkgAcqArchive::Finished()
 /* The file is added to the queue */
 pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash,
                       unsigned long Size,string Dsc,string ShortDesc,
-                      const string &DestDir, const string &DestFilename) :
-                       Item(Owner), ExpectedHash(Hash)
+                      const string &DestDir, const string &DestFilename,
+                       bool IsIndexFile) :
+                       Item(Owner), ExpectedHash(Hash), IsIndexFile(IsIndexFile)
 {
    Retries = _config->FindI("Acquire::Retries",0);
    
@@ -1677,3 +1678,12 @@ void pkgAcqFile::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    Item::Failed(Message,Cnf);
 }
                                                                        /*}}}*/
+// AcqIndex::Custom600Headers - Insert custom request headers          /*{{{*/
+// ---------------------------------------------------------------------
+/* The only header we use is the last-modified header. */
+string pkgAcqFile::Custom600Headers()
+{
+   if (IsIndexFile)
+      return "\nIndex-File: true";
+}
+                                                                       /*}}}*/
index d862d0fdd9b363c918331a234061ceb05d52d100..b338b2a4199f9fe60cc437b2e298876a171e291c 100644 (file)
@@ -27,6 +27,7 @@
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/indexrecords.h>
 #include <apt-pkg/hashes.h>
+#include <apt-pkg/weakptr.h>
 
 /** \addtogroup acquire
  *  @{
@@ -46,7 +47,7 @@
  *
  *  \see pkgAcquire
  */
-class pkgAcquire::Item
+class pkgAcquire::Item : public WeakPointable
 {  
    protected:
    
@@ -861,6 +862,9 @@ class pkgAcqFile : public pkgAcquire::Item
     */
    unsigned int Retries;
    
+   /** \brief Should this file be considered a index file */
+   bool IsIndexFile;
+
    public:
    
    // Specialized action members
@@ -869,6 +873,7 @@ class pkgAcqFile : public pkgAcquire::Item
                     pkgAcquire::MethodConfig *Cnf);
    virtual string DescURI() {return Desc.URI;};
    virtual string HashSum() {return ExpectedHash.toStr(); };
+   virtual string Custom600Headers();
 
    /** \brief Create a new pkgAcqFile object.
     *
@@ -892,6 +897,8 @@ class pkgAcqFile : public pkgAcquire::Item
     *
     *  \param DestFilename The filename+path the file is downloaded to.
     *
+    *  \param IsIndexFile The file is considered a IndexFile and cache-control
+    *                     headers like "cache-control: max-age=0" are send
     *
     * If DestFilename is empty, download to DestDir/<basename> if
     * DestDir is non-empty, $CWD/<basename> otherwise.  If
@@ -901,7 +908,8 @@ class pkgAcqFile : public pkgAcquire::Item
 
    pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long Size,
              string Desc, string ShortDesc,
-             const string &DestDir="", const string &DestFilename="");
+             const string &DestDir="", const string &DestFilename="",
+             bool IsIndexFile=false);
 };
                                                                        /*}}}*/
 /** @} */
index 2942df69fd8460ff8a81df14912c94277e25b21e..06283922e5e4dbe41c951b083d2eefd866ee68e7 100644 (file)
@@ -20,6 +20,7 @@
 #define PKGLIB_ACQUIRE_WORKER_H
 
 #include <apt-pkg/acquire.h>
+#include <apt-pkg/weakptr.h>
 
 
 /** \brief A fetch subprocess.
@@ -41,7 +42,7 @@
  *
  *  \sa pkgAcqMethod, pkgAcquire::Item, pkgAcquire
  */
-class pkgAcquire::Worker
+class pkgAcquire::Worker : public WeakPointable
 {
    friend class pkgAcquire;
    
index 9e91a9f67c7fc26ca5b38bfed736d160b0410958..8e2c21151af135fd9b7c6c19dfdff3ffd663174a 100644 (file)
@@ -67,6 +67,7 @@
 #define PKGLIB_ACQUIRE_H
 
 #include <apt-pkg/macros.h>
+#include <apt-pkg/weakptr.h>
 
 #include <vector>
 #include <string>
@@ -376,7 +377,7 @@ class pkgAcquire
  *
  *  An item may have several assocated ItemDescs over its lifetime.
  */
-struct pkgAcquire::ItemDesc
+struct pkgAcquire::ItemDesc : public WeakPointable
 {
    /** \brief The URI from which to download this item. */
    string URI;
diff --git a/apt-pkg/contrib/weakptr.h b/apt-pkg/contrib/weakptr.h
new file mode 100644 (file)
index 0000000..5158e39
--- /dev/null
@@ -0,0 +1,62 @@
+/* weakptr.h - An object which supports weak pointers.
+ *
+ * Copyright (C) 2010 Julian Andres Klode <jak@debian.org>
+ * 
+ * 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 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 Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#ifndef WEAK_POINTER_H
+#define WEAK_POINTER_H
+
+#include <set>
+/**
+ * Class for objects providing support for weak pointers.
+ *
+ * This class allows for the registration of certain pointers as weak,
+ * which will cause them to be set to NULL when the destructor of the
+ * object is called.
+ */
+class WeakPointable {
+private:
+    std::set<WeakPointable**> pointers;
+
+public:
+
+    /**
+     * Add a new weak pointer.
+     */
+    inline void AddWeakPointer(WeakPointable** weakptr) {
+       pointers.insert(weakptr);
+    }
+
+    /**
+     * Remove the weak pointer from the list of weak pointers.
+     */
+    inline void RemoveWeakPointer(WeakPointable **weakptr) {
+       pointers.erase(weakptr);
+    }
+
+    /**
+     * Deconstruct the object, set all weak pointers to NULL.
+     */
+    ~WeakPointable() {
+        std::set<WeakPointable**>::iterator iter = pointers.begin();
+        while (iter != pointers.end())
+            **(iter++) = NULL;
+    }
+};
+
+#endif // WEAK_POINTER_H
index 659c4227e3f9245e8df6abafa573c285caed7ebf..4d1a08eb628da10d00a6f4c379dda58c07afc243 100644 (file)
@@ -192,7 +192,7 @@ bool pkgDepCache::readStateFile(OpProgress *Prog)                   /*{{{*/
         {
            PkgState[pkg->ID].Flags |= Flag::Auto;
            if (unlikely(debug_autoremove))
-              std::cout << "Auto-Installed : " << pkg.FullName() << std::endl;
+              std::clog << "Auto-Installed : " << pkg.FullName() << std::endl;
            if (pkgarch == "any")
            {
               pkgCache::GrpIterator G = pkg.Group();
@@ -1819,7 +1819,7 @@ bool pkgDepCache::Sweep()                                         /*{{{*/
      {
        state.Garbage=true;
        if(debug_autoremove)
-          std::cout << "Garbage: " << p.FullName() << std::endl;
+          std::clog << "Garbage: " << p.FullName() << std::endl;
      }
   }   
 
index bdd49c08903730574ab442313719716cac9ac995..148ad581b367a9258cca3066e8dd6f32a7762d99 100644 (file)
@@ -25,7 +25,7 @@ SOURCE = contrib/mmap.cc contrib/error.cc contrib/strutl.cc \
         contrib/fileutl.cc 
 HEADERS = mmap.h error.h configuration.h fileutl.h  cmndline.h netrc.h\
          md5.h crc-16.h cdromutl.h strutl.h sptr.h sha1.h sha256.h hashes.h \
-         macros.h
+         macros.h weakptr.h
 
 # Source code for the core main library
 SOURCE+= pkgcache.cc version.cc depcache.cc \
index ba3c5cbf8b54fa6f9418e6db692c90a6ba4ea1e3..a59a06d65411375cad6ceebeea33bc08290d2d9f 100644 (file)
@@ -221,7 +221,7 @@ pkgCache::PkgIterator pkgCache::FindPkg(const string &Name) {
 /* Returns 0 on error, pointer to the package otherwise */
 pkgCache::PkgIterator pkgCache::FindPkg(const string &Name, string const &Arch) {
        if (MultiArchCache() == false) {
-               if (Arch == "native" || Arch == "all" ||
+               if (Arch == "native" || Arch == "all" || Arch == "any" ||
                    Arch == _config->Find("APT::Architecture"))
                        return SingleArchFindPkg(Name);
                else
index 9b24c2ef183dad1b8fe7e26f50e94e836055c4e6..479cf393549ef6eb67c760e1f63552a33b78c6ce 100644 (file)
@@ -106,7 +106,7 @@ bool pkgPolicy::InitDefaults()
 
    if (_config->FindB("Debug::pkgPolicy",false) == true)
       for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++)
-        cout << "Prio of " << F.FileName() << ' ' << PFPriority[F->ID] << endl; 
+        std::clog << "Prio of " << F.FileName() << ' ' << PFPriority[F->ID] << std::endl; 
    
    return true;   
 }
index b43164c2fc94e53f443005bf75741e13742385eb..8f9faf158bb1f27097e46dad6a10be4e1be6d0c5 100644 (file)
@@ -1315,6 +1315,10 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
                  break;
               fuzzy = true;
               Ver = Pkg.VersionList();
+              // exit right away from the Pkg.VersionList() loop if we
+              // don't have any versions
+              if (Ver.end() == true)
+                 break;
            }
            // We match against a concrete version (or a part of this version)
            if (VerTag.empty() == false &&
@@ -2009,6 +2013,60 @@ bool DoInstall(CommandLine &CmdL)
 
    return InstallPackages(Cache,false);   
 }
+
+/* show automatically installed packages. */
+bool DoShowAuto(CommandLine &CmdL)
+{
+   OpProgress progress;
+   pkgCacheFile Cache;
+   if (Cache.Open(progress, false) == false)
+      return false;
+
+   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++)
+      if (Cache[P].Flags & pkgCache::Flag::Auto)
+          ioprintf(c1out,_("%s\n"), P.Name());
+   return true;
+}
+
+/* mark packages as automatically/manually installed. */
+bool DoMarkAuto(CommandLine &CmdL)
+{
+   bool Action = true;
+   int AutoMarkChanged = 0;
+   OpTextProgress progress;
+   CacheFile Cache;
+   if (Cache.Open() == false)
+      return false;
+
+   if (strcasecmp(CmdL.FileList[0],"markauto") == 0)
+      Action = true;
+   else if (strcasecmp(CmdL.FileList[0],"unmarkauto") == 0)
+      Action = false;
+
+   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   {
+      const char *S = *I;
+      // Locate the package
+      pkgCache::PkgIterator Pkg = Cache->FindPkg(S);
+      if (Pkg.end() == true) {
+         return _error->Error(_("Couldn't find package %s"),S);
+      }
+      else
+      {
+         if (!Action)
+            ioprintf(c1out,_("%s set to manually installed.\n"), Pkg.Name());
+         else
+            ioprintf(c1out,_("%s set to automatically installed.\n"),
+                      Pkg.Name());
+
+         Cache->MarkAuto(Pkg,Action);
+         AutoMarkChanged++;
+      }
+   }
+   if (AutoMarkChanged && ! _config->FindB("APT::Get::Simulate",false))
+      return Cache->writeStateFile(NULL);
+   return false;
+}
                                                                        /*}}}*/
 // DoDistUpgrade - Automatic smart upgrader                            /*{{{*/
 // ---------------------------------------------------------------------
@@ -2794,6 +2852,9 @@ bool ShowHelp(CommandLine &CmdL)
       "   clean - Erase downloaded archive files\n"
       "   autoclean - Erase old downloaded archive files\n"
       "   check - Verify that there are no broken dependencies\n"
+      "   markauto - Mark the given packages as automatically installed\n"
+      "   unmarkauto - Mark the given packages as manually installed\n"
+      "   showauto - Display a list of automatically installed packages\n"
       "\n"
       "Options:\n"
       "  -h  This help text.\n"
@@ -2900,6 +2961,9 @@ int main(int argc,const char *argv[])                                     /*{{{*/
                                    {"purge",&DoInstall},
                                   {"autoremove",&DoInstall},
                                   {"purge",&DoInstall},
+                                  {"showauto",&DoShowAuto},
+                                  {"markauto",&DoMarkAuto},
+                                  {"unmarkauto",&DoMarkAuto},
                                    {"dist-upgrade",&DoDistUpgrade},
                                    {"dselect-upgrade",&DoDSelectUpgrade},
                                   {"build-dep",&DoBuildDep},
index 12768b7088069fa9968ead5c89148325207bb048..c64d4356cc101e3c6dafcc7c0d04f646d7cad9b4 100755 (executable)
@@ -8,7 +8,7 @@ import os.path
 try:
     import apt_pkg
 except ImportError:
-    print "Error importing apt_pkg, is python-apt installed?"
+    print >> sys.stderr, "Error importing apt_pkg, is python-apt installed?"
     sys.exit(1)
     
 actions = { "markauto" : 1,
@@ -68,6 +68,7 @@ if __name__ == "__main__":
     # option parsing
     parser = OptionParser()
     parser.usage = "%prog [options] {markauto|unmarkauto} packages..."
+    parser.epilog = "apt-mark is deprecated, use apt-get markauto/unmarkauto."
     parser.add_option("-f", "--file", action="store", type="string",
                       dest="filename",
                       help="read/write a different file")
index 3fd3f0a33592facc112bdd9259818177ba7d979d..07fc0845353cd244b55ff9b3fbaa177f94b6fb6e 100644 (file)
@@ -1,4 +1,4 @@
-apt (0.7.26~exp4) experimental; urgency=low
+apt (0.7.26~exp4) UNRELEASEDexperimental; urgency=low
 
   [ David Kalnischkies ]
   * apt-pkg/depcache.cc:
@@ -30,7 +30,6 @@ apt (0.7.26~exp4) experimental; urgency=low
   * cmdline/apt-cache.cc:
     - align Installed and Candidate Version in policy so they can be compared
       easier, thanks Ralf Gesellensetter for the pointer! (Closes: #578657)
-    - use GroupCount for package names in stats and add a package struct line
   * doc/apt.ent:
     - Add a note about APT_CONFIG in the -c description (Closes: #578267)
   * doc/po/de.po:
@@ -56,6 +55,29 @@ apt (0.7.26~exp4) experimental; urgency=low
     - modernize if-statements not to use 'x' (Closes: #577117)
     - replace backticks with POSIX $() (Closes: #577116)
 
+  [ Michael Vogt ]
+  * [ Abi break ] apt-pkg/acquire-item.{cc,h}:
+    - add "IsIndexFile" to constructor of pkgAcqFile so that it sends
+      the right cache control headers
+  * cmdline/apt-get.cc:
+    - fix crash when pkg.VersionList() is empty
+  * apt-pkg/depcache.cc:
+    - fix incorrect std::cout usage for debug output
+  * test/libapt/getlanguages_test.cc:
+    - Add test for Esperanto that has nocounty associated with them
+      (LP: #560956)
+
+  [ Julian Andres Klode ]
+  * apt-pkg/contrib/weakptr.h:
+    - add a class WeakPointable which allows one to register weak pointers to
+      an object which will be set to NULL when the object is deallocated.
+  * [ABI break] apt-pkg/acquire{-worker,-item,}.h:
+    - subclass pkgAcquire::{Worker,Item,ItemDesc} from WeakPointable.
+  * apt-pkg/pkgcache.cc:
+    - Merge fix from David to correct handling in single-arch environments.
+  * cmdline/apt-get.cc:
+    - Add apt-get markauto, showauto and unmarkauto commands.
+
  -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 03 Apr 2010 14:58:39 +0200
 
 apt (0.7.26~exp3) experimental; urgency=low
index adb16a19973c9341dfc9b38f0a311f913cac63a2..2f6b4833e2e636ccf12e87ce8c6b3d5ab86796eb 100644 (file)
@@ -116,6 +116,9 @@ static bool DoConnect(struct addrinfo *Addr,string Host,
       errno = Err;
       if(errno == ECONNREFUSED)
          Owner->SetFailExtraMsg("\nFailReason: ConnectionRefused");
+      else if (errno == ETIMEDOUT)
+        Owner->SetFailExtraMsg("\nFailReason: ConnectionTimedOut");
+      bad_addr.insert(bad_addr.begin(), string(Name));
       return _error->Errno("connect",_("Could not connect to %s:%s (%s)."),Host.c_str(),
                           Service,Name);
    }
index 0db190b507b9a0ff76ca78407d5f2fd4bcb99914..9a8910b586930c0367a59e9a5011a421bd00e064 100644 (file)
@@ -43,6 +43,13 @@ int main(int argc,char *argv[])
        equals(vec[0], "en_GB");
        equals(vec[1], "en");
 
+       // esperanto
+       env[0] = "eo.UTF-8";
+       vec = APT::Configuration::getLanguages(false, false, env);
+       equals(vec.size(), 2);
+       equals(vec[0], "eo");
+       equals(vec[1], "en");
+
        env[0] = "tr_DE@euro";
        vec = APT::Configuration::getLanguages(false, false, env);
        equals(vec.size(), 2);