summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2009-07-22 06:03:25 +0200
committerDan McGee <dan@archlinux.org>2009-09-06 22:50:42 +0200
commit594621cbeb2f27ce8d36e652c4fdd9a9d4385ec3 (patch)
tree78041ce99beafb27918a52b6398db92e3386cfd6
parent92f0775e76c75ebe9e30355cc99bb40cf365abcb (diff)
downloadpacman-594621cbeb2f27ce8d36e652c4fdd9a9d4385ec3.tar.gz
pacman-594621cbeb2f27ce8d36e652c4fdd9a9d4385ec3.tar.xz
Add Architecture and --arch option
Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--doc/pacman.8.txt2
-rw-r--r--doc/pacman.conf.5.txt8
-rw-r--r--etc/pacman.conf.in1
-rw-r--r--lib/libalpm/alpm.h3
-rw-r--r--lib/libalpm/handle.c16
-rw-r--r--lib/libalpm/handle.h1
-rw-r--r--src/pacman/pacman.c22
7 files changed, 53 insertions, 0 deletions
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt
index b288a592..a534e057 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 46a0b3de..59bed156 100644
--- a/doc/pacman.conf.5.txt
+++ b/doc/pacman.conf.5.txt
@@ -97,6 +97,14 @@ Options
Include another config file. This file can include repositories or
general configuration options.
+*Architecture =* auto | i686 | x86_64 | ...::
+ If set, pacman will only allow installation of packages of the given
+ architecture (e.g. 'i686', 'x86_64', etc). The special value 'auto' will
+ use the system architecture, provided by in ``uname -m''. If unset, no
+ architecture checks are made. *NOTE*: packages with the special
+ architecture 'any' can always be installed, as they are meant to be
+ architecture independent.
+
*XferCommand =* /path/to/command %u::
If set, an external program will be used to download all remote files.
All instances of `%u` will be replaced with the download URL. If present,
diff --git a/etc/pacman.conf.in b/etc/pacman.conf.in
index 35572740..929d38ba 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 9a935c28..b81b3f83 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 819b9742..012d4121 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 541eb23a..a1eb1cde 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 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 <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) {