![FreeBSD,引导 pkg,“pkg-static:执行 INSERT 或 ROLLBACK INTO pkg_search 时出现 sqlite 错误”](https://linux22.com/image/141241/FreeBSD%EF%BC%8C%E5%BC%95%E5%AF%BC%20pkg%EF%BC%8C%E2%80%9Cpkg-static%EF%BC%9A%E6%89%A7%E8%A1%8C%20INSERT%20%E6%88%96%20ROLLBACK%20INTO%20pkg_search%20%E6%97%B6%E5%87%BA%E7%8E%B0%20sqlite%20%E9%94%99%E8%AF%AF%E2%80%9D.png)
我试图在 FreeBSD 10.2 系统上安装 bash,请参阅如何在 FreeBSD 上安装 bash
但安装失败,因为 pkg 试图从太新的存储库中获取。
然后我尝试按照以下食谱进行操作https://glasz.org/sheeplog/2017/02/freebsd-usrlocalliblibpkgso3-undefined-symbol-utimensat.html,一些消息来源称这是正确的做法。
然而,部分方法涉及卸载 pkg 并重新安装它。结果如下:
# pkg install -y pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from
pkg+http://pkg.FreeBSD.org/FreeBSD:10:amd64/release_2, please
wait...
Verifying signature with trusted certificate
pkg.freebsd.org.2013102301... done
pkg-static: warning: database version 34 is newer than libpkg(3)
version 31, but still compatible
pkg-static: sqlite error while executing INSERT OR ROLLBACK INTO
pkg_search(id, name, origin) VALUES (?1, ?2 || '-' || ?3, ?4); in
file pkgdb.c:1542: no such table: pkg_search
所以现在我被困住了。谁能告诉我如何从这种状态中恢复过来?
答案1
您可以尝试删除/var/db/pkg/
目录中的所有内容,但正确的解决方案是升级到受支持的 FreeBSD 版本(10.4 或 11.2)
答案2
我最近遇到了类似的症状(为了可读性添加了换行符):
# pkg info
pkg: Warning: Major OS version upgrade detected. \
Running "pkg-static install -f pkg" recommended
pkg: warning: database version 34 is newer than libpkg(3) version 33, \
but still compatible
pkg: sqlite error while executing INSERT OR ROLLBACK INTO pkg_search(id, name, origin) \
VALUES (?1, ?2 || '-' || ?3, ?4); in file pkgdb.c:1544: \
no such table: pkg_search
我重点关注了错误消息的这一部分:
no such table: pkg_search
在我的具体情况下,我能够通过执行以下操作来解决我的问题:
# cp -p /var/db/pkg/local.sqlite /var/db/pkg/local.sqlite.safety
# sqlite3 /var/db/pkg/local.sqlite
SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
sqlite> CREATE VIRTUAL TABLE pkg_search USING fts4(id, name, origin);
sqlite> .quit
该特定 SQL 查询在这个线程从 2017 年 1 月开始。
在 SQL 咒语之后,它pkg
再次发挥作用,我能够升级到最新版本,pkg
然后升级或重新安装其余的软件包。这是从 10.x 到 12.x 的迁移,因此升级后pkg
我完成了pkg upgrade -f
所有操作,最终没有再出现警告或sqlite3
错误:
# pkg -N; pkg info; pkg upgrade
pkg: 15 packages installed
apache24-2.4.41 Version 2.4.x of Apache web server
apr-1.7.0.1.6.1 Apache Portability Library
bash-5.0.7 GNU Project's Bourne Again SHell
db5-5.3.28_7 Oracle Berkeley DB, revision 5.3
expat-2.2.6_1 XML 1.0 parser written in C
gdbm-1.18.1_1 GNU database manager
gettext-runtime-0.20.1 GNU gettext runtime libraries and programs
indexinfo-0.3.1 Utility to regenerate the GNU info page index
libnghttp2-1.39.2 HTTP/2.0 C Library
libxml2-2.9.9 XML parser library for GNOME
linux_base-f10-10_10 Base set of packages needed in Linux mode for i386/amd64 (Linux Fedora 10)
pcre-8.43_2 Perl Compatible Regular Expressions library
perl5-5.30.0 Practical Extraction and Report Language
pkg-1.11.1 Package manager
readline-8.0.0 Library for editing command lines as they are typed
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (0 candidates): 100%
Processing candidates (0 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.