xbps-reconfigure(8): new option -i, --ignore to ignore pkgs with -a, --all.
-i, --ignore can be specified multiple times and can be used to ignore configuration of those packages while configuration of all packages is being performed. Close #67
This commit is contained in:
parent
925ec15c3d
commit
c8ecf4ac6c
4
NEWS
4
NEWS
@ -1,5 +1,9 @@
|
||||
xbps-0.42 (???):
|
||||
|
||||
* xbps-reconfigure(8): new option -i, --ignore to ignore packages
|
||||
while performing configuration of all packages with -a, --all.
|
||||
Fix #67 (https://github.com/voidlinux/xbps/issues/67)
|
||||
|
||||
* xbps-{install,query}: fix alignment in the column output mode
|
||||
when pkgname is shorter than 4 chars. Fix #71 (https://github.com/voidlinux/xbps/issues/71)
|
||||
|
||||
|
@ -91,13 +91,14 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbd _unused)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
const char *shortopts = "aC:dfhr:Vv";
|
||||
const char *shortopts = "aC:dfhi:r:Vv";
|
||||
const struct option longopts[] = {
|
||||
{ "all", no_argument, NULL, 'a' },
|
||||
{ "config", required_argument, NULL, 'C' },
|
||||
{ "debug", no_argument, NULL, 'd' },
|
||||
{ "force", no_argument, NULL, 'f' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "ignore", required_argument, NULL, 'i' },
|
||||
{ "rootdir", required_argument, NULL, 'r' },
|
||||
{ "verbose", no_argument, NULL, 'v' },
|
||||
{ "version", no_argument, NULL, 'V' },
|
||||
@ -107,6 +108,7 @@ main(int argc, char **argv)
|
||||
const char *confdir = NULL, *rootdir = NULL;
|
||||
int c, i, rv, flags = 0;
|
||||
bool all = false;
|
||||
xbps_array_t ignpkgs = NULL;
|
||||
|
||||
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
|
||||
switch (c) {
|
||||
@ -125,6 +127,12 @@ main(int argc, char **argv)
|
||||
case 'h':
|
||||
usage(false);
|
||||
/* NOTREACHED */
|
||||
case 'i':
|
||||
if (ignpkgs == NULL)
|
||||
ignpkgs = xbps_array_create();
|
||||
|
||||
xbps_array_add_cstring_nocopy(ignpkgs, optarg);
|
||||
break;
|
||||
case 'r':
|
||||
rootdir = optarg;
|
||||
break;
|
||||
@ -164,7 +172,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (all) {
|
||||
rv = xbps_configure_packages(&xh);
|
||||
rv = xbps_configure_packages(&xh, ignpkgs);
|
||||
} else {
|
||||
for (i = optind; i < argc; i++) {
|
||||
rv = xbps_configure_pkg(&xh, argv[i], true, false);
|
||||
|
@ -45,6 +45,15 @@ Enables extra debugging shown to stderr.
|
||||
Forcefully reconfigure package even if it was configured previously.
|
||||
.It Fl h, Fl -help
|
||||
Show the help usage.
|
||||
.It Fl i, Fl -ignore Ar PKG
|
||||
Ignore
|
||||
.Ar PKG
|
||||
when configuring all packages with
|
||||
.Fl a, Fl -all .
|
||||
The
|
||||
.Ar PKG
|
||||
argument can be a package name or a package name with version.
|
||||
This option can be specified multiple times.
|
||||
.It Fl r, Fl -rootdir Ar dir
|
||||
Specifies a path for the target root directory.
|
||||
.It Fl v, Fl -verbose
|
||||
|
@ -48,7 +48,7 @@
|
||||
*
|
||||
* This header documents the full API for the XBPS Library.
|
||||
*/
|
||||
#define XBPS_API_VERSION "20141127"
|
||||
#define XBPS_API_VERSION "20141209"
|
||||
|
||||
#ifndef XBPS_VERSION
|
||||
#define XBPS_VERSION "UNSET"
|
||||
@ -655,10 +655,11 @@ int xbps_configure_pkg(struct xbps_handle *xhp, const char *pkgname,
|
||||
* Configure (or force reconfiguration of) all packages.
|
||||
*
|
||||
* @param[in] xhp Pointer to an xbps_handle struct.
|
||||
* @param[in] ignpkgs Proplib array of strings with pkgname or pkgvers to ignore.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_configure_packages(struct xbps_handle *xhp);
|
||||
int xbps_configure_packages(struct xbps_handle *xhp, xbps_array_t ignpkgs);
|
||||
|
||||
/*@}*/
|
||||
|
||||
@ -986,6 +987,16 @@ bool xbps_match_any_virtualpkg_in_rundeps(xbps_array_t rundeps,
|
||||
*/
|
||||
bool xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname);
|
||||
|
||||
/**
|
||||
* Match a package name/version in the specified array of strings with pkgnames.
|
||||
*
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pkgname The package name/version to match.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_match_pkgver_in_array(xbps_array_t array, const char *pkgver);
|
||||
|
||||
/**
|
||||
* Match a package pattern in the specified array of strings.
|
||||
*
|
||||
|
@ -46,7 +46,7 @@
|
||||
* state is XBPS_PKG_STATE_INSTALLED.
|
||||
*/
|
||||
int
|
||||
xbps_configure_packages(struct xbps_handle *xhp)
|
||||
xbps_configure_packages(struct xbps_handle *xhp, xbps_array_t ignpkgs)
|
||||
{
|
||||
xbps_dictionary_t pkgd;
|
||||
xbps_object_t obj;
|
||||
@ -62,6 +62,14 @@ xbps_configure_packages(struct xbps_handle *xhp)
|
||||
while ((obj = xbps_object_iterator_next(iter))) {
|
||||
pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj);
|
||||
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
if (xbps_array_count(ignpkgs)) {
|
||||
if ((xbps_match_string_in_array(ignpkgs, pkgver)) ||
|
||||
(xbps_match_pkgver_in_array(ignpkgs, pkgver))) {
|
||||
xbps_dbg_printf(xhp, "%s: ignoring pkg %s\n",
|
||||
__func__, pkgver);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
rv = xbps_configure_pkg(xhp, pkgver, true, false);
|
||||
if (rv != 0) {
|
||||
xbps_dbg_printf(xhp, "%s: failed to configure %s: %s\n",
|
||||
|
@ -128,7 +128,7 @@ match_string_in_array(xbps_array_t array, const char *str, int mode)
|
||||
break;
|
||||
}
|
||||
} else if (mode == 1) {
|
||||
/* match by pkgname */
|
||||
/* match by pkgname against pkgver */
|
||||
pkgdep = xbps_string_cstring_nocopy(obj);
|
||||
if (strchr(pkgdep, '_') == NULL) {
|
||||
tmp = xbps_xasprintf("%s_1", pkgdep);
|
||||
@ -146,6 +146,18 @@ match_string_in_array(xbps_array_t array, const char *str, int mode)
|
||||
}
|
||||
free(curpkgname);
|
||||
} else if (mode == 2) {
|
||||
/* match by pkgver against pkgname */
|
||||
pkgdep = xbps_string_cstring_nocopy(obj);
|
||||
curpkgname = xbps_pkg_name(str);
|
||||
if (curpkgname == NULL)
|
||||
break;
|
||||
if (strcmp(curpkgname, pkgdep) == 0) {
|
||||
free(curpkgname);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
free(curpkgname);
|
||||
} else if (mode == 3) {
|
||||
/* match pkgpattern against pkgdep */
|
||||
pkgdep = xbps_string_cstring_nocopy(obj);
|
||||
if (strchr(pkgdep, '_') == NULL) {
|
||||
@ -161,7 +173,7 @@ match_string_in_array(xbps_array_t array, const char *str, int mode)
|
||||
if (tmp != NULL)
|
||||
free(tmp);
|
||||
|
||||
} else if (mode == 3) {
|
||||
} else if (mode == 4) {
|
||||
/* match pkgdep against pkgpattern */
|
||||
pkgdep = xbps_string_cstring_nocopy(obj);
|
||||
if (strchr(pkgdep, '_') == NULL) {
|
||||
@ -195,14 +207,20 @@ xbps_match_pkgname_in_array(xbps_array_t array, const char *pkgname)
|
||||
return match_string_in_array(array, pkgname, 1);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_match_pkgver_in_array(xbps_array_t array, const char *pkgver)
|
||||
{
|
||||
return match_string_in_array(array, pkgver, 2);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_match_pkgpattern_in_array(xbps_array_t array, const char *pattern)
|
||||
{
|
||||
return match_string_in_array(array, pattern, 2);
|
||||
return match_string_in_array(array, pattern, 3);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_match_pkgdep_in_array(xbps_array_t array, const char *pkgver)
|
||||
{
|
||||
return match_string_in_array(array, pkgver, 3);
|
||||
return match_string_in_array(array, pkgver, 4);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user