Skip to content

Commit aa83511

Browse files
AMDmi3bapt
authored andcommitted
Make duplicate-related warning fatal in developer mode
Conflicts: libpkg/pkg.c
1 parent 6c7de52 commit aa83511

File tree

1 file changed

+81
-24
lines changed

1 file changed

+81
-24
lines changed

libpkg/pkg.c

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,13 @@ pkg_addlicense(struct pkg *pkg, const char *name)
498498

499499
HASH_FIND_STR(pkg->licenses, name, l);
500500
if (l != NULL) {
501-
pkg_emit_error("duplicate license listing: %s, ignoring", name);
502-
return (EPKG_OK);
501+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
502+
pkg_emit_error("duplicate license listing: %s, fatal (developer mode)", name);
503+
return (EPKG_FATAL);
504+
} else {
505+
pkg_emit_error("duplicate license listing: %s, ignoring", name);
506+
return (EPKG_OK);
507+
}
503508
}
504509

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

522527
HASH_FIND_STR(pkg->users, name, u);
523528
if (u != NULL) {
524-
pkg_emit_error("duplicate user listing: %s, ignoring", name);
525-
return (EPKG_OK);
529+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
530+
pkg_emit_error("duplicate user listing: %s, fatal (developer mode)", name);
531+
return (EPKG_FATAL);
532+
} else {
533+
pkg_emit_error("duplicate user listing: %s, ignoring", name);
534+
return (EPKG_OK);
535+
}
526536
}
527537

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

556566
HASH_FIND_STR(pkg->groups, name, g);
557567
if (g != NULL) {
558-
pkg_emit_error("duplicate group listing: %s, ignoring", name);
559-
return (EPKG_OK);
568+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
569+
pkg_emit_error("duplicate group listing: %s, fatal (developer mode)", name);
570+
return (EPKG_FATAL);
571+
} else {
572+
pkg_emit_error("duplicate group listing: %s, ignoring", name);
573+
return (EPKG_OK);
574+
}
560575
}
561576

562577
pkg_group_new(&g);
@@ -593,9 +608,15 @@ pkg_adddep(struct pkg *pkg, const char *name, const char *origin, const char *ve
593608
HASH_FIND_STR(pkg->deps, origin, d);
594609
if (d != NULL) {
595610
pkg_get(pkg, PKG_NAME, &n1, PKG_VERSION, &v1);
596-
pkg_emit_error("%s-%s: duplicate dependency listing: %s-%s, ignoring",
597-
n1, v1, name, version);
598-
return (EPKG_OK);
611+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
612+
pkg_emit_error("%s-%s: duplicate dependency listing: %s-%s, fatal (developer mode)",
613+
n1, v1, name, version);
614+
return (EPKG_FATAL);
615+
} else {
616+
pkg_emit_error("%s-%s: duplicate dependency listing: %s-%s, ignoring",
617+
n1, v1, name, version);
618+
return (EPKG_OK);
619+
}
599620
}
600621

601622
pkg_dep_new(&d);
@@ -654,8 +675,13 @@ pkg_addfile_attr(struct pkg *pkg, const char *path, const char *sha256, const ch
654675
if (check_duplicates) {
655676
HASH_FIND_STR(pkg->files, path, f);
656677
if (f != NULL) {
657-
pkg_emit_error("duplicate file listing: %s, ignoring", pkg_file_path(f));
658-
return (EPKG_OK);
678+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
679+
pkg_emit_error("duplicate file listing: %s, fatal (developer mode)", pkg_file_path(f));
680+
return (EPKG_FATAL);
681+
} else {
682+
pkg_emit_error("duplicate file listing: %s, ignoring", pkg_file_path(f));
683+
return (EPKG_OK);
684+
}
659685
}
660686
}
661687

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

690716
HASH_FIND_STR(pkg->categories, name, c);
691717
if (c != NULL) {
692-
pkg_emit_error("duplicate category listing: %s, ignoring", name);
693-
return (EPKG_OK);
718+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
719+
pkg_emit_error("duplicate category listing: %s, fatal (developer mode)", name);
720+
return (EPKG_FATAL);
721+
} else {
722+
pkg_emit_error("duplicate category listing: %s, ignoring", name);
723+
return (EPKG_OK);
724+
}
694725
}
695726

696727
pkg_category_new(&c);
@@ -721,8 +752,13 @@ pkg_adddir_attr(struct pkg *pkg, const char *path, const char *uname, const char
721752
if (check_duplicates) {
722753
HASH_FIND_STR(pkg->dirs, path, d);
723754
if (d != NULL) {
724-
pkg_emit_error("duplicate directory listing: %s, ignoring", path);
725-
return (EPKG_OK);
755+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
756+
pkg_emit_error("duplicate directory listing: %s, fatal (developer mode)", path);
757+
return (EPKG_FATAL);
758+
} else {
759+
pkg_emit_error("duplicate directory listing: %s, ignoring", path);
760+
return (EPKG_OK);
761+
}
726762
}
727763
}
728764

@@ -856,8 +892,13 @@ pkg_addoption(struct pkg *pkg, const char *key, const char *value)
856892
pkg_option_new(&o);
857893
sbuf_set(&o->key, key);
858894
} else if ( o->value != NULL) {
859-
pkg_emit_error("duplicate options listing: %s, ignoring", key);
860-
return (EPKG_OK);
895+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
896+
pkg_emit_error("duplicate options listing: %s, fatal (developer mode)", key);
897+
return (EPKG_FATAL);
898+
} else {
899+
pkg_emit_error("duplicate options listing: %s, ignoring", key);
900+
return (EPKG_OK);
901+
}
861902
}
862903

863904
sbuf_set(&o->value, value);
@@ -889,8 +930,13 @@ pkg_addoption_default(struct pkg *pkg, const char *key,
889930
pkg_option_new(&o);
890931
sbuf_set(&o->key, key);
891932
} else if ( o->default_value != NULL) {
892-
pkg_emit_error("duplicate default value for option: %s, ignoring", key);
893-
return (EPKG_OK);
933+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
934+
pkg_emit_error("duplicate default value for option: %s, fatal (developer mode)", key);
935+
return (EPKG_FATAL);
936+
} else {
937+
pkg_emit_error("duplicate default value for option: %s, ignoring", key);
938+
return (EPKG_OK);
939+
}
894940
}
895941

896942
sbuf_set(&o->default_value, default_value);
@@ -921,8 +967,13 @@ pkg_addoption_description(struct pkg *pkg, const char *key,
921967
pkg_option_new(&o);
922968
sbuf_set(&o->key, key);
923969
} else if ( o->description != NULL) {
924-
pkg_emit_error("duplicate description for option: %s, ignoring", key);
925-
return (EPKG_OK);
970+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
971+
pkg_emit_error("duplicate description for option: %s, fatal (developer mode)", key);
972+
return (EPKG_FATAL);
973+
} else {
974+
pkg_emit_error("duplicate description for option: %s, ignoring", key);
975+
return (EPKG_OK);
976+
}
926977
}
927978

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

10441095
an = ucl_object_find_key(pkg->annotations, tag);
10451096
if (an != NULL) {
1046-
pkg_emit_error("duplicate annotation tag: %s value: %s,"
1047-
" ignoring", tag, value);
1048-
return (EPKG_OK);
1097+
if (pkg_object_bool(pkg_config_get("DEVELOPER_MODE"))) {
1098+
pkg_emit_error("duplicate annotation tag: %s value: %s,"
1099+
" fatal (developer mode)", tag, value);
1100+
return (EPKG_OK);
1101+
} else {
1102+
pkg_emit_error("duplicate annotation tag: %s value: %s,"
1103+
" ignoring", tag, value);
1104+
return (EPKG_OK);
1105+
}
10491106
}
10501107
an = ucl_object_fromstring_common(value, strlen(value), 0);
10511108
pkg->annotations = ucl_object_insert_key(pkg->annotations,

0 commit comments

Comments
 (0)