Shell wildcard patterns can now be used in the PackagesOnHold option.

This commit is contained in:
Juan RP 2012-11-11 16:11:40 +01:00
parent a77727887d
commit 58333419a0
3 changed files with 19 additions and 20 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.18 (???):
* Shell wildcard patterns (fnmatch(3)) can now be used in the
PackagesOnHold configuration option.
* New utilities replacing xbps-bin(8) and xbps-repo(8):
- xbps-install(8): to install and update packages.

View File

@ -55,11 +55,10 @@ repositories = {
# Packages on hold.
#
# Packages that are put on hold won't be updated even if there is a
# newer version in repository pool.
# newer version in repository pool. Package names and shell wildcards
# can be specified.
#
# This expects package names and separated by commas.
#
#PackagesOnHold = { glibc, xbps }
#PackagesOnHold = { "glibc-*" }
# Virtual packages.
#

View File

@ -28,6 +28,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fnmatch.h>
#include "xbps_api_impl.h"
@ -72,21 +73,11 @@ transaction_find_pkg(struct xbps_handle *xhp,
assert(pkg != NULL);
if (action == TRANS_INSTALL) {
/* install */
reason = "install";
} else {
/* update */
if ((pkg_pkgdb = xbps_pkgdb_get_pkgd(xhp, pkg, false)) == NULL)
return ENODEV;
reason = "update";
}
/*
* Find out if the pkg has been found in repository pool.
*/
if (action == TRANS_INSTALL) {
reason = "install";
if (exact) {
pkg_repod = xbps_rpool_find_pkg_exact(xhp, pkg);
if (pkg_repod == NULL) {
@ -102,6 +93,10 @@ transaction_find_pkg(struct xbps_handle *xhp,
}
}
} else {
if ((pkg_pkgdb = xbps_pkgdb_get_pkgd(xhp, pkg, false)) == NULL)
return ENODEV;
reason = "update";
pkg_repod = xbps_rpool_find_pkg(xhp, pkg, false, true);
if (pkg_repod == NULL) {
/* not found */
@ -202,7 +197,7 @@ int
xbps_transaction_update_packages(struct xbps_handle *xhp)
{
prop_object_t obj;
const char *pkgname, *holdpkgname;
const char *pkgname, *holdpkg;
bool foundhold = false, newpkg_found = false;
int rv = 0;
size_t i, x;
@ -213,11 +208,13 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
for (i = 0; i < prop_array_count(xhp->pkgdb); i++) {
obj = prop_array_get(xhp->pkgdb, i);
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
for (x = 0; x < cfg_size(xhp->cfg, "PackagesOnHold"); x++) {
holdpkgname = cfg_getnstr(xhp->cfg, "PackagesOnHold", x);
if (strcmp(pkgname, holdpkgname) == 0) {
xbps_dbg_printf(xhp, "[rpool] package %s on hold, "
"ignoring updates.\n", pkgname);
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' "
"on hold, ignoring updates.\n", pkgname);
foundhold = true;
break;
}