pkgng

Check-in [ebae45aa87]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When iterating through repos to check for database access, igore the ones which aren't enabled. Add boolean flag to pkg_count_repos: if true, only count the active repos. Fixes #598
Timelines: family | ancestors | descendants | both | trunk | multi-repos | stash
Files: files | file ages | folders
SHA1:ebae45aa8768e1f72b2162e84d6060782c193ae0
User & Date: m.seaman@infracaninophile.co.uk 2013-09-27 11:55:10
Context
2013-09-29
08:53
Quick'n'dirty implementation of pkg+foo:// URL scheme, for foo in (http, https, ftp). Some style improvements Code in libpkg/fetch.c needs refactoring so we can cleanly implement pkg+ssh:// issue #550 check-in: 54821fb118 user: m.seaman@infracaninophile.co.uk tags: trunk, multi-repos, stash
2013-09-27
11:55
When iterating through repos to check for database access, igore the ones which aren't enabled. Add boolean flag to pkg_count_repos: if true, only count the active repos. Fixes #598 check-in: ebae45aa87 user: m.seaman@infracaninophile.co.uk tags: trunk, multi-repos, stash
2013-09-24
21:51
Extract mtree and execute script when staging check-in: 13039abea4 user: bapt@FreeBSD.org tags: trunk, multi-repos, stash
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to libpkg/pkg.h.in.

1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
int pkg_old_load_from_path(struct pkg *pkg, const char *path);
int pkg_old_emit_content(struct pkg *pkg, char **dest);
int pkg_from_old(struct pkg *pkg);
int pkg_to_old(struct pkg *pkg);
int pkg_register_old(struct pkg *pkg);
int pkg_sshserve(void);

int pkg_repos_count(void);
int pkg_repos(struct pkg_repo **);
const char *pkg_repo_url(struct pkg_repo *r);
const char *pkg_repo_ident(struct pkg_repo *r);
const char *pkg_repo_name(struct pkg_repo *r);
const char * pkg_repo_ident_from_name(const char *repo_name);
const char *pkg_repo_key(struct pkg_repo *r);
const char *pkg_repo_fingerprints(struct pkg_repo *r);







|







1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
int pkg_old_load_from_path(struct pkg *pkg, const char *path);
int pkg_old_emit_content(struct pkg *pkg, char **dest);
int pkg_from_old(struct pkg *pkg);
int pkg_to_old(struct pkg *pkg);
int pkg_register_old(struct pkg *pkg);
int pkg_sshserve(void);

int pkg_repos_count(bool);
int pkg_repos(struct pkg_repo **);
const char *pkg_repo_url(struct pkg_repo *r);
const char *pkg_repo_ident(struct pkg_repo *r);
const char *pkg_repo_name(struct pkg_repo *r);
const char * pkg_repo_ident_from_name(const char *repo_name);
const char *pkg_repo_key(struct pkg_repo *r);
const char *pkg_repo_fingerprints(struct pkg_repo *r);

Changes to libpkg/pkg_config.c.

1256
1257
1258
1259
1260
1261
1262
1263
1264
















1265


1266
1267
1268
1269
1270
1271
1272

	parsed = false;

	return;
}

int
pkg_repos_count(void)
{
















	return (HASH_COUNT(repos));


}

int
pkg_repos(struct pkg_repo **r)
{
	HASH_NEXT(repos, (*r));
}







|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>







1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290

	parsed = false;

	return;
}

int
pkg_repos_count(bool activated_only)
{
	int	count;

	if (!activated_only) {
		struct pkg_repo *r = NULL;

		count = 0;

		while(1) {
			HASH_NEXT(repos, r);
			if (r == NULL)
				break;

			if (r->enable)
				count++;
		}
	} else
		count = HASH_COUNT(repos);

	return (count);
}

int
pkg_repos(struct pkg_repo **r)
{
	HASH_NEXT(repos, (*r));
}

Changes to libpkg/pkgdb.c.

954
955
956
957
958
959
960




961
962
963
964
965
966
967
....
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
			return (retval);
	}

	if ((database & PKGDB_DB_REPO) != 0) {
		struct pkg_repo	*r = NULL;

		while (pkg_repos(&r) == EPKG_OK) {




			retval = database_access(mode, dbdir, pkg_repo_name(r));
			if (retval != EPKG_OK)
				return (retval);
		}
	}
	return (retval);
}
................................................................................
		else {
			pkg_emit_error("Repository %s can't be loaded",
					reponame);
			sbuf_delete(sql);
			return (NULL);
		}
	} else {
		if (pkg_repos_count() == 0) {
			pkg_emit_error("No repositories configured");
			sbuf_delete(sql);
			return (NULL);
		}
		/* test on all the attached databases */
		if (sql_on_all_attached_db(db->sqlite, sql,
		    multireposql, " UNION ALL ") != EPKG_OK) {
			sbuf_delete(sql);







>
>
>
>







 







|
|







954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
....
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
			return (retval);
	}

	if ((database & PKGDB_DB_REPO) != 0) {
		struct pkg_repo	*r = NULL;

		while (pkg_repos(&r) == EPKG_OK) {
			/* Ignore any repos marked as inactive */
			if (!pkg_repo_enabled(r))
				continue;

			retval = database_access(mode, dbdir, pkg_repo_name(r));
			if (retval != EPKG_OK)
				return (retval);
		}
	}
	return (retval);
}
................................................................................
		else {
			pkg_emit_error("Repository %s can't be loaded",
					reponame);
			sbuf_delete(sql);
			return (NULL);
		}
	} else {
		if (pkg_repos_count(true) == 0) {
			pkg_emit_error("No active repositories configured");
			sbuf_delete(sql);
			return (NULL);
		}
		/* test on all the attached databases */
		if (sql_on_all_attached_db(db->sqlite, sql,
		    multireposql, " UNION ALL ") != EPKG_OK) {
			sbuf_delete(sql);

Changes to pkg/stats.c.

91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
			printf("\tDisk space occupied: %" PRId64 "\n\n", flatsize);
		else {
			humanize_number(size, sizeof(size), flatsize, "B", HN_AUTOSCALE, 0);
			printf("\tDisk space occupied: %s\n\n", size);
		}
	}

	if (opt & STATS_REMOTE && pkg_repos_count() > 0) {
		printf("Remote package database(s):\n");
		printf("\tNumber of repositories: %" PRId64 "\n", pkgdb_stats(db, PKG_STATS_REMOTE_REPOS));
		printf("\tPackages available: %" PRId64 "\n", pkgdb_stats(db, PKG_STATS_REMOTE_COUNT));
		printf("\tUnique packages: %" PRId64 "\n", pkgdb_stats(db, PKG_STATS_REMOTE_UNIQUE));

		flatsize = pkgdb_stats(db, PKG_STATS_REMOTE_SIZE);








|







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
			printf("\tDisk space occupied: %" PRId64 "\n\n", flatsize);
		else {
			humanize_number(size, sizeof(size), flatsize, "B", HN_AUTOSCALE, 0);
			printf("\tDisk space occupied: %s\n\n", size);
		}
	}

	if (opt & STATS_REMOTE && pkg_repos_count(false) > 0) {
		printf("Remote package database(s):\n");
		printf("\tNumber of repositories: %" PRId64 "\n", pkgdb_stats(db, PKG_STATS_REMOTE_REPOS));
		printf("\tPackages available: %" PRId64 "\n", pkgdb_stats(db, PKG_STATS_REMOTE_COUNT));
		printf("\tUnique packages: %" PRId64 "\n", pkgdb_stats(db, PKG_STATS_REMOTE_UNIQUE));

		flatsize = pkgdb_stats(db, PKG_STATS_REMOTE_SIZE);

Changes to pkg/utils.c.

598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637

				dlsize += pkgsize;

			if (oldversion != NULL) {
				switch (pkg_version_change(pkg)) {
				case PKG_DOWNGRADE:
					pkg_printf("\tDowngrading %n: %V -> %v", pkg, pkg, pkg);
					if (pkg_repos_count() > 1)
						pkg_printf(" [%N]", pkg);
					printf("\n");
					break;
				case PKG_REINSTALL:
					pkg_printf("\tReinstalling %n-%v", pkg, pkg);
					if (pkg_repos_count() > 1)
						pkg_printf(" [%N]", pkg);
					if (why != NULL)
						printf(" (%s)", why);
					printf("\n");
					break;
				case PKG_UPGRADE:
					pkg_printf("\tUpgrading %n: %V -> %v", pkg, pkg, pkg);
					if (pkg_repos_count() > 1)
						pkg_printf(" [%N]", pkg);
					printf("\n");
					break;
				}
				oldsize += oldflatsize;
				newsize += flatsize;
			} else {
				newsize += flatsize;

				pkg_printf("\tInstalling %n: %v", pkg, pkg);
				if (pkg_repos_count() > 1)
					pkg_printf(" [%N]", pkg);
				printf("\n");
			}
			break;
		case PKG_JOBS_DEINSTALL:
		case PKG_JOBS_AUTOREMOVE:
			oldsize += oldflatsize;







|





|







|










|







598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637

				dlsize += pkgsize;

			if (oldversion != NULL) {
				switch (pkg_version_change(pkg)) {
				case PKG_DOWNGRADE:
					pkg_printf("\tDowngrading %n: %V -> %v", pkg, pkg, pkg);
					if (pkg_repos_count(false) > 1)
						pkg_printf(" [%N]", pkg);
					printf("\n");
					break;
				case PKG_REINSTALL:
					pkg_printf("\tReinstalling %n-%v", pkg, pkg);
					if (pkg_repos_count(false) > 1)
						pkg_printf(" [%N]", pkg);
					if (why != NULL)
						printf(" (%s)", why);
					printf("\n");
					break;
				case PKG_UPGRADE:
					pkg_printf("\tUpgrading %n: %V -> %v", pkg, pkg, pkg);
					if (pkg_repos_count(false) > 1)
						pkg_printf(" [%N]", pkg);
					printf("\n");
					break;
				}
				oldsize += oldflatsize;
				newsize += flatsize;
			} else {
				newsize += flatsize;

				pkg_printf("\tInstalling %n: %v", pkg, pkg);
				if (pkg_repos_count(false) > 1)
					pkg_printf(" [%N]", pkg);
				printf("\n");
			}
			break;
		case PKG_JOBS_DEINSTALL:
		case PKG_JOBS_AUTOREMOVE:
			oldsize += oldflatsize;