Remove currrent installed pkg first while updating a package.
--HG-- extra : convert_revision : 8d93d1a59f47edf468781c66116bba45a3ecd70b
This commit is contained in:
parent
54b6d87809
commit
797b3dad46
4 changed files with 27 additions and 17 deletions
|
@ -281,7 +281,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
|
|
||||||
rv = xbps_remove_binary_pkg(argv[1]);
|
rv = xbps_remove_binary_pkg(argv[1], false);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
printf("failed! (%s)\n", strerror(rv));
|
printf("failed! (%s)\n", strerror(rv));
|
||||||
|
@ -380,7 +380,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
|
|
||||||
rv = xbps_remove_binary_pkg(pkgname);
|
rv = xbps_remove_binary_pkg(pkgname, false);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
if (!verbose)
|
if (!verbose)
|
||||||
printf("failed! (%s)\n", strerror(rv));
|
printf("failed! (%s)\n", strerror(rv));
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#define _XBPS_REMOVE_H_
|
#define _XBPS_REMOVE_H_
|
||||||
|
|
||||||
/* From lib/remove.c */
|
/* From lib/remove.c */
|
||||||
int xbps_remove_binary_pkg(const char *);
|
int xbps_remove_binary_pkg(const char *, bool);
|
||||||
int xbps_unregister_pkg(const char *);
|
int xbps_unregister_pkg(const char *);
|
||||||
|
|
||||||
#endif /* !_XBPS_REMOVE_H_ */
|
#endif /* !_XBPS_REMOVE_H_ */
|
||||||
|
|
|
@ -58,15 +58,22 @@ xbps_install_binary_pkg_fini(prop_dictionary_t repo, prop_dictionary_t pkgrd,
|
||||||
automatic = true;
|
automatic = true;
|
||||||
|
|
||||||
if (update == true) {
|
if (update == true) {
|
||||||
|
/*
|
||||||
|
* Update a package, firstly removing current package.
|
||||||
|
*/
|
||||||
instpkg = xbps_find_pkg_installed_from_plist(pkgname);
|
instpkg = xbps_find_pkg_installed_from_plist(pkgname);
|
||||||
if (instpkg == NULL)
|
if (instpkg == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
prop_dictionary_get_cstring_nocopy(instpkg, "version",
|
prop_dictionary_get_cstring_nocopy(instpkg, "version",
|
||||||
&instver);
|
&instver);
|
||||||
printf("Updating %s-%s to %s ...\n", pkgname,
|
printf("Removing current package %s-%s ...\n", pkgname,
|
||||||
instver, version);
|
instver);
|
||||||
prop_object_release(instpkg);
|
prop_object_release(instpkg);
|
||||||
|
rv = xbps_remove_binary_pkg(pkgname, update);
|
||||||
|
if (rv != 0)
|
||||||
|
return rv;
|
||||||
|
printf("Installing new package %s-%s ...\n", pkgname, version);
|
||||||
} else {
|
} else {
|
||||||
printf("Installing %s%s: found version %s ...\n",
|
printf("Installing %s%s: found version %s ...\n",
|
||||||
automatic ? "dependency " : "", pkgname, version);
|
automatic ? "dependency " : "", pkgname, version);
|
||||||
|
|
27
lib/remove.c
27
lib/remove.c
|
@ -205,7 +205,7 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_remove_binary_pkg(const char *pkgname)
|
xbps_remove_binary_pkg(const char *pkgname, bool update)
|
||||||
{
|
{
|
||||||
prop_dictionary_t dict;
|
prop_dictionary_t dict;
|
||||||
const char *rootdir = xbps_get_rootdir();
|
const char *rootdir = xbps_get_rootdir();
|
||||||
|
@ -305,18 +305,21 @@ xbps_remove_binary_pkg(const char *pkgname)
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the required_by array of all required dependencies.
|
* Update the required_by array of all required dependencies
|
||||||
|
* and unregister package if this is really a removal and
|
||||||
|
* not an update.
|
||||||
*/
|
*/
|
||||||
rv = xbps_requiredby_pkg_remove(pkgname);
|
if (update == false) {
|
||||||
if (rv != 0)
|
rv = xbps_requiredby_pkg_remove(pkgname);
|
||||||
return rv;
|
if (rv != 0)
|
||||||
|
return rv;
|
||||||
/*
|
/*
|
||||||
* Unregister pkg from database.
|
* Unregister pkg from database.
|
||||||
*/
|
*/
|
||||||
rv = xbps_unregister_pkg(pkgname);
|
rv = xbps_unregister_pkg(pkgname);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
return rv;
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove pkg metadata directory.
|
* Remove pkg metadata directory.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue