Some improvements for installation of binary packages.
* If any dep of a package cannot be found in the repository pool, show it on xbps-bin. * Add the automatic-install boolean obj into pkg's dictionary on regpkgdb.plist, this will be used to implemented something like "apt-get autoremove". --HG-- extra : convert_revision : 666e2fa666ac94140159896e28b445e88e8afb7a
This commit is contained in:
parent
e7c17a5cd8
commit
746d59a9dd
5 changed files with 69 additions and 10 deletions
|
@ -35,6 +35,8 @@
|
||||||
#include <xbps_api.h>
|
#include <xbps_api.h>
|
||||||
|
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
|
static void show_missing_deps(prop_dictionary_t, const char *);
|
||||||
|
static int show_missing_dep_cb(prop_object_t, void *, bool *);
|
||||||
static int list_pkgs_in_dict(prop_object_t, void *, bool *);
|
static int list_pkgs_in_dict(prop_object_t, void *, bool *);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -77,6 +79,31 @@ list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_missing_deps(prop_dictionary_t d, const char *pkgname)
|
||||||
|
{
|
||||||
|
printf("Unable to locate some required packages for %s:\n",
|
||||||
|
pkgname);
|
||||||
|
(void)xbps_callback_array_iter_in_dict(d, "missing_deps",
|
||||||
|
show_missing_dep_cb, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
show_missing_dep_cb(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
|
{
|
||||||
|
const char *pkgname, *version;
|
||||||
|
|
||||||
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||||
|
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||||
|
if (pkgname && version) {
|
||||||
|
printf("\tmissing binary package for: %s >= %s\n",
|
||||||
|
pkgname, version);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -138,12 +165,12 @@ main(int argc, char **argv)
|
||||||
if (strcasecmp(argv[0], "install") == 0) {
|
if (strcasecmp(argv[0], "install") == 0) {
|
||||||
rv = xbps_install_binary_pkg(argv[1], root);
|
rv = xbps_install_binary_pkg(argv[1], root);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
if (errno == ENOENT)
|
dict = xbps_get_pkg_deps_dictionary();
|
||||||
|
if (dict == NULL && errno == ENOENT)
|
||||||
printf("Unable to locate %s in "
|
printf("Unable to locate %s in "
|
||||||
"repository pool.\n", argv[1]);
|
"repository pool.\n", argv[1]);
|
||||||
else
|
else
|
||||||
printf("Unable to install %s (%s).\n",
|
show_missing_deps(dict, argv[1]);
|
||||||
argv[1], strerror(errno));
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
printf("Package %s installed successfully.\n", argv[1]);
|
printf("Package %s installed successfully.\n", argv[1]);
|
||||||
|
|
|
@ -113,7 +113,8 @@ main(int argc, char **argv)
|
||||||
if (argc != 4)
|
if (argc != 4)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
rv = xbps_register_pkg(NULL, argv[1], argv[2], argv[3]);
|
rv = xbps_register_pkg(NULL, argv[1], argv[2],
|
||||||
|
argv[3], false);
|
||||||
if (rv == EEXIST) {
|
if (rv == EEXIST) {
|
||||||
printf("%s=> %s-%s already registered.\n",
|
printf("%s=> %s-%s already registered.\n",
|
||||||
in_chroot ? "[chroot] " : "", argv[1], argv[2]);
|
in_chroot ? "[chroot] " : "", argv[1], argv[2]);
|
||||||
|
|
|
@ -32,13 +32,15 @@ int xbps_install_binary_pkg(const char *, const char *);
|
||||||
int xbps_install_binary_pkg_fini(prop_dictionary_t, prop_dictionary_t,
|
int xbps_install_binary_pkg_fini(prop_dictionary_t, prop_dictionary_t,
|
||||||
const char *);
|
const char *);
|
||||||
int xbps_register_pkg(prop_dictionary_t, const char *, const char *,
|
int xbps_register_pkg(prop_dictionary_t, const char *, const char *,
|
||||||
const char *);
|
const char *, bool);
|
||||||
int xbps_unpack_binary_pkg(prop_dictionary_t, prop_dictionary_t,
|
int xbps_unpack_binary_pkg(prop_dictionary_t, prop_dictionary_t,
|
||||||
const char *,
|
const char *,
|
||||||
void (*cb_print)(prop_dictionary_t));
|
void (*cb_print)(prop_dictionary_t));
|
||||||
int xbps_update_pkg_requiredby(prop_array_t, prop_dictionary_t);
|
int xbps_update_pkg_requiredby(prop_array_t, prop_dictionary_t);
|
||||||
int xbps_find_deps_in_pkg(prop_dictionary_t);
|
int xbps_find_deps_in_pkg(prop_dictionary_t);
|
||||||
|
|
||||||
|
prop_dictionary_t xbps_get_pkg_deps_dictionary(void);
|
||||||
|
|
||||||
/* From lib/sortdeps.c */
|
/* From lib/sortdeps.c */
|
||||||
int xbps_sort_pkg_deps(prop_dictionary_t);
|
int xbps_sort_pkg_deps(prop_dictionary_t);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ static int find_pkg_missing_deps_from_repo(prop_dictionary_t,
|
||||||
prop_dictionary_t);
|
prop_dictionary_t);
|
||||||
|
|
||||||
static prop_dictionary_t chaindeps;
|
static prop_dictionary_t chaindeps;
|
||||||
|
static bool deps_dict;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates the dictionary to store the dependency chain.
|
* Creates the dictionary to store the dependency chain.
|
||||||
|
@ -369,6 +370,7 @@ xbps_find_deps_in_pkg(prop_dictionary_t pkg)
|
||||||
missing_rdeps = prop_dictionary_get(chaindeps, "missing_deps");
|
missing_rdeps = prop_dictionary_get(chaindeps, "missing_deps");
|
||||||
if (prop_array_count(missing_rdeps) == 0)
|
if (prop_array_count(missing_rdeps) == 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are missing deps, iterate one more time
|
* If there are missing deps, iterate one more time
|
||||||
* just in case that indirect deps weren't found.
|
* just in case that indirect deps weren't found.
|
||||||
|
@ -405,6 +407,15 @@ out:
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prop_dictionary_t
|
||||||
|
xbps_get_pkg_deps_dictionary(void)
|
||||||
|
{
|
||||||
|
if (!deps_dict)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return prop_dictionary_copy(chaindeps);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
find_pkg_missing_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg)
|
find_pkg_missing_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg)
|
||||||
{
|
{
|
||||||
|
@ -473,7 +484,6 @@ find_pkg_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg,
|
||||||
const char *reqpkg, *reqvers;
|
const char *reqpkg, *reqvers;
|
||||||
char *pkgname;
|
char *pkgname;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
static bool deps_dict;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Package doesn't have deps, check to be sure.
|
* Package doesn't have deps, check to be sure.
|
||||||
|
@ -602,6 +612,7 @@ xbps_install_pkg_deps(prop_dictionary_t pkg, const char *destdir)
|
||||||
if (required == NULL)
|
if (required == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
iter = prop_array_iterator(required);
|
iter = prop_array_iterator(required);
|
||||||
if (iter == NULL)
|
if (iter == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
|
@ -47,6 +47,7 @@ xbps_install_binary_pkg_fini(prop_dictionary_t repo, prop_dictionary_t pkg,
|
||||||
{
|
{
|
||||||
const char *pkgname, *version, *desc;
|
const char *pkgname, *version, *desc;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
bool automatic = false;
|
||||||
|
|
||||||
assert(pkg != NULL);
|
assert(pkg != NULL);
|
||||||
prop_dictionary_get_cstring_nocopy(pkg, "pkgname", &pkgname);
|
prop_dictionary_get_cstring_nocopy(pkg, "pkgname", &pkgname);
|
||||||
|
@ -56,9 +57,12 @@ xbps_install_binary_pkg_fini(prop_dictionary_t repo, prop_dictionary_t pkg,
|
||||||
assert(version != NULL);
|
assert(version != NULL);
|
||||||
assert(desc != NULL);
|
assert(desc != NULL);
|
||||||
|
|
||||||
|
if (repo == false)
|
||||||
|
automatic = true;
|
||||||
|
|
||||||
rv = xbps_unpack_binary_pkg(repo, pkg, destdir, NULL);
|
rv = xbps_unpack_binary_pkg(repo, pkg, destdir, NULL);
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
rv = xbps_register_pkg(pkg, pkgname, version, desc);
|
rv = xbps_register_pkg(pkg, pkgname, version, desc, automatic);
|
||||||
if (rv == EEXIST)
|
if (rv == EEXIST)
|
||||||
rv = 0;
|
rv = 0;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +91,8 @@ xbps_install_binary_pkg(const char *pkgname, const char *destdir)
|
||||||
*/
|
*/
|
||||||
rv = xbps_callback_array_iter_in_repolist(install_binpkg_repo_cb,
|
rv = xbps_callback_array_iter_in_repolist(install_binpkg_repo_cb,
|
||||||
(void *)&cb);
|
(void *)&cb);
|
||||||
|
if (rv == 0 && errno == ENOENT)
|
||||||
|
rv = errno;
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -139,9 +145,10 @@ install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done)
|
||||||
*/
|
*/
|
||||||
if ((rv = xbps_find_deps_in_pkg(pkgrd)) != 0) {
|
if ((rv = xbps_find_deps_in_pkg(pkgrd)) != 0) {
|
||||||
prop_object_release(repod);
|
prop_object_release(repod);
|
||||||
if (rv == ENOENT)
|
if (rv == ENOENT) {
|
||||||
|
errno = ENOENT;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +162,10 @@ install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done)
|
||||||
*cbloop_done = true;
|
*cbloop_done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Cleanup errno, just in case */
|
||||||
|
if (rv == 0)
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +186,8 @@ make_dict_from_pkg(const char *name, const char *ver, const char *desc)
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_register_pkg(prop_dictionary_t pkgrd, const char *pkgname,
|
xbps_register_pkg(prop_dictionary_t pkgrd, const char *pkgname,
|
||||||
const char *version, const char *desc)
|
const char *version, const char *desc,
|
||||||
|
bool automatic)
|
||||||
{
|
{
|
||||||
prop_dictionary_t dict, pkgd;
|
prop_dictionary_t dict, pkgd;
|
||||||
prop_array_t array;
|
prop_array_t array;
|
||||||
|
@ -212,6 +224,9 @@ xbps_register_pkg(prop_dictionary_t pkgrd, const char *pkgname,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prop_dictionary_set_bool(pkgd, "automatic-install",
|
||||||
|
automatic);
|
||||||
|
|
||||||
if (!xbps_add_obj_to_dict(dict, array, "packages")) {
|
if (!xbps_add_obj_to_dict(dict, array, "packages")) {
|
||||||
prop_object_release(array);
|
prop_object_release(array);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
|
@ -234,6 +249,9 @@ xbps_register_pkg(prop_dictionary_t pkgrd, const char *pkgname,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prop_dictionary_set_bool(pkgd, "automatic-install",
|
||||||
|
automatic);
|
||||||
|
|
||||||
if (pkgrd && xbps_pkg_has_rundeps(pkgrd)) {
|
if (pkgrd && xbps_pkg_has_rundeps(pkgrd)) {
|
||||||
rv = xbps_update_pkg_requiredby(array, pkgrd);
|
rv = xbps_update_pkg_requiredby(array, pkgrd);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue