diff --git a/NEWS b/NEWS index e986e871..a2e5d7d8 100644 --- a/NEWS +++ b/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: diff --git a/bin/xbps-pkgdb/main.c b/bin/xbps-pkgdb/main.c index 78c2c2c8..7a42b1ad 100644 --- a/bin/xbps-pkgdb/main.c +++ b/bin/xbps-pkgdb/main.c @@ -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 #include #include +#include #include #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 Full path to configuration file\n" - " -d --debug Debug mode shown to stderr\n" - " -h --help Print usage help\n" - " -r --rootdir Full path to rootdir\n" - " -v --verbose Verbose messages\n" - " -V --version Show XBPS version\n"); + " -a --all Process all packages\n" + " -C --config Full path to configuration file\n" + " -d --debug Debug mode shown to stderr\n" + " -h --help Print usage help\n" + " -m --mode Change PKGNAME to automatic or manual mode\n" + " -r --rootdir 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++) { diff --git a/bin/xbps-pkgdb/xbps-pkgdb.8 b/bin/xbps-pkgdb/xbps-pkgdb.8 index d8ddf83d..fe62afbd 100644 --- a/bin/xbps-pkgdb/xbps-pkgdb.8 +++ b/bin/xbps-pkgdb/xbps-pkgdb.8 @@ -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