xbps-checkvers: allow files argument to be paths or package name

This commit is contained in:
Duncaen 2019-06-14 12:29:50 +02:00 committed by Duncan Overbruck
parent b2f5afd02e
commit 5dfaf5c075

View File

@ -35,6 +35,7 @@
#include <errno.h> #include <errno.h>
#include <ctype.h> #include <ctype.h>
#include <dirent.h> #include <dirent.h>
#include <limits.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <assert.h> #include <assert.h>
@ -755,7 +756,7 @@ 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:diImR:r:sV", *tmpl; const char *prog = argv[0], *sopts = "hC:D:diImR:r:sV";
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' },
@ -834,16 +835,18 @@ main(int argc, char **argv)
} }
rcv.manual = true; rcv.manual = true;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
tmpl = argv[i] + (strlen(argv[i]) - strlen("template")); char tmp[PATH_MAX], *tmpl, *p;
if ((strcmp("template", tmpl)) == 0) { if (strncmp(argv[i], "srcpkgs/", sizeof ("srcpkgs/")-1) == 0) {
/* strip "srcpkgs/" prefix if found */ argv[i] += sizeof ("srcpkgs/")-1;
if (strncmp(argv[i], "srcpkgs/", 8) == 0)
tmpl = strchr(argv[i], '/') + 1;
else
tmpl = argv[i];
rcv_process_file(&rcv, tmpl, rcv_check_version);
} }
if ((p = strrchr(argv[i], '/')) && (strcmp(p, "/template")) == 0) {
tmpl = argv[i];
} else {
xbps_strlcat(tmp, argv[i], sizeof tmp);
xbps_strlcat(tmp, "/template", sizeof tmp);
tmpl = tmp;
}
rcv_process_file(&rcv, tmpl, rcv_check_version);
} }
rcv_end(&rcv); rcv_end(&rcv);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);