包预安装脚本子进程返回错误退出状态 1

包预安装脚本子进程返回错误退出状态 1

我有类似的问题 dpkg:新的预安装脚本返回错误退出状态 1

尝试安装 PacketTracer 7.3.1 时遇到与上述相同的错误。我想我拒绝了 EULA。我对 bash 和 debconf 一无所知。有谁知道如何修改这个脚本?

#!/bin/sh -e


# Source debconf library.
. /usr/share/debconf/confmodule

remove_pt ()
{
if [ -e /opt/pt ]; then
  echo "Removing old version of Packet Tracer from /opt/pt"
  sudo rm -rf /opt/pt
  sudo rm -rf /usr/share/applications/cisco-pt7.desktop
  sudo rm -rf /usr/share/applications/cisco-ptsa7.desktop
  sudo rm -rf /usr/share/icons/hicolor/48x48/apps/pt7.png
fi
}




db_fset PacketTracer_731_amd64/show-eula seen false
db_fset PacketTracer_731_amd64/accept-eula seen false
STATE=1 
while [ "$STATE" != 0 -a "$STATE" != 4 ]; do
    case "$STATE" in
    1)
        db_input critical PacketTracer_731_amd64/show-eula || true
    ;;
    2)
        db_input critical PacketTracer_731_amd64/accept-eula || true
    ;;
    3)
        db_get PacketTracer_731_amd64/accept-eula
        if [ "$RET" = "false" ]; then
            exit 1
        fi
    ;;
    esac

    if db_go; then
        STATE=$(($STATE + 1))
    else
        STATE=$(($STATE - 1))
    fi
done

这是我将 set -x 添加到 preinst 脚本并尝试安装数据包后得到的结果。

+ . /usr/share/debconf/confmodule
+ [ !  ]
+ PERL_DL_NONLAZY=1
+ export PERL_DL_NONLAZY
+ [  ]
+ exec /usr/share/debconf/frontend /var/lib/dpkg/tmp.ci/preinst install 8.0.0 7.3.1
+ . /usr/share/debconf/confmodule
+ [ ! 1 ]
+ [ -z  ]
+ exec
+ [  ]
+ exec
+ DEBCONF_REDIR=1
+ export DEBCONF_REDIR
+ db_fset PacketTracer_731_amd64/show-eula seen false
+ _db_cmd FSET PacketTracer_731_amd64/show-eula seen false
+ _db_internal_IFS=     

+ IFS= 
+ printf %%s\n FSET PacketTracer_731_amd64/show-eula seen false
+ IFS=  

+ IFS=
 read -r _db_internal_line
+ RET=false
+ return 0
+ db_fset PacketTracer_731_amd64/accept-eula seen false
+ _db_cmd FSET PacketTracer_731_amd64/accept-eula seen false
+ _db_internal_IFS=     

+ IFS= 
+ printf %%s\n FSET PacketTracer_731_amd64/accept-eula seen false
+ IFS=  

+ IFS=
 read -r _db_internal_line
+ RET=false
+ return 0
+ STATE=1
+ [ 1 != 0 -a 1 != 4 ]
+ db_input critical PacketTracer_731_amd64/show-eula
+ _db_cmd INPUT critical PacketTracer_731_amd64/show-eula
+ _db_internal_IFS=     

+ IFS= 
+ printf %%s\n INPUT critical PacketTracer_731_amd64/show-eula
+ IFS=  

+ IFS=
 read -r _db_internal_line
+ RET=question will be asked
+ return 0
+ db_go
+ _db_cmd GO 
+ _db_internal_IFS=     

+ IFS= 
+ printf %%s\n GO 
+ IFS=  

+ IFS=
 read -r _db_internal_line
+ RET=ok
+ return 0
+ STATE=2
+ [ 2 != 0 -a 2 != 4 ]
+ db_input critical PacketTracer_731_amd64/accept-eula
+ _db_cmd INPUT critical PacketTracer_731_amd64/accept-eula
+ _db_internal_IFS=     

+ IFS= 
+ printf %%s\n INPUT critical PacketTracer_731_amd64/accept-eula
+ IFS=  

+ IFS=
 read -r _db_internal_line
+ RET=question will be asked
+ return 0
+ db_go
+ _db_cmd GO 
+ _db_internal_IFS=     

+ IFS= 
+ printf %%s\n GO 
+ IFS=  

+ IFS=
 read -r _db_internal_line
+ RET=ok
+ return 0
+ STATE=3
+ [ 3 != 0 -a 3 != 4 ]
+ db_get PacketTracer_731_amd64/accept-eula
+ _db_cmd GET PacketTracer_731_amd64/accept-eula
+ _db_internal_IFS=     

+ IFS= 
+ printf %%s\n GET PacketTracer_731_amd64/accept-eula
+ IFS=  

+ IFS=
 read -r _db_internal_line
+ RET=false
+ return 0
+ [ false = false ]
+ exit 1
dpkg: error processing archive /home/yanaz/Pobrane/packet_tracer_modified.deb (--install):
 new packettracer package pre-installation script subprocess returned error exit status 1
gtk-update-icon-cache: Cache file created successfully.```

答案1

要修复 EULA 选择,您可以直接更改存储在数据库中的值debconf

debconf-get-selections |
grep PacketTracer_731_amd64/accept-eula |
sed s/false/true/ |
sudo debconf-set-selections

然后配置待处理的包:

sudo dpkg-reconfigure --pending

相关内容