Freebsd

FreeBSD,引導 pkg,“pkg-static:執行 INSERT OR ROLLBACK INTO pkg_search 時出現 sqlite 錯誤”

  • August 20, 2019

我試圖在 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

所以現在我被困住了。誰能告訴我如何從這種狀態中恢復過來?

您可以嘗試刪除/var/db/pkg/目錄中的所有內容,但正確的解決方案是升級到受支持的 FreeBSD 版本(10.4 或 11.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

從 2017 年 1 月開始,此執行緒中提到了該特定 SQL 查詢。

在那個 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.

引用自:https://unix.stackexchange.com/questions/478217