title: Cancel debian package installation inside preinst script
body: <p>I would like to cancel the installation of a .deb package if a check fails in my preinst script. </p>
  
  <p>My preinst script:</p>
  
  <pre><code>#!/bin/sh
  # Stop if any error
  set -e 
  assertexists(){
      # $1 File
      if [ -e "$1" ]
      then
          echo "File existence checked for: $1"
      else
          echo "ERROR, file does not exist: $1"
          exit 1
      fi
  }
  assertexists "$JAVAPATH/bin/java"
  </code></pre>
  
  <p>When i run:</p>
  
  <pre><code>dpkg -i my.deb
  </code></pre>
  
  <p>I see the error but the package appears as installed when i run:</p>
  
  <pre><code>dpkg --get-selections
  </code></pre>
  
  <p>Is there a way to cancel the installation inside preinst ?</p>