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 1fbe23a..f7d6e7c 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 6cbe5dd..ebade1d 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 d3e7d81..75da292 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 8ac3eca..eb77395 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