Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make duplicate-related warning fatal in developer mode
Conflicts:
	libpkg/pkg.c
  • Loading branch information
AMDmi3 authored and bapt committed Mar 31, 2014
1 parent 6c7de52 commit aa83511
Showing 1 changed file with 81 additions and 24 deletions.
105 changes: 81 additions & 24 deletions libpkg/pkg.c
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit aa83511

Please sign in to comment.