xbps-pkgdb: new option -m --mode <auto|manual> to change pkg install mode.
This commit is contained in:
parent
9ab97aa2cf
commit
0c50c0bb2d
4
NEWS
4
NEWS
@ -1,5 +1,9 @@
|
||||
xbps-0.21 (???):
|
||||
|
||||
* xbps-pkgdb(8): new option -m --mode to change package installation
|
||||
mode to auto (might be detected as orphan) or manual
|
||||
(explicitly installed).
|
||||
|
||||
* xbps-query(8): the search mode (-s, --search) now is able to find
|
||||
packages by matching virtual package strings, i.e:
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Juan Romero Pardines.
|
||||
* Copyright (c) 2013 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -29,6 +29,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
#include "defs.h"
|
||||
@ -39,32 +40,53 @@ usage(bool fail)
|
||||
fprintf(stdout,
|
||||
"Usage: xbps-pkgdb [OPTIONS] [PKGNAME...]\n\n"
|
||||
"OPTIONS\n"
|
||||
" -a --all Process all packages\n"
|
||||
" -C --config <file> Full path to configuration file\n"
|
||||
" -d --debug Debug mode shown to stderr\n"
|
||||
" -h --help Print usage help\n"
|
||||
" -r --rootdir <dir> Full path to rootdir\n"
|
||||
" -v --verbose Verbose messages\n"
|
||||
" -V --version Show XBPS version\n");
|
||||
" -a --all Process all packages\n"
|
||||
" -C --config <file> Full path to configuration file\n"
|
||||
" -d --debug Debug mode shown to stderr\n"
|
||||
" -h --help Print usage help\n"
|
||||
" -m --mode <auto|manual> Change PKGNAME to automatic or manual mode\n"
|
||||
" -r --rootdir <dir> Full path to rootdir\n"
|
||||
" -v --verbose Verbose messages\n"
|
||||
" -V --version Show XBPS version\n");
|
||||
exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static int
|
||||
change_pkg_instmode(struct xbps_handle *xhp,
|
||||
const char *pkgname,
|
||||
const char *modestr)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
bool mode = false;
|
||||
|
||||
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
|
||||
if (pkgd == NULL)
|
||||
return errno;
|
||||
|
||||
if (strcmp(modestr, "auto") == 0)
|
||||
mode = true;
|
||||
|
||||
prop_dictionary_set_bool(pkgd, "automatic-install", mode);
|
||||
return xbps_pkgdb_update(xhp, true);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const char *shortopts = "aC:dhr:Vv";
|
||||
const char *shortopts = "aC:dhm:r:Vv";
|
||||
const struct option longopts[] = {
|
||||
{ "all", no_argument, NULL, 'a' },
|
||||
{ "config", required_argument, NULL, 'C' },
|
||||
{ "debug", no_argument, NULL, 'd' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "mode", required_argument, NULL, 'm' },
|
||||
{ "rootdir", required_argument, NULL, 'r' },
|
||||
{ "verbose", no_argument, NULL, 'v' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
struct xbps_handle xh;
|
||||
const char *conffile = NULL, *rootdir = NULL;
|
||||
const char *conffile = NULL, *rootdir = NULL, *instmode = NULL;
|
||||
int c, i, rv, flags = 0;
|
||||
bool all = false;
|
||||
|
||||
@ -82,6 +104,9 @@ main(int argc, char **argv)
|
||||
case 'h':
|
||||
usage(false);
|
||||
/* NOTREACHED */
|
||||
case 'm':
|
||||
instmode = optarg;
|
||||
break;
|
||||
case 'r':
|
||||
rootdir = optarg;
|
||||
break;
|
||||
@ -111,7 +136,25 @@ main(int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (all) {
|
||||
if (instmode) {
|
||||
if ((strcmp(instmode, "auto")) && (strcmp(instmode, "manual")))
|
||||
usage(true);
|
||||
|
||||
if (argc == optind) {
|
||||
fprintf(stderr,
|
||||
"xbps-pkgdb: missing PKGNAME argument\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
for (i = optind; i < argc; i++) {
|
||||
rv = change_pkg_instmode(&xh, argv[i], instmode);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "xbps-pkgdb: failed to "
|
||||
"change to %s mode to %s: %s\n",
|
||||
instmode, argv[i], strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
} else if (all) {
|
||||
rv = check_pkg_integrity_all(&xh);
|
||||
} else {
|
||||
for (i = optind; i < argc; i++) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
.Dd November 6, 2012
|
||||
.Dd February 20, 2013
|
||||
.Os Void Linux
|
||||
.Dt xbps-pkgdb 8
|
||||
.Sh NAME
|
||||
.Nm xbps-pkgdb
|
||||
.Nd XBPS utility to report and fix issues in pkgdb
|
||||
.Nd XBPS utility to report/fix issues and modify the package database (pkgdb)
|
||||
.Sh SYNOPSYS
|
||||
.Nm xbps-pkgdb
|
||||
.Op OPTIONS
|
||||
@ -11,10 +11,9 @@
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility checks and fix issues in the package database (pkgdb).
|
||||
It's able to check missing dependencies, modified files and symlinks,
|
||||
fix wrong or missing reverse dependencies, and more errors that have been
|
||||
fixed in newer versions of xbps.
|
||||
utility can check/fix issues and modify the package database (pkgdb).
|
||||
It's able to check for missing dependencies, modified files and symlinks,
|
||||
and more errors that have been fixed in newer versions of xbps.
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width -x
|
||||
.It Fl a, Fl -all
|
||||
@ -25,6 +24,10 @@ Specifies a full path to the XBPS configuration file.
|
||||
Enables extra debugging shown to stderr.
|
||||
.It Fl h, Fl -help
|
||||
Show the help usage.
|
||||
.It Fl m, Fl -mode Ar auto|manual
|
||||
Switches
|
||||
.Ar PKGNAME
|
||||
to the specified installation mode: automatic or manual mode.
|
||||
.It Fl r, Fl -rootdir Ar dir
|
||||
Specifies a full path for the target root directory.
|
||||
.It Fl v, Fl -verbose
|
||||
|
Loading…
Reference in New Issue
Block a user