Skip to content

Commit

Permalink
Merge pull request #5 from MidnightBSD/update_fix
Browse files Browse the repository at this point in the history
Update fix
  • Loading branch information
laffer1 authored Jun 19, 2021
2 parents 0c2f76a + 220c0bd commit d5dcceb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libmport/mport_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define MPORT_MASTER_VERSION 7
#define MPORT_BUNDLE_VERSION 5
#define MPORT_BUNDLE_VERSION_STR "5"
#define MPORT_VERSION "2.1.1"
#define MPORT_VERSION "2.1.2"

#define MPORT_SETTING_MIRROR_REGION "mirror_region"

Expand Down
21 changes: 21 additions & 0 deletions libmport/update.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,32 @@
MPORT_PUBLIC_API int
mport_update(mportInstance *mport, const char *packageName) {
char *path;
mportDependsEntry **depends;
mportIndexEntry **indexEntry;

if (packageName == NULL) {
return (1);
}

int result = mport_download(mport, packageName, &path);
if (result != 0)
return result;

/* in the event the package is not found in the index, it could be user generated and we still want to update it if
present */
if (mport_index_lookup_pkgname(mport, packageName, &indexEntry) != MPORT_OK ||
indexEntry == NULL || *indexEntry == NULL) {
mport_call_msg_cb(mport, "Package %s not found in the index", packageName);
} else {
/* get the dependency list and start updating/installing missing entries */
mport_index_depends_list(mport, packageName, (*indexEntry)->version, &depends);

while (*depends != NULL) {
mport_install_depends(mport, (*depends)->d_pkgname, (*depends)->d_version);
depends++;
}
}

if (mport_update_primative(mport, path) != MPORT_OK) {
mport_call_msg_cb(mport, "%s\n", mport_err_string());
free(path);
Expand Down

0 comments on commit d5dcceb

Please sign in to comment.