Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add per repo mirror type, and use the repo all over the place
Baptiste Daroussin committed 13 years ago
commit 8b174022c1ca7fa35d53496029941bd8bdccda16
parent d3cba8d
9 files changed +94 -108
modified libpkg/fetch.c
@@ -46,7 +46,7 @@
#include "private/utils.h"

static void
-
gethttpmirrors(struct pkg_fetch *fetch, const char *url) {
+
gethttpmirrors(struct pkg_repo *repo, const char *url) {
	FILE *f;
	char *line = NULL;
	size_t linecap = 0;
@@ -73,7 +73,7 @@ gethttpmirrors(struct pkg_fetch *fetch, const char *url) {
			if ((u = fetchParseURL(line)) != NULL) {
				m = malloc(sizeof(struct http_mirror));
				m->url = u;
-
				LL_APPEND(fetch->http, m);
+
				LL_APPEND(repo->http, m);
			}
		}
	}
@@ -82,44 +82,17 @@ gethttpmirrors(struct pkg_fetch *fetch, const char *url) {
}

int
-
pkg_fetch_new(struct pkg_fetch **f)
-
{
-
	setenv("HTTP_USER_AGENT", "pkg/"PKGVERSION, 1);
-
	if ((*f = calloc(1, sizeof(struct pkg_fetch))) == NULL) {
-
		pkg_emit_errno("calloc", "fetch");
-
		return (EPKG_FATAL);
-
	}
-

-
	return (EPKG_OK);
-
}
-

-
int
-
pkg_fetch_free(struct pkg_fetch *f)
-
{
-
	if (f->ssh != NULL) {
-
		fprintf(f->ssh, "quit\n");
-
		pclose(f->ssh);
-
	}
-
	free(f);
-

-
	return (EPKG_OK);
-
}
-

-
int
-
pkg_fetch_file(const char *url, const char *dest, time_t t)
+
pkg_fetch_file(struct pkg_repo *repo, const char *url, const char *dest, time_t t)
{
	int fd = -1;
	int retcode = EPKG_FATAL;
-
	struct pkg_fetch *f;

	if ((fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644)) == -1) {
		pkg_emit_errno("open", dest);
		return(EPKG_FATAL);
	}

-
	pkg_fetch_new(&f);
-
	retcode = pkg_fetch_file_to_fd(f, url, fd, &t);
-
	pkg_fetch_free(f);
+
	retcode = pkg_fetch_file_to_fd(repo, url, fd, &t);

	if (t != 0) {
		struct timeval ftimes[2] = {
@@ -145,7 +118,7 @@ pkg_fetch_file(const char *url, const char *dest, time_t t)
}

static int
-
start_ssh(struct pkg_fetch *f, struct url *u, off_t *sz)
+
start_ssh(struct pkg_repo *repo, struct url *u, off_t *sz)
{
	char *line = NULL;
	ssize_t linecap = 0;
@@ -153,7 +126,7 @@ start_ssh(struct pkg_fetch *f, struct url *u, off_t *sz)
	struct sbuf *cmd = NULL;
	const char *errstr;

-
	if (f->ssh == NULL) {
+
	if (repo->ssh == NULL) {
		cmd = sbuf_new_auto();
		sbuf_cat(cmd, "/usr/bin/ssh -e none -T ");
		if (u->port > 0)
@@ -163,27 +136,27 @@ start_ssh(struct pkg_fetch *f, struct url *u, off_t *sz)
		sbuf_cat(cmd, u->host);
		sbuf_printf(cmd, " pkg ssh");
		sbuf_finish(cmd);
-
		if ((f->ssh = popen(sbuf_data(cmd), "r+")) == NULL) {
+
		if ((repo->ssh = popen(sbuf_data(cmd), "r+")) == NULL) {
			pkg_emit_errno("popen", "ssh");
			sbuf_delete(cmd);
			return (EPKG_FATAL);
		}
		sbuf_delete(cmd);

-
		if (getline(&line, &linecap, f->ssh) > 0) {
+
		if (getline(&line, &linecap, repo->ssh) > 0) {
			if (strncmp(line, "ok:", 3) != 0) {
-
				pclose(f->ssh);
+
				pclose(repo->ssh);
				free(line);
				return (EPKG_FATAL);
			}
		} else {
-
			pclose(f->ssh);
+
			pclose(repo->ssh);
			return (EPKG_FATAL);
		}
	}

-
	fprintf(f->ssh, "get %s %" PRIdMAX "\n", u->doc, (intmax_t)u->ims_time);
-
	if ((linelen = getline(&line, &linecap, f->ssh)) > 0) {
+
	fprintf(repo->ssh, "get %s %" PRIdMAX "\n", u->doc, (intmax_t)u->ims_time);
+
	if ((linelen = getline(&line, &linecap, repo->ssh)) > 0) {
		if (line[linelen -1 ] == '\n')
			line[linelen -1 ] = '\0';
		if (strncmp(line, "ok:", 3) == 0) {
@@ -207,7 +180,7 @@ start_ssh(struct pkg_fetch *f, struct url *u, off_t *sz)
}

int
-
pkg_fetch_file_to_fd(struct pkg_fetch *f, const char *url, int dest, time_t *t)
+
pkg_fetch_file_to_fd(struct pkg_repo *repo, const char *url, int dest, time_t *t)
{
	FILE *remote = NULL;
	struct url *u;
@@ -224,12 +197,9 @@ pkg_fetch_file_to_fd(struct pkg_fetch *f, const char *url, int dest, time_t *t)
	char *doc = NULL;
	char docpath[MAXPATHLEN];
	int retcode = EPKG_OK;
-
	bool srv = false;
-
	bool http = false;
	char zone[MAXHOSTNAMELEN + 13];
	struct dns_srvinfo *srv_current = NULL;
	struct http_mirror *http_current = NULL;
-
	const char *mt;
	off_t sz = 0;
	int kq = -1, flags = 0;
	struct kevent e, ev;
@@ -250,27 +220,27 @@ pkg_fetch_file_to_fd(struct pkg_fetch *f, const char *url, int dest, time_t *t)
		u->ims_time = *t;

	if (strcmp(u->scheme, "ssh") == 0) {
-
		if ((retcode = start_ssh(f, u, &sz)) != EPKG_OK)
+
		if ((retcode = start_ssh(repo, u, &sz)) != EPKG_OK)
			goto cleanup;
-
		remote = f->ssh;
+
		remote = repo->ssh;
		kq = kqueue();
		if (kq == -1) {
			pkg_emit_errno("kqueue", "ssh");
			retcode = EPKG_FATAL;
			goto cleanup;
		}
-
		EV_SET(&e, fileno(f->ssh), EVFILT_READ, EV_ADD, 0, 0, 0);
+
		EV_SET(&e, fileno(repo->ssh), EVFILT_READ, EV_ADD, 0, 0, 0);
		if (kevent(kq, &e, 1, NULL, 0, NULL) == -1) {
			pkg_emit_errno("kevent", "ssh");
			retcode = EPKG_FATAL;
			goto cleanup;
		}
-
		if ((flags = fcntl(fileno(f->ssh), F_GETFL)) == -1) {
+
		if ((flags = fcntl(fileno(repo->ssh), F_GETFL)) == -1) {
			pkg_emit_errno("fcntl", "set ssh non-blocking");
			retcode = EPKG_FATAL;
			goto cleanup;
		}
-
		if (fcntl(fileno(f->ssh), F_SETFL, flags | O_NONBLOCK) == -1) {
+
		if (fcntl(fileno(repo->ssh), F_SETFL, flags | O_NONBLOCK) == -1) {
			pkg_emit_errno("fcntl", "set ssh non-blocking");
			retcode = EPKG_FATAL;
			goto cleanup;
@@ -280,30 +250,27 @@ pkg_fetch_file_to_fd(struct pkg_fetch *f, const char *url, int dest, time_t *t)
	doc = u->doc;
	while (remote == NULL) {
		if (retry == max_retry) {
-
			pkg_config_string(PKG_CONFIG_MIRRORS, &mt);
-
			if (mt != NULL && strncasecmp(mt, "srv", 3) == 0 &&
+
			if (repo->mirror_type == SRV &&
			    (strncmp(u->scheme, "http", 4) == 0
			     || strcmp(u->scheme, "ftp") == 0)) {
-
				srv = true;
				snprintf(zone, sizeof(zone),
				    "_%s._tcp.%s", u->scheme, u->host);
-
				if (f->srv == NULL)
-
					f->srv = dns_getsrvinfo(zone);
-
				srv_current = f->srv;
-
			} else if (mt != NULL && strncasecmp(mt, "http", 4) == 0 &&
+
				if (repo->srv == NULL)
+
					repo->srv = dns_getsrvinfo(zone);
+
				srv_current = repo->srv;
+
			} else if (repo->mirror_type == HTTP &&
			           strncmp(u->scheme, "http", 4) == 0) {
-
				http = true;
				snprintf(zone, sizeof(zone),
				    "%s://%s", u->scheme, u->host);
-
				if (f->http == NULL)
-
					gethttpmirrors(f, zone);
-
				http_current = f->http;
+
				if (repo->http == NULL)
+
					gethttpmirrors(repo, zone);
+
				http_current = repo->http;
			}
		}

-
		if (srv && f->srv != NULL)
+
		if (repo->mirror_type == SRV && repo->srv != NULL)
			strlcpy(u->host, srv_current->host, sizeof(u->host));
-
		else if (http && f->http != NULL) {
+
		else if (repo->mirror_type == HTTP && repo->http != NULL) {
			strlcpy(u->scheme, http_current->url->scheme, sizeof(u->scheme));
			strlcpy(u->host, http_current->url->host, sizeof(u->host));
			snprintf(docpath, MAXPATHLEN, "%s%s", http_current->url->doc, doc);
@@ -324,14 +291,14 @@ pkg_fetch_file_to_fd(struct pkg_fetch *f, const char *url, int dest, time_t *t)
				retcode = EPKG_FATAL;
				goto cleanup;
			}
-
			if (srv && f->srv != NULL) {
+
			if (repo->mirror_type == SRV && repo->srv != NULL) {
				srv_current = srv_current->next;
				if (srv_current == NULL)
-
					srv_current = f->srv;
-
			} else if (http && f->http != NULL) {
-
				http_current = f->http->next;
+
					srv_current = repo->srv;
+
			} else if (repo->mirror_type == HTTP && repo->http != NULL) {
+
				http_current = repo->http->next;
				if (http_current == NULL)
-
					http_current = f->http;
+
					http_current = repo->http;
			} else {
				sleep(1);
			}
@@ -403,16 +370,16 @@ pkg_fetch_file_to_fd(struct pkg_fetch *f, const char *url, int dest, time_t *t)
		if (remote != NULL)
			fclose(remote);
	} else {
-
		EV_SET(&e, fileno(f->ssh), EVFILT_READ, EV_DELETE, 0, 0, 0);
+
		EV_SET(&e, fileno(repo->ssh), EVFILT_READ, EV_DELETE, 0, 0, 0);
		kevent(kq, &e, 1, NULL, 0, NULL);
		flags &= ~O_NONBLOCK;
-
		if (fcntl(fileno(f->ssh), F_SETFL, flags) == -1)
+
		if (fcntl(fileno(repo->ssh), F_SETFL, flags) == -1)
			flags = -1;

		/* if something went wrong close the ssh connection */
		if (flags == -1) {
-
			pclose(f->ssh);
-
			f->ssh = NULL;
+
			pclose(repo->ssh);
+
			repo->ssh = NULL;
		}
	}

modified libpkg/pkg.h.in
@@ -271,6 +271,13 @@ typedef enum {
	PKG_ANNOTATIONS,
} pkg_list;

+
typedef enum {
+
	ALL,
+
	SRV,
+
	HTTP,
+
	NOMIRROR,
+
} mirror_t;
+

/**
 * Determine the type of a pkg_script.
 */
@@ -1102,7 +1109,7 @@ int pkg_create_staged(const char *, pkg_formats, const char *, const char *,
 * Download the latest repo db file and checks its signature if any
 * @param force Always download the repo catalogue
 */
-
int pkg_update(const char *name, const char *packagesite, bool force);
+
int pkg_update(struct pkg_repo *repo, bool force);

/**
 * Get statistics information from the package database(s)
@@ -1173,7 +1180,7 @@ int pkg_version_cmp(const char * const , const char * const);
 * Fetch a file.
 * @return An error code.
 */
-
int pkg_fetch_file(const char *url, const char *dest, time_t t);
+
int pkg_fetch_file(struct pkg_repo *repo, const char *url, const char *dest, time_t t);

/* glue to deal with ports */
int ports_parse_plist(struct pkg *, const char *, const char *);
modified libpkg/pkg_config.c
@@ -1040,6 +1040,8 @@ pkg_init(const char *path)
	/* load the repositories */
	load_repositories();

+
	setenv("HTTP_USER_AGENT", "pkg/"PKGVERSION, 1);
+

	/* bypass resolv.conf with specified NAMESERVER if any */
	pkg_config_string(PKG_CONFIG_NAMESERVER, &nsname);
	if (nsname != NULL)
@@ -1106,6 +1108,19 @@ pkg_configs(struct pkg_config **conf)
	HASH_NEXT(config, (*conf));
}

+
static void
+
pkg_repo_free(struct pkg_repo *r)
+
{
+
	free(r->url);
+
	free(r->name);
+
	free(r->pubkey);
+
	if (r->ssh != NULL) {
+
		fprintf(r->ssh, "quit\n");
+
		pclose(r->ssh);
+
	}
+
	free(r);
+
}
+

int
pkg_shutdown(void)
{
@@ -1115,6 +1130,7 @@ pkg_shutdown(void)
	}

	HASH_FREE(config, pkg_config, pkg_config_free);
+
	HASH_FREE(repos, pkg_repo, pkg_repo_free);

	config_by_key = NULL;

modified libpkg/pkg_repo.c
@@ -60,6 +60,7 @@ pkg_repo_fetch(struct pkg *pkg)
	const char *cachedir = NULL;
	int retcode = EPKG_OK;
	const char *repopath, *sum, *name, *version, *reponame;
+
	struct pkg_repo *repo;

	assert((pkg->type & PKG_REMOTE) == PKG_REMOTE);

@@ -93,7 +94,8 @@ pkg_repo_fetch(struct pkg *pkg)
	 */
	if (strncmp(reponame, "repo-", 5) == 0)
		reponame += 5;
-
	packagesite = pkg_repo_url(pkg_repo_find(reponame));
+
	repo = pkg_repo_find(reponame);
+
	packagesite = pkg_repo_url(repo);

	if (packagesite == NULL || packagesite[0] == '\0') {
		pkg_emit_error("PACKAGESITE is not defined");
@@ -106,7 +108,7 @@ pkg_repo_fetch(struct pkg *pkg)
	else
		snprintf(url, sizeof(url), "%s/%s", packagesite, repopath);

-
	retcode = pkg_fetch_file(url, dest, 0);
+
	retcode = pkg_fetch_file(repo, url, dest, 0);
	fetched = 1;

	if (retcode != EPKG_OK)
modified libpkg/private/pkg.h
@@ -262,6 +262,12 @@ struct pkg_repo {
	char *name;
	char *url;
	char *pubkey;
+
	mirror_t mirror_type;
+
	union {
+
		struct dns_srvinfo *srv;
+
		struct http_mirror *http;
+
	};
+
	FILE *ssh;
	bool enable;
	UT_hash_handle hh;
};
@@ -298,9 +304,7 @@ int pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags);
#define PKG_DELETE_UPGRADE (1<<1)
#define PKG_DELETE_NOSCRIPT (1<<2)

-
int pkg_fetch_new(struct pkg_fetch **f);
-
int pkg_fetch_free(struct pkg_fetch *f);
-
int pkg_fetch_file_to_fd(struct pkg_fetch *f, const char *url, int dest, time_t *t);
+
int pkg_fetch_file_to_fd(struct pkg_repo *repo, const char *url, int dest, time_t *t);
int pkg_repo_fetch(struct pkg *pkg);

int pkg_start_stop_rc_scripts(struct pkg *, pkg_rc_attr attr);
modified libpkg/update.c
@@ -68,15 +68,14 @@ remote_add_indexes(const char *reponame)

/* Return opened file descriptor */
static int
-
repo_fetch_remote_tmp(const char *reponame, const char *filename, const char *extension, time_t *t, int *rc)
+
repo_fetch_remote_tmp(struct pkg_repo *repo, const char *filename, const char *extension, time_t *t, int *rc)
{
	char url[MAXPATHLEN];
	char tmp[MAXPATHLEN];
	int fd;
	const char *tmpdir;
-
	struct pkg_fetch *f;

-
	snprintf(url, MAXPATHLEN, "%s/%s.%s", reponame, filename, extension);
+
	snprintf(url, MAXPATHLEN, "%s/%s.%s", pkg_repo_url(repo), filename, extension);

	tmpdir = getenv("TMPDIR");
	if (tmpdir == NULL)
@@ -92,12 +91,10 @@ repo_fetch_remote_tmp(const char *reponame, const char *filename, const char *ex
	}
	(void)unlink(tmp);

-
	pkg_fetch_new(&f);
-
	if ((*rc = pkg_fetch_file_to_fd(f, url, fd, t)) != EPKG_OK) {
+
	if ((*rc = pkg_fetch_file_to_fd(repo, url, fd, t)) != EPKG_OK) {
		close(fd);
		fd = -1;
	}
-
	pkg_fetch_free(f);

	return (fd);
}
@@ -188,7 +185,7 @@ cleanup:
}

static FILE *
-
repo_fetch_remote_extract_tmp(const char *packagesite, const char *filename,
+
repo_fetch_remote_extract_tmp(struct pkg_repo *repo, const char *filename,
		const char *extension, time_t *t, int *rc, const char *archive_file)
{
	int fd, dest_fd;
@@ -196,7 +193,7 @@ repo_fetch_remote_extract_tmp(const char *packagesite, const char *filename,
	const char *tmpdir;
	char tmp[MAXPATHLEN];

-
	fd = repo_fetch_remote_tmp(packagesite, filename, extension, t, rc);
+
	fd = repo_fetch_remote_tmp(repo, filename, extension, t, rc);
	if (fd == -1) {
		return (NULL);
	}
@@ -237,7 +234,7 @@ cleanup:
}

static int
-
pkg_update_full(const char *repofile, const char *name, const char *packagesite, time_t *mtime)
+
pkg_update_full(const char *repofile, struct pkg_repo *repo, time_t *mtime)
{
	char repofile_unchecked[MAXPATHLEN];
	int fd = -1, rc = EPKG_FATAL;
@@ -263,7 +260,7 @@ pkg_update_full(const char *repofile, const char *name, const char *packagesite,
		goto cleanup;
	}

-
	if ((fd = repo_fetch_remote_tmp(packagesite, repo_db_archive, "txz", mtime, &rc)) == -1) {
+
	if ((fd = repo_fetch_remote_tmp(repo, repo_db_archive, "txz", mtime, &rc)) == -1) {
		goto cleanup;
	}

@@ -327,7 +324,7 @@ pkg_update_full(const char *repofile, const char *name, const char *packagesite,
		goto cleanup;
	}

-
	sqlite3_bind_text(stmt, 1, packagesite, -1, SQLITE_STATIC);
+
	sqlite3_bind_text(stmt, 1, pkg_repo_name(repo), -1, SQLITE_STATIC);

	if (sqlite3_step(stmt) != SQLITE_DONE) {
		ERROR_SQLITE(sqlite);
@@ -341,14 +338,13 @@ pkg_update_full(const char *repofile, const char *name, const char *packagesite,
	sqlite3_close(sqlite);
	sqlite3_shutdown();

-

	if (rename(repofile_unchecked, repofile) != 0) {
		pkg_emit_errno("rename", "");
		rc = EPKG_FATAL;
		goto cleanup;
	}

-
	if ((rc = remote_add_indexes(name)) != EPKG_OK)
+
	if ((rc = remote_add_indexes(repofile)) != EPKG_OK)
		goto cleanup;
	rc = EPKG_OK;

@@ -431,7 +427,7 @@ pkg_update_increment_item_new(struct pkg_increment_task_item **head, const char
}

static int
-
pkg_update_incremental(const char *name, const char *packagesite, time_t *mtime)
+
pkg_update_incremental(const char *name, struct pkg_repo *repo, time_t *mtime)
{
	FILE *fmanifest = NULL, *fdigests = NULL;
	sqlite3 *sqlite = NULL;
@@ -475,13 +471,13 @@ pkg_update_incremental(const char *name, const char *packagesite, time_t *mtime)
		goto cleanup;
	}

-
	fdigests = repo_fetch_remote_extract_tmp(packagesite,
+
	fdigests = repo_fetch_remote_extract_tmp(repo,
			repo_digests_archive, "txz", &local_t,
			&rc, repo_digests_file);
	if (fdigests == NULL)
		goto cleanup;
	local_t = *mtime;
-
	fmanifest = repo_fetch_remote_extract_tmp(packagesite,
+
	fmanifest = repo_fetch_remote_extract_tmp(repo,
			repo_packagesite_archive, "txz", &local_t,
			&rc, repo_packagesite_file);
	if (fmanifest == NULL)
@@ -604,7 +600,7 @@ cleanup:
}

int
-
pkg_update(const char *name, const char *packagesite, bool force)
+
pkg_update(struct pkg_repo *repo, bool force)
{
	char repofile[MAXPATHLEN];

@@ -623,7 +619,7 @@ pkg_update(const char *name, const char *packagesite, bool force)
		return (EPKG_FATAL);
	}

-
	snprintf(repofile, sizeof(repofile), "%s/%s.sqlite", dbdir, name);
+
	snprintf(repofile, sizeof(repofile), "%s/repo-%s.sqlite", dbdir, pkg_repo_name(repo));

	if (stat(repofile, &st) != -1)
		t = force ? 0 : st.st_mtime;
@@ -650,7 +646,7 @@ pkg_update(const char *name, const char *packagesite, bool force)

	if (t != 0) {
		req = sqlite3_mprintf("select count(key) from repodata "
-
		    "WHERE key = \"packagesite\" and value = '%q'", packagesite);
+
		    "WHERE key = \"packagesite\" and value = '%q'", pkg_repo_url(repo));

		if (get_pragma(sqlite, req, &res) != EPKG_OK) {
			sqlite3_free(req);
@@ -668,11 +664,11 @@ pkg_update(const char *name, const char *packagesite, bool force)
			sqlite3_close(sqlite);
	}
	if (can_increment)
-
		res = pkg_update_incremental(repofile, packagesite, &t);
+
		res = pkg_update_incremental(repofile, repo, &t);

	if (!can_increment || res != EPKG_OK) {
		/* Still try to do full upgrade */
-
		if ((res = pkg_update_full(repofile, name, packagesite, &t)) != EPKG_OK)
+
		if ((res = pkg_update_full(repofile, repo, &t)) != EPKG_OK)
			goto cleanup;
	}

modified pkg/add.c
@@ -118,7 +118,7 @@ exec_add(int argc, char **argv)
	for (i = 0; i < argc; i++) {
		if (is_url(argv[i]) == EPKG_OK) {
			snprintf(path, sizeof(path), "./%s", basename(argv[i]));
-
			if ((retcode = pkg_fetch_file(argv[i], path, 0)) != EPKG_OK)
+
			if ((retcode = pkg_fetch_file(NULL, argv[i], path, 0)) != EPKG_OK)
				break;

			file = path;
modified pkg/audit.c
@@ -157,7 +157,7 @@ fetch_and_extract(const char *src, const char *dest, bool xml)
	if (stat(dest, &st) != -1) {
		t = st.st_mtime;
	}
-
	switch (pkg_fetch_file(src, tmp, t)) {
+
	switch (pkg_fetch_file(NULL, src, tmp, t)) {
	case EPKG_OK:
		break;
	case EPKG_UPTODATE:
modified pkg/update.c
@@ -45,10 +45,7 @@
 */
int
pkgcli_update(bool force) {
-
	const char *packagesite = NULL;
-
	const char *repo_name;
	int retcode = EPKG_FATAL;
-
	char name[MAXPATHLEN];
	struct pkg_repo *r = NULL;

	/* Only auto update if the user has write access. */
@@ -60,16 +57,13 @@ pkgcli_update(bool force) {
		printf("Updating repository catalogue\n");

	while (pkg_repos(&r) == EPKG_OK) {
-
		repo_name = pkg_repo_name(r);
-
		packagesite = pkg_repo_url(r);

-
		snprintf(name, MAXPATHLEN, "repo-%s", repo_name);
-
		retcode = pkg_update(name, packagesite, force);
+
		retcode = pkg_update(r, force);
		if (retcode == EPKG_UPTODATE) {
			if (!quiet)
				printf("%s repository catalogue is "
				       "up-to-date, no need to fetch "
-
				       "fresh copy\n", repo_name);
+
				       "fresh copy\n", pkg_repo_name(r));
				retcode = EPKG_OK;
		}
		if (retcode != EPKG_OK)