CPackDeb: Debian packages built on Windows fail to install
I am using CPackDeb to build Debian packages on Windows. When running dpkg -i my-package_0.0.1_all.deb
I get the following error message:
dpkg-deb: error: archive has invalid format version: format version followed by junk
dpkg: error processing archive my-package_0.0.1_all.deb (--install):
subprocess dpkg-deb --control returned error exit status 2
Errors were encountered while processing:
my-package_0.0.1_all.deb
Using the same configuration I can build valid Debian packages on Linux.
After reading the source code of dpkg
and CMake I think I found the cause. There seems to be a problem in the debian-binary
created on Windows:
void DebGenerator::generateDebianBinaryFile() const
{
// debian-binary file
const std::string dbfilename = WorkDir + "/debian-binary";
cmGeneratedFileStream out(dbfilename);
out << "2.0";
out << std::endl; // required for valid debian package
}
On Windows the std::endl
ist translated to \r\n
because the file is opened in text mode. dpkg
does not like Windows line endings.
To confirm I changed the method as follows:
void DebGenerator::generateDebianBinaryFile() const
{
// debian-binary file
const std::string dbfilename = WorkDir + "/debian-binary";
cmGeneratedFileStream out;
out.Open(dbfilename, false, true);
out.put('2');
out.put('.');
out.put('0');
out.put('\n');
}
Here the file is opened in binary mode and voila it works ...
... until the control file is parsed where again the final std::endl
from DebGenerator::generateControlFile()
causes dpkg
to complain.
Edited by Jan Deinhard