2009-08-17 22:37:20 +05:30
|
|
|
/*-
|
2012-01-04 22:26:52 +05:30
|
|
|
* Copyright (c) 2008-2012 Juan Romero Pardines.
|
2009-08-17 22:37:20 +05:30
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-01-25 17:30:23 +05:30
|
|
|
#include <strings.h>
|
2009-08-17 22:37:20 +05:30
|
|
|
#include <errno.h>
|
2009-10-23 14:50:25 +05:30
|
|
|
#include <signal.h>
|
2010-11-13 07:48:58 +05:30
|
|
|
#include <assert.h>
|
2010-11-19 18:10:13 +05:30
|
|
|
#include <unistd.h>
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
#include <xbps_api.h>
|
2011-07-09 14:20:44 +05:30
|
|
|
#include "compat.h"
|
2009-08-17 22:37:20 +05:30
|
|
|
#include "defs.h"
|
2009-11-24 16:35:39 +05:30
|
|
|
#include "../xbps-repo/defs.h"
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-06-14 13:41:50 +05:30
|
|
|
static struct xbps_handle xh;
|
|
|
|
|
2011-01-15 16:29:44 +05:30
|
|
|
static void __attribute__((noreturn))
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(bool fail)
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
2010-01-15 19:49:16 +05:30
|
|
|
fprintf(stderr,
|
2012-02-14 15:05:33 +05:30
|
|
|
"Usage: xbps-bin [options] target [arguments]\n\n"
|
|
|
|
"[options]\n"
|
|
|
|
" -A Enable Automatic installation (shown as orphan)\n"
|
|
|
|
" -C file Full path to configuration file\n"
|
|
|
|
" -c cachedir Full path to cachedir, to store downloaded binpkgs\n"
|
|
|
|
" -d Debug mode shown to stderr\n"
|
|
|
|
" -D Print URLs when packages need to be downloaded\n"
|
|
|
|
" -F Force package removal even if there are reverse dependencies\n"
|
|
|
|
" -f Force package installation, configuration or removal\n"
|
|
|
|
" -h Print usage help\n"
|
|
|
|
" -M Enable Manual installation\n"
|
|
|
|
" -n Dry-run mode\n"
|
|
|
|
" -o key[,key] Print package metadata keys in show target\n"
|
|
|
|
" -R Remove recursively packages\n"
|
|
|
|
" -r rootdir Full path to rootdir\n"
|
2012-05-31 11:38:32 +05:30
|
|
|
" -S Sync repository index\n"
|
2012-02-14 15:05:33 +05:30
|
|
|
" -v Verbose messages\n"
|
|
|
|
" -y Assume yes to all questions\n"
|
|
|
|
" -V Show XBPS version\n\n"
|
|
|
|
"[targets]\n"
|
|
|
|
" check <pkgname|all>\n"
|
|
|
|
" Package integrity check for `pkgname' or `all' packages.\n"
|
2012-05-08 13:24:06 +05:30
|
|
|
" dist-upgrade\n"
|
|
|
|
" Update all currently installed packages to newest versions.\n"
|
2012-02-14 15:05:33 +05:30
|
|
|
" find-files <pattern> [patterns]\n"
|
|
|
|
" Print package name/version for any pattern matched.\n"
|
|
|
|
" install <pattern> [patterns]\n"
|
|
|
|
" Install package by specifying pkgnames or package patterns.\n"
|
|
|
|
" list [state]\n"
|
|
|
|
" List installed packages, and optionally matching `state'.\n"
|
|
|
|
" Possible states: half-removed, half-unpacked, installed, unpacked.\n"
|
|
|
|
" reconfigure <pkgname|all>\n"
|
|
|
|
" Reconfigure `pkgname' or `all' packages.\n"
|
|
|
|
" remove <pkgname> [pkgnames]\n"
|
|
|
|
" Remove a list of packages.\n"
|
2012-05-08 13:28:56 +05:30
|
|
|
" remove-orphans\n"
|
|
|
|
" Remove all package orphans from system.\n"
|
2012-02-14 15:05:33 +05:30
|
|
|
" show <pkgname>\n"
|
|
|
|
" Print package information for `pkgname'.\n"
|
|
|
|
" show-deps <pkgname>\n"
|
|
|
|
" Print package's required dependencies for `pkgname'.\n"
|
|
|
|
" show-files <pkgname>\n"
|
|
|
|
" Print package's files list for `pkgname'.\n"
|
|
|
|
" show-orphans\n"
|
|
|
|
" List all package orphans currently installed.\n"
|
|
|
|
" show-revdeps <pkgname>\n"
|
|
|
|
" Print package's reverse dependencies for `pkgname'.\n"
|
|
|
|
" update <pkgname> [pkgnames]\n"
|
|
|
|
" Update a list of packages by specifing its names.\n\n"
|
|
|
|
"Refer to xbps-bin(8) for a more detailed description.\n");
|
|
|
|
|
|
|
|
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
|
2011-01-15 16:29:44 +05:30
|
|
|
static void __attribute__((noreturn))
|
2010-01-21 07:40:19 +05:30
|
|
|
cleanup(int signum)
|
|
|
|
{
|
2012-06-14 13:41:50 +05:30
|
|
|
xbps_end(&xh);
|
2010-01-21 07:40:19 +05:30
|
|
|
exit(signum);
|
|
|
|
}
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2011-07-27 21:34:38 +05:30
|
|
|
struct xferstat xfer;
|
2010-11-24 21:07:30 +05:30
|
|
|
struct list_pkgver_cb lpc;
|
2009-10-23 14:50:25 +05:30
|
|
|
struct sigaction sa;
|
2011-12-15 15:49:20 +05:30
|
|
|
const char *rootdir, *cachedir, *conffile, *option;
|
2011-11-27 13:35:18 +05:30
|
|
|
int i, c, flags, rv;
|
2012-05-31 11:38:32 +05:30
|
|
|
bool sync, yes, reqby_force, force_rm_with_deps, recursive_rm;
|
2012-02-03 19:23:28 +05:30
|
|
|
bool reinstall, show_download_pkglist_url, dry_run;
|
2009-10-28 08:09:13 +05:30
|
|
|
|
2011-12-15 15:49:20 +05:30
|
|
|
rootdir = cachedir = conffile = option = NULL;
|
2011-02-03 22:19:43 +05:30
|
|
|
flags = rv = 0;
|
2012-05-31 11:38:32 +05:30
|
|
|
reqby_force = sync = yes = dry_run = force_rm_with_deps = false;
|
2012-01-22 15:22:35 +05:30
|
|
|
recursive_rm = reinstall = show_download_pkglist_url = false;
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-05-31 11:38:32 +05:30
|
|
|
while ((c = getopt(argc, argv, "AC:c:dDFfhMno:Rr:SVvy")) != -1) {
|
2009-08-17 22:37:20 +05:30
|
|
|
switch (c) {
|
2011-02-26 15:44:05 +05:30
|
|
|
case 'A':
|
2012-01-22 15:22:35 +05:30
|
|
|
flags |= XBPS_FLAG_INSTALL_AUTO;
|
2011-02-26 15:44:05 +05:30
|
|
|
break;
|
2011-06-04 17:07:53 +05:30
|
|
|
case 'C':
|
2011-12-15 15:49:20 +05:30
|
|
|
conffile = optarg;
|
2011-06-04 17:07:53 +05:30
|
|
|
break;
|
2009-11-28 07:08:41 +05:30
|
|
|
case 'c':
|
2011-02-21 22:12:47 +05:30
|
|
|
cachedir = optarg;
|
2009-11-28 07:08:41 +05:30
|
|
|
break;
|
2010-11-19 18:10:13 +05:30
|
|
|
case 'd':
|
2012-01-22 15:22:35 +05:30
|
|
|
flags |= XBPS_FLAG_DEBUG;
|
2010-11-19 18:10:13 +05:30
|
|
|
break;
|
2011-01-27 19:06:33 +05:30
|
|
|
case 'D':
|
|
|
|
show_download_pkglist_url = true;
|
|
|
|
break;
|
2010-12-03 22:06:07 +05:30
|
|
|
case 'F':
|
|
|
|
force_rm_with_deps = true;
|
|
|
|
break;
|
2009-08-17 22:37:20 +05:30
|
|
|
case 'f':
|
2011-12-20 20:38:23 +05:30
|
|
|
reinstall = true;
|
2011-11-24 16:20:53 +05:30
|
|
|
flags |= XBPS_FLAG_FORCE_CONFIGURE;
|
|
|
|
flags |= XBPS_FLAG_FORCE_REMOVE_FILES;
|
2009-08-17 22:37:20 +05:30
|
|
|
break;
|
2012-02-14 15:05:33 +05:30
|
|
|
case 'h':
|
|
|
|
usage(false);
|
|
|
|
break;
|
2011-02-26 15:44:05 +05:30
|
|
|
case 'M':
|
2012-01-22 15:22:35 +05:30
|
|
|
flags |= XBPS_FLAG_INSTALL_MANUAL;
|
2011-02-26 15:44:05 +05:30
|
|
|
break;
|
2012-02-03 19:23:28 +05:30
|
|
|
case 'n':
|
|
|
|
dry_run = true;
|
|
|
|
break;
|
2011-10-29 11:47:54 +05:30
|
|
|
case 'o':
|
|
|
|
option = optarg;
|
|
|
|
break;
|
2011-01-30 12:38:34 +05:30
|
|
|
case 'R':
|
|
|
|
recursive_rm = true;
|
|
|
|
break;
|
2009-08-17 22:37:20 +05:30
|
|
|
case 'r':
|
|
|
|
/* To specify the root directory */
|
2011-02-21 22:12:47 +05:30
|
|
|
rootdir = optarg;
|
2009-08-17 22:37:20 +05:30
|
|
|
break;
|
2012-05-31 11:38:32 +05:30
|
|
|
case 'S':
|
|
|
|
sync = true;
|
|
|
|
break;
|
2009-08-17 22:37:20 +05:30
|
|
|
case 'v':
|
|
|
|
flags |= XBPS_FLAG_VERBOSE;
|
|
|
|
break;
|
2009-10-18 14:12:04 +05:30
|
|
|
case 'V':
|
|
|
|
printf("%s\n", XBPS_RELVER);
|
|
|
|
exit(EXIT_SUCCESS);
|
2009-12-22 19:13:38 +05:30
|
|
|
case 'y':
|
|
|
|
yes = true;
|
|
|
|
break;
|
2009-08-17 22:37:20 +05:30
|
|
|
case '?':
|
|
|
|
default:
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
if (argc < 1)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2011-02-26 15:44:05 +05:30
|
|
|
/* Specifying -A and -M is illegal */
|
2012-01-22 15:22:35 +05:30
|
|
|
if ((flags & XBPS_FLAG_INSTALL_AUTO) &&
|
|
|
|
(flags & XBPS_FLAG_INSTALL_MANUAL)) {
|
2011-02-26 15:44:05 +05:30
|
|
|
xbps_error_printf("xbps-bin: -A and -M options cannot be "
|
|
|
|
"used together!\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2010-11-19 18:10:13 +05:30
|
|
|
/*
|
2011-12-15 15:49:20 +05:30
|
|
|
* Initialize libxbps.
|
2010-11-19 18:10:13 +05:30
|
|
|
*/
|
2012-01-17 20:47:03 +05:30
|
|
|
memset(&xh, 0, sizeof(xh));
|
|
|
|
xh.state_cb = state_cb;
|
|
|
|
xh.fetch_cb = fetch_file_progress_cb;
|
|
|
|
xh.fetch_cb_data = &xfer;
|
|
|
|
xh.rootdir = rootdir;
|
|
|
|
xh.cachedir = cachedir;
|
|
|
|
xh.conffile = conffile;
|
|
|
|
xh.flags = flags;
|
2011-02-21 18:08:44 +05:30
|
|
|
if (flags & XBPS_FLAG_VERBOSE)
|
2012-01-17 20:47:03 +05:30
|
|
|
xh.unpack_cb = unpack_progress_cb_verbose;
|
2011-02-24 14:48:24 +05:30
|
|
|
else
|
2012-01-17 20:47:03 +05:30
|
|
|
xh.unpack_cb = unpack_progress_cb;
|
2011-10-17 16:07:15 +05:30
|
|
|
|
2012-01-17 20:47:03 +05:30
|
|
|
if ((rv = xbps_init(&xh)) != 0) {
|
2011-06-04 17:07:53 +05:30
|
|
|
xbps_error_printf("xbps-bin: couldn't initialize library: %s\n",
|
2011-12-15 15:49:20 +05:30
|
|
|
strerror(rv));
|
2011-06-04 17:07:53 +05:30
|
|
|
exit(EXIT_FAILURE);
|
2010-11-26 02:03:14 +05:30
|
|
|
}
|
|
|
|
|
2011-12-24 05:35:26 +05:30
|
|
|
/*
|
|
|
|
* Register a signal handler to clean up resources used by libxbps.
|
|
|
|
*/
|
|
|
|
memset(&sa, 0, sizeof(sa));
|
|
|
|
sa.sa_handler = cleanup;
|
2012-06-14 13:41:50 +05:30
|
|
|
sigaction(SIGHUP, &sa, NULL);
|
2011-12-24 05:35:26 +05:30
|
|
|
sigaction(SIGINT, &sa, NULL);
|
|
|
|
sigaction(SIGTERM, &sa, NULL);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
if (strcasecmp(argv[0], "list") == 0) {
|
|
|
|
/* Lists packages currently registered in database. */
|
2010-10-27 16:40:03 +05:30
|
|
|
if (argc < 1 || argc > 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2011-12-03 15:07:31 +05:30
|
|
|
lpc.check_state = true;
|
2010-11-24 21:09:14 +05:30
|
|
|
lpc.state = 0;
|
2010-10-27 16:40:03 +05:30
|
|
|
if (argv[1]) {
|
|
|
|
if (strcmp(argv[1], "installed") == 0)
|
2010-11-24 21:07:30 +05:30
|
|
|
lpc.state = XBPS_PKG_STATE_INSTALLED;
|
2011-07-28 19:55:01 +05:30
|
|
|
if (strcmp(argv[1], "half-unpacked") == 0)
|
|
|
|
lpc.state = XBPS_PKG_STATE_HALF_UNPACKED;
|
2010-10-27 16:40:03 +05:30
|
|
|
else if (strcmp(argv[1], "unpacked") == 0)
|
2010-11-24 21:07:30 +05:30
|
|
|
lpc.state = XBPS_PKG_STATE_UNPACKED;
|
2011-12-24 05:35:26 +05:30
|
|
|
else if (strcmp(argv[1], "half-removed") == 0)
|
|
|
|
lpc.state = XBPS_PKG_STATE_HALF_REMOVED;
|
2010-10-27 16:40:03 +05:30
|
|
|
else {
|
2012-02-25 15:00:15 +05:30
|
|
|
xbps_error_printf(
|
|
|
|
"invalid state `%s'. Accepted values: "
|
2011-12-24 05:35:26 +05:30
|
|
|
"half-removed, unpacked, half-unpacked, "
|
2010-10-27 16:40:03 +05:30
|
|
|
"installed [default]\n", argv[1]);
|
|
|
|
rv = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-11-24 21:07:30 +05:30
|
|
|
/*
|
|
|
|
* Find the longest pkgver string to pretty print the output.
|
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
lpc.pkgver_len = find_longest_pkgver(&xh, NULL);
|
|
|
|
rv = xbps_pkgdb_foreach_cb(&xh, list_pkgs_in_dict, &lpc);
|
2011-12-22 19:11:40 +05:30
|
|
|
if (rv == ENOENT) {
|
|
|
|
printf("No packages currently registered.\n");
|
|
|
|
rv = 0;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "install") == 0) {
|
|
|
|
/* Installs a binary package and required deps. */
|
2009-12-22 17:07:36 +05:30
|
|
|
if (argc < 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
if (sync && ((rv = xbps_rpool_sync(&xh, NULL)) != 0))
|
2012-05-31 11:38:32 +05:30
|
|
|
goto out;
|
|
|
|
|
2009-12-22 17:07:36 +05:30
|
|
|
for (i = 1; i < argc; i++)
|
2012-06-14 11:52:11 +05:30
|
|
|
if ((rv = install_new_pkg(&xh, argv[i], reinstall)) != 0)
|
2009-12-22 17:07:36 +05:30
|
|
|
goto out;
|
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = exec_transaction(&xh, yes, dry_run, show_download_pkglist_url);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "update") == 0) {
|
|
|
|
/* Update an installed package. */
|
2009-12-22 17:07:36 +05:30
|
|
|
if (argc < 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
if (sync && ((rv = xbps_rpool_sync(&xh, NULL)) != 0))
|
2012-05-31 11:38:32 +05:30
|
|
|
goto out;
|
|
|
|
|
2009-12-22 17:07:36 +05:30
|
|
|
for (i = 1; i < argc; i++)
|
2012-06-14 11:52:11 +05:30
|
|
|
if ((rv = update_pkg(&xh, argv[i])) != 0)
|
2009-12-22 17:07:36 +05:30
|
|
|
goto out;
|
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = exec_transaction(&xh, yes, dry_run, show_download_pkglist_url);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "remove") == 0) {
|
2011-11-27 13:35:18 +05:30
|
|
|
/* Removes a package. */
|
2009-12-22 17:07:36 +05:30
|
|
|
if (argc < 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2011-11-27 13:35:18 +05:30
|
|
|
for (i = 1; i < argc; i++) {
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = remove_pkg(&xh, argv[i], recursive_rm);
|
2011-11-27 13:35:18 +05:30
|
|
|
if (rv == 0)
|
|
|
|
continue;
|
|
|
|
else if (rv != EEXIST)
|
|
|
|
goto out;
|
2011-11-27 14:29:39 +05:30
|
|
|
else
|
|
|
|
reqby_force = true;
|
2011-11-27 13:35:18 +05:30
|
|
|
}
|
|
|
|
if (reqby_force && !force_rm_with_deps) {
|
|
|
|
rv = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = exec_transaction(&xh, yes, dry_run, false);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "show") == 0) {
|
|
|
|
/* Shows info about an installed binary package. */
|
|
|
|
if (argc != 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = show_pkg_info_from_metadir(&xh, argv[1], option);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (rv != 0) {
|
|
|
|
printf("Package %s not installed.\n", argv[1]);
|
2009-10-23 17:31:54 +05:30
|
|
|
goto out;
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
|
2009-10-06 03:36:59 +05:30
|
|
|
} else if (strcasecmp(argv[0], "show-files") == 0) {
|
2009-08-17 22:37:20 +05:30
|
|
|
/* Shows files installed by a binary package. */
|
|
|
|
if (argc != 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = show_pkg_files_from_metadir(&xh, argv[1]);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (rv != 0) {
|
|
|
|
printf("Package %s not installed.\n", argv[1]);
|
2009-10-23 17:31:54 +05:30
|
|
|
goto out;
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "check") == 0) {
|
|
|
|
/* Checks the integrity of an installed package. */
|
|
|
|
if (argc != 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-10-06 04:12:37 +05:30
|
|
|
if (strcasecmp(argv[1], "all") == 0)
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = check_pkg_integrity_all(&xh);
|
2009-10-06 04:12:37 +05:30
|
|
|
else
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = check_pkg_integrity(&xh, NULL, argv[1], true, NULL);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-05-08 13:39:01 +05:30
|
|
|
} else if ((strcasecmp(argv[0], "dist-upgrade") == 0) ||
|
|
|
|
(strcasecmp(argv[0], "autoupdate") == 0)) {
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* To update all packages currently installed.
|
|
|
|
*/
|
|
|
|
if (argc != 1)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
if (sync && ((rv = xbps_rpool_sync(&xh, NULL)) != 0))
|
2012-05-31 11:38:32 +05:30
|
|
|
goto out;
|
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = dist_upgrade(&xh, yes, dry_run, show_download_pkglist_url);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2010-05-04 20:34:36 +05:30
|
|
|
} else if (strcasecmp(argv[0], "show-orphans") == 0) {
|
|
|
|
/*
|
|
|
|
* Only show the package name of all currently package
|
|
|
|
* orphans.
|
|
|
|
*/
|
|
|
|
if (argc != 1)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2010-05-04 20:34:36 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = show_orphans(&xh);
|
2010-05-04 20:34:36 +05:30
|
|
|
|
2012-05-08 13:39:01 +05:30
|
|
|
} else if ((strcasecmp(argv[0], "remove-orphans") == 0) ||
|
|
|
|
(strcasecmp(argv[0], "autoremove") == 0)) {
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* Removes orphan pkgs. These packages were installed
|
|
|
|
* as dependency and any installed package does not depend
|
|
|
|
* on it currently.
|
|
|
|
*/
|
|
|
|
if (argc != 1)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = remove_pkg_orphans(&xh, yes, dry_run);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
} else if (strcasecmp(argv[0], "reconfigure") == 0) {
|
|
|
|
/*
|
|
|
|
* Reconfigure a package.
|
|
|
|
*/
|
|
|
|
if (argc != 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-08-21 15:01:26 +05:30
|
|
|
if (strcasecmp(argv[1], "all") == 0)
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = xbps_configure_packages(&xh, true);
|
2009-08-21 15:01:26 +05:30
|
|
|
else
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = xbps_configure_pkg(&xh, argv[1], true, false, true);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-08-22 04:42:19 +05:30
|
|
|
} else if (strcasecmp(argv[0], "show-deps") == 0) {
|
|
|
|
/*
|
|
|
|
* Show dependencies for a package.
|
|
|
|
*/
|
|
|
|
if (argc != 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-22 04:42:19 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = show_pkg_deps(&xh, argv[1]);
|
2009-08-22 04:42:19 +05:30
|
|
|
|
2009-11-09 07:29:19 +05:30
|
|
|
} else if (strcasecmp(argv[0], "list-manual") == 0) {
|
2009-10-28 08:09:13 +05:30
|
|
|
/*
|
2009-11-09 07:29:19 +05:30
|
|
|
* List packages that were installed manually, not as
|
2009-10-28 08:09:13 +05:30
|
|
|
* dependencies.
|
|
|
|
*/
|
|
|
|
if (argc != 1)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-10-28 08:09:13 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = xbps_pkgdb_foreach_cb(&xh, list_manual_pkgs, NULL);
|
2010-11-19 18:10:13 +05:30
|
|
|
|
2009-08-22 04:42:19 +05:30
|
|
|
} else if (strcasecmp(argv[0], "show-revdeps") == 0) {
|
|
|
|
/*
|
|
|
|
* Show reverse dependencies for a package.
|
|
|
|
*/
|
|
|
|
if (argc != 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-22 04:42:19 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = show_pkg_reverse_deps(&xh, argv[1]);
|
2009-08-22 04:42:19 +05:30
|
|
|
|
2010-10-27 03:55:02 +05:30
|
|
|
} else if (strcasecmp(argv[0], "find-files") == 0) {
|
|
|
|
/*
|
|
|
|
* Find files matched by a pattern from installed
|
|
|
|
* packages.
|
|
|
|
*/
|
2011-12-22 15:15:13 +05:30
|
|
|
if (argc < 2)
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2010-10-27 03:55:02 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = find_files_in_packages(&xh, argc, argv);
|
2010-10-27 03:55:02 +05:30
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
} else {
|
2012-02-14 15:05:33 +05:30
|
|
|
usage(true);
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_end(&xh);
|
2011-01-30 22:53:33 +05:30
|
|
|
exit(rv);
|
2009-10-23 14:50:25 +05:30
|
|
|
}
|