Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Make duplicate-related warning fatal in developer mode
Dmitry Marakasov committed 12 years ago
commit aa835114af15cc2b5556bc273baaedfa22a5ef63
parent 6c7de52
1 file changed +81 -24
modified libpkg/pkg.c
@@ -498,8 +498,13 @@ pkg_addlicense(struct pkg *pkg, const char *name)

	HASH_FIND_STR(pkg->licenses, name, l);
	if (l != NULL) {
-
		pkg_emit_error("duplicate license listing: %s, ignoring", name);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("duplicate license listing: %s, fatal (developer mode)", name);
+
			return (EPKG_FATAL);
+
		} else {
+
			pkg_emit_error("duplicate license listing: %s, ignoring", name);
+
			return (EPKG_OK);
+
		}
	}

	pkg_license_new(&l);
@@ -521,8 +526,13 @@ pkg_adduid(struct pkg *pkg, const char *name, const char *uidstr)

	HASH_FIND_STR(pkg->users, name, u);
	if (u != NULL) {
-
		pkg_emit_error("duplicate user listing: %s, ignoring", name);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("duplicate user listing: %s, fatal (developer mode)", name);
+
			return (EPKG_FATAL);
+
		} else {
+
			pkg_emit_error("duplicate user listing: %s, ignoring", name);
+
			return (EPKG_OK);
+
		}
	}

	pkg_user_new(&u);
@@ -555,8 +565,13 @@ pkg_addgid(struct pkg *pkg, const char *name, const char *gidstr)

	HASH_FIND_STR(pkg->groups, name, g);
	if (g != NULL) {
-
		pkg_emit_error("duplicate group listing: %s, ignoring", name);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("duplicate group listing: %s, fatal (developer mode)", name);
+
			return (EPKG_FATAL);
+
		} else {
+
			pkg_emit_error("duplicate group listing: %s, ignoring", name);
+
			return (EPKG_OK);
+
		}
	}

	pkg_group_new(&g);
@@ -593,9 +608,15 @@ pkg_adddep(struct pkg *pkg, const char *name, const char *origin, const char *ve
	HASH_FIND_STR(pkg->deps, origin, d);
	if (d != NULL) {
		pkg_get(pkg, PKG_NAME, &n1, PKG_VERSION, &v1);
-
		pkg_emit_error("%s-%s: duplicate dependency listing: %s-%s, ignoring",
-
		    n1, v1, name, version);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("%s-%s: duplicate dependency listing: %s-%s, fatal (developer mode)",
+
			    n1, v1, name, version);
+
			return (EPKG_FATAL);
+
		} else {
+
			pkg_emit_error("%s-%s: duplicate dependency listing: %s-%s, ignoring",
+
			    n1, v1, name, version);
+
			return (EPKG_OK);
+
		}
	}

	pkg_dep_new(&d);
@@ -654,8 +675,13 @@ pkg_addfile_attr(struct pkg *pkg, const char *path, const char *sha256, const ch
	if (check_duplicates) {
		HASH_FIND_STR(pkg->files, path, f);
		if (f != NULL) {
-
			pkg_emit_error("duplicate file listing: %s, ignoring", pkg_file_path(f));
-
			return (EPKG_OK);
+
			if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
				pkg_emit_error("duplicate file listing: %s, fatal (developer mode)", pkg_file_path(f));
+
				return (EPKG_FATAL);
+
			} else {
+
				pkg_emit_error("duplicate file listing: %s, ignoring", pkg_file_path(f));
+
				return (EPKG_OK);
+
			}
		}
	}

@@ -689,8 +715,13 @@ pkg_addcategory(struct pkg *pkg, const char *name)

	HASH_FIND_STR(pkg->categories, name, c);
	if (c != NULL) {
-
		pkg_emit_error("duplicate category listing: %s, ignoring", name);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("duplicate category listing: %s, fatal (developer mode)", name);
+
			return (EPKG_FATAL);
+
		} else {
+
			pkg_emit_error("duplicate category listing: %s, ignoring", name);
+
			return (EPKG_OK);
+
		}
	}

	pkg_category_new(&c);
@@ -721,8 +752,13 @@ pkg_adddir_attr(struct pkg *pkg, const char *path, const char *uname, const char
	if (check_duplicates) {
		HASH_FIND_STR(pkg->dirs, path, d);
		if (d != NULL) {
-
			pkg_emit_error("duplicate directory listing: %s, ignoring", path);
-
			return (EPKG_OK);
+
			if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
				pkg_emit_error("duplicate directory listing: %s, fatal (developer mode)", path);
+
				return (EPKG_FATAL);
+
			} else {
+
				pkg_emit_error("duplicate directory listing: %s, ignoring", path);
+
				return (EPKG_OK);
+
			}
		}
	}

@@ -856,8 +892,13 @@ pkg_addoption(struct pkg *pkg, const char *key, const char *value)
		pkg_option_new(&o);
		sbuf_set(&o->key, key);
	} else if ( o->value != NULL) {
-
		pkg_emit_error("duplicate options listing: %s, ignoring", key);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("duplicate options listing: %s, fatal (developer mode)", key);
+
			return (EPKG_FATAL);
+
		} else {
+
			pkg_emit_error("duplicate options listing: %s, ignoring", key);
+
			return (EPKG_OK);
+
		}
	}

	sbuf_set(&o->value, value);
@@ -889,8 +930,13 @@ pkg_addoption_default(struct pkg *pkg, const char *key,
		pkg_option_new(&o);
		sbuf_set(&o->key, key);
	} else if ( o->default_value != NULL) {
-
		pkg_emit_error("duplicate default value for option: %s, ignoring", key);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("duplicate default value for option: %s, fatal (developer mode)", key);
+
			return (EPKG_FATAL);
+
		} else {
+
			pkg_emit_error("duplicate default value for option: %s, ignoring", key);
+
			return (EPKG_OK);
+
		}
	}

	sbuf_set(&o->default_value, default_value);
@@ -921,8 +967,13 @@ pkg_addoption_description(struct pkg *pkg, const char *key,
		pkg_option_new(&o);
		sbuf_set(&o->key, key);
	} else if ( o->description != NULL) {
-
		pkg_emit_error("duplicate description for option: %s, ignoring", key);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("duplicate description for option: %s, fatal (developer mode)", key);
+
			return (EPKG_FATAL);
+
		} else {
+
			pkg_emit_error("duplicate description for option: %s, ignoring", key);
+
			return (EPKG_OK);
+
		}
	}

	sbuf_set(&o->description, description);
@@ -1043,9 +1094,15 @@ pkg_addannotation(struct pkg *pkg, const char *tag, const char *value)

	an = ucl_object_find_key(pkg->annotations, tag);
	if (an != NULL) {
-
		pkg_emit_error("duplicate annotation tag: %s value: %s,"
-
	           " ignoring", tag, value);
-
		return (EPKG_OK);
+
		if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
+
			pkg_emit_error("duplicate annotation tag: %s value: %s,"
+
			    " fatal (developer mode)", tag, value);
+
			return (EPKG_OK);
+
		} else {
+
			pkg_emit_error("duplicate annotation tag: %s value: %s,"
+
			    " ignoring", tag, value);
+
			return (EPKG_OK);
+
		}
	}
	an = ucl_object_fromstring_common(value, strlen(value), 0);
	pkg->annotations = ucl_object_insert_key(pkg->annotations,