2005-03-14 20:51:43 -05:00
|
|
|
/*
|
|
|
|
* pacman.c
|
2007-08-21 21:28:05 -04:00
|
|
|
*
|
2013-01-01 23:19:59 -05:00
|
|
|
* Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
|
2009-07-01 03:08:33 -04:00
|
|
|
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
2007-08-21 21:28:05 -04:00
|
|
|
*
|
2005-03-14 20:51:43 -05:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-12-10 23:55:22 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-03-14 20:51:43 -05:00
|
|
|
*/
|
|
|
|
|
2008-05-31 12:53:51 -04:00
|
|
|
/* special handling of package version for GIT */
|
|
|
|
#if defined(GIT_VERSION)
|
|
|
|
#undef PACKAGE_VERSION
|
|
|
|
#define PACKAGE_VERSION GIT_VERSION
|
|
|
|
#endif
|
|
|
|
|
2007-08-16 16:19:06 -04:00
|
|
|
#include <stdlib.h> /* atoi */
|
2005-03-14 20:51:43 -05:00
|
|
|
#include <stdio.h>
|
2010-10-14 04:02:38 -04:00
|
|
|
#include <ctype.h> /* isspace */
|
2005-03-14 20:51:43 -05:00
|
|
|
#include <limits.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <signal.h>
|
2007-04-25 02:21:12 -04:00
|
|
|
#include <unistd.h>
|
2006-12-05 01:55:52 -05:00
|
|
|
#include <sys/types.h>
|
2007-08-16 16:19:06 -04:00
|
|
|
#include <sys/utsname.h> /* uname */
|
|
|
|
#include <locale.h> /* setlocale */
|
2008-10-12 22:07:49 -04:00
|
|
|
#include <errno.h>
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-04-25 02:21:12 -04:00
|
|
|
/* alpm */
|
2005-03-14 20:51:43 -05:00
|
|
|
#include <alpm.h>
|
2007-01-19 04:28:44 -05:00
|
|
|
#include <alpm_list.h>
|
2007-03-05 17:13:33 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
/* pacman */
|
2007-04-25 02:21:12 -04:00
|
|
|
#include "pacman.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
#include "util.h"
|
|
|
|
#include "conf.h"
|
2006-03-13 15:34:47 -05:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
/* list of targets specified on command line */
|
2007-01-19 04:28:44 -05:00
|
|
|
static alpm_list_t *pm_targets;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2010-10-14 04:02:38 -04:00
|
|
|
/* Used to sort the options in --help */
|
|
|
|
static int options_cmp(const void *p1, const void *p2)
|
|
|
|
{
|
|
|
|
const char *s1 = p1;
|
|
|
|
const char *s2 = p2;
|
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
if(s1 == s2) return 0;
|
|
|
|
if(!s1) return -1;
|
|
|
|
if(!s2) return 1;
|
2010-10-14 04:02:38 -04:00
|
|
|
/* First skip all spaces in both strings */
|
|
|
|
while(isspace((unsigned char)*s1)) {
|
|
|
|
s1++;
|
|
|
|
}
|
|
|
|
while(isspace((unsigned char)*s2)) {
|
|
|
|
s2++;
|
|
|
|
}
|
|
|
|
/* If we compare a long option (--abcd) and a short one (-a),
|
|
|
|
* the short one always wins */
|
|
|
|
if(*s1 == '-' && *s2 == '-') {
|
|
|
|
s1++;
|
|
|
|
s2++;
|
|
|
|
if(*s1 == '-' && *s2 == '-') {
|
|
|
|
/* two long -> strcmp */
|
|
|
|
s1++;
|
|
|
|
s2++;
|
|
|
|
} else if(*s2 == '-') {
|
|
|
|
/* s1 short, s2 long */
|
2011-03-20 20:45:57 -04:00
|
|
|
return -1;
|
2010-10-14 04:02:38 -04:00
|
|
|
} else if(*s1 == '-') {
|
|
|
|
/* s1 long, s2 short */
|
2011-03-20 20:45:57 -04:00
|
|
|
return 1;
|
2010-10-14 04:02:38 -04:00
|
|
|
}
|
|
|
|
/* two short -> strcmp */
|
|
|
|
}
|
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return strcmp(s1, s2);
|
2010-10-14 04:02:38 -04:00
|
|
|
}
|
|
|
|
|
2007-07-23 16:58:04 -04:00
|
|
|
/** Display usage/syntax for the specified operation.
|
2007-03-28 16:14:42 -04:00
|
|
|
* @param op the operation code requested
|
|
|
|
* @param myname basename(argv[0])
|
2006-03-13 15:34:47 -05:00
|
|
|
*/
|
2007-10-31 12:43:04 -04:00
|
|
|
static void usage(int op, const char * const myname)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2010-10-14 04:02:38 -04:00
|
|
|
#define addlist(s) (list = alpm_list_add(list, s))
|
|
|
|
alpm_list_t *list = NULL, *i;
|
2007-03-27 20:26:54 -04:00
|
|
|
/* prefetch some strings for usage below, which moves a lot of calls
|
|
|
|
* out of gettext. */
|
2007-10-31 12:43:04 -04:00
|
|
|
char const * const str_opt = _("options");
|
2009-05-21 19:06:33 -04:00
|
|
|
char const * const str_file = _("file(s)");
|
|
|
|
char const * const str_pkg = _("package(s)");
|
2007-10-31 12:43:04 -04:00
|
|
|
char const * const str_usg = _("usage");
|
|
|
|
char const * const str_opr = _("operation");
|
2007-03-27 20:26:54 -04:00
|
|
|
|
2011-03-25 14:47:27 -04:00
|
|
|
/* please limit your strings to 80 characters in width */
|
2006-03-13 15:34:47 -05:00
|
|
|
if(op == PM_OP_MAIN) {
|
2007-03-28 11:20:18 -04:00
|
|
|
printf("%s: %s <%s> [...]\n", str_usg, myname, str_opr);
|
2008-08-07 13:50:07 -04:00
|
|
|
printf(_("operations:\n"));
|
2007-03-27 20:26:54 -04:00
|
|
|
printf(" %s {-h --help}\n", myname);
|
|
|
|
printf(" %s {-V --version}\n", myname);
|
2009-05-20 15:46:23 -04:00
|
|
|
printf(" %s {-D --database} <%s> <%s>\n", myname, str_opt, str_pkg);
|
|
|
|
printf(" %s {-Q --query} [%s] [%s]\n", myname, str_opt, str_pkg);
|
|
|
|
printf(" %s {-R --remove} [%s] <%s>\n", myname, str_opt, str_pkg);
|
|
|
|
printf(" %s {-S --sync} [%s] [%s]\n", myname, str_opt, str_pkg);
|
2011-03-24 22:00:35 -04:00
|
|
|
printf(" %s {-T --deptest} [%s] [%s]\n", myname, str_opt, str_pkg);
|
2009-05-20 15:46:23 -04:00
|
|
|
printf(" %s {-U --upgrade} [%s] <%s>\n", myname, str_opt, str_file);
|
2008-08-07 13:50:07 -04:00
|
|
|
printf(_("\nuse '%s {-h --help}' with an operation for available options\n"),
|
|
|
|
myname);
|
2006-03-13 15:34:47 -05:00
|
|
|
} else {
|
2007-12-02 15:04:18 -05:00
|
|
|
if(op == PM_OP_REMOVE) {
|
2007-03-28 11:20:18 -04:00
|
|
|
printf("%s: %s {-R --remove} [%s] <%s>\n", str_usg, myname, str_opt, str_pkg);
|
2007-03-27 20:26:54 -04:00
|
|
|
printf("%s:\n", str_opt);
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" -c, --cascade remove packages and all packages that depend on them\n"));
|
2011-03-25 14:47:27 -04:00
|
|
|
addlist(_(" -n, --nosave remove configuration files\n"));
|
|
|
|
addlist(_(" -s, --recursive remove unnecessary dependencies\n"
|
|
|
|
" (-ss includes explicitly installed dependencies)\n"));
|
|
|
|
addlist(_(" -u, --unneeded remove unneeded packages\n"));
|
2006-03-13 15:34:47 -05:00
|
|
|
} else if(op == PM_OP_UPGRADE) {
|
2007-11-21 12:25:50 -05:00
|
|
|
printf("%s: %s {-U --upgrade} [%s] <%s>\n", str_usg, myname, str_opt, str_file);
|
2011-08-11 09:55:12 -04:00
|
|
|
addlist(_(" --needed do not reinstall up to date packages\n"));
|
2007-03-27 20:26:54 -04:00
|
|
|
printf("%s:\n", str_opt);
|
2006-03-13 15:34:47 -05:00
|
|
|
} else if(op == PM_OP_QUERY) {
|
2007-03-28 11:20:18 -04:00
|
|
|
printf("%s: %s {-Q --query} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
|
2007-03-27 20:26:54 -04:00
|
|
|
printf("%s:\n", str_opt);
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" -c, --changelog view the changelog of a package\n"));
|
|
|
|
addlist(_(" -d, --deps list packages installed as dependencies [filter]\n"));
|
|
|
|
addlist(_(" -e, --explicit list packages explicitly installed [filter]\n"));
|
|
|
|
addlist(_(" -g, --groups view all members of a package group\n"));
|
|
|
|
addlist(_(" -i, --info view package information (-ii for backup files)\n"));
|
2013-04-02 19:53:45 -04:00
|
|
|
addlist(_(" -k, --check check that package files exist (-kk for file properties)\n"));
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" -l, --list list the contents of the queried package\n"));
|
|
|
|
addlist(_(" -m, --foreign list installed packages not found in sync db(s) [filter]\n"));
|
2012-11-16 01:26:44 -05:00
|
|
|
addlist(_(" -n, --native list installed packages only found in sync db(s) [filter]\n"));
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" -o, --owns <file> query the package that owns <file>\n"));
|
|
|
|
addlist(_(" -p, --file <package> query a package file instead of the database\n"));
|
|
|
|
addlist(_(" -q, --quiet show less information for query and search\n"));
|
|
|
|
addlist(_(" -s, --search <regex> search locally-installed packages for matching strings\n"));
|
2013-06-17 04:46:38 -04:00
|
|
|
addlist(_(" -t, --unrequired list packages not (optionally) required by any\n"
|
|
|
|
" package (-tt to ignore optdepends) [filter]\n"));
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" -u, --upgrades list outdated packages [filter]\n"));
|
2006-03-13 15:34:47 -05:00
|
|
|
} else if(op == PM_OP_SYNC) {
|
2007-03-28 11:20:18 -04:00
|
|
|
printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
|
2007-03-27 20:26:54 -04:00
|
|
|
printf("%s:\n", str_opt);
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" -c, --clean remove old packages from cache directory (-cc for all)\n"));
|
|
|
|
addlist(_(" -g, --groups view all members of a package group\n"));
|
|
|
|
addlist(_(" -i, --info view package information\n"));
|
|
|
|
addlist(_(" -l, --list <repo> view a list of packages in a repo\n"));
|
|
|
|
addlist(_(" -q, --quiet show less information for query and search\n"));
|
|
|
|
addlist(_(" -s, --search <regex> search remote repositories for matching strings\n"));
|
|
|
|
addlist(_(" -u, --sysupgrade upgrade installed packages (-uu allows downgrade)\n"));
|
|
|
|
addlist(_(" -w, --downloadonly download packages but do not install/upgrade anything\n"));
|
|
|
|
addlist(_(" -y, --refresh download fresh package databases from the server\n"));
|
2011-08-11 09:55:12 -04:00
|
|
|
addlist(_(" --needed do not reinstall up to date packages\n"));
|
2011-04-20 20:45:16 -04:00
|
|
|
} else if(op == PM_OP_DATABASE) {
|
2009-05-20 15:46:23 -04:00
|
|
|
printf("%s: %s {-D --database} <%s> <%s>\n", str_usg, myname, str_opt, str_pkg);
|
|
|
|
printf("%s:\n", str_opt);
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" --asdeps mark packages as non-explicitly installed\n"));
|
|
|
|
addlist(_(" --asexplicit mark packages as explicitly installed\n"));
|
2011-03-24 22:00:35 -04:00
|
|
|
} else if(op == PM_OP_DEPTEST) {
|
|
|
|
printf("%s: %s {-T --deptest} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
|
|
|
|
printf("%s:\n", str_opt);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2010-10-10 12:57:41 -04:00
|
|
|
switch(op) {
|
|
|
|
case PM_OP_SYNC:
|
|
|
|
case PM_OP_UPGRADE:
|
2011-10-11 13:35:33 -04:00
|
|
|
addlist(_(" --force force install, overwrite conflicting files\n"));
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" --asdeps install packages as non-explicitly installed\n"));
|
|
|
|
addlist(_(" --asexplicit install packages as explicitly installed\n"));
|
|
|
|
addlist(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n"));
|
|
|
|
addlist(_(" --ignoregroup <grp>\n"
|
2011-03-25 14:47:27 -04:00
|
|
|
" ignore a group upgrade (can be used more than once)\n"));
|
2010-10-10 12:57:41 -04:00
|
|
|
/* pass through */
|
|
|
|
case PM_OP_REMOVE:
|
2011-03-25 14:47:27 -04:00
|
|
|
addlist(_(" -d, --nodeps skip dependency version checks (-dd to skip all checks)\n"));
|
2011-08-11 09:18:55 -04:00
|
|
|
addlist(_(" --dbonly only modify database entries, not package files\n"));
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" --noprogressbar do not show a progress bar when downloading files\n"));
|
|
|
|
addlist(_(" --noscriptlet do not execute the install scriptlet if one exists\n"));
|
2011-09-12 19:47:05 -04:00
|
|
|
addlist(_(" -p, --print print the targets instead of performing the operation\n"));
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" --print-format <string>\n"
|
2011-03-25 14:47:27 -04:00
|
|
|
" specify how the targets should be printed\n"));
|
2010-10-10 12:57:41 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" -b, --dbpath <path> set an alternate database location\n"));
|
|
|
|
addlist(_(" -r, --root <path> set an alternate installation root\n"));
|
|
|
|
addlist(_(" -v, --verbose be verbose\n"));
|
|
|
|
addlist(_(" --arch <arch> set an alternate architecture\n"));
|
|
|
|
addlist(_(" --cachedir <dir> set an alternate package cache location\n"));
|
2013-03-01 14:27:40 -05:00
|
|
|
addlist(_(" --color <when> colorize the output\n"));
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" --config <path> set an alternate configuration file\n"));
|
|
|
|
addlist(_(" --debug display debug messages\n"));
|
2008-12-14 13:59:39 -05:00
|
|
|
addlist(_(" --gpgdir <path> set an alternate home directory for GnuPG\n"));
|
2010-10-14 04:02:38 -04:00
|
|
|
addlist(_(" --logfile <path> set an alternate log file\n"));
|
|
|
|
addlist(_(" --noconfirm do not ask for any confirmation\n"));
|
|
|
|
}
|
|
|
|
list = alpm_list_msort(list, alpm_list_count(list), options_cmp);
|
2011-12-06 23:37:32 -05:00
|
|
|
for(i = list; i; i = alpm_list_next(i)) {
|
2011-10-03 11:54:08 -04:00
|
|
|
fputs((const char *)i->data, stdout);
|
2006-02-01 13:20:13 -05:00
|
|
|
}
|
2010-10-14 04:02:38 -04:00
|
|
|
alpm_list_free(list);
|
|
|
|
#undef addlist
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-07-23 16:58:04 -04:00
|
|
|
/** Output pacman version and copyright.
|
2006-10-15 15:34:52 -04:00
|
|
|
*/
|
2007-04-14 17:26:39 -04:00
|
|
|
static void version(void)
|
2006-10-15 15:34:52 -04:00
|
|
|
{
|
|
|
|
printf("\n");
|
2008-02-29 15:52:57 -05:00
|
|
|
printf(" .--. Pacman v%s - libalpm v%s\n", PACKAGE_VERSION, alpm_version());
|
2013-01-01 23:19:59 -05:00
|
|
|
printf("/ _.-' .-. .-. .-. Copyright (C) 2006-2013 Pacman Development Team\n");
|
2009-07-27 00:02:20 -04:00
|
|
|
printf("\\ '-. '-' '-' '-' Copyright (C) 2002-2006 Judd Vinet\n");
|
2007-03-27 20:26:54 -04:00
|
|
|
printf(" '--'\n");
|
|
|
|
printf(_(" This program may be freely redistributed under\n"
|
2008-06-08 14:50:01 -04:00
|
|
|
" the terms of the GNU General Public License.\n"));
|
2006-10-15 15:34:52 -04:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2007-07-23 16:58:04 -04:00
|
|
|
/** Sets up gettext localization. Safe to call multiple times.
|
2007-03-28 16:14:42 -04:00
|
|
|
*/
|
|
|
|
/* Inspired by the monotone function localize_monotone. */
|
2007-10-23 00:52:55 -04:00
|
|
|
#if defined(ENABLE_NLS)
|
2007-04-14 17:26:39 -04:00
|
|
|
static void localize(void)
|
2007-03-28 16:14:42 -04:00
|
|
|
{
|
|
|
|
static int init = 0;
|
2011-04-20 20:45:16 -04:00
|
|
|
if(!init) {
|
2007-03-28 16:14:42 -04:00
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
textdomain(PACKAGE);
|
|
|
|
init = 1;
|
|
|
|
}
|
|
|
|
}
|
2007-10-23 00:52:55 -04:00
|
|
|
#endif
|
2007-03-28 16:14:42 -04:00
|
|
|
|
2007-07-23 16:58:04 -04:00
|
|
|
/** Set user agent environment variable.
|
2007-04-28 04:50:16 -04:00
|
|
|
*/
|
|
|
|
static void setuseragent(void)
|
|
|
|
{
|
|
|
|
char agent[101];
|
|
|
|
struct utsname un;
|
|
|
|
|
|
|
|
uname(&un);
|
2008-02-29 15:52:57 -05:00
|
|
|
snprintf(agent, 100, "pacman/%s (%s %s) libalpm/%s",
|
|
|
|
PACKAGE_VERSION, un.sysname, un.machine, alpm_version());
|
2007-04-28 04:50:16 -04:00
|
|
|
setenv("HTTP_USER_AGENT", agent, 0);
|
|
|
|
}
|
|
|
|
|
2008-03-09 07:56:00 -04:00
|
|
|
/** Free the resources.
|
|
|
|
*
|
|
|
|
* @param ret the return value
|
|
|
|
*/
|
2013-01-03 16:48:52 -05:00
|
|
|
static void cleanup(int ret)
|
|
|
|
{
|
2008-03-09 07:56:00 -04:00
|
|
|
/* free alpm library resources */
|
2011-06-07 14:15:43 -04:00
|
|
|
if(config->handle && alpm_release(config->handle) == -1) {
|
2011-07-01 12:01:38 -04:00
|
|
|
pm_printf(ALPM_LOG_ERROR, "error releasing alpm library\n");
|
2008-03-09 07:56:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free memory */
|
|
|
|
FREELIST(pm_targets);
|
|
|
|
if(config) {
|
|
|
|
config_free(config);
|
|
|
|
config = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(ret);
|
|
|
|
}
|
|
|
|
|
2008-10-12 22:07:49 -04:00
|
|
|
/** Write function that correctly handles EINTR.
|
|
|
|
*/
|
|
|
|
static ssize_t xwrite(int fd, const void *buf, size_t count)
|
|
|
|
{
|
|
|
|
ssize_t ret;
|
2009-11-12 18:59:34 -05:00
|
|
|
do {
|
|
|
|
ret = write(fd, buf, count);
|
|
|
|
} while(ret == -1 && errno == EINTR);
|
2011-03-20 20:45:57 -04:00
|
|
|
return ret;
|
2008-10-12 22:07:49 -04:00
|
|
|
}
|
|
|
|
|
2007-07-23 16:58:04 -04:00
|
|
|
/** Catches thrown signals. Performs necessary cleanup to ensure database is
|
2013-04-14 22:33:46 -04:00
|
|
|
* in a consistent state.
|
2007-03-28 16:14:42 -04:00
|
|
|
* @param signum the thrown signal
|
|
|
|
*/
|
2010-11-16 21:13:37 -05:00
|
|
|
static void handler(int signum)
|
2006-10-15 15:34:52 -04:00
|
|
|
{
|
2008-10-12 22:07:49 -04:00
|
|
|
int out = fileno(stdout);
|
|
|
|
int err = fileno(stderr);
|
2011-09-26 16:22:13 -04:00
|
|
|
const char *msg;
|
2008-10-12 22:07:49 -04:00
|
|
|
if(signum == SIGSEGV) {
|
2011-09-26 16:22:13 -04:00
|
|
|
msg = "\nerror: segmentation fault\n"
|
2008-10-12 22:07:49 -04:00
|
|
|
"Please submit a full bug report with --debug if appropriate.\n";
|
2011-09-26 16:22:13 -04:00
|
|
|
xwrite(err, msg, strlen(msg));
|
2006-10-15 15:34:52 -04:00
|
|
|
exit(signum);
|
2011-09-26 16:22:13 -04:00
|
|
|
} else if(signum == SIGINT || signum == SIGHUP) {
|
|
|
|
if(signum == SIGINT) {
|
|
|
|
msg = "\nInterrupt signal received\n";
|
|
|
|
} else {
|
|
|
|
msg = "\nHangup signal received\n";
|
|
|
|
}
|
2008-10-12 22:07:49 -04:00
|
|
|
xwrite(err, msg, strlen(msg));
|
2011-06-07 14:29:05 -04:00
|
|
|
if(alpm_trans_interrupt(config->handle) == 0) {
|
2007-09-07 18:36:38 -04:00
|
|
|
/* a transaction is being interrupted, don't exit pacman yet. */
|
|
|
|
return;
|
|
|
|
}
|
2006-10-15 15:34:52 -04:00
|
|
|
}
|
2013-04-14 22:33:46 -04:00
|
|
|
/* SIGINT: no committing transaction, release it now and then exit pacman
|
2011-09-26 16:22:13 -04:00
|
|
|
* SIGHUP, SIGTERM: release no matter what */
|
|
|
|
alpm_trans_release(config->handle);
|
|
|
|
/* output a newline to be sure we clear any line we may be on */
|
|
|
|
xwrite(out, "\n", 1);
|
2011-06-30 10:49:55 -04:00
|
|
|
cleanup(128 + signum);
|
2006-10-15 15:34:52 -04:00
|
|
|
}
|
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
#define check_optarg() if(!optarg) { return 1; }
|
2009-12-05 17:45:34 -05:00
|
|
|
|
2011-06-03 17:13:04 -04:00
|
|
|
static int parsearg_util_addlist(alpm_list_t **list)
|
2010-10-08 16:59:30 -04:00
|
|
|
{
|
2013-10-12 13:32:04 -04:00
|
|
|
char *i, *save;
|
2010-10-08 16:59:30 -04:00
|
|
|
|
|
|
|
check_optarg();
|
2013-10-12 13:32:04 -04:00
|
|
|
|
|
|
|
for(i = strtok_r(optarg, ",", &save); i; i = strtok_r(NULL, ",", &save)) {
|
|
|
|
*list = alpm_list_add(*list, strdup(i));
|
2010-10-08 16:59:30 -04:00
|
|
|
}
|
2013-10-12 13:32:04 -04:00
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-08 16:59:30 -04:00
|
|
|
}
|
|
|
|
|
2010-10-08 16:34:17 -04:00
|
|
|
/** Helper function for parsing operation from command-line arguments.
|
|
|
|
* @param opt Keycode returned by getopt_long
|
|
|
|
* @param dryrun If nonzero, application state is NOT changed
|
|
|
|
* @return 0 if opt was handled, 1 if it was not handled
|
|
|
|
*/
|
|
|
|
static int parsearg_op(int opt, int dryrun)
|
|
|
|
{
|
|
|
|
switch(opt) {
|
|
|
|
/* operations */
|
|
|
|
case 'D':
|
|
|
|
if(dryrun) break;
|
|
|
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DATABASE); break;
|
|
|
|
case 'Q':
|
|
|
|
if(dryrun) break;
|
|
|
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break;
|
|
|
|
case 'R':
|
|
|
|
if(dryrun) break;
|
|
|
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_REMOVE); break;
|
|
|
|
case 'S':
|
|
|
|
if(dryrun) break;
|
|
|
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_SYNC); break;
|
|
|
|
case 'T':
|
|
|
|
if(dryrun) break;
|
|
|
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_DEPTEST); break;
|
|
|
|
case 'U':
|
|
|
|
if(dryrun) break;
|
|
|
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE); break;
|
|
|
|
case 'V':
|
|
|
|
if(dryrun) break;
|
|
|
|
config->version = 1; break;
|
|
|
|
case 'h':
|
|
|
|
if(dryrun) break;
|
|
|
|
config->help = 1; break;
|
|
|
|
default:
|
2011-03-20 20:45:57 -04:00
|
|
|
return 1;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Helper functions for parsing command-line arguments.
|
|
|
|
* @param opt Keycode returned by getopt_long
|
|
|
|
* @return 0 on success, 1 on failure
|
|
|
|
*/
|
|
|
|
static int parsearg_global(int opt)
|
|
|
|
{
|
|
|
|
switch(opt) {
|
2011-05-05 12:12:49 -04:00
|
|
|
case OP_ARCH:
|
|
|
|
check_optarg();
|
2011-08-26 07:10:35 -04:00
|
|
|
config_set_arch(optarg);
|
2011-05-05 12:12:49 -04:00
|
|
|
break;
|
2010-10-08 16:34:17 -04:00
|
|
|
case OP_ASK:
|
|
|
|
check_optarg();
|
|
|
|
config->noask = 1;
|
2011-01-07 22:06:06 -05:00
|
|
|
config->ask = (unsigned int)atoi(optarg);
|
2010-10-08 16:34:17 -04:00
|
|
|
break;
|
|
|
|
case OP_CACHEDIR:
|
|
|
|
check_optarg();
|
2011-06-03 17:13:04 -04:00
|
|
|
config->cachedirs = alpm_list_add(config->cachedirs, strdup(optarg));
|
2010-10-08 16:34:17 -04:00
|
|
|
break;
|
2013-03-01 14:27:40 -05:00
|
|
|
case OP_COLOR:
|
|
|
|
if(strcmp("never", optarg) == 0) {
|
|
|
|
config->color = PM_COLOR_OFF;
|
|
|
|
} else if(strcmp("auto", optarg) == 0) {
|
|
|
|
config->color = isatty(fileno(stdout)) ? PM_COLOR_ON : PM_COLOR_OFF;
|
|
|
|
} else if(strcmp("always", optarg) == 0) {
|
|
|
|
config->color = PM_COLOR_ON;
|
|
|
|
} else {
|
2013-03-14 22:57:02 -04:00
|
|
|
pm_printf(ALPM_LOG_ERROR, _("invalid argument '%s' for %s\n"),
|
2013-03-01 14:27:40 -05:00
|
|
|
optarg, "--color");
|
|
|
|
return 1;
|
|
|
|
}
|
2013-03-01 14:52:16 -05:00
|
|
|
enable_colors(config->color);
|
2013-03-01 14:27:40 -05:00
|
|
|
break;
|
2010-10-08 16:34:17 -04:00
|
|
|
case OP_CONFIG:
|
|
|
|
check_optarg();
|
|
|
|
if(config->configfile) {
|
|
|
|
free(config->configfile);
|
|
|
|
}
|
|
|
|
config->configfile = strndup(optarg, PATH_MAX);
|
|
|
|
break;
|
|
|
|
case OP_DEBUG:
|
|
|
|
/* debug levels are made more 'human readable' than using a raw logmask
|
|
|
|
* here, error and warning are set in config_new, though perhaps a
|
|
|
|
* --quiet option will remove these later */
|
|
|
|
if(optarg) {
|
2011-01-07 22:06:06 -05:00
|
|
|
unsigned short debug = (unsigned short)atoi(optarg);
|
2010-10-08 16:34:17 -04:00
|
|
|
switch(debug) {
|
|
|
|
case 2:
|
2011-07-01 12:01:38 -04:00
|
|
|
config->logmask |= ALPM_LOG_FUNCTION; /* fall through */
|
2010-10-08 16:34:17 -04:00
|
|
|
case 1:
|
2011-07-01 12:01:38 -04:00
|
|
|
config->logmask |= ALPM_LOG_DEBUG;
|
2010-10-08 16:34:17 -04:00
|
|
|
break;
|
|
|
|
default:
|
2011-07-01 12:01:38 -04:00
|
|
|
pm_printf(ALPM_LOG_ERROR, _("'%s' is not a valid debug level\n"),
|
2010-10-08 16:34:17 -04:00
|
|
|
optarg);
|
2011-03-20 20:45:57 -04:00
|
|
|
return 1;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
} else {
|
2011-07-01 12:01:38 -04:00
|
|
|
config->logmask |= ALPM_LOG_DEBUG;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
/* progress bars get wonky with debug on, shut them off */
|
|
|
|
config->noprogressbar = 1;
|
|
|
|
break;
|
2008-12-14 13:59:39 -05:00
|
|
|
case OP_GPGDIR:
|
|
|
|
config->gpgdir = strdup(optarg);
|
|
|
|
break;
|
2010-10-08 16:34:17 -04:00
|
|
|
case OP_LOGFILE:
|
|
|
|
check_optarg();
|
|
|
|
config->logfile = strndup(optarg, PATH_MAX);
|
|
|
|
break;
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_NOCONFIRM:
|
|
|
|
config->noconfirm = 1;
|
|
|
|
break;
|
|
|
|
case OP_DBPATH:
|
2010-10-08 16:34:17 -04:00
|
|
|
case 'b':
|
|
|
|
check_optarg();
|
|
|
|
config->dbpath = strdup(optarg);
|
|
|
|
break;
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_ROOT:
|
|
|
|
case 'r':
|
|
|
|
check_optarg();
|
|
|
|
config->rootdir = strdup(optarg);
|
|
|
|
break;
|
|
|
|
case OP_VERBOSE:
|
|
|
|
case 'v':
|
|
|
|
(config->verbose)++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int parsearg_database(int opt)
|
|
|
|
{
|
|
|
|
switch(opt) {
|
2011-07-01 12:01:39 -04:00
|
|
|
case OP_ASDEPS: config->flags |= ALPM_TRANS_FLAG_ALLDEPS; break;
|
|
|
|
case OP_ASEXPLICIT: config->flags |= ALPM_TRANS_FLAG_ALLEXPLICIT; break;
|
2011-03-20 20:45:57 -04:00
|
|
|
default: return 1;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int parsearg_query(int opt)
|
|
|
|
{
|
|
|
|
switch(opt) {
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_CHANGELOG:
|
|
|
|
case 'c':
|
|
|
|
config->op_q_changelog = 1;
|
|
|
|
break;
|
|
|
|
case OP_DEPS:
|
|
|
|
case 'd':
|
|
|
|
config->op_q_deps = 1;
|
|
|
|
break;
|
|
|
|
case OP_EXPLICIT:
|
|
|
|
case 'e':
|
|
|
|
config->op_q_explicit = 1;
|
|
|
|
break;
|
|
|
|
case OP_GROUPS:
|
|
|
|
case 'g':
|
|
|
|
(config->group)++;
|
|
|
|
break;
|
|
|
|
case OP_INFO:
|
|
|
|
case 'i':
|
|
|
|
(config->op_q_info)++;
|
|
|
|
break;
|
|
|
|
case OP_CHECK:
|
|
|
|
case 'k':
|
|
|
|
(config->op_q_check)++;
|
|
|
|
break;
|
|
|
|
case OP_LIST:
|
|
|
|
case 'l':
|
|
|
|
config->op_q_list = 1;
|
|
|
|
break;
|
|
|
|
case OP_FOREIGN:
|
|
|
|
case 'm':
|
|
|
|
config->op_q_locality |= PKG_LOCALITY_LOCAL;
|
|
|
|
break;
|
|
|
|
case OP_NATIVE:
|
|
|
|
case 'n':
|
|
|
|
config->op_q_locality |= PKG_LOCALITY_FOREIGN;
|
|
|
|
break;
|
|
|
|
case OP_OWNS:
|
|
|
|
case 'o':
|
|
|
|
config->op_q_owns = 1;
|
|
|
|
break;
|
|
|
|
case OP_FILE:
|
|
|
|
case 'p':
|
|
|
|
config->op_q_isfile = 1;
|
|
|
|
break;
|
|
|
|
case OP_QUIET:
|
|
|
|
case 'q':
|
|
|
|
config->quiet = 1;
|
|
|
|
break;
|
|
|
|
case OP_SEARCH:
|
|
|
|
case 's':
|
|
|
|
config->op_q_search = 1;
|
|
|
|
break;
|
|
|
|
case OP_UNREQUIRED:
|
|
|
|
case 't':
|
|
|
|
(config->op_q_unrequired)++;
|
|
|
|
break;
|
|
|
|
case OP_UPGRADES:
|
|
|
|
case 'u':
|
|
|
|
config->op_q_upgrade = 1; break;
|
|
|
|
default:
|
|
|
|
return 1;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
|
2010-10-10 12:57:41 -04:00
|
|
|
/* options common to -S -R -U */
|
|
|
|
static int parsearg_trans(int opt)
|
2010-10-08 16:34:17 -04:00
|
|
|
{
|
|
|
|
switch(opt) {
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_NODEPS:
|
2010-10-01 10:42:09 -04:00
|
|
|
case 'd':
|
2011-07-01 12:01:39 -04:00
|
|
|
if(config->flags & ALPM_TRANS_FLAG_NODEPVERSION) {
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_NODEPS;
|
2010-10-01 10:42:09 -04:00
|
|
|
} else {
|
2011-07-01 12:01:39 -04:00
|
|
|
config->flags |= ALPM_TRANS_FLAG_NODEPVERSION;
|
2010-10-01 10:42:09 -04:00
|
|
|
}
|
|
|
|
break;
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_DBONLY:
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_DBONLY;
|
|
|
|
break;
|
|
|
|
case OP_NOPROGRESSBAR:
|
|
|
|
config->noprogressbar = 1;
|
|
|
|
break;
|
|
|
|
case OP_NOSCRIPTLET:
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_NOSCRIPTLET;
|
|
|
|
break;
|
|
|
|
case OP_PRINT:
|
|
|
|
case 'p':
|
|
|
|
config->print = 1;
|
|
|
|
break;
|
2010-10-10 12:57:41 -04:00
|
|
|
case OP_PRINTFORMAT:
|
|
|
|
check_optarg();
|
2013-10-12 13:32:07 -04:00
|
|
|
config->print = 1;
|
2010-10-10 12:57:41 -04:00
|
|
|
config->print_format = strdup(optarg);
|
|
|
|
break;
|
2013-10-12 13:32:05 -04:00
|
|
|
default:
|
|
|
|
return 1;
|
2010-10-10 12:57:41 -04:00
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-10 12:57:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int parsearg_remove(int opt)
|
|
|
|
{
|
2013-10-12 13:32:05 -04:00
|
|
|
if(parsearg_trans(opt) == 0) {
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2013-10-12 13:32:05 -04:00
|
|
|
}
|
2010-10-10 12:57:41 -04:00
|
|
|
switch(opt) {
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_CASCADE:
|
|
|
|
case 'c':
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_CASCADE;
|
|
|
|
break;
|
|
|
|
case OP_NOSAVE:
|
|
|
|
case 'n':
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_NOSAVE;
|
|
|
|
break;
|
|
|
|
case OP_RECURSIVE:
|
2010-10-08 16:34:17 -04:00
|
|
|
case 's':
|
2011-07-01 12:01:39 -04:00
|
|
|
if(config->flags & ALPM_TRANS_FLAG_RECURSE) {
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_RECURSEALL;
|
2010-10-08 16:34:17 -04:00
|
|
|
} else {
|
2011-07-01 12:01:39 -04:00
|
|
|
config->flags |= ALPM_TRANS_FLAG_RECURSE;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
break;
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_UNNEEDED:
|
|
|
|
case 'u':
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_UNNEEDED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
|
2010-10-10 12:57:41 -04:00
|
|
|
/* options common to -S -U */
|
|
|
|
static int parsearg_upgrade(int opt)
|
2010-10-08 16:34:17 -04:00
|
|
|
{
|
2013-10-12 13:32:05 -04:00
|
|
|
if(parsearg_trans(opt) == 0) {
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2013-10-12 13:32:05 -04:00
|
|
|
}
|
2010-10-08 16:34:17 -04:00
|
|
|
switch(opt) {
|
2011-10-11 13:35:33 -04:00
|
|
|
case OP_FORCE: config->flags |= ALPM_TRANS_FLAG_FORCE; break;
|
2011-07-01 12:01:39 -04:00
|
|
|
case OP_ASDEPS: config->flags |= ALPM_TRANS_FLAG_ALLDEPS; break;
|
|
|
|
case OP_ASEXPLICIT: config->flags |= ALPM_TRANS_FLAG_ALLEXPLICIT; break;
|
2011-08-11 09:55:12 -04:00
|
|
|
case OP_NEEDED: config->flags |= ALPM_TRANS_FLAG_NEEDED; break;
|
2010-10-10 12:57:41 -04:00
|
|
|
case OP_IGNORE:
|
2011-06-03 17:13:04 -04:00
|
|
|
parsearg_util_addlist(&(config->ignorepkg));
|
2010-10-10 12:57:41 -04:00
|
|
|
break;
|
|
|
|
case OP_IGNOREGROUP:
|
2011-06-03 17:13:04 -04:00
|
|
|
parsearg_util_addlist(&(config->ignoregrp));
|
2010-10-10 12:57:41 -04:00
|
|
|
break;
|
2011-03-20 20:45:57 -04:00
|
|
|
default: return 1;
|
2010-10-10 12:57:41 -04:00
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-10 12:57:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int parsearg_sync(int opt)
|
|
|
|
{
|
2013-10-12 13:32:05 -04:00
|
|
|
if(parsearg_upgrade(opt) == 0) {
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2013-10-12 13:32:05 -04:00
|
|
|
}
|
2010-10-10 12:57:41 -04:00
|
|
|
switch(opt) {
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_CLEAN:
|
|
|
|
case 'c':
|
|
|
|
(config->op_s_clean)++;
|
|
|
|
break;
|
|
|
|
case OP_GROUPS:
|
|
|
|
case 'g':
|
|
|
|
(config->group)++;
|
|
|
|
break;
|
|
|
|
case OP_INFO:
|
|
|
|
case 'i':
|
|
|
|
(config->op_s_info)++;
|
|
|
|
break;
|
|
|
|
case OP_LIST:
|
|
|
|
case 'l':
|
|
|
|
config->op_q_list = 1;
|
|
|
|
break;
|
|
|
|
case OP_QUIET:
|
|
|
|
case 'q':
|
|
|
|
config->quiet = 1;
|
|
|
|
break;
|
|
|
|
case OP_SEARCH:
|
|
|
|
case 's':
|
|
|
|
config->op_s_search = 1;
|
|
|
|
break;
|
|
|
|
case OP_SYSUPGRADE:
|
|
|
|
case 'u':
|
|
|
|
(config->op_s_upgrade)++;
|
|
|
|
break;
|
|
|
|
case OP_DOWNLOADONLY:
|
2010-10-08 16:34:17 -04:00
|
|
|
case 'w':
|
|
|
|
config->op_s_downloadonly = 1;
|
2011-07-01 12:01:39 -04:00
|
|
|
config->flags |= ALPM_TRANS_FLAG_DOWNLOADONLY;
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_NOCONFLICTS;
|
2010-10-08 16:34:17 -04:00
|
|
|
break;
|
2013-10-12 13:32:05 -04:00
|
|
|
case OP_REFRESH:
|
|
|
|
case 'y':
|
|
|
|
(config->op_s_sync)++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
|
2007-07-23 16:58:04 -04:00
|
|
|
/** Parse command-line arguments for each operation.
|
2007-03-28 16:14:42 -04:00
|
|
|
* @param argc argc
|
|
|
|
* @param argv argv
|
|
|
|
* @return 0 on success, 1 on error
|
2005-03-14 20:51:43 -05:00
|
|
|
*/
|
2006-03-13 15:34:47 -05:00
|
|
|
static int parseargs(int argc, char *argv[])
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
|
|
|
int opt;
|
|
|
|
int option_index = 0;
|
2010-10-08 16:34:17 -04:00
|
|
|
int result;
|
|
|
|
const char *optstring = "DQRSTUVb:cdefghiklmnopqr:stuvwy";
|
2011-08-08 14:37:30 -04:00
|
|
|
static const struct option opts[] =
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2009-05-20 15:46:23 -04:00
|
|
|
{"database", no_argument, 0, 'D'},
|
2005-03-14 20:51:43 -05:00
|
|
|
{"query", no_argument, 0, 'Q'},
|
2005-03-25 17:37:13 -05:00
|
|
|
{"remove", no_argument, 0, 'R'},
|
2005-03-14 20:51:43 -05:00
|
|
|
{"sync", no_argument, 0, 'S'},
|
2005-03-25 17:37:13 -05:00
|
|
|
{"deptest", no_argument, 0, 'T'}, /* used by makepkg */
|
|
|
|
{"upgrade", no_argument, 0, 'U'},
|
2005-03-14 20:51:43 -05:00
|
|
|
{"version", no_argument, 0, 'V'},
|
2005-03-25 17:37:13 -05:00
|
|
|
{"help", no_argument, 0, 'h'},
|
2011-08-11 02:00:47 -04:00
|
|
|
|
2013-10-12 13:32:05 -04:00
|
|
|
{"dbpath", required_argument, 0, OP_DBPATH},
|
|
|
|
{"cascade", no_argument, 0, OP_CASCADE},
|
|
|
|
{"changelog", no_argument, 0, OP_CHANGELOG},
|
|
|
|
{"clean", no_argument, 0, OP_CLEAN},
|
|
|
|
{"nodeps", no_argument, 0, OP_NODEPS},
|
|
|
|
{"deps", no_argument, 0, OP_DEPS},
|
|
|
|
{"explicit", no_argument, 0, OP_EXPLICIT},
|
|
|
|
{"groups", no_argument, 0, OP_GROUPS},
|
|
|
|
{"info", no_argument, 0, OP_INFO},
|
|
|
|
{"check", no_argument, 0, OP_CHECK},
|
|
|
|
{"list", no_argument, 0, OP_LIST},
|
|
|
|
{"foreign", no_argument, 0, OP_FOREIGN},
|
|
|
|
{"native", no_argument, 0, OP_NATIVE},
|
|
|
|
{"nosave", no_argument, 0, OP_NOSAVE},
|
|
|
|
{"owns", no_argument, 0, OP_OWNS},
|
|
|
|
{"file", no_argument, 0, OP_FILE},
|
|
|
|
{"print", no_argument, 0, OP_PRINT},
|
|
|
|
{"quiet", no_argument, 0, OP_QUIET},
|
|
|
|
{"root", required_argument, 0, OP_ROOT},
|
|
|
|
{"recursive", no_argument, 0, OP_RECURSIVE},
|
|
|
|
{"search", no_argument, 0, OP_SEARCH},
|
|
|
|
{"unrequired", no_argument, 0, OP_UNREQUIRED},
|
|
|
|
{"upgrades", no_argument, 0, OP_UPGRADES},
|
|
|
|
{"sysupgrade", no_argument, 0, OP_SYSUPGRADE},
|
|
|
|
{"unneeded", no_argument, 0, OP_UNNEEDED},
|
|
|
|
{"verbose", no_argument, 0, OP_VERBOSE},
|
|
|
|
{"downloadonly", no_argument, 0, OP_DOWNLOADONLY},
|
|
|
|
{"refresh", no_argument, 0, OP_REFRESH},
|
2009-10-12 23:14:56 -04:00
|
|
|
{"noconfirm", no_argument, 0, OP_NOCONFIRM},
|
|
|
|
{"config", required_argument, 0, OP_CONFIG},
|
|
|
|
{"ignore", required_argument, 0, OP_IGNORE},
|
|
|
|
{"debug", optional_argument, 0, OP_DEBUG},
|
2011-10-11 13:35:33 -04:00
|
|
|
{"force", no_argument, 0, OP_FORCE},
|
2009-10-12 23:14:56 -04:00
|
|
|
{"noprogressbar", no_argument, 0, OP_NOPROGRESSBAR},
|
|
|
|
{"noscriptlet", no_argument, 0, OP_NOSCRIPTLET},
|
|
|
|
{"ask", required_argument, 0, OP_ASK},
|
|
|
|
{"cachedir", required_argument, 0, OP_CACHEDIR},
|
|
|
|
{"asdeps", no_argument, 0, OP_ASDEPS},
|
|
|
|
{"logfile", required_argument, 0, OP_LOGFILE},
|
|
|
|
{"ignoregroup", required_argument, 0, OP_IGNOREGROUP},
|
|
|
|
{"needed", no_argument, 0, OP_NEEDED},
|
|
|
|
{"asexplicit", no_argument, 0, OP_ASEXPLICIT},
|
|
|
|
{"arch", required_argument, 0, OP_ARCH},
|
2009-07-19 05:15:11 -04:00
|
|
|
{"print-format", required_argument, 0, OP_PRINTFORMAT},
|
2008-12-14 13:59:39 -05:00
|
|
|
{"gpgdir", required_argument, 0, OP_GPGDIR},
|
2011-08-11 09:18:55 -04:00
|
|
|
{"dbonly", no_argument, 0, OP_DBONLY},
|
2013-03-01 14:27:40 -05:00
|
|
|
{"color", required_argument, 0, OP_COLOR},
|
2005-03-14 20:51:43 -05:00
|
|
|
{0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2010-10-08 16:34:17 -04:00
|
|
|
/* parse operation */
|
|
|
|
while((opt = getopt_long(argc, argv, optstring, opts, &option_index))) {
|
2005-03-14 20:51:43 -05:00
|
|
|
if(opt < 0) {
|
|
|
|
break;
|
2010-10-08 16:34:17 -04:00
|
|
|
} else if(opt == 0) {
|
|
|
|
continue;
|
|
|
|
} else if(opt == '?') {
|
2010-10-10 12:57:41 -04:00
|
|
|
/* unknown option, getopt printed an error */
|
2011-03-20 20:45:57 -04:00
|
|
|
return 1;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2010-10-08 16:34:17 -04:00
|
|
|
parsearg_op(opt, 0);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
if(config->op == 0) {
|
2011-07-01 12:01:38 -04:00
|
|
|
pm_printf(ALPM_LOG_ERROR, _("only one operation may be used at a time\n"));
|
2011-03-20 20:45:57 -04:00
|
|
|
return 1;
|
2006-03-13 15:34:47 -05:00
|
|
|
}
|
|
|
|
if(config->help) {
|
2007-10-31 12:43:04 -04:00
|
|
|
usage(config->op, mbasename(argv[0]));
|
2011-03-20 20:45:57 -04:00
|
|
|
return 2;
|
2006-03-13 15:34:47 -05:00
|
|
|
}
|
|
|
|
if(config->version) {
|
|
|
|
version();
|
2011-03-20 20:45:57 -04:00
|
|
|
return 2;
|
2006-03-13 15:34:47 -05:00
|
|
|
}
|
|
|
|
|
2010-10-08 16:34:17 -04:00
|
|
|
/* parse all other options */
|
|
|
|
optind = 1;
|
|
|
|
while((opt = getopt_long(argc, argv, optstring, opts, &option_index))) {
|
|
|
|
if(opt < 0) {
|
|
|
|
break;
|
|
|
|
} else if(opt == 0) {
|
|
|
|
continue;
|
|
|
|
} else if(opt == '?') {
|
2010-10-10 12:57:41 -04:00
|
|
|
/* this should have failed during first pass already */
|
2011-03-20 20:45:57 -04:00
|
|
|
return 1;
|
2011-03-21 01:24:36 -04:00
|
|
|
} else if(parsearg_op(opt, 1) == 0) {
|
|
|
|
/* opt is an operation */
|
2010-10-08 16:34:17 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(config->op) {
|
|
|
|
case PM_OP_DATABASE:
|
|
|
|
result = parsearg_database(opt);
|
|
|
|
break;
|
|
|
|
case PM_OP_QUERY:
|
|
|
|
result = parsearg_query(opt);
|
|
|
|
break;
|
|
|
|
case PM_OP_REMOVE:
|
|
|
|
result = parsearg_remove(opt);
|
|
|
|
break;
|
|
|
|
case PM_OP_SYNC:
|
|
|
|
result = parsearg_sync(opt);
|
|
|
|
break;
|
|
|
|
case PM_OP_UPGRADE:
|
|
|
|
result = parsearg_upgrade(opt);
|
|
|
|
break;
|
2011-03-21 01:24:36 -04:00
|
|
|
case PM_OP_DEPTEST:
|
2010-10-08 16:34:17 -04:00
|
|
|
default:
|
2011-03-21 01:24:36 -04:00
|
|
|
result = 1;
|
|
|
|
break;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
2011-04-20 20:45:16 -04:00
|
|
|
if(result == 0) {
|
2010-10-10 12:57:41 -04:00
|
|
|
continue;
|
2011-03-21 01:24:36 -04:00
|
|
|
}
|
2010-10-10 12:57:41 -04:00
|
|
|
|
|
|
|
/* fall back to global options */
|
|
|
|
result = parsearg_global(opt);
|
2010-10-08 16:34:17 -04:00
|
|
|
if(result != 0) {
|
2010-10-10 12:57:41 -04:00
|
|
|
/* global option parsing failed, abort */
|
2011-07-01 12:01:38 -04:00
|
|
|
pm_printf(ALPM_LOG_ERROR, _("invalid option\n"));
|
2011-03-20 20:45:57 -04:00
|
|
|
return result;
|
2010-10-08 16:34:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
while(optind < argc) {
|
|
|
|
/* add the target to our target array */
|
2007-01-19 04:28:44 -05:00
|
|
|
pm_targets = alpm_list_add(pm_targets, strdup(argv[optind]));
|
2006-03-13 15:34:47 -05:00
|
|
|
optind++;
|
|
|
|
}
|
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2006-03-13 15:34:47 -05:00
|
|
|
}
|
|
|
|
|
2012-02-06 23:12:11 -05:00
|
|
|
/** Print command line to logfile.
|
|
|
|
* @param argc
|
|
|
|
* @param argv
|
2008-12-20 00:51:59 -05:00
|
|
|
*/
|
2012-08-01 11:24:34 -04:00
|
|
|
static void cl_to_log(int argc, char *argv[])
|
2008-12-20 00:51:59 -05:00
|
|
|
{
|
|
|
|
size_t size = 0;
|
|
|
|
int i;
|
2011-06-28 18:46:04 -04:00
|
|
|
for(i = 0; i < argc; i++) {
|
2008-12-20 00:51:59 -05:00
|
|
|
size += strlen(argv[i]) + 1;
|
|
|
|
}
|
2011-06-28 18:46:04 -04:00
|
|
|
if(!size) {
|
|
|
|
return;
|
|
|
|
}
|
2008-12-20 00:51:59 -05:00
|
|
|
char *cl_text = malloc(size);
|
2011-05-19 17:59:53 -04:00
|
|
|
if(!cl_text) {
|
2008-12-20 00:51:59 -05:00
|
|
|
return;
|
2011-05-19 17:59:53 -04:00
|
|
|
}
|
2008-12-20 00:51:59 -05:00
|
|
|
char *p = cl_text;
|
2011-06-28 18:46:04 -04:00
|
|
|
for(i = 0; i < argc - 1; i++) {
|
2008-12-20 00:51:59 -05:00
|
|
|
strcpy(p, argv[i]);
|
|
|
|
p += strlen(argv[i]);
|
|
|
|
*p++ = ' ';
|
|
|
|
}
|
|
|
|
strcpy(p, argv[i]);
|
2013-01-18 20:42:21 -05:00
|
|
|
alpm_logaction(config->handle, PACMAN_CALLER_PREFIX,
|
|
|
|
"Running '%s'\n", cl_text);
|
2008-12-20 00:51:59 -05:00
|
|
|
free(cl_text);
|
|
|
|
}
|
|
|
|
|
2007-07-23 16:58:04 -04:00
|
|
|
/** Main function.
|
2012-02-06 23:12:11 -05:00
|
|
|
* @param argc
|
|
|
|
* @param argv
|
2007-03-28 16:14:42 -04:00
|
|
|
* @return A return code indicating success, failure, etc.
|
|
|
|
*/
|
2006-03-13 15:34:47 -05:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2011-09-26 19:18:42 -04:00
|
|
|
int ret = 0;
|
|
|
|
size_t i;
|
2008-03-09 08:12:32 -04:00
|
|
|
struct sigaction new_action, old_action;
|
2011-09-26 16:22:13 -04:00
|
|
|
const int signals[] = { SIGHUP, SIGINT, SIGTERM, SIGSEGV };
|
2007-06-07 20:49:31 -04:00
|
|
|
uid_t myuid = geteuid();
|
2006-03-13 15:34:47 -05:00
|
|
|
|
2008-03-09 08:12:32 -04:00
|
|
|
/* Set signal handlers */
|
|
|
|
/* Set up the structure to specify the new action. */
|
|
|
|
new_action.sa_handler = handler;
|
|
|
|
sigemptyset(&new_action.sa_mask);
|
|
|
|
new_action.sa_flags = 0;
|
|
|
|
|
2011-09-26 16:22:13 -04:00
|
|
|
/* assign our handler to any signals we care about */
|
|
|
|
for(i = 0; i < sizeof(signals) / sizeof(signals[0]); i++) {
|
|
|
|
int signal = signals[i];
|
|
|
|
sigaction(signal, NULL, &old_action);
|
|
|
|
if(old_action.sa_handler != SIG_IGN) {
|
|
|
|
sigaction(signal, &new_action, NULL);
|
|
|
|
}
|
2008-03-09 08:12:32 -04:00
|
|
|
}
|
2006-03-13 15:34:47 -05:00
|
|
|
|
2006-06-28 01:37:15 -04:00
|
|
|
/* i18n init */
|
2007-10-23 00:52:55 -04:00
|
|
|
#if defined(ENABLE_NLS)
|
2007-03-28 16:14:42 -04:00
|
|
|
localize();
|
2007-10-23 00:52:55 -04:00
|
|
|
#endif
|
2006-06-28 01:37:15 -04:00
|
|
|
|
2007-04-28 04:50:16 -04:00
|
|
|
/* set user agent for downloading */
|
|
|
|
setuseragent();
|
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
/* init config data */
|
|
|
|
config = config_new();
|
2007-04-25 17:24:23 -04:00
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
/* disable progressbar if the output is redirected */
|
2012-01-12 08:47:29 -05:00
|
|
|
if(!isatty(fileno(stdout))) {
|
2006-03-13 15:34:47 -05:00
|
|
|
config->noprogressbar = 1;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-08-21 21:28:05 -04:00
|
|
|
/* Priority of options:
|
|
|
|
* 1. command line
|
|
|
|
* 2. config file
|
|
|
|
* 3. compiled-in defaults
|
|
|
|
* However, we have to parse the command line first because a config file
|
|
|
|
* location can be specified here, so we need to make sure we prefer these
|
|
|
|
* options over the config file coming second.
|
|
|
|
*/
|
2007-06-07 20:49:31 -04:00
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
/* parse the command line */
|
|
|
|
ret = parseargs(argc, argv);
|
|
|
|
if(ret != 0) {
|
2007-06-07 22:20:40 -04:00
|
|
|
cleanup(ret);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2011-03-16 17:23:00 -04:00
|
|
|
/* we support reading targets from stdin if a cmdline parameter is '-' */
|
2013-02-02 04:58:50 -05:00
|
|
|
if(alpm_list_find_str(pm_targets, "-")) {
|
|
|
|
if(!isatty(fileno(stdin))) {
|
2013-06-02 23:45:05 -04:00
|
|
|
int target_found = 0;
|
2013-02-02 04:58:50 -05:00
|
|
|
size_t current_size = PATH_MAX;
|
|
|
|
char *vdata, *line = malloc(current_size);
|
2013-08-12 07:09:01 -04:00
|
|
|
int c;
|
2013-02-02 04:58:50 -05:00
|
|
|
|
|
|
|
/* remove the '-' from the list */
|
|
|
|
pm_targets = alpm_list_remove_str(pm_targets, "-", &vdata);
|
|
|
|
free(vdata);
|
|
|
|
|
|
|
|
i = 0;
|
2013-08-12 07:09:01 -04:00
|
|
|
while((c = fgetc(stdin)) != EOF) {
|
|
|
|
line[i] = (char)c;
|
2013-02-02 04:58:50 -05:00
|
|
|
if(isspace((unsigned char)line[i])) {
|
|
|
|
/* avoid adding zero length arg when multiple spaces separate args */
|
|
|
|
if(i > 0) {
|
|
|
|
line[i] = '\0';
|
|
|
|
pm_targets = alpm_list_add(pm_targets, strdup(line));
|
2013-06-02 23:45:05 -04:00
|
|
|
target_found = 1;
|
2013-02-02 04:58:50 -05:00
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
/* we may be at the end of our allocated buffer now */
|
|
|
|
if(i >= current_size) {
|
|
|
|
char *new = realloc(line, current_size * 2);
|
|
|
|
if(new) {
|
|
|
|
line = new;
|
|
|
|
current_size *= 2;
|
|
|
|
} else {
|
|
|
|
free(line);
|
|
|
|
line = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2011-09-19 20:57:29 -04:00
|
|
|
}
|
|
|
|
}
|
2010-11-04 16:05:28 -04:00
|
|
|
}
|
|
|
|
|
2013-02-02 04:58:50 -05:00
|
|
|
/* check for memory exhaustion */
|
|
|
|
if(!line) {
|
|
|
|
pm_printf(ALPM_LOG_ERROR, _("memory exhausted in argument parsing\n"));
|
|
|
|
cleanup(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* end of stream -- check for data still in line buffer */
|
|
|
|
if(i > 0) {
|
|
|
|
line[i] = '\0';
|
|
|
|
pm_targets = alpm_list_add(pm_targets, strdup(line));
|
2013-06-02 23:45:05 -04:00
|
|
|
target_found = 1;
|
2013-02-02 04:58:50 -05:00
|
|
|
}
|
|
|
|
free(line);
|
|
|
|
if(!freopen(ctermid(NULL), "r", stdin)) {
|
|
|
|
pm_printf(ALPM_LOG_ERROR, _("failed to reopen stdin for reading: (%s)\n"),
|
|
|
|
strerror(errno));
|
|
|
|
}
|
2013-06-02 23:45:05 -04:00
|
|
|
|
|
|
|
if(!target_found) {
|
|
|
|
pm_printf(ALPM_LOG_ERROR, _("argument '-' specified with empty stdin\n"));
|
|
|
|
cleanup(1);
|
|
|
|
}
|
2013-02-02 04:58:50 -05:00
|
|
|
} else {
|
|
|
|
/* do not read stdin from terminal */
|
|
|
|
pm_printf(ALPM_LOG_ERROR, _("argument '-' specified without input on stdin\n"));
|
|
|
|
cleanup(1);
|
2010-11-04 16:05:28 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-07 00:51:45 -04:00
|
|
|
pm_printf(ALPM_LOG_DEBUG, "pacman v%s - libalpm v%s\n", PACKAGE_VERSION, alpm_version());
|
|
|
|
|
2007-06-07 20:49:31 -04:00
|
|
|
/* parse the config file */
|
2007-06-07 22:20:40 -04:00
|
|
|
ret = parseconfig(config->configfile);
|
|
|
|
if(ret != 0) {
|
|
|
|
cleanup(ret);
|
2007-06-07 20:49:31 -04:00
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
|
Re-add the non-user friendly --ask option
This re-implements the --ask option which was removed in commit
1ff8e7f364a9f640ada7526384646d510ac29967.
This option does not have to be exposed to the user (help,doc,etc), but is
very very useful for pactest if we want to have more coverage there.
This was rewritten in a smarter way, without code duplication. And with a
different behavior : this option is now only used to inverse default
behavior to questions.
We still use bit operations based on the following struct :
/* Transaction Conversations (ie, questions) */
typedef enum _pmtransconv_t {
PM_TRANS_CONV_INSTALL_IGNOREPKG = 0x01,
PM_TRANS_CONV_REPLACE_PKG = 0x02,
PM_TRANS_CONV_CONFLICT_PKG = 0x04,
PM_TRANS_CONV_CORRUPTED_PKG = 0x08,
PM_TRANS_CONV_LOCAL_NEWER = 0x10,
PM_TRANS_CONV_REMOVE_PKGS = 0x20,
} pmtransconv_t;
for each conv matched, the default answer is inversed.
--ask 0 : all default answers are preserved
--ask 4 : only conflict question is inversed
--ask 63 : all questions are inversed (63 == 1+2+4+8+16+32)
Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-08-31 14:17:05 -04:00
|
|
|
/* noask is meant to be non-interactive */
|
|
|
|
if(config->noask) {
|
|
|
|
config->noconfirm = 1;
|
|
|
|
}
|
|
|
|
|
2009-07-19 05:15:11 -04:00
|
|
|
/* set up the print operations */
|
2011-05-16 12:52:49 -04:00
|
|
|
if(config->print && !config->op_s_clean) {
|
2009-07-19 05:15:11 -04:00
|
|
|
config->noconfirm = 1;
|
2011-07-01 12:01:39 -04:00
|
|
|
config->flags |= ALPM_TRANS_FLAG_NOCONFLICTS;
|
|
|
|
config->flags |= ALPM_TRANS_FLAG_NOLOCK;
|
2009-07-19 05:15:11 -04:00
|
|
|
/* Display only errors */
|
2011-07-01 12:01:38 -04:00
|
|
|
config->logmask &= ~ALPM_LOG_WARNING;
|
2009-07-19 05:15:11 -04:00
|
|
|
}
|
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
/* check if we have sufficient permission for the requested operation */
|
2009-05-16 11:59:45 -04:00
|
|
|
if(myuid > 0 && needs_root()) {
|
2011-07-01 12:01:38 -04:00
|
|
|
pm_printf(ALPM_LOG_ERROR, _("you cannot perform this operation unless you are root.\n"));
|
2007-09-28 00:03:35 -04:00
|
|
|
cleanup(EXIT_FAILURE);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
if(config->verbose > 0) {
|
2012-04-07 14:01:13 -04:00
|
|
|
alpm_list_t *j;
|
2011-06-07 14:15:43 -04:00
|
|
|
printf("Root : %s\n", alpm_option_get_root(config->handle));
|
2007-05-31 02:51:28 -04:00
|
|
|
printf("Conf File : %s\n", config->configfile);
|
2011-06-07 14:15:43 -04:00
|
|
|
printf("DB Path : %s\n", alpm_option_get_dbpath(config->handle));
|
2007-06-04 14:50:16 -04:00
|
|
|
printf("Cache Dirs: ");
|
2012-04-07 14:01:13 -04:00
|
|
|
for(j = alpm_option_get_cachedirs(config->handle); j; j = alpm_list_next(j)) {
|
|
|
|
printf("%s ", (const char *)j->data);
|
2007-06-04 14:50:16 -04:00
|
|
|
}
|
|
|
|
printf("\n");
|
2011-06-07 14:15:43 -04:00
|
|
|
printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle));
|
|
|
|
printf("Log File : %s\n", alpm_option_get_logfile(config->handle));
|
2011-06-15 13:02:29 -04:00
|
|
|
printf("GPG Dir : %s\n", alpm_option_get_gpgdir(config->handle));
|
2012-03-16 18:57:04 -04:00
|
|
|
list_display("Targets :", pm_targets, 0);
|
2006-03-13 15:34:47 -05:00
|
|
|
}
|
|
|
|
|
2012-02-06 23:12:11 -05:00
|
|
|
/* Log command line */
|
2008-12-20 00:51:59 -05:00
|
|
|
if(needs_root()) {
|
|
|
|
cl_to_log(argc, argv);
|
|
|
|
}
|
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
/* start the requested operation */
|
|
|
|
switch(config->op) {
|
2009-05-20 15:46:23 -04:00
|
|
|
case PM_OP_DATABASE:
|
|
|
|
ret = pacman_database(pm_targets);
|
|
|
|
break;
|
2007-04-25 17:24:23 -04:00
|
|
|
case PM_OP_REMOVE:
|
|
|
|
ret = pacman_remove(pm_targets);
|
|
|
|
break;
|
|
|
|
case PM_OP_UPGRADE:
|
|
|
|
ret = pacman_upgrade(pm_targets);
|
|
|
|
break;
|
|
|
|
case PM_OP_QUERY:
|
|
|
|
ret = pacman_query(pm_targets);
|
|
|
|
break;
|
|
|
|
case PM_OP_SYNC:
|
|
|
|
ret = pacman_sync(pm_targets);
|
|
|
|
break;
|
|
|
|
case PM_OP_DEPTEST:
|
|
|
|
ret = pacman_deptest(pm_targets);
|
|
|
|
break;
|
2006-03-13 15:34:47 -05:00
|
|
|
default:
|
2011-07-01 12:01:38 -04:00
|
|
|
pm_printf(ALPM_LOG_ERROR, _("no operation specified (use -h for help)\n"));
|
2007-06-07 20:49:31 -04:00
|
|
|
ret = EXIT_FAILURE;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2006-03-13 15:34:47 -05:00
|
|
|
cleanup(ret);
|
|
|
|
/* not reached */
|
2011-03-20 20:45:57 -04:00
|
|
|
return EXIT_SUCCESS;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* vim: set ts=2 sw=2 noet: */
|