Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Restore files order
Baptiste Daroussin committed 10 years ago
commit b0f1d581acafce9f6c81f18ffa872a394d2cc2db
parent cbe7cb1
7 files changed +36 -17
modified libpkg/pkg.c
@@ -505,6 +505,21 @@ pkg_conflicts(const struct pkg *pkg, struct pkg_conflict **c)
	HASH_NEXT(pkg->conflicts, (*c));
}

+
int
+
pkg_files(const struct pkg *pkg, struct pkg_file **f)
+
{
+
	assert(pkg != NULL);
+

+
	if ((*f) == NULL)
+
		(*f) = pkg->files;
+
	else
+
		(*f) = (*f)->next;
+
	if ((*f) == NULL)
+
		return (EPKG_END);
+

+
	return (EPKG_OK);
+
}
+

#define pkg_each_hash(name, htype, type, attrib)	\
int							\
pkg_##name(const struct pkg *pkg, type **c) {		\
@@ -513,7 +528,6 @@ pkg_##name(const struct pkg *pkg, type **c) { \
}
pkg_each_hash(deps, pkg_deps, struct pkg_dep, name);
pkg_each_hash(rdeps, pkg_deps, struct pkg_dep, name);
-
pkg_each_hash(files, pkg_files, struct pkg_file, path);
pkg_each_hash(config_files, pkg_config_files, struct pkg_config_file, path);
pkg_each_hash(dirs, pkg_dirs, struct pkg_dir, path);

@@ -661,7 +675,7 @@ pkg_addfile_attr(struct pkg *pkg, const char *path, const char *sum,
	path = pkg_absolutepath(path, abspath, sizeof(abspath));
	pkg_debug(3, "Pkg: add new file '%s'", path);

-
	if (check_duplicates && kh_contains(pkg_files, pkg->files, path)) {
+
	if (check_duplicates && kh_contains(pkg_files, pkg->filehash, path)) {
		if (developer_mode) {
			pkg_emit_error("duplicate file listing: %s, fatal (developer mode)", path);
			return (EPKG_FATAL);
@@ -689,7 +703,8 @@ pkg_addfile_attr(struct pkg *pkg, const char *path, const char *sum,
	if (fflags != 0)
		f->fflags = fflags;

-
	kh_add(pkg_files, pkg->files, f, f->path);
+
	kh_add(pkg_files, pkg->filehash, f, f->path);
+
	LL_APPEND(pkg->files, f);

	return (EPKG_OK);
}
@@ -1208,7 +1223,7 @@ pkg_list_count(const struct pkg *pkg, pkg_list list)
	case PKG_OPTIONS:
		return (HASH_COUNT(pkg->options));
	case PKG_FILES:
-
		return (kh_count(pkg->files));
+
		return (kh_count(pkg->filehash));
	case PKG_DIRS:
		return (kh_count(pkg->dirs));
	case PKG_USERS:
@@ -1253,7 +1268,7 @@ pkg_list_free(struct pkg *pkg, pkg_list list) {
		break;
	case PKG_FILES:
	case PKG_CONFIG_FILES:
-
		kh_free(pkg_files, pkg->files, struct pkg_file, pkg_file_free);
+
		kh_free(pkg_files, pkg->filehash, struct pkg_file, pkg_file_free);
		kh_free(pkg_config_files, pkg->config_files, struct pkg_config_file, pkg_config_file_free);
		pkg->flags &= ~PKG_LOAD_FILES;
		break;
@@ -1663,15 +1678,15 @@ pkg_is_config_file(struct pkg *p, const char *path,
	if (kh_count(p->config_files) == 0)
		return (false);

-
	k = kh_get_pkg_files(p->files, path);
-
	if (k == kh_end(p->files))
+
	k = kh_get_pkg_files(p->filehash, path);
+
	if (k == kh_end(p->filehash))
		return (false);

	k2 = kh_get_pkg_config_files(p->config_files, path);
	if (k2 == kh_end(p->config_files))
		return (false);

-
	*file = kh_value(p->files, k);
+
	*file = kh_value(p->filehash, k);
	*cfile = kh_value(p->config_files, k2);

	return (true);
@@ -1680,7 +1695,7 @@ pkg_is_config_file(struct pkg *p, const char *path,
bool
pkg_has_file(struct pkg *p, const char *path)
{
-
	return (kh_contains(pkg_files, p->files, path));
+
	return (kh_contains(pkg_files, p->filehash, path));
}

bool
modified libpkg/pkg_add.c
@@ -669,7 +669,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,

	/* add the user and group if necessary */

-
	nfiles = kh_count(pkg->files);
+
	nfiles = kh_count(pkg->filehash);
	/*
	 * Extract the files on disk.
	 */
modified libpkg/pkg_create.c
@@ -75,7 +75,7 @@ pkg_create_from_dir(struct pkg *pkg, const char *root,
	 * Get / compute size / checksum if not provided in the manifest
	 */

-
	nfiles = kh_count(pkg->files);
+
	nfiles = kh_count(pkg->filehash);
	counter_init("file sizes/checksums", nfiles);

	hardlinks = kh_init_hardlinks();
modified libpkg/pkg_delete.c
@@ -329,7 +329,7 @@ pkg_delete_files(struct pkg *pkg, unsigned force)

	int		nfiles, cur_file = 0;

-
	nfiles = kh_count(pkg->files);
+
	nfiles = kh_count(pkg->filehash);

	if (nfiles == 0)
		return (EPKG_OK);
modified libpkg/pkg_jobs_conflicts.c
@@ -234,12 +234,12 @@ pkg_conflicts_need_conflict(struct pkg_jobs *j, struct pkg *p1, struct pkg *p2)
	/*
	 * We need to check all files and dirs and find the similar ones
	 */
-
	kh_each_value(p1->files, fcur, {
+
	LL_FOREACH(p1->files, fcur) {
		if (pkg_has_file(p2, fcur->path))
			return (true);
		if (pkg_has_dir(p2, fcur->path))
			return (true);
-
	});
+
	}
	/* XXX pkg dirs are terribly broken */

	/* No common paths are found in p1 and p2 */
@@ -468,7 +468,7 @@ pkg_conflicts_check_chain_conflict(struct pkg_job_universe_item *it,
	struct pkg_job_universe_item *cun;
	struct sipkey *k;

-
	kh_each_value(it->pkg->files, fcur, {
+
	LL_FOREACH(it->pkg->files, fcur) {
		k = pkg_conflicts_sipkey_init();
		/* Check in hash tree */
		cun = pkg_conflicts_check_all_paths(j, fcur->path, it, k);
@@ -488,7 +488,7 @@ pkg_conflicts_check_chain_conflict(struct pkg_job_universe_item *it,
			assert(cun != NULL);
			pkg_conflicts_register_chain(j, it, cun, fcur->path);
		}
-
	});
+
	}
	/* XXX: dirs are currently broken terribly */
#if 0
	struct pkg_dir *dcur, *dtmp, *df;
modified libpkg/private/pkg.h
@@ -244,7 +244,8 @@ struct pkg {
	kh_pkg_deps_t		*rdeps;
	kh_strings_t		*categories;
	kh_strings_t		*licenses;
-
	kh_pkg_files_t		*files;
+
	kh_pkg_files_t		*filehash;
+
	struct pkg_file		*files;
	kh_pkg_dirs_t		*dirs;
	struct pkg_option	*options;
	kh_strings_t		*users;
@@ -303,6 +304,7 @@ struct pkg_file {
	char		 gname[MAXLOGNAME];
	mode_t		 perm;
	u_long		 fflags;
+
	struct pkg_file	*next;
};

struct pkg_dir {
modified libpkg/repo/binary/query.c
@@ -463,8 +463,10 @@ pkg_repo_binary_ensure_loaded(struct pkg_repo *repo,
		pkg_list_free(pkg, PKG_FILES);
		pkg_list_free(pkg, PKG_DIRS);
		pkg->files = cached->files;
+
		pkg->filehash = cached->filehash;
		pkg->dirs = cached->dirs;
		cached->files = NULL;
+
		cached->filehash = NULL;
		cached->dirs = NULL;

		pkg_free(cached);