Remove PackagesOnHold from xbps.conf; use xbps-pkgdb -m hold|unhold instead.

To put a package on hold mode:
	$ xbps-pkgdb -m hold foo

To unhold the package:
	$ xbps-pkgdb -m unhold foo

To list packages on hold mode:
	$ xbps-query -H

This also close #12 from github.
This commit is contained in:
Juan RP 2013-08-12 14:46:54 +02:00
parent 9c9d5b58dd
commit 776b94e6bc
11 changed files with 96 additions and 60 deletions

9
NEWS
View File

@ -1,5 +1,14 @@
xbps-0.26 (???): xbps-0.26 (???):
* Removed "PackagesOnHold" from xbps.conf. This has been replaced by a new mode
in xbps-pkgdb(8):
$ xbps-pkgdb -m <hold|unhold> <pkgname>
To list packages that are currently on hold mode use xbps-query(8):
$ xbps-query -H
* On terminals with 0 columns, assume 80. Xen's PV guest running Linux and its * On terminals with 0 columns, assume 80. Xen's PV guest running Linux and its
hvc console does report 0 columns/rows. hvc console does report 0 columns/rows.

View File

@ -44,7 +44,7 @@ usage(bool fail)
" -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"
" -m --mode <auto|manual> Change PKGNAME to automatic or manual mode\n" " -m --mode <auto|manual|hold|unhold> Change PKGNAME to this mode\n"
" -r --rootdir <dir> Full path to rootdir\n" " -r --rootdir <dir> Full path to rootdir\n"
" -u --update Update pkgdb to the latest format\n" " -u --update Update pkgdb to the latest format\n"
" -v --verbose Verbose messages\n" " -v --verbose Verbose messages\n"
@ -53,21 +53,25 @@ usage(bool fail)
} }
static int static int
change_pkg_instmode(struct xbps_handle *xhp, change_pkg_mode(struct xbps_handle *xhp, const char *pkgname, const char *mode)
const char *pkgname,
const char *modestr)
{ {
xbps_dictionary_t pkgd; xbps_dictionary_t pkgd;
bool mode = false;
pkgd = xbps_pkgdb_get_pkg(xhp, pkgname); pkgd = xbps_pkgdb_get_pkg(xhp, pkgname);
if (pkgd == NULL) if (pkgd == NULL)
return errno; return errno;
if (strcmp(modestr, "auto") == 0) if (strcmp(mode, "auto") == 0)
mode = true; xbps_dictionary_set_bool(pkgd, "automatic-install", true);
else if (strcmp(mode, "manual") == 0)
xbps_dictionary_set_bool(pkgd, "automatic-install", false);
else if (strcmp(mode, "hold") == 0)
xbps_dictionary_set_bool(pkgd, "hold", true);
else if (strcmp(mode, "unhold") == 0)
xbps_dictionary_remove(pkgd, "hold");
else
usage(true);
xbps_dictionary_set_bool(pkgd, "automatic-install", mode);
return xbps_pkgdb_update(xhp, true); return xbps_pkgdb_update(xhp, true);
} }
@ -144,16 +148,13 @@ main(int argc, char **argv)
if (update_format) if (update_format)
convert_pkgdb_format(&xh); convert_pkgdb_format(&xh);
else if (instmode) { else if (instmode) {
if ((strcmp(instmode, "auto")) && (strcmp(instmode, "manual")))
usage(true);
if (argc == optind) { if (argc == optind) {
fprintf(stderr, fprintf(stderr,
"xbps-pkgdb: missing PKGNAME argument\n"); "xbps-pkgdb: missing PKGNAME argument\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
for (i = optind; i < argc; i++) { for (i = optind; i < argc; i++) {
rv = change_pkg_instmode(&xh, argv[i], instmode); rv = change_pkg_mode(&xh, argv[i], instmode);
if (rv != 0) { if (rv != 0) {
fprintf(stderr, "xbps-pkgdb: failed to " fprintf(stderr, "xbps-pkgdb: failed to "
"change to %s mode to %s: %s\n", "change to %s mode to %s: %s\n",

View File

@ -1,4 +1,4 @@
.Dd March 4, 2013 .Dd August 12, 2013
.Os Void Linux .Os Void Linux
.Dt xbps-pkgdb 8 .Dt xbps-pkgdb 8
.Sh NAME .Sh NAME
@ -42,10 +42,19 @@ 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 .It Fl m, Fl -mode Ar auto|manual|hold|unhold
Switches Switches
.Ar PKGNAME .Ar PKGNAME
to the specified installation mode: automatic or manual mode. to the specified mode: automatic or manual installation mode, or to (un)set it on hold mode.
A package that was installed as dependency will be in
.Sy automatic
mode, otherwise will be set to
.Sy manual .
A package in
.Sy hold
mode won't be updated in full system upgrades. The list of packages in this mode can be
seen with
.Xr xbps-query 8 .
.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 u, Fl -update .It Fl u, Fl -update

View File

@ -61,6 +61,7 @@ unsigned int find_longest_pkgver(struct xbps_handle *, xbps_object_t);
int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_manual_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); int list_manual_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_hold_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_orphans(struct xbps_handle *); int list_orphans(struct xbps_handle *);
int list_pkgs_pkgdb(struct xbps_handle *); int list_pkgs_pkgdb(struct xbps_handle *);

View File

@ -116,6 +116,24 @@ list_manual_pkgs(struct xbps_handle *xhp,
return 0; return 0;
} }
int
list_hold_pkgs(struct xbps_handle *xhp, xbps_object_t obj,
const char *key, void *arg, bool *loop_done)
{
const char *pkgver;
(void)xhp;
(void)key;
(void)arg;
(void)loop_done;
if (xbps_dictionary_get(obj, "hold")) {
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s\n", pkgver);
}
return 0;
}
int int
list_orphans(struct xbps_handle *xhp) list_orphans(struct xbps_handle *xhp)
{ {

View File

@ -50,6 +50,7 @@ usage(bool fail)
"\nMODE [only one mode may be specified]\n" "\nMODE [only one mode may be specified]\n"
" -l --list-pkgs List available packages\n" " -l --list-pkgs List available packages\n"
" -L --list-repos List working repositories\n" " -L --list-repos List working repositories\n"
" -H --list-hold-pkgs List packages on hold state\n"
" -m --list-manual-pkgs List packages installed explicitly\n" " -m --list-manual-pkgs List packages installed explicitly\n"
" -O --list-orphans List package orphans\n" " -O --list-orphans List package orphans\n"
" -o --ownedby PATTERN(s) Search for packages owning PATTERN(s)\n" " -o --ownedby PATTERN(s) Search for packages owning PATTERN(s)\n"
@ -65,7 +66,7 @@ usage(bool fail)
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
const char *shortopts = "C:c:D:dfhLlmOop:Rr:sVvXx"; const char *shortopts = "C:c:D:dfhHLlmOop:Rr:sVvXx";
const struct option longopts[] = { const struct option longopts[] = {
{ "config", required_argument, NULL, 'C' }, { "config", required_argument, NULL, 'C' },
{ "cachedir", required_argument, NULL, 'c' }, { "cachedir", required_argument, NULL, 'c' },
@ -74,6 +75,7 @@ main(int argc, char **argv)
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "list-repos", no_argument, NULL, 'L' }, { "list-repos", no_argument, NULL, 'L' },
{ "list-pkgs", no_argument, NULL, 'l' }, { "list-pkgs", no_argument, NULL, 'l' },
{ "list-hold-pkgs", no_argument, NULL, 'H' },
{ "list-manual-pkgs", no_argument, NULL, 'm' }, { "list-manual-pkgs", no_argument, NULL, 'm' },
{ "list-orphans", no_argument, NULL, 'O' }, { "list-orphans", no_argument, NULL, 'O' },
{ "ownedby", no_argument, NULL, 'o' }, { "ownedby", no_argument, NULL, 'o' },
@ -92,12 +94,12 @@ main(int argc, char **argv)
const char *rootdir, *cachedir, *conffile, *props, *defrepo; const char *rootdir, *cachedir, *conffile, *props, *defrepo;
int c, flags, rv, show_deps = 0; int c, flags, rv, show_deps = 0;
bool list_pkgs, list_repos, orphans, own; bool list_pkgs, list_repos, orphans, own;
bool list_manual, show_prop, show_files, show_rdeps; bool list_manual, list_hold, show_prop, show_files, show_rdeps;
bool show, search, repo_mode, opmode, fulldeptree; bool show, search, repo_mode, opmode, fulldeptree;
rootdir = cachedir = conffile = defrepo = props = NULL; rootdir = cachedir = conffile = defrepo = props = NULL;
flags = rv = c = 0; flags = rv = c = 0;
list_pkgs = list_repos = orphans = search = own = false; list_pkgs = list_repos = list_hold = orphans = search = own = false;
list_manual = show_prop = show_files = false; list_manual = show_prop = show_files = false;
show = show_rdeps = fulldeptree = false; show = show_rdeps = fulldeptree = false;
repo_mode = opmode = false; repo_mode = opmode = false;
@ -119,6 +121,9 @@ main(int argc, char **argv)
case 'f': case 'f':
show_files = opmode = true; show_files = opmode = true;
break; break;
case 'H':
list_hold = true;
break;
case 'h': case 'h':
usage(false); usage(false);
/* NOTREACHED */ /* NOTREACHED */
@ -195,6 +200,10 @@ main(int argc, char **argv)
/* list repositories */ /* list repositories */
rv = repo_list(&xh); rv = repo_list(&xh);
} else if (list_hold) {
/* list on hold pkgs */
rv = xbps_pkgdb_foreach_cb(&xh, list_hold_pkgs, NULL);
} else if (list_manual) { } else if (list_manual) {
/* list manual pkgs */ /* list manual pkgs */
rv = xbps_pkgdb_foreach_cb(&xh, list_manual_pkgs, NULL); rv = xbps_pkgdb_foreach_cb(&xh, list_manual_pkgs, NULL);

View File

@ -1,4 +1,4 @@
.Dd July 26, 2013 .Dd August 12, 2013
.Os Void Linux .Os Void Linux
.Dt xbps-query 8 .Dt xbps-query 8
.Sh NAME .Sh NAME
@ -78,6 +78,8 @@ option is specified, the target
will be queried in the root directory, otherwise it will be will be queried in the root directory, otherwise it will be
queried in registered repositories. queried in registered repositories.
.Bl -tag -width -x .Bl -tag -width -x
.If Fl H, Fl -list-hold-pkgs
List packages that are put on hold, and won't be updated in full system upgrades.
.It Fl l, Fl -list-pkgs .It Fl l, Fl -list-pkgs
Lists registered packages in the package database (pkgdb). Lists registered packages in the package database (pkgdb).
A package can be in any of the following states: A package can be in any of the following states:

View File

@ -41,15 +41,6 @@ repositories = {
#http://xbps.nopcode.org/repos/current/nonfree #http://xbps.nopcode.org/repos/current/nonfree
} }
# Packages on hold.
#
# Packages that are put on hold won't be updated when running a full
# system upgrade, these packages must be updated manually.
#
# Package names and shell wildcards can be specified.
#
#PackagesOnHold = { "glibc-*" }
# Virtual packages. # Virtual packages.
# #
# The following syntax is used: # The following syntax is used:

View File

@ -127,7 +127,6 @@ xbps_init(struct xbps_handle *xhp)
XBPS_FETCH_TIMEOUT, CFGF_NONE), XBPS_FETCH_TIMEOUT, CFGF_NONE),
CFG_BOOL(__UNCONST("syslog"), true, CFGF_NONE), CFG_BOOL(__UNCONST("syslog"), true, CFGF_NONE),
CFG_STR_LIST(__UNCONST("repositories"), NULL, CFGF_MULTI), CFG_STR_LIST(__UNCONST("repositories"), NULL, CFGF_MULTI),
CFG_STR_LIST(__UNCONST("PackagesOnHold"), NULL, CFGF_MULTI),
CFG_SEC(__UNCONST("virtual-package"), CFG_SEC(__UNCONST("virtual-package"),
vpkg_opts, CFGF_MULTI|CFGF_TITLE), vpkg_opts, CFGF_MULTI|CFGF_TITLE),
CFG_FUNC(__UNCONST("include"), &cfg_include), CFG_FUNC(__UNCONST("include"), &cfg_include),

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2008-2012 Juan Romero Pardines. * Copyright (c) 2008-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
@ -237,12 +237,18 @@ find_repo_deps(struct xbps_handle *xhp,
if (rv == 0) { if (rv == 0) {
/* /*
* Package is installed but does not match * Package is installed but does not match
* the dependency pattern, update pkg. * the dependency pattern, update pkg if it's not
* on hold state.
*/ */
xbps_dbg_printf_append(xhp, xbps_dbg_printf_append(xhp,
"installed `%s', " "installed `%s', "
"must be updated.\n", pkgver_q); "must be updated.", pkgver_q);
if (xbps_dictionary_get(tmpd, "hold"))
xbps_dbg_printf_append(xhp, " on hold state! ignoring update.\n");
else {
xbps_dbg_printf_append(xhp, "\n");
reason = "update"; reason = "update";
}
} else if (rv == 1) { } else if (rv == 1) {
rv = 0; rv = 0;
if (state == XBPS_PKG_STATE_UNPACKED) { if (state == XBPS_PKG_STATE_UNPACKED) {

View File

@ -189,11 +189,10 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
xbps_dictionary_t pkgd; xbps_dictionary_t pkgd;
xbps_object_t obj; xbps_object_t obj;
xbps_object_iterator_t iter; xbps_object_iterator_t iter;
const char *pkgver, *holdpkg; const char *pkgver;
char *pkgname; char *pkgname = NULL;
bool foundhold = false, newpkg_found = false; bool hold, newpkg_found = false;
int rv = 0; int rv = 0;
unsigned int x;
if ((rv = xbps_pkgdb_init(xhp)) != 0) if ((rv = xbps_pkgdb_init(xhp)) != 0)
return rv; return rv;
@ -204,23 +203,15 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
while ((obj = xbps_object_iterator_next(iter))) { while ((obj = xbps_object_iterator_next(iter))) {
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj); pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
pkgname = xbps_pkg_name(pkgver); hold = false;
assert(pkgname); xbps_dictionary_get_bool(pkgd, "hold", &hold);
if (hold) {
for (x = 0; x < cfg_size(xhp->cfg, "PackagesOnHold"); x++) {
holdpkg = cfg_getnstr(xhp->cfg, "PackagesOnHold", x);
if ((strcmp(holdpkg, pkgname) == 0) ||
(fnmatch(holdpkg, pkgname, FNM_PERIOD) == 0)) {
xbps_dbg_printf(xhp, "[rpool] package `%s' " xbps_dbg_printf(xhp, "[rpool] package `%s' "
"on hold, ignoring updates.\n", pkgname); "on hold, ignoring updates.\n", pkgver);
foundhold = true;
break;
}
}
if (foundhold) {
foundhold = false;
continue; continue;
} }
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
rv = trans_find_pkg(xhp, pkgname, TRANS_UPDATE); rv = trans_find_pkg(xhp, pkgname, TRANS_UPDATE);
if (rv == 0) if (rv == 0)
newpkg_found = true; newpkg_found = true;