The prerm of uwsgi script contains this:
#!/bin/sh
set -e
# Automatically added by dh_installinit
if [ -x "/etc/init.d/uwsgi" ] || [ -e "/etc/init/uwsgi.conf" ]; then
invoke-rc.d uwsgi stop || exit $?
fi
# End automatically added section
You have a few options:
Edit the prerm script.
The script is usually located at /var/lib/dpkg/uwsgi.prerm.
Do:
sudo sed -i '/invoke-rc.d/ s/^/#/' /var/lib/dpkg/uwsgi.prerm
to comment out the command that stops the service.
Use the conditions in the script to your advantage
Either:
sudo chmod -x /etc/init.d/uwsgi
since the script checks for execute permissions of this script,
Or:
mv /etc/init/uwsgi.conf /etc/init/uwsgi.conf.bak
since the script checks for existence of this Upstart service file.
According to the list of files, the package has /etc/init.d/uwsgi and not the Upstart script.
(Mis)Use policy-rc.d
invoke-rc.d is controlled by policy-rc.d. However, using it directly has a problem. The prerm script is has exit $?, and dpkg doesn't like non-zero exit codes. Hence, this will still require changing the prerm script:
echo 'exit 101' > /usr/sbin/invoke-rc.d
chmod +x /usr/sbin/invoke-rc.d
sed 's/exit/echo/' -i /var/lib/dpkg/uwsgi.prerm
Why did I even answer?
There are some brilliant answers already available: Install packages without starting background processes and services (possibly with some slight adaptation required).