在 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

這解決了我的錯誤。

相關內容