--- doc/pacman.8.txt | 2 ++ doc/pacman.conf.5.txt | 8 ++++++++ etc/pacman.conf.in | 1 + lib/libalpm/alpm.h | 3 +++ lib/libalpm/handle.c | 16 ++++++++++++++++ lib/libalpm/handle.h | 1 + src/pacman/pacman.c | 22 ++++++++++++++++++++++ 7 files changed, 53 insertions(+), 0 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index b288a59..a534e05 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -166,6 +166,8 @@ Options If an install scriptlet exists, do not execute it. Do not use this unless you know what you are doing. +*\--arch* <'arch'>:: + Specify an alternate architecture. Query Options[[QO]] ------------------- diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt index 46a0b3d..51c5188 100644 --- a/doc/pacman.conf.5.txt +++ b/doc/pacman.conf.5.txt @@ -150,6 +150,14 @@ Options than the percent of each individual download target. The progress bar is still based solely on the current file download. +*Architecture =* auto | i686 | x86_64 | ...:: + If set, pacman will only allow to install packages of the given + architecture (e.g. 'i686', 'x86_64', etc). The special value 'auto' will + use the system architecture, as in 'uname -m'. + If unset, no architecture checks are made. + *NOTE*: the packages with the special architecture 'any' can always be + installed, as they are meant to be architecture independent. + Repository Sections ------------------- Each repository section defines a section name and at least one location where diff --git a/etc/pacman.conf.in b/etc/pacman.conf.in index 3557274..929d38b 100644 --- a/etc/pacman.conf.in +++ b/etc/pacman.conf.in @@ -19,6 +19,7 @@ SyncFirst = pacman #XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u #XferCommand = /usr/bin/curl %u > %o #CleanMethod = KeepInstalled +Architecture = auto # Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup #IgnorePkg = diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 9a935c2..b81b3f8 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -151,6 +151,9 @@ void alpm_option_add_ignoregrp(const char *grp); void alpm_option_set_ignoregrps(alpm_list_t *ignoregrps); int alpm_option_remove_ignoregrp(const char *grp); +const char *alpm_option_get_arch(); +void alpm_option_set_arch(const char *arch); + void alpm_option_set_usedelta(unsigned short usedelta); pmdb_t *alpm_option_get_localdb(); diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 819b974..012d412 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -79,6 +79,7 @@ void _alpm_handle_free(pmhandle_t *handle) FREELIST(handle->cachedirs); FREE(handle->logfile); FREE(handle->lockfile); + FREE(handle->arch); FREELIST(handle->dbs_sync); FREELIST(handle->noupgrade); FREELIST(handle->noextract); @@ -213,6 +214,15 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignoregrps() return handle->ignoregrp; } +const char SYMEXPORT *alpm_option_get_arch() +{ + if (handle == NULL) { + pm_errno = PM_ERR_HANDLE_NULL; + return NULL; + } + return handle->arch; +} + pmdb_t SYMEXPORT *alpm_option_get_localdb() { if (handle == NULL) { @@ -520,6 +530,12 @@ int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp) return(0); } +void SYMEXPORT alpm_option_set_arch(const char *arch) +{ + if(handle->arch) FREE(handle->arch); + if(arch) handle->arch = strdup(arch); +} + void SYMEXPORT alpm_option_set_usedelta(unsigned short usedelta) { handle->usedelta = usedelta; diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index 541eb23..a1eb1cd 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -58,6 +58,7 @@ typedef struct _pmhandle_t { /* options */ unsigned short usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */ + char *arch; /* Architecture of packages we should allow */ unsigned short usedelta; /* Download deltas if possible */ } pmhandle_t; diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 25647b5..5fab247 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 <path> set an alternate installation root\n")); printf(_(" -b, --dbpath <path> set an alternate database location\n")); printf(_(" --cachedir <dir> set an alternate package cache location\n")); + printf(_(" --arch <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) { -- 1.6.4