diff --git a/NEWS b/NEWS index 50ee84cb..095e7cd0 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ xbps-0.11.0 (???): + * xbps-bin(8): it is possible now to reinstall a package even if it's + installed with the '-f' option. If reinstalling the same package version, + only unexistent files or files not matching its hash will be extracted. + * While unpacking a binary package, always check that file to be extracted exists on filesystem, if true and its hash is matched, skip extraction. diff --git a/TODO b/TODO index b4feb852..33ab6502 100644 --- a/TODO +++ b/TODO @@ -3,12 +3,6 @@ libxbps: - properties: (hold) still unimplemented. - properties: (update-first) still unimplemented. -xbps-bin: - - Add a flag (or use -f install) to force reinstallation of any - installed package (if same version is available) and preserve - requiredby entries, but overwritting those files that weren't - matched by the hash. - xbps-repo: - New target to clean binpkgs in cachedir that aren't available on any registered repository or its hash doesn't match. diff --git a/bin/xbps-bin/defs.h b/bin/xbps-bin/defs.h index 53126c36..df7ba392 100644 --- a/bin/xbps-bin/defs.h +++ b/bin/xbps-bin/defs.h @@ -45,7 +45,7 @@ struct list_pkgver_cb { }; /* from transaction.c */ -int install_new_pkg(const char *); +int install_new_pkg(const char *, bool); int update_pkg(const char *); int remove_pkg(const char *, bool, bool); int autoupdate_pkgs(bool, bool); diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index abc178dd..8d1c5d28 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -70,11 +70,12 @@ main(int argc, char **argv) int i, c, flags, rv; bool yes, purge, debug, reqby_force, force_rm_with_deps, recursive_rm; bool install_auto, install_manual, show_download_pkglist_url; + bool reinstall; rootdir = cachedir = conffile = option = NULL; flags = rv = 0; reqby_force = yes = purge = force_rm_with_deps = false; - recursive_rm = debug = false; + recursive_rm = debug = reinstall = false; install_auto = install_manual = show_download_pkglist_url = false; while ((c = getopt(argc, argv, "AC:c:dDFfMo:pRr:Vvy")) != -1) { @@ -98,6 +99,7 @@ main(int argc, char **argv) force_rm_with_deps = true; break; case 'f': + reinstall = true; flags |= XBPS_FLAG_FORCE_CONFIGURE; flags |= XBPS_FLAG_FORCE_REMOVE_FILES; break; @@ -227,7 +229,7 @@ main(int argc, char **argv) usage(xhp); for (i = 1; i < argc; i++) - if ((rv = install_new_pkg(argv[i])) != 0) + if ((rv = install_new_pkg(argv[i], reinstall)) != 0) goto out; rv = exec_transaction(yes, show_download_pkglist_url); diff --git a/bin/xbps-bin/transaction.c b/bin/xbps-bin/transaction.c index 71105526..5baa0782 100644 --- a/bin/xbps-bin/transaction.c +++ b/bin/xbps-bin/transaction.c @@ -240,7 +240,7 @@ autoremove_pkgs(bool yes, bool purge) } int -install_new_pkg(const char *pkg) +install_new_pkg(const char *pkg, bool reinstall) { prop_dictionary_t pkgd; char *pkgname = NULL, *pkgpatt = NULL; @@ -273,10 +273,14 @@ install_new_pkg(const char *pkg) } prop_object_release(pkgd); if (state == XBPS_PKG_STATE_INSTALLED) { - printf("Package '%s' is already installed.\n", pkgname); - goto out; + if (!reinstall) { + printf("Package '%s' is already installed.\n", + pkgname); + goto out; + } + } else { + printf("Package `%s' needs to be configured.\n", pkgname); } - printf("Package `%s' needs to be configured.\n", pkgname); } if ((rv = xbps_transaction_install_pkg(pkgpatt)) != 0) { if (rv == ENOENT) { diff --git a/bin/xbps-bin/xbps-bin.8 b/bin/xbps-bin/xbps-bin.8 index 993511bc..0dc78cfb 100644 --- a/bin/xbps-bin/xbps-bin.8 +++ b/bin/xbps-bin/xbps-bin.8 @@ -1,4 +1,4 @@ -.Dd December 15, 2011 +.Dd December 20, 2011 .Os Void GNU/Linux .Dt xbps-bin 8 .Sh NAME @@ -59,6 +59,7 @@ target. If set, package will be removed even if other packages are currently depending on it, i.e package is a dependency of any other installed package. .It Fl f Used currently in the +.Em install , .Em purge , .Em reconfigure and @@ -71,7 +72,11 @@ removal of package files even if its hash does not match in the .Em purge and .Em remove -targets. +targets. If set, package(s) will be reinstalled even if its state is +.Em installed +when used with the +.Em install +target. .It Fl M Sets the .Em automatic-install