Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
push back and manifest on top of the package
Baptiste Daroussin committed 14 years ago
commit d6dfd00bb11824f13698fdfdcb500af182b95dc7
parent 577f506e18256cb79b04d95b9452ecc9ef1fe9f7
2 files changed +21 -13
modified libpkg/pkg.c
@@ -903,7 +903,7 @@ pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae, con
		fpath = archive_entry_pathname(*ae);

		if (fpath[0] != '+')
-
			continue;
+
			break;

		if (strcmp(fpath, "+MANIFEST") == 0) {
			size = archive_entry_size(*ae);
modified libpkg/pkg_create.c
@@ -28,24 +28,36 @@ pkg_create_from_dir(struct pkg *pkg, const char *root, struct packing *pkg_archi
	struct stat st;
	char sha256[65];

+
	/*
+
	 * if the checksum is not provided in the manifest recompute it
+
	 */
+
	while (pkg_files(pkg, &file) == EPKG_OK) {
+
		if (root != NULL)
+
			snprintf(fpath, MAXPATHLEN, "%s%s", root, pkg_file_path(file));
+
		else
+
			strlcpy(fpath, pkg_file_path(file), MAXPATHLEN);
+

+
		if ((pkg_file_sha256(file) == NULL || pkg_file_sha256(file)[0] == '\0') && lstat(fpath, &st) == 0 && !S_ISLNK(st.st_mode)) {
+
			sha256_file(fpath, sha256);
+
			strlcpy(file->sha256, sha256, 65);
+
		}
+

+
	}
+

+
	pkg_emit_manifest(pkg, &m);
+
	packing_append_buffer(pkg_archive, m, "+MANIFEST", strlen(m));
+
	free(m);
+

	mtree = pkg_get(pkg, PKG_MTREE);
	if (mtree != NULL)
		packing_append_buffer(pkg_archive, mtree, "+MTREE_DIRS", strlen(mtree));

	while (pkg_files(pkg, &file) == EPKG_OK) {
-

		if (root != NULL)
			snprintf(fpath, MAXPATHLEN, "%s%s", root, pkg_file_path(file));
		else
			strlcpy(fpath, pkg_file_path(file), MAXPATHLEN);

-
		/*
-
		 * if the checksum is not provided in the manifest recompute it
-
		 */
-
		if (pkg_file_sha256(file) == NULL && lstat(fpath, &st) == 0 && !S_ISLNK(st.st_mode)) {
-
			sha256_file(fpath, sha256);
-
			strlcpy(file->sha256, sha256, 65);
-
		}
		packing_append_file_attr(pkg_archive, fpath, pkg_file_path(file), file->uname, file->gname, file->perm);
	}

@@ -58,10 +70,6 @@ pkg_create_from_dir(struct pkg *pkg, const char *root, struct packing *pkg_archi
		packing_append_file_attr(pkg_archive, fpath, pkg_dir_path(dir), dir->uname, dir->gname, dir->perm);
	}

-
	pkg_emit_manifest(pkg, &m);
-
	packing_append_buffer(pkg_archive, m, "+MANIFEST", strlen(m));
-
	free(m);
-

	return (EPKG_OK);
}