make pool.setarch() do the right thing
authorMichael Schroeder <mls@suse.de>
Fri, 2 Nov 2012 14:27:53 +0000 (15:27 +0100)
committerMichael Schroeder <mls@suse.de>
Fri, 2 Nov 2012 14:27:53 +0000 (15:27 +0100)
bindings/solv.i
examples/p5solv
examples/pysolv
examples/rbsolv

index 1fbe23ac60cfaf52b4360e4c8c48e20f584ef7a0..f7d6e7c4529320c4ae14260171ecf0e682d33854 100644 (file)
@@ -334,6 +334,7 @@ typedef VALUE AppObjectPtr;
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/stat.h>
+#include <sys/utsname.h>
 #include <sys/types.h>
 #include <unistd.h>
 
@@ -1038,7 +1039,15 @@ typedef struct {
   Id id2langid(Id id, const char *lang, bool create=1) {
     return pool_id2langid($self, id, lang, create);
   }
-  void setarch(const char *arch) {
+  void setarch(const char *arch = 0) {
+    struct utsname un;
+    if (!arch) {
+      if (uname(&un)) {
+        perror("uname");
+        return;
+      }
+      arch = un.machine;
+    }
     pool_setarch($self, arch);
   }
   Repo *add_repo(const char *name) {
index 6cbe5dd20fc5dde0683be699e24874b055fb094a..ebade1d118fcccd96557c7a56de74b3c217a2839 100755 (executable)
@@ -539,7 +539,7 @@ for my $reposdir (@reposdirs) {
 }
 
 my $pool = solv::Pool->new();
-$pool->setarch((POSIX::uname())[4]);
+$pool->setarch();
 $pool->set_loadcallback(\&load_stub);
 
 my $sysrepo = Repo::system->new('@System', 'system');
index d3e7d818b1ac2f8d1e1f134fab0f805e1b393ecc..75da2924e21a5d3791551c23a9b79621ccb19c09 100755 (executable)
@@ -626,7 +626,7 @@ for reposdir in reposdirs:
             repos.append(repo)
 
 pool = solv.Pool()
-pool.setarch(os.uname()[4])
+pool.setarch()
 pool.set_loadcallback(load_stub)
 
 # now load all enabled repos into the pool
index 8ac3eca3fad990c8f79a7fe18ecba1a5c922dbb2..eb77395502aeff30b8556964d25e44bbd18db774 100755 (executable)
@@ -525,9 +525,7 @@ for reposdir in reposdirs do
 end
 
 pool = Solv::Pool.new()
-# require 'sys/uname' ; sysarch = Sys::Uname.machine
-sysarch = `uname -p`.strip
-pool.setarch(sysarch)
+pool.setarch()
 
 pool.set_loadcallback { |repodata|
   repo = repodata.repo.appdata