]> git.saurik.com Git - apt.git/commitdiff
merge with debian-experimental-ma
authorDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 5 Jul 2010 10:06:45 +0000 (12:06 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 5 Jul 2010 10:06:45 +0000 (12:06 +0200)
apt-pkg/contrib/fileutl.cc
apt-pkg/contrib/fileutl.h
apt-pkg/deb/deblistparser.cc
apt-pkg/versionmatch.cc
apt-pkg/versionmatch.h
debian/changelog
debian/control
methods/ftp.h

index e95ddf56256143ff8264d44a504ba28ad9d11099..62d42e4da8abe8e84a6706273e13a9da6fac22df 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <cstdlib>
 #include <cstring>
+#include <cstdio>
 
 #include <iostream>
 #include <unistd.h>
@@ -658,10 +659,11 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
       
       case WriteEmpty:
       {
-        struct stat Buf;
-        if (lstat(FileName.c_str(),&Buf) == 0 && S_ISLNK(Buf.st_mode))
-           unlink(FileName.c_str());
-        iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms);
+        Flags |= Replace;
+        char *name = strdup((FileName + ".XXXXXX").c_str());
+        TemporaryFileName = string(mktemp(name));
+        iFd = open(TemporaryFileName.c_str(),O_RDWR | O_CREAT | O_EXCL,Perms);
+        free(name);
         break;
       }
       
@@ -843,11 +845,19 @@ bool FileFd::Close()
       if (iFd >= 0 && close(iFd) != 0)
         Res &= _error->Errno("close",_("Problem closing the file"));
    iFd = -1;
-   
+
+   if ((Flags & Replace) == Replace) {
+      if (rename(TemporaryFileName.c_str(), FileName.c_str()) != 0)
+        Res &= _error->Errno("rename",_("Problem renaming the file"));
+      FileName = TemporaryFileName; // for the unlink() below.
+   }
+           
    if ((Flags & Fail) == Fail && (Flags & DelOnFail) == DelOnFail &&
        FileName.empty() == false)
       if (unlink(FileName.c_str()) != 0)
         Res &= _error->WarningE("unlnk",_("Problem unlinking the file"));
+
+
    return Res;
 }
                                                                        /*}}}*/
index 003bd9b83f499ab41592f60373d48be9d217b316..528725f8984a498e4af0e5082afc997a757938e2 100644 (file)
@@ -34,9 +34,10 @@ class FileFd
    int iFd;
  
    enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2),
-                    HitEof = (1<<3)};
+                    HitEof = (1<<3), Replace = (1<<4) };
    unsigned long Flags;
    string FileName;
+   string TemporaryFileName;
    
    public:
    enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp};
index d1931f90926b4e151308a12477978a19ff6d7da3..24df57a5c2d9de4b431697efff74e2ea39d00cac 100644 (file)
@@ -19,6 +19,7 @@
 #include <apt-pkg/md5.h>
 #include <apt-pkg/macros.h>
 
+#include <fnmatch.h>
 #include <ctype.h>
                                                                        /*}}}*/
 
@@ -473,6 +474,20 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
    return I;
 }
 
+/*
+ * CompleteArch:
+ *
+ * The complete architecture, consisting of <kernel>-<cpu>.
+ */
+static string CompleteArch(std::string& arch) {
+    if (arch == "armel")              return "linux-arm";
+    if (arch == "lpia")               return "linux-i386";
+    if (arch == "powerpcspe")         return "linux-powerpc";
+    if (arch == "uclibc-linux-armel") return "linux-arm";
+    if (arch == "uclinux-armel")      return "uclinux-arm";
+
+    return (arch.find("-") != string::npos) ? arch : "linux-" + arch;
+}
                                                                        /*}}}*/
 // ListParser::ParseDepends - Parse a dependency element               /*{{{*/
 // ---------------------------------------------------------------------
@@ -546,6 +561,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
    if (ParseArchFlags == true)
    {
       string arch = _config->Find("APT::Architecture");
+      string completeArch = CompleteArch(arch);
 
       // Parse an architecture
       if (I != Stop && *I == '[')
@@ -573,8 +589,13 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
               I++;
             }
 
-           if (stringcmp(arch,I,End) == 0)
+           if (stringcmp(arch,I,End) == 0) {
               Found = true;
+           } else {
+              std::string wildcard = SubstVar(string(I, End), "any", "*");
+              if (fnmatch(wildcard.c_str(), completeArch.c_str(), 0) == 0)
+                 Found = true;
+           }
            
            if (*End++ == ']') {
               I = End;
index e5f0fafd29ce0773922e2bfca71f65470b17bd8a..093180f9b78e2f9d9397eed1e39b3e191fa52626 100644 (file)
 
 #include <stdio.h>
 #include <ctype.h>
+#include <fnmatch.h>
+#include <sys/types.h>
+#include <regex.h>
+
                                                                        /*}}}*/
 
 // VersionMatch::pkgVersionMatch - Constructor                         /*{{{*/
@@ -151,6 +155,8 @@ pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg)
       {
         if (MatchVer(Ver.VerStr(),VerStr,VerPrefixMatch) == true)
            return Ver;
+        if (ExpressionMatches(VerStr, Ver.VerStr()) == true)
+           return Ver;
         continue;
       }
       
@@ -162,6 +168,36 @@ pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg)
    // This will be Ended by now.
    return Ver;
 }
+
+#ifndef FNM_CASEFOLD
+#define FNM_CASEFOLD 0
+#endif
+
+bool pkgVersionMatch::ExpressionMatches(const char *pattern, const char *string)
+{
+   if (pattern[0] == '/') {
+      bool res = false;
+      size_t length = strlen(pattern);
+      if (pattern[length - 1] == '/') {
+        regex_t preg;
+        char *regex = strdup(pattern + 1);
+        regex[length - 2] = '\0';
+        if (regcomp(&preg, regex, REG_EXTENDED | REG_ICASE) != 0) {
+           _error->Warning("Invalid regular expression: %s", regex);
+        } else if (regexec(&preg, string, 0, NULL, 0) == 0) {
+           res = true;
+        }
+        free(regex);
+        regfree(&preg);
+        return res;
+      }
+   }
+   return fnmatch(pattern, string, FNM_CASEFOLD) == 0;
+}
+bool pkgVersionMatch::ExpressionMatches(const std::string& pattern, const char *string)
+{
+    return ExpressionMatches(pattern.c_str(), string);
+}
                                                                        /*}}}*/
 // VersionMatch::FileMatch - Match against an index file               /*{{{*/
 // ---------------------------------------------------------------------
@@ -185,37 +221,37 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File)
 
       if (RelVerStr.empty() == false)
         if (File->Version == 0 ||
-            MatchVer(File.Version(),RelVerStr,RelVerPrefixMatch) == false)
+            (MatchVer(File.Version(),RelVerStr,RelVerPrefixMatch) == false &&
+             ExpressionMatches(RelVerStr, File.Version()) == false))
            return false;
       if (RelOrigin.empty() == false)
-        if (File->Origin == 0 ||
-            stringcasecmp(RelOrigin,File.Origin()) != 0)
+        if (File->Origin == 0 || !ExpressionMatches(RelOrigin,File.Origin()))
            return false;
       if (RelArchive.empty() == false)
         if (File->Archive == 0 ||
-            stringcasecmp(RelArchive,File.Archive()) != 0)
+            !ExpressionMatches(RelArchive,File.Archive()))
             return false;
       if (RelCodename.empty() == false)
         if (File->Codename == 0 ||
-            stringcasecmp(RelCodename,File.Codename()) != 0)
+            !ExpressionMatches(RelCodename,File.Codename()))
             return false;
       if (RelRelease.empty() == false)
         if ((File->Archive == 0 ||
-            stringcasecmp(RelRelease,File.Archive()) != 0) &&
+            !ExpressionMatches(RelRelease,File.Archive())) &&
              (File->Codename == 0 ||
-             stringcasecmp(RelRelease,File.Codename()) != 0))
+             !ExpressionMatches(RelRelease,File.Codename())))
               return false;
       if (RelLabel.empty() == false)
         if (File->Label == 0 ||
-            stringcasecmp(RelLabel,File.Label()) != 0)
+            !ExpressionMatches(RelLabel,File.Label()))
            return false;
       if (RelComponent.empty() == false)
         if (File->Component == 0 ||
-            stringcasecmp(RelComponent,File.Component()) != 0)
+            !ExpressionMatches(RelComponent,File.Component()))
            return false;
       if (RelArchitecture.empty() == false)
         if (File->Architecture == 0 ||
-            stringcasecmp(RelArchitecture,File.Architecture()) != 0)
+            !ExpressionMatches(RelArchitecture,File.Architecture()))
            return false;
       return true;
    }
@@ -223,12 +259,12 @@ bool pkgVersionMatch::FileMatch(pkgCache::PkgFileIterator File)
    if (Type == Origin)
    {
       if (OrSite.empty() == false) {
-        if (File->Site == 0 || OrSite != File.Site())
+        if (File->Site == 0 || !ExpressionMatches(OrSite, File.Site()))
            return false;
       } else // so we are talking about file:// or status file
         if (strcmp(File.Site(),"") == 0 && File->Archive != 0) // skip the status file
            return false;
-      return (OrSite == File.Site());          /* both strings match */
+      return (ExpressionMatches(OrSite, File.Site())); /* both strings match */
    }
 
    return false;
index a8da072ae078e039ce8dafd9004ec8183eca9fb7..39639a23dc3dd565126b008ada319074764921ae 100644 (file)
@@ -67,6 +67,8 @@ class pkgVersionMatch
    enum MatchType {None = 0,Version,Release,Origin} Type;
    
    bool MatchVer(const char *A,string B,bool Prefix);
+   bool ExpressionMatches(const char *pattern, const char *string);
+   bool ExpressionMatches(const std::string& pattern, const char *string);
    bool FileMatch(pkgCache::PkgFileIterator File);
    pkgCache::VerIterator Find(pkgCache::PkgIterator Pkg);
                               
index 51c75dad0d15c42cfd01ffaee3704b6e222249d1..878d5238a1893a115476845203a105e76c0b9407 100644 (file)
@@ -1,5 +1,6 @@
 apt (0.7.26~exp8) UNRELEASED; urgency=low
 
+  [ David Kalnischkies ]
   * cmdline/cacheset.cc:
     - doesn't include it in the library for now as it is too volatile
     - get the candidate either from an already built depcache
@@ -37,7 +38,21 @@ apt (0.7.26~exp8) UNRELEASED; urgency=low
     - add another round of const& madness as the previous round accidentally
       NOT overrides the virtual GetCandidateVer() method (Closes: #587725)
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 28 Jun 2010 22:12:24 +0200
+  [ Julian Andres Klode ]
+  * methods/ftp.h:
+    - Handle different logins on the same server (Closes: #586904).
+  * apt-pkg/deb/deblistparser.cc:
+    - Handle architecture wildcards (Closes: #547724).
+  * apt-pkg/versionmatch.cc:
+    - Support matching pins by regular expressions or glob() like patterns,
+      regular expressions have to be put between to slashes; for example,
+      /.*/.
+  * apt-pkg/contrib/fileutl.cc:
+    - Make FileFd replace files atomically in WriteTemp mode (for cache, etc).
+  * debian/control:
+    - Set Standards-Version to 3.9.0
+
+ -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 05 Jul 2010 12:05:30 +0200
 
 apt (0.7.26~exp7) experimental; urgency=low
 
index 4f41c130b43975a6317522cde1ac3f080a5e75a9..d482f2d0b0bf05b60fb44cfbff1ff0cf25334f22 100644 (file)
@@ -5,7 +5,7 @@ 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>, Julian Andres Klode <jak@debian.org>
-Standards-Version: 3.8.4
+Standards-Version: 3.9.0
 Build-Depends: debhelper (>= 5.0), libdb-dev, gettext (>= 0.12), libcurl4-gnutls-dev | libcurl3-gnutls-dev (>= 7.15.5), debiandoc-sgml, xsltproc, docbook-xsl, po4a (>= 0.34-2), autotools-dev, autoconf, automake, doxygen
 Build-Conflicts: autoconf2.13, automake1.4
 
index 1bcea41b6829d09299c963bf8da2222aa19cb3cb..d7f1f7fbece776cb0bfba3febbcf4fbc44da0384 100644 (file)
@@ -40,7 +40,7 @@ class FTPConn
    
    public:
 
-   bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
+   bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port && Other.User == ServerName.User && Other.Password == ServerName.Password; };
    
    // Raw connection IO
    bool ReadResp(unsigned int &Ret,string &Text);