Cancel debian package installation inside preinst script -
i cancel installation of .deb package if check fails in preinst script.
my preinst script:
#!/bin/sh # stop if error set -e assertexists(){ # $1 file if [ -e "$1" ] echo "file existence checked for: $1" else echo "error, file not exist: $1" exit 1 fi } assertexists "$javapath/bin/java"
when run:
dpkg -i my.deb
i see error package appears installed when run:
dpkg --get-selections
is there way cancel installation inside preinst ?
i recall there dpkg switch disable execution of preinst/postinst script ( check dpkg manpage), if started installation , broke ( happen ) , can't out of error loop, simplest way put
exit 0
in /var/lib/dpkg/info/packagename.postinst ( or preinst respectively )
i believe installation must finish or unsuccessfully ( if 2nd package must purged hand ), there no "official" way of "cancel, remove_me()" in preinst/postint script. put dpkg --purge in script in case, guess won't do, due lock or whatever else, rather make no sense. note how apt-get multiple install/removal - first removes packages removed, , install remaining ones. can make
echo packagename purge | dpkg --set-selections
and then
apt-get -f dselect-upgrade
or
apt-get -f install
but think not way it's supposed work.
you can hand
dpkg -i mypackage.deb || dpkg --purge mypackage
generally, dependencies provide way of conditional installation or removal. might want create dummy dependance or dependent package, fail before or after installation , trigger dependency warning. such package listed within "autoremove" list.
Comments
Post a Comment