Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
libpkg: remove now unused pkg_recompute and pkgdb_reanalyse_shlibs
Baptiste Daroussin committed 2 years ago
commit d839e6f8db95eb0a649c00c6c1f48f8b124f2a68
parent 65e8620
4 files changed +4 -155
modified libpkg/libpkg.ver
@@ -135,7 +135,6 @@ global:
	pkg_plugins_shutdown;
	pkg_printf;
	pkg_rdeps;
-
	pkg_recompute;
	pkg_repo_cached_name;
	pkg_repo_create;
	pkg_repo_create_free;
@@ -219,7 +218,6 @@ global:
	pkgdb_query_shlib_provide;
	pkgdb_query_shlib_require;
	pkgdb_query_which;
-
	pkgdb_reanalyse_shlibs;
	pkgdb_register_ports;
	pkgdb_release_lock;
	pkgdb_repo_query;
modified libpkg/pkg.c
@@ -1,33 +1,13 @@
/*-
-
 * Copyright (c) 2011-2016 Baptiste Daroussin <bapt@FreeBSD.org>
+
 * Copyright (c) 2011-2024 Baptiste Daroussin <bapt@FreeBSD.org>
 * Copyright (c) 2011-2012 Julien Laffaye <jlaffaye@FreeBSD.org>
 * Copyright (c) 2012 Bryan Drewery <bryan@shatow.net>
 * Copyright (c) 2013 Matthew Seaman <matthew@FreeBSD.org>
 * Copyright (c) 2017 Vsevolod Stakhov <vsevolod@FreeBSD.org>
 * Copyright (c) 2023, Serenity Cyber Security, LLC
 *                     Author: Gleb Popov <arrowd@FreeBSD.org>
-
 * All rights reserved.
 *
-
 * Redistribution and use in source and binary forms, with or without
-
 * modification, are permitted provided that the following conditions
-
 * are met:
-
 * 1. Redistributions of source code must retain the above copyright
-
 *    notice, this list of conditions and the following disclaimer
-
 *    in this position and unchanged.
-
 * 2. Redistributions in binary form must reproduce the above copyright
-
 *    notice, this list of conditions and the following disclaimer in the
-
 *    documentation and/or other materials provided with the distribution.
-
 *
-
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
-
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
-
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <archive.h>
@@ -1371,50 +1351,6 @@ pkg_test_filesum(struct pkg *pkg)
}

int
-
pkg_recompute(struct pkgdb *db, struct pkg *pkg)
-
{
-
	struct pkg_file *f = NULL;
-
	hardlinks_t hl = tll_init();
-
	int64_t flatsize = 0;
-
	struct stat st;
-
	bool regular = false;
-
	char *sum;
-
	int rc = EPKG_OK;
-

-
	while (pkg_files(pkg, &f) == EPKG_OK) {
-
		if (lstat(f->path, &st) != 0)
-
			continue;
-
		regular = true;
-
		sum = pkg_checksum_generate_file(f->path,
-
		    PKG_HASH_TYPE_SHA256_HEX);
-

-
		if (S_ISLNK(st.st_mode))
-
			regular = false;
-

-
		if (sum == NULL) {
-
			rc = EPKG_FATAL;
-
			break;
-
		}
-

-
		if (st.st_nlink > 1)
-
			regular = !check_for_hardlink(&hl, &st);
-

-
		if (regular)
-
			flatsize += st.st_size;
-

-
		if (strcmp(sum, f->sum) != 0)
-
			pkgdb_file_set_cksum(db, f, sum);
-
		free(sum);
-
	}
-
	tll_free_and_free(hl, free);
-

-
	if (flatsize != pkg->flatsize)
-
		pkg->flatsize = flatsize;
-

-
	return (rc);
-
}
-

-
int
pkg_try_installed(struct pkgdb *db, const char *name,
		struct pkg **pkg, unsigned flags) {
	struct pkgdb_it *it = NULL;
modified libpkg/pkg.h.in
@@ -1479,8 +1479,6 @@ int pkg_initialized(void);
void pkg_shutdown(void);

int pkg_test_filesum(struct pkg *);
-
int pkg_recompute(struct pkgdb *, struct pkg *);
-
int pkgdb_reanalyse_shlibs(struct pkgdb *, struct pkg *);

void pkgdb_cmd(int argc, char **argv);
int pkg_sshserve(int fd);
modified libpkg/pkgdb.c
@@ -1,5 +1,5 @@
/*-
-
 * Copyright (c) 2011-2023 Baptiste Daroussin <bapt@FreeBSD.org>
+
 * Copyright (c) 2011-2024 Baptiste Daroussin <bapt@FreeBSD.org>
 * Copyright (c) 2011-2012 Julien Laffaye <jlaffaye@FreeBSD.org>
 * Copyright (c) 2011 Will Andrews <will@FreeBSD.org>
 * Copyright (c) 2011 Philippe Pepiot <phil@philpep.org>
@@ -10,28 +10,8 @@
 * Copyright (c) 2013-2014 Vsevolod Stakhov <vsevolod@FreeBSD.org>
 * Copyright (c) 2023 Serenity Cyber Security, LLC
 *                    Author: Gleb Popov <arrowd@FreeBSD.org>
-
 * All rights reserved.
 *
-
 * Redistribution and use in source and binary forms, with or without
-
 * modification, are permitted provided that the following conditions
-
 * are met:
-
 * 1. Redistributions of source code must retain the above copyright
-
 *    notice, this list of conditions and the following disclaimer
-
 *    in this position and unchanged.
-
 * 2. Redistributions in binary form must reproduce the above copyright
-
 *    notice, this list of conditions and the following disclaimer in the
-
 *    documentation and/or other materials provided with the distribution.
-
 *
-
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
-
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
-
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
 * SPDX-License-Identifier: BSD-2-Clause
 */

#ifdef HAVE_CONFIG_H
@@ -2060,69 +2040,6 @@ pkgdb_insert_annotations(struct pkg *pkg, int64_t package_id, sqlite3 *s)
}

int
-
pkgdb_reanalyse_shlibs(struct pkgdb *db, struct pkg *pkg)
-
{
-
	sqlite3		*s;
-
	int64_t		 package_id;
-
	int		 ret = EPKG_OK;
-
	int		 i;
-
	const char	*sql[] = {
-
		"DELETE FROM pkg_shlibs_required WHERE package_id = ?1",
-

-
		"DELETE FROM pkg_shlibs_provided WHERE package_id = ?1",
-

-
		"DELETE FROM shlibs "
-
		"WHERE id NOT IN "
-
		"(SELECT DISTINCT shlib_id FROM pkg_shlibs_required)"
-
		"AND id NOT IN "
-
		"(SELECT DISTINCT shlib_id FROM pkg_shlibs_provided)",
-
	};
-

-
	sqlite3_stmt	*stmt_del;
-

-
	assert(db != NULL);
-

-
	if (pkg_is_valid(pkg) != EPKG_OK) {
-
		pkg_emit_error("the package is not valid");
-
		return (EPKG_FATAL);
-
	}
-

-
	if ((ret = pkg_analyse_files(db, pkg, ctx.pkg_rootdir)) == EPKG_OK) {
-
		s = db->sqlite;
-
		package_id = pkg->id;
-

-
		for (i = 0; i < 2; i++) {
-
			/* Clean out old shlibs first */
-
			stmt_del = prepare_sql(db->sqlite, sql[i]);
-
			if (stmt_del == NULL)
-
				return (EPKG_FATAL);
-

-
			sqlite3_bind_int64(stmt_del, 1, package_id);
-
			pkgdb_debug(4, stmt_del);
-

-
			ret = sqlite3_step(stmt_del);
-

-
			if (ret != SQLITE_DONE) {
-
				ERROR_STMT_SQLITE(db->sqlite, stmt_del);
-
				sqlite3_finalize(stmt_del);
-
				return (EPKG_FATAL);
-
			}
-
			sqlite3_finalize(stmt_del);
-
		}
-

-
		if (sql_exec(db->sqlite, sql[2]) != EPKG_OK)
-
			return (EPKG_FATAL);
-

-
		/* Save shlibs */
-
		ret = pkgdb_update_shlibs_required(pkg, package_id, s);
-
		if (ret == EPKG_OK)
-
			ret = pkgdb_update_shlibs_provided(pkg, package_id, s);
-
	}
-

-
	return (ret);
-
}
-

-
int
pkgdb_add_annotation(struct pkgdb *db, struct pkg *pkg, const char *tag,
    const char *value)
{