From 594621cbeb2f27ce8d36e652c4fdd9a9d4385ec3 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Tue, 21 Jul 2009 23:03:25 -0500 Subject: Add Architecture and --arch option Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- src/pacman/pacman.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 25647b5e..5fab247d 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -149,6 +149,7 @@ static void usage(int op, const char * const myname) printf(_(" -r, --root set an alternate installation root\n")); printf(_(" -b, --dbpath set an alternate database location\n")); printf(_(" --cachedir set an alternate package cache location\n")); + printf(_(" --arch set an alternate architecture\n")); } } @@ -195,6 +196,19 @@ static void setuseragent(void) setenv("HTTP_USER_AGENT", agent, 0); } +static void setarch(const char *arch) +{ + if (strcmp(arch, "auto") == 0) { + struct utsname un; + uname(&un); + pm_printf(PM_LOG_DEBUG, "config: architecture: %s\n", un.machine); + alpm_option_set_arch(un.machine); + } else { + pm_printf(PM_LOG_DEBUG, "config: architecture: %s\n", arch); + alpm_option_set_arch(arch); + } +} + /** Free the resources. * * @param ret the return value @@ -376,6 +390,7 @@ static int parseargs(int argc, char *argv[]) {"ignoregroup", required_argument, 0, 1010}, {"needed", no_argument, 0, 1011}, {"asexplicit", no_argument, 0, 1012}, + {"arch", required_argument, 0, 1013}, {0, 0, 0, 0} }; @@ -450,6 +465,9 @@ static int parseargs(int argc, char *argv[]) case 1012: config->flags |= PM_TRANS_FLAG_ALLEXPLICIT; break; + case 1013: + setarch(optarg); + break; case 'Q': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break; case 'R': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_REMOVE); break; case 'S': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_SYNC); break; @@ -827,6 +845,10 @@ static int _parseconfig(const char *file, const char *givensection, setrepeatingoption(ptr, "HoldPkg", option_add_holdpkg); } else if(strcmp(key, "SyncFirst") == 0) { setrepeatingoption(ptr, "SyncFirst", option_add_syncfirst); + } else if(strcmp(key, "Architecture") == 0) { + if(!alpm_option_get_arch()) { + setarch(ptr); + } } else if(strcmp(key, "DBPath") == 0) { /* don't overwrite a path specified on the command line */ if(!config->dbpath) { -- cgit v1.2.3