CRLF vs LF
After generated a deb package with CPack I was having a weird error when installing with dpkg:
dpkg (subprocess): unable to execute installed devicehub package post-installation script (/var/lib/dpkg/info/devicehub.postinst): No such file or directory
So I checked the folder and tried to execute the script and it returned the same error message and that’s the moment I remembered that I copied this file from a windows machine and realized that it probably still had the windows newline (CRLF) instead of Unix newline (LF).
After replacing CRLF with LF the script now run successfully.