Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libpkg: populate shilbs_{provided,required}_ignore
Isaac Freund committed 3 months ago
commit 838536e42eeba5fea3ff0c293fc36ae0761cfd8d
parent cd69108
3 files changed +48 -13
modified libpkg/pkg/vec.h
@@ -74,15 +74,20 @@
#define vec_pop(v) \
	(v)->d[--(v)->len]

-
#define vec_remove_and_free(v, cnt, free_func) \
+
#define vec_remove(v, cnt) \
	do {                                                    \
-
		free_func((v)->d[cnt]);                         \
		for (size_t _i = cnt; _i < (v)->len - 1; _i++) {    \
			(v)->d[_i] = (v)->d[_i + 1];            \
		}                                               \
		(v)->len--;                                     \
	} while (0)

+
#define vec_remove_and_free(v, cnt, free_func) \
+
	do {                                                    \
+
		free_func((v)->d[cnt]);                         \
+
		vec_remove(v, cnt);                             \
+
	} while (0)
+

/*
 * Remove the element at the given index and replace it with the last
 * element in the vec. Does not preserve order, but is O(1).
modified libpkg/pkg_abi.c
@@ -462,7 +462,7 @@ pkg_cleanup_shlibs_required(struct pkg *pkg, charv_t *internal_provided)
	const char *lib;

	vec_foreach(pkg->shlibs_required, i) {
-
		const char *s = pkg->shlibs_required.d[i];
+
		char *s = pkg->shlibs_required.d[i];
		if (charv_search(&pkg->shlibs_provided, s) != NULL ||
		    charv_search(internal_provided, s) != NULL) {
			pkg_debug(2,
@@ -473,6 +473,15 @@ pkg_cleanup_shlibs_required(struct pkg *pkg, charv_t *internal_provided)
			i--;
			continue;
		}
+
		if (charv_search(&pkg->shlibs_required_ignore, s) != NULL) {
+
			pkg_debug(2,
+
			    "remove %s from required shlibs for package %s as it "
+
			    "is listed in shlibs_required_ignore.",
+
			    s, pkg->name);
+
			vec_remove_and_free(&pkg->shlibs_required, i, free);
+
			i--;
+
			continue;
+
		}
		if (match_ucl_lists(s,
		    pkg_config_get("SHLIB_REQUIRE_IGNORE_GLOB"),
		    pkg_config_get("SHLIB_REQUIRE_IGNORE_REGEX"))) {
@@ -480,7 +489,10 @@ pkg_cleanup_shlibs_required(struct pkg *pkg, charv_t *internal_provided)
			    "remove %s from required shlibs for package %s as it "
			    "is matched by SHLIB_REQUIRE_IGNORE_GLOB/REGEX.",
			    s, pkg->name);
-
			vec_remove_and_free(&pkg->shlibs_required, i, free);
+
			vec_remove(&pkg->shlibs_required, i);
+
			if (charv_insert_sorted(&pkg->shlibs_required_ignore, s) != NULL) {
+
				free(s);
+
			}
			i--;
			continue;
		}
@@ -623,17 +635,35 @@ pkg_analyse_files(struct pkgdb *db __unused, struct pkg *pkg, const char *stage)
	 * Do not depend on libraries that a package provides itself
	 */
	pkg_cleanup_shlibs_required(pkg, &internal_provided);
-
	vec_free_and_free(&internal_provided, free);
+
	while (internal_provided.len > 0) {
+
		char *s = vec_pop(&internal_provided);
+
		if (charv_insert_sorted(&pkg->shlibs_provided_ignore, s) != NULL) {
+
			free(s);
+
		}
+
	}

	vec_foreach(pkg->shlibs_provided, i) {
-
		if (match_ucl_lists(pkg->shlibs_provided.d[i],
+
		char *s = pkg->shlibs_provided.d[i];
+
		if (charv_search(&pkg->shlibs_provided_ignore, s) != NULL) {
+
			pkg_debug(2,
+
			    "remove %s from provided shlibs for package %s as it "
+
			    "is listed in shlibs_provided_ignore.",
+
			    s, pkg->name);
+
			vec_remove_and_free(&pkg->shlibs_provided, i, free);
+
			i--;
+
			continue;
+
		}
+
		if (match_ucl_lists(s,
		    pkg_config_get("SHLIB_PROVIDE_IGNORE_GLOB"),
		    pkg_config_get("SHLIB_PROVIDE_IGNORE_REGEX"))) {
			pkg_debug(2,
			    "remove %s from provided shlibs for package %s as it "
			    "is matched by SHLIB_PROVIDE_IGNORE_GLOB/REGEX.",
-
			    pkg->shlibs_provided.d[i], pkg->name);
-
			vec_remove_and_free(&pkg->shlibs_provided, i, free);
+
			    s, pkg->name);
+
			vec_remove(&pkg->shlibs_provided, i);
+
			if (charv_insert_sorted(&pkg->shlibs_provided_ignore, s) != NULL) {
+
				free(s);
+
			}
			i--;
			continue;
		}
modified tests/frontend/create-parsebin.sh
@@ -40,10 +40,6 @@ genmanifest() {
        shift
    done

-
    if [ -n "${hide_provided}" ]; then
-
        Xshlibs_provided=""
-
    fi
-

	cat << EOF > ${PKG_NAME}.manifest
name: ${PKG_NAME}
origin: ${PKG_NAME}
@@ -85,7 +81,11 @@ EOF
        echo "]" >> ${PKG_NAME}.expected
    fi
    if [ -n "${Xshlibs_provided}" ]; then
-
        echo "shlibs_provided [" >> ${PKG_NAME}.expected
+
        if [ -n "${hide_provided}" ]; then
+
            echo "shlibs_provided_ignore [" >> ${PKG_NAME}.expected
+
        else
+
            echo "shlibs_provided [" >> ${PKG_NAME}.expected
+
        fi
        for i in ${Xshlibs_provided}; do
            echo ${NL}"    "\"$i\", >> ${PKG_NAME}.expected
        done