chroot_live-packages: use dpkg-query to see if a package is installed
Closes: #944983
This commit is contained in:
parent
04ea46d07b
commit
0647e985fa
|
@ -36,3 +36,14 @@ Chroot ()
|
|||
|
||||
return "${?}"
|
||||
}
|
||||
|
||||
Chroot_has_package() {
|
||||
PACKAGE="${1}"; shift
|
||||
CHROOT="${2:-chroot}"; shift
|
||||
|
||||
if dpkg-query --admindir=${CHROOT}/var/lib/dpkg -s ${PACKAGE} >/dev/null 2>&1 | grep -q "^Status: install"
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ case "${LB_INITSYSTEM}" in
|
|||
systemd)
|
||||
_PACKAGES="${_PACKAGES} systemd-sysv"
|
||||
|
||||
if [ -e chroot/var/lib/dpkg/info/sysvinit.list ]
|
||||
if Chroot_has_package sysvinit
|
||||
then
|
||||
Chroot chroot "dpkg --force-remove-essential --purge sysvinit"
|
||||
fi
|
||||
|
@ -62,7 +62,7 @@ case "${LB_INITSYSTEM}" in
|
|||
sysvinit)
|
||||
_PACKAGES="${_PACKAGES} sysvinit"
|
||||
|
||||
if [ -e chroot/var/lib/dpkg/info/systemd-sysv.list ]
|
||||
if Chroot_has_package systemd-sysv
|
||||
then
|
||||
Chroot chroot "dpkg --force-remove-essential --purge systemd systemd-sysv"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue