Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix writing annotations to manifests
Bryan Drewery committed 11 years ago
commit fcd167d9e84449405cf614eddfd64a3843f51890
parent 2712f66
1 file changed +16 -8
modified libpkg/pkg_manifest.c
@@ -896,6 +896,7 @@ pkg_emit_object(struct pkg *pkg, short flags)
	const char *script_types = NULL;
	lic_t licenselogic;
	int64_t pkgsize;
+
	ucl_object_iter_t it = NULL;
	ucl_object_t *annotations, *categories, *licenses;
	ucl_object_t *map, *seq, *submap;
	ucl_object_t *top = ucl_object_typed_new(UCL_OBJECT);
@@ -913,6 +914,7 @@ pkg_emit_object(struct pkg *pkg, short flags)
		PKG_FLATSIZE,
		-1
	};
+
	size_t key_len;

	pkg_get(pkg, PKG_COMMENT, &comment, PKG_LICENSE_LOGIC, &licenselogic,
	    PKG_DESC, &desc, PKG_MESSAGE, &message, PKG_PKGSIZE, &pkgsize,
@@ -1062,16 +1064,22 @@ pkg_emit_object(struct pkg *pkg, short flags)
	if (map)
		ucl_object_insert_key(top, map, "options", 7, false);

-
	/* XXXB: Fix this code please */
-
#if 0
	if (annotations != NULL) {
-
		/* Remove internal only annotations */
-
		ucl_object_delete_keyl(annotations, "repository", 10);
-
		ucl_object_delete_keyl(annotations, "relocated", 9);
-
		ucl_object_insert_key(top,
-
		    ucl_object_ref(annotations), "annotations", 11, false);
+
		it = NULL;
+
		map = ucl_object_typed_new(UCL_OBJECT);
+
		/* Add annotations except for internal ones. */
+
		while ((o = ucl_iterate_object(annotations, &it, true))) {
+
			if ((key = ucl_object_keyl(o, &key_len)) == NULL)
+
				continue;
+
			/* Internal annotations. */
+
			if (strcmp(key, "repository") == 0 ||
+
			    strcmp(key, "relocated") == 0)
+
				continue;
+
			ucl_object_insert_key(map, ucl_object_ref(o), key,
+
			    key_len, true);
+
		}
+
		ucl_object_insert_key(top, map, "annotations", 11, false);
	}
-
#endif

	if ((flags & PKG_MANIFEST_EMIT_COMPACT) == 0) {
		if ((flags & PKG_MANIFEST_EMIT_NOFILES) == 0) {