diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-04-30 13:42:08 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-04-30 14:58:22 (GMT) |
commit | 3ffd2741c1e062162950ffb7ba2c0b291c91e596 (patch) | |
tree | 7fdb356dd4e7165d4f897c76b9515d664bae0351 /Source/CPack | |
parent | c09efe074d793203ab846e97bde8d03e4714dc2a (diff) | |
download | CMake-3ffd2741c1e062162950ffb7ba2c0b291c91e596.zip CMake-3ffd2741c1e062162950ffb7ba2c0b291c91e596.tar.gz CMake-3ffd2741c1e062162950ffb7ba2c0b291c91e596.tar.bz2 |
CPack: Fix newline output in .deb generator
When running CPack on Windows, LF newlines are converted to CRLF
unless binary mode is used. Use binary mode whenever possible.
Fixes: #20659
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackDebGenerator.cxx | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 8eca2ff..3d5fe6b 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -135,16 +135,17 @@ 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 + cmGeneratedFileStream out; + out.Open(dbfilename, false, true); + out << "2.0\n"; // required for valid debian package } void DebGenerator::generateControlFile() const { std::string ctlfilename = WorkDir + "/control"; - cmGeneratedFileStream out(ctlfilename); + cmGeneratedFileStream out; + out.Open(ctlfilename, false, true); for (auto const& kv : ControlValues) { out << kv.first << ": " << kv.second << "\n"; } @@ -156,8 +157,7 @@ void DebGenerator::generateControlFile() const totalSize += cmSystemTools::FileLength(file); } } - out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n"; - out << std::endl; + out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n\n"; } bool DebGenerator::generateDataTar() const @@ -248,7 +248,8 @@ std::string DebGenerator::generateMD5File() const { std::string md5filename = WorkDir + "/md5sums"; - cmGeneratedFileStream out(md5filename); + cmGeneratedFileStream out; + out.Open(md5filename, false, true); std::string topLevelWithTrailingSlash = cmStrCat(TemporaryDir, '/'); for (std::string const& file : PackageFiles) { @@ -757,15 +758,17 @@ int cmCPackDebGenerator::createDeb() const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") && debian_pkg_shlibs && *debian_pkg_shlibs; if (gen_shibs) { - cmGeneratedFileStream out(shlibsfilename); + cmGeneratedFileStream out; + out.Open(shlibsfilename, false, true); out << debian_pkg_shlibs; - out << std::endl; + out << '\n'; } const std::string postinst = strGenWDIR + "/postinst"; const std::string postrm = strGenWDIR + "/postrm"; if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) { - cmGeneratedFileStream out(postinst); + cmGeneratedFileStream out; + out.Open(postinst, false, true); out << "#!/bin/sh\n\n" "set -e\n\n" "if [ \"$1\" = \"configure\" ]; then\n" @@ -773,7 +776,8 @@ int cmCPackDebGenerator::createDeb() "fi\n"; } if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) { - cmGeneratedFileStream out(postrm); + cmGeneratedFileStream out; + out.Open(postrm, false, true); out << "#!/bin/sh\n\n" "set -e\n\n" "if [ \"$1\" = \"remove\" ]; then\n" |