Skip to content

Commit

Permalink
Update mport tool with latest from current. fixes memory free issue, …
Browse files Browse the repository at this point in the history
…adds region support
  • Loading branch information
laffer1 committed Feb 23, 2019
1 parent 3c11575 commit 862deed
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/libmport/bundle_read_install_pkg.c
Expand Up @@ -530,7 +530,7 @@ do_actual_install(mportInstance *mport, mportBundleRead *bundle, mportPackageMet
if (e->owner != NULL && e->group != NULL && e->owner[0] != '\0' &&
e->group[0] != '\0') {
#ifdef DEBUG
fprintf(stderr, "owner %s and group %s\n", fm_owner, fm_group);
fprintf(stderr, "owner %s and group %s\n", e->owner, e->group);
#endif
if (chown(file, mport_get_uid(e->owner),
mport_get_gid(e->group)) == -1) {
Expand Down
2 changes: 1 addition & 1 deletion lib/libmport/create_primative.c
Expand Up @@ -172,7 +172,7 @@ insert_assetlist(sqlite3 *db, mportAssetList *assetlist, mportPackageMeta *pack,
e->type == ASSET_FILE_OWNER_MODE) {
/* Don't prepend cwd onto absolute file paths (this is useful for update) */
if (e->data[0] == '/') {
(void) strlcpy(file, e->data, FILENAME_MAX);
(void) snprintf(file, FILENAME_MAX, "%s%s", extra->sourcedir, e->data);
} else {
(void) snprintf(file, FILENAME_MAX, "%s/%s", cwd, e->data);
}
Expand Down
11 changes: 9 additions & 2 deletions lib/libmport/index.c
Expand Up @@ -36,6 +36,7 @@ __MBSDID("$MidnightBSD$");
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <stddef.h>

static int index_is_recentish(void);
static int index_last_checked_recentish(mportInstance *);
Expand Down Expand Up @@ -209,17 +210,23 @@ int mport_index_get_mirror_list(mportInstance *mport, char ***list_p, int *list_
int ret, i;
int len;
sqlite3_stmt *stmt;
char *mirror_region;

mirror_region = mport_setting_get(mport, MPORT_SETTING_MIRROR_REGION);
if (mirror_region == NULL) {
mirror_region = "us";
}

/* XXX the country is hard coded until a configuration system is created */
if (mport_db_count(mport->db, &len, "SELECT COUNT(*) FROM idx.mirrors WHERE country='us'") != MPORT_OK)
if (mport_db_count(mport->db, &len, "SELECT COUNT(*) FROM idx.mirrors WHERE country=%Q", mirror_region) != MPORT_OK)
RETURN_CURRENT_ERROR;

*list_size = len;
list = calloc((size_t) len + 1, sizeof(char *));
*list_p = list;
i = 0;

if (mport_db_prepare(mport->db, &stmt, "SELECT mirror FROM idx.mirrors WHERE country='us'") != MPORT_OK) {
if (mport_db_prepare(mport->db, &stmt, "SELECT mirror FROM idx.mirrors WHERE country=%Q", mirror_region) != MPORT_OK) {
sqlite3_finalize(stmt);
RETURN_CURRENT_ERROR;
}
Expand Down
8 changes: 7 additions & 1 deletion lib/libmport/mport_private.h
Expand Up @@ -47,6 +47,8 @@
#define MPORT_BUNDLE_VERSION 5
#define MPORT_BUNDLE_VERSION_STR "5"

#define MPORT_SETTING_MIRROR_REGION "mirror_region"

/* callback syntaxtic sugar */
void mport_call_msg_cb(mportInstance *, const char *, ...);
void mport_call_progress_init_cb(mportInstance *, const char *, ...);
Expand Down Expand Up @@ -172,7 +174,11 @@ int mport_set_errx(int , const char *, ...);
#error "Unable to detect arch!"
#endif

#if __MidnightBSD_version >= 100000
#if __MidnightBSD_version >= 102000
#define MPORT_OSVERSION "1.2"
#elif __MidnightBSD_version >= 101000
#define MPORT_OSVERSION "1.1"
#elif __MidnightBSD_version >= 100000
#define MPORT_OSVERSION "1.0"
#elif __MidnightBSD_version >= 9000
#define MPORT_OSVERSION "0.9"
Expand Down

0 comments on commit 862deed

Please sign in to comment.