From 26f2f1fe6e2f6a27c45b01c2e53970ec25b32e93 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Fri, 2 Nov 2012 15:27:53 +0100 Subject: [PATCH] make pool.setarch() do the right thing --- bindings/solv.i | 11 ++++++++++- examples/p5solv | 2 +- examples/pysolv | 2 +- examples/rbsolv | 4 +--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bindings/solv.i b/bindings/solv.i index 1fbe23a..f7d6e7c 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -334,6 +334,7 @@ typedef VALUE AppObjectPtr; #include #include #include +#include #include #include @@ -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) { diff --git a/examples/p5solv b/examples/p5solv index 6cbe5dd..ebade1d 100755 --- a/examples/p5solv +++ b/examples/p5solv @@ -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'); diff --git a/examples/pysolv b/examples/pysolv index d3e7d81..75da292 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -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 diff --git a/examples/rbsolv b/examples/rbsolv index 8ac3eca..eb77395 100755 --- a/examples/rbsolv +++ b/examples/rbsolv @@ -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 -- 2.34.1