今天(2014 年 8 月 16 日)应用最新更新后,Libreoffice-base 无法完成升级,因为出现“无转移”错误,这似乎破坏了 postrm 脚本,现在我无法更新、安装或删除软件包。
我关闭了所有 ppa 存储库,执行了“sudo dpkg --configure -a”、“sudo apt-get autoremove”以及“sudo rm -fR /var/cache/apt”以创建一个干净的版本 - 但无济于事。我还尝试将有问题的文件重命名为 .bak。
有任何想法吗?
最新尝试的输出:
$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
iw crda wireless-crda wireless-regdb
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
libreoffice-base
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 6,748 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 221883 files and directories currently installed.)
Removing libreoffice-base ...
No diversion 'diversion of /usr/lib/libreoffice/share/basic/dialog.xlc to /usr/lib/libreoffice/share/basic/dialog.xlc.noaccess by libreoffice-base', none removed.
No diversion 'diversion of /usr/lib/libreoffice/share/basic/script.xlc to /usr/lib/libreoffice/share/basic/script.xlc.noaccess by libreoffice-base', none removed.
/var/lib/dpkg/info/libreoffice-base.postrm: 31: /var/lib/dpkg/info/libreoffice-base.postrm: Syntax error: end of file unexpected (expecting "fi")
dpkg: error processing libreoffice-base (--remove):
subprocess installed post-removal script returned error exit status 2
Errors were encountered while processing:
libreoffice-base
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
此错误已报告这里。简而言之,/var/lib/dpkg/info/libreoffice-base.postrm 脚本中存在语法错误,导致其中断。
这是我在我的机器上修复这个问题的方法 - 也是由 nadrach 建议的这里. 打开该损坏的脚本进行编辑:
sudo gedit /var/lib/dpkg/info/libreoffice-base.postrm
编辑文件:
#!/bin/sh
set -e
if [ "$1" = remove -o "$1" = abort-install -o "$1" = disappear ]; then
dpkg-divert --package $DPKG_MAINTSCRIPT_PACKAGE --remove --rename \
--divert /usr/lib/libreoffice/share/basic/dialog.xlc.noaccess \
/usr/lib/libreoffice/share/basic/dialog.xlc
dpkg-divert --package $DPKG_MAINTSCRIPT_PACKAGE --remove --rename \
--divert /usr/lib/libreoffice/share/basic/script.xlc.noaccess \
/usr/lib/libreoffice/share/basic/script.xlc
fi
if [ "$1" = abort-upgrade ] && dpkg --compare-versions "$2" lt dpkg --compare-versions "$2" lt 1:4.3.0~beta1-1; then
dpkg-divert --package $DPKG_MAINTSCRIPT_PACKAGE --remove --rename \
--divert /usr/lib/libreoffice/share/basic/dialog.xlc.noaccess \
/usr/lib/libreoffice/share/basic/dialog.xlc
dpkg-divert --package $DPKG_MAINTSCRIPT_PACKAGE --remove --rename \
--divert /usr/lib/libreoffice/share/basic/script.xlc.noaccess \
将此行放在此处:/usr/lib/libreoffice/share/basic/script.xlc
fi
# Automatically added by dh_installmenu
if [ -x "`which update-menus 2>/dev/null`" ]; then update-menus ; fi
# End automatically added section
exit 0
保存文件并运行更新。此修复尚未给我带来任何问题。
正如 David 指出的那样,在应用此方法后可能需要修复损坏的软件包,然后一切才能恢复正常:
sudo apt-get -f install
答案2
我曾经aptitude
解决过这个问题。我不确定使用 是否有区别aptitude
,但由于它现在已经解决了,我无法测试。因此,如果您已经安装了它,或者可以通过 安装它apt-get install aptitude
,您可以尝试对我有用的方法:
启动aptitude
,使用 进行更新u,然后按“可升级包”安装剩余的包+,然后g显示将要执行的操作,如果这看起来合理,则g再次进行更改。有一个 libreoffice 包未安装,按照所述操作,它已安装,并且错误已在安装过程中得到修复。
问题修复后的终端输出如下:
Preparing to unpack .../libreoffice-base_1%3a4.3.0-3ubuntu1~trusty1_amd64.deb ...
Unpacking libreoffice-base (1:4.3.0-3ubuntu1~trusty1) over (1:4.3.0-0ubuntu1~trusty1) ...
/var/lib/dpkg/info/libreoffice-base.postrm: 28: /var/lib/dpkg/info/libreoffice-base.postrm: Syntax error: end of file unexpected (expecting "fi")
dpkg: warning: subprocess old post-removal script returned error exit status 2
dpkg: trying script from the new package instead ...
dpkg: ... it looks like that went OK
Preparing to unpack .../libreoffice-ogltrans_1%3a4.3.0-3ubuntu1~trusty1_amd64.deb ...
Unpacking libreoffice-ogltrans (1:4.3.0-3ubuntu1~trusty1) over (1:4.3.0-0ubuntu1~trusty1) ...
答案3
我能够消除有问题的错误,但无法访问 libreoffice-base。我现在可以不用它,因为我通常使用 MySql。我这样做的方法是打开 nautilus 窗口作为 root 'gksu nautilus',然后遍历到 postrm 文件所在的目录 '/var/lib/dpkg/info',然后在文本编辑器中打开 'libreoffice-base.postrm' 并完全注释掉第二个块(直到它的 'fi') - 以 'if ["$1" = abort-upgrade ] && dpkg --compare-versions"$2"lt dpkg --compare-versions"$2"lt 1:4.3.0~beta1-1; then' 开头。保存文件,然后执行 'sudo apt-get install libreoffice-base',结果如下:
正在读取软件包列表... 完成 正在构建依赖关系树
正在读取状态信息... 完成 libreoffice-base 已经是最新版本。以下软件包已自动安装,现在不再需要: iw crda wireless-crda wireless-regdb 使用“apt-get autoremove”将其删除。以下软件包将被删除: libreoffice-base 已升级 0 个软件包,新安装 0 个软件包,要删除 1 个软件包,未升级 0 个软件包。未完全安装或删除 1 个软件包。此操作后,将释放 6,748 kB 磁盘空间。是否要继续 [Y/n]?y(正在读取数据库...当前安装了 221883 个文件和目录。)正在删除 libreoffice-base...无转移“libreoffice-base 将 /usr/lib/libreoffice/share/basic/dialog.xlc 转移到 /usr/lib/libreoffice/share/basic/dialog.xlc.noaccess”,未删除任何软件包。无转移 '/usr/lib/libreoffice/share/basic/script.xlc 被 libreoffice-base 转移至 /usr/lib/libreoffice/share/basic/script.xlc.noaccess',无删除。正在处理菜单触发器...
当我尝试重新安装基础包时,它会抱怨依赖关系,但识别的所有文件都是所需的最新版本。很奇怪。但至少我可以再次更新和安装包。