diff --git a/NEWS b/NEWS index a8afcaff..891acfc7 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ xbps-0.24 (???): + * xbps-rindex(8): added -f, --force flag to forcefully register a package even + if an entry of the same package already exists on the index. xbps-0.23 (2013-04-19): diff --git a/bin/xbps-rindex/defs.h b/bin/xbps-rindex/defs.h index f2b2d940..c9cee5c1 100644 --- a/bin/xbps-rindex/defs.h +++ b/bin/xbps-rindex/defs.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2012 Juan Romero Pardines. + * Copyright (c) 2012-2013 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ #include /* From index-add.c */ -int index_add(struct xbps_handle *, int, char **); +int index_add(struct xbps_handle *, int, char **, bool); /* From index-clean.c */ int index_clean(struct xbps_handle *, const char *); diff --git a/bin/xbps-rindex/index-add.c b/bin/xbps-rindex/index-add.c index 138f234c..14925c19 100644 --- a/bin/xbps-rindex/index-add.c +++ b/bin/xbps-rindex/index-add.c @@ -41,7 +41,7 @@ * and entry when it's necessary. */ int -index_add(struct xbps_handle *xhp, int argc, char **argv) +index_add(struct xbps_handle *xhp, int argc, char **argv, bool force) { prop_array_t filespkgar, pkg_files, pkg_links, pkg_cffiles; prop_dictionary_t idx, idxfiles, newpkgd, newpkgfilesd, curpkgd; @@ -134,7 +134,8 @@ index_add(struct xbps_handle *xhp, int argc, char **argv) free(pkgname); return errno; } - } else { + } else if (!force) { + /* Only check version if !force */ prop_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &oldpkgver); prop_dictionary_get_cstring_nocopy(curpkgd, diff --git a/bin/xbps-rindex/main.c b/bin/xbps-rindex/main.c index f4f22936..80f265d7 100644 --- a/bin/xbps-rindex/main.c +++ b/bin/xbps-rindex/main.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2012 Juan Romero Pardines. + * Copyright (c) 2012-2013 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -37,6 +37,7 @@ usage(bool fail) fprintf(stdout, "Usage: xbps-rindex [OPTIONS] MODE ARGUMENTS\n\n" "OPTIONS\n" + " -f --force Force mode to overwrite entry in add mode\n" " -h --help Show help usage\n" " -V --version Show XBPS version\n\n" "MODE\n" @@ -49,10 +50,11 @@ usage(bool fail) int main(int argc, char **argv) { - const char *shortopts = "achrV"; + const char *shortopts = "acfhrV"; struct option longopts[] = { { "add", no_argument, NULL, 'a' }, { "clean", no_argument, NULL, 'c' }, + { "force", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, { "remove-obsoletes", no_argument, NULL, 'r' }, { "version", no_argument, NULL, 'V' }, @@ -60,7 +62,7 @@ main(int argc, char **argv) }; struct xbps_handle xh; int rv, c; - bool clean_mode = false, add_mode = false, rm_mode = false; + bool clean_mode = false, add_mode = false, rm_mode = false, force = false; while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) { switch (c) { @@ -70,6 +72,9 @@ main(int argc, char **argv) case 'c': clean_mode = true; break; + case 'f': + force = true; + break; case 'h': usage(false); /* NOTREACHED */ @@ -100,7 +105,7 @@ main(int argc, char **argv) } if (add_mode) - rv = index_add(&xh, argc - optind, argv + optind); + rv = index_add(&xh, argc - optind, argv + optind, force); else if (clean_mode) rv = index_clean(&xh, argv[optind]); else if (rm_mode) diff --git a/bin/xbps-rindex/xbps-rindex.8 b/bin/xbps-rindex/xbps-rindex.8 index 4a13472f..03dbfeff 100644 --- a/bin/xbps-rindex/xbps-rindex.8 +++ b/bin/xbps-rindex/xbps-rindex.8 @@ -1,4 +1,4 @@ -.Dd February 20, 2013 +.Dd May 2, 2013 .Os Void Linux .Dt xbps-rindex 8 .Sh NAME @@ -16,6 +16,11 @@ utility creates, updates and removes obsolete binary packages stored in local repositories. .Sh OPTIONS .Bl -tag -width -x +.It Fl f -force +Forcefully register binary package into the local repository, overwriting existing entry. +This flag is only useful with the +.Em add +mode. .It Fl h -help Show the help usage. .It Fl V -version