在 chroot 环境中执行脚本时出错

在 chroot 环境中执行脚本时出错

我编写了一个小脚本来删除和清除一些软件包并在 chroot 环境(debian 9)中安装新的软件包,但是当我运行该脚本时,当脚本运行清除命令时,我收到此错误:

Fetched 355 B in 4s (88 B/s)       
(appstreamcli:8321): GLib-CRITICAL **: 14:31:37.785: g_variant_builder_end: assertion '!GVSB(builder)->uniform_item_types || GVSB(builder)->prev_item_type != NULL || g_variant_type_is_definite (GVSB(builder)->type)' failed
(appstreamcli:8321): GLib-CRITICAL **: 14:31:37.785: g_variant_new_variant: assertion 'value != NULL' failed
(appstreamcli:8321): GLib-ERROR **: 14:31:37.785: g_variant_new_parsed: 11-13:invalid GVariant format string
Trace/breakpoint trap (core dumped)
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh-cache > /dev/null; fi'
E: Sub-process returned an error code
Reading package lists... Done

这是我的脚本:

#!/bin/bash
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts

export HOME=/root
export LC_ALL=C

apt update
apt-get remove --purge -y gnome* kodi* tilix* rhythmbox*
apt -y autoremove
apt install -y mate-desktop-environment-extras gparted vlc gksu
apt-get purge --no-install-recommends -y linux-image-4.16* linux-image-4.17*
apt -y autoremove
umount /proc || umount -lf /proc
umount /sys
umount /dev/pts

exit

那么,我该如何修复这个错误?

答案1

搜索后,我通过清除appstreamchroot 内的包解决了我的问题:

# apt purge appstream

然后使用autoremove命令执行清除命令:

# apt-get remove --purge -y gnome* kodi* tilix* rhythmbox* && apt autoremove

appstearm再次重新安装包

答案2

我在运行时遇到了类似的问题

sudo apt-get upgrade

我遇到了几乎相同的错误控制台建议我运行以下命令:

sudo apt --fix-broken install

这解决了我的错误。

相关内容