xbps-checkvers: added -d,--debug and -R,--repository=url options.

- -d, --debug new option to enable xbps debug output.
- --distdir short option has been changed to -D.
- -R, --repository=url new option to append repos to the xbps list.
This commit is contained in:
Juan RP 2014-04-17 10:31:00 +02:00
parent c2c149bd29
commit 5d0ffd8f03
2 changed files with 23 additions and 8 deletions

View File

@ -187,10 +187,12 @@ show_usage(const char *prog)
" -h,--help Show this helpful help-message for help.\n" " -h,--help Show this helpful help-message for help.\n"
" -C,--config=FILENAME Set (or override) the `xbps.conf' (which may\n" " -C,--config=FILENAME Set (or override) the `xbps.conf' (which may\n"
" have automatically been detected).\n" " have automatically been detected).\n"
" -d,--distdir=DIRECTORY Set (or override) the path to xbps-packages\n" " -D,--distdir=DIRECTORY Set (or override) the path to xbps-packages\n"
" (defaults to ~/xbps-packages).\n" " (defaults to ~/xbps-packages).\n"
" -d,--debug Enable debug output to stderr.\n"
" -i,--installed Check for outdated packages in rootdir, rather\n" " -i,--installed Check for outdated packages in rootdir, rather\n"
" than in the XBPS repositories.\n" " than in the XBPS repositories.\n"
" -R,--repository=URL Append repository to the head of repository list.\n"
" -r,--rootdir=DIRECTORY Set root directory (defaults to /).\n" " -r,--rootdir=DIRECTORY Set root directory (defaults to /).\n"
" -s,--show-missing List any binary packages which are not built.\n" " -s,--show-missing List any binary packages which are not built.\n"
"\n [FILES...] Extra packages to process with the outdated\n" "\n [FILES...] Extra packages to process with the outdated\n"
@ -205,7 +207,6 @@ rcv_init(rcv_t *rcv, const char *prog)
rcv->prog = prog; rcv->prog = prog;
rcv->have_vars = 0; rcv->have_vars = 0;
rcv->ptr = rcv->input = NULL; rcv->ptr = rcv->input = NULL;
memset(&rcv->xhp, 0, sizeof(struct xbps_handle));
if (rcv->xbps_conf != NULL) if (rcv->xbps_conf != NULL)
rcv->xhp.conffile = rcv->xbps_conf; rcv->xhp.conffile = rcv->xbps_conf;
if (rcv->rootdir != NULL) if (rcv->rootdir != NULL)
@ -594,12 +595,14 @@ main(int argc, char **argv)
int i, c; int i, c;
rcv_t rcv; rcv_t rcv;
char *distdir = NULL; char *distdir = NULL;
const char *prog = argv[0], *sopts = "hC:d:ir:sV", *tmpl; const char *prog = argv[0], *sopts = "hC:D:diR:r:sV", *tmpl;
const struct option lopts[] = { const struct option lopts[] = {
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "config", required_argument, NULL, 'C' }, { "config", required_argument, NULL, 'C' },
{ "distdir", required_argument, NULL, 'd' }, { "distdir", required_argument, NULL, 'D' },
{ "debug", no_argument, NULL, 'd' },
{ "installed", no_argument, NULL, 'i' }, { "installed", no_argument, NULL, 'i' },
{ "repository", required_argument, NULL, 'R' },
{ "rootdir", required_argument, NULL, 'r' }, { "rootdir", required_argument, NULL, 'r' },
{ "show-missing", no_argument, NULL, 's' }, { "show-missing", no_argument, NULL, 's' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
@ -616,14 +619,23 @@ main(int argc, char **argv)
free(rcv.xbps_conf); free(rcv.xbps_conf);
rcv.xbps_conf = strdup(optarg); rcv.xbps_conf = strdup(optarg);
break; break;
case 'd': case 'D':
free(rcv.distdir); rcv.distdir = NULL; free(rcv.distdir); rcv.distdir = NULL;
free(rcv.pkgdir); rcv.pkgdir = NULL; free(rcv.pkgdir); rcv.pkgdir = NULL;
rcv_set_distdir(&rcv, optarg); rcv_set_distdir(&rcv, optarg);
break; break;
case 'd':
rcv.xhp.flags |= XBPS_FLAG_DEBUG;
break;
case 'i': case 'i':
rcv.installed = true; rcv.installed = true;
break; break;
case 'R':
if (rcv.xhp.repositories == NULL)
rcv.xhp.repositories = xbps_array_create();
xbps_array_add_cstring_nocopy(rcv.xhp.repositories, optarg);
break;
case 'r': case 'r':
rcv.rootdir = strdup(optarg); rcv.rootdir = strdup(optarg);
break; break;
@ -645,7 +657,6 @@ main(int argc, char **argv)
rcv_set_distdir(&rcv, distdir); rcv_set_distdir(&rcv, distdir);
free(distdir); free(distdir);
} }
argc -= optind; argc -= optind;
argv += optind; argv += optind;

View File

@ -1,4 +1,4 @@
.Dd April 7, 2014 .Dd April 17, 2014
.Os Void Linux .Os Void Linux
.Dt xbps-checkvers 8 .Dt xbps-checkvers 8
.Sh NAME .Sh NAME
@ -27,13 +27,17 @@ argument sets extra packages to process with the outdated ones (only processed i
.Bl -tag -width -x .Bl -tag -width -x
.It Fl C, Fl -config Ar file .It Fl C, Fl -config Ar file
Specifies a full path to the XBPS configuration file. Specifies a full path to the XBPS configuration file.
.It Fl d, Fl -distdir Ar dir .It Fl D, Fl -distdir Ar dir
Specifies a full path to the xbps-packages repository. By default set to Specifies a full path to the xbps-packages repository. By default set to
.Nm ~/xbps-packages . .Nm ~/xbps-packages .
.It Fl d, Fl -debug
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 i, Fl -installed .It Fl i, Fl -installed
Check for outdated installed packages rather than in repositories. Check for outdated installed packages rather than in repositories.
.It Fl R, Fl -repository=uri
Repository to be added to the top of the list. This option can be specified multiple times.
.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 s, Fl -show-missing .It Fl s, Fl -show-missing