Instead of making dependency on rootsh and pipng commands to `sudo gainroot' you shoud create appropriate *sudoers file in /etc/sudoers.d/ directory, add `update-sudoers' to package's post-installation and post-removal scripts and use sudo to gain superuser access.