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