- discard pattern files with incompatbile architecture, both
authorKlaus Kaempf <kkaempf@suse.de>
Thu, 16 Aug 2007 15:23:38 +0000 (15:23 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Thu, 16 Aug 2007 15:23:38 +0000 (15:23 +0000)
  for download and for parsing. (#298716)

package/libzypp.changes
zypp/parser/susetags/RepoParser.cc
zypp/repo/susetags/Downloader.cc

index ea62473..399da71 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Thu Aug 16 17:21:52 CEST 2007 - kkaempf@suse.de
+
+- discard pattern files with incompatbile architecture, both
+  for download and for parsing. (#298716)
+- rev 6711
+
+-------------------------------------------------------------------
 Thu Aug 16 17:12:45 CEST 2007 - kkaempf@suse.de
 
 - run sqlite asynchronously and add sql index files where
index b86fe9a..c32a556 100644 (file)
@@ -486,6 +486,42 @@ namespace zypp
         {
           if ( isPatternFile( it->first ) )
           {
+            // *** see also zypp/repo/susetags/Downloader.cc ***
+
+            // omit unwanted patterns, see https://bugzilla.novell.com/show_bug.cgi?id=298716
+            // expect "<name>.<arch>.pat[.gz]", <name> might contain additional dots
+            // split at dots, take .pat or .pat.gz into account
+
+            // vector of splitted pattern filename elements
+            std::vector<std::string> patparts;
+
+            // this is the offset from the last element of patparts
+            unsigned archoff = 2;
+
+            unsigned count = str::split( it->first, std::back_inserter( patparts ), "." );
+
+            if ( patparts[count-1] == "gz" )
+              archoff++;
+
+            if ( count > archoff )
+            {
+              try                              // might by an invalid architecture
+              {
+                Arch patarch( patparts[count-archoff] );
+                if ( !patarch.compatibleWith( ZConfig::instance().systemArchitecture() ) )
+                {
+                  // discard, if not compatible
+                  MIL << "Discarding pattern " << it->first << endl;
+                  continue;
+                }
+              }
+              catch ( const Exception & excpt )
+              {
+                WAR << "Pattern file name does not contain recognizable architecture: " << it->first << endl;
+                // keep .pat file if it doesn't contain an recognizable arch
+              }
+            }
+
            Pathname inputfile( getOptionalFile( _descrdir / it->first, false /*filename already contains .gz */ ) );
            if ( ! inputfile.empty() )
            {
index 831c736..5684dea 100644 (file)
@@ -120,6 +120,42 @@ void Downloader::download( MediaSetAccess &media,
           }
         }
       }
+      else if ( str::endsWith( words[3], ".pat" ) 
+               || str::endsWith( words[3], ".pat.gz" ) )
+      {
+
+        // *** see also zypp/parser/susetags/RepoParser.cc ***
+
+        // omit unwanted patterns, see https://bugzilla.novell.com/show_bug.cgi?id=298716
+        // expect "<name>.<arch>.pat[.gz]", <name> might contain additional dots
+        // split at dots, take .pat or .pat.gz into account
+
+        std::vector<std::string> patparts;
+       unsigned archpos = 2;
+        // expect "<name>.<arch>.pat[.gz]", <name> might contain additional dots
+        unsigned count = str::split( buffer, std::back_inserter(patparts), "." );
+       if ( patparts[count-1] == "gz" )
+           archpos++;
+
+        if ( count > archpos )
+        {
+          try                          // might by an invalid architecture
+          {
+            Arch patarch( patparts[count-archpos] );
+            if ( !patarch.compatibleWith( ZConfig::instance().systemArchitecture() ) )
+            {
+              // discard, if not compatible
+              MIL << "Discarding pattern " << words[3] << endl;
+              continue;
+            }
+          }
+          catch ( const Exception & excpt )
+          {
+            WAR << "Pattern file name does not contain recognizable architecture: " << words[3] << endl;
+            // keep .pat file if it doesn't contain an recognizable arch
+          }
+        }
+      }
       OnMediaLocation location( _path + descr_dir + words[3], 1 );
       location.setChecksum( CheckSum( words[1], words[2] ) );
       this->enqueueDigested(location);